index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. disabled: {
  5. type: Boolean,
  6. value: false
  7. }
  8. },
  9. options: {
  10. addGlobalClass: true
  11. },
  12. data: {
  13. sa_hospitaldepid: 0,
  14. content: {
  15. nocache: true,
  16. pageNumber: 1,
  17. pageSize: 10,
  18. pageTotal: 1,
  19. total: null,
  20. where: {
  21. condition: ""
  22. }
  23. },
  24. list: [],
  25. showSearch: false,
  26. focus: false,
  27. condition: "",
  28. stages: [],
  29. showAction: false
  30. },
  31. methods: {
  32. changeStage(e) {
  33. const {
  34. item
  35. } = e.currentTarget.dataset,
  36. that = this;
  37. this.setData({
  38. stages: this.data.stages.map(v => {
  39. v.color = v.stagename == item.stagename ? '#3874F6' : ''
  40. return v
  41. }),
  42. showAction: true,
  43. changeItem: item
  44. })
  45. },
  46. onSelect({
  47. detail
  48. }) {
  49. let item = this.data.changeItem,
  50. that = this;
  51. if (detail.color) return that.onCancel()
  52. wx.showModal({
  53. content: `是否确定将阶段修改为“${detail.stagename}”?`,
  54. complete: ({
  55. confirm
  56. }) => {
  57. if (confirm) _Http.basic({
  58. "id": "2025102110224102",
  59. "content": {
  60. sa_hospitaldep_itemid: item.sa_hospitaldep_itemid,
  61. sa_devstageid: detail.sa_devstageid
  62. },
  63. }).then(res => {
  64. wx.showToast({
  65. title: res.code == 1 ? '修改成功' : res.msg,
  66. icon: "none"
  67. })
  68. if (res.code == 1) {
  69. that.getList('', true)
  70. that.onCancel()
  71. getCurrentPages().find(v => v.__route__ == 'prsx/department/detail').getDetail()
  72. }
  73. })
  74. }
  75. })
  76. },
  77. onCancel() {
  78. this.setData({
  79. showAction: false,
  80. changeItem: null
  81. })
  82. },
  83. getList(id, init = false) {
  84. let content = {
  85. ...this.data.content,
  86. sa_hospitaldepid: id || this.data.sa_hospitaldepid
  87. };
  88. if (init) {
  89. content.pageNumber = 1
  90. content.pageTotal = 1
  91. }
  92. if (this.data.stages.length == 0) _Http.basic({
  93. "content": {
  94. "pageNumber": 1,
  95. "pageSize": 999,
  96. "where": {
  97. "condition": ""
  98. }
  99. },
  100. "id": 2025100916245502,
  101. }).then(res => {
  102. console.log("获取阶段列表", res)
  103. if (res.code != 1) return;
  104. this.setData({
  105. stages: res.data.map(v => {
  106. v.name = v.stagename
  107. return v
  108. })
  109. })
  110. })
  111. _Http.basic({
  112. "id": 2025102110205102,
  113. content
  114. }).then(res => {
  115. console.log("科室推荐产品", res)
  116. if (res.code != '1') return wx.showToast({
  117. title: res.data,
  118. icon: "none"
  119. });
  120. let list = res.data.map(v => {
  121. v.cover = v.attinfos.length ? _Http.getSpecifiedImage(v.attinfos[0]) : ''
  122. return v
  123. })
  124. this.setData({
  125. "content.pageNumber": res.pageNumber + 1,
  126. "content.pageTotal": res.pageTotal,
  127. "content.total": res.total,
  128. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  129. sa_hospitaldepid: content.sa_hospitaldepid
  130. })
  131. })
  132. },
  133. insetr() {
  134. let params = {
  135. "id": "2025102110220202",
  136. "content": {
  137. "sa_hospitaldepid": this.data.sa_hospitaldepid,
  138. "where": {
  139. "condition": "",
  140. }
  141. }
  142. };
  143. wx.navigateTo({
  144. url: `/prsx/select/product/index?params=${JSON.stringify(params)}&radio=true`
  145. })
  146. let that = this;
  147. _Http.handleSelect = ({
  148. item
  149. }) => {
  150. wx.showModal({
  151. content: `是否确定添加“${item.itemname}”到推荐产品?`,
  152. complete: ({
  153. confirm
  154. }) => {
  155. if (confirm) _Http.basic({
  156. "id": "2025102110170902",
  157. "content": {
  158. "sa_hospitaldepid": that.data.sa_hospitaldepid,
  159. "itemids": [item.itemid]
  160. },
  161. }).then(res => {
  162. wx.showToast({
  163. title: res.code == 1 ? '添加成功' : res.msg,
  164. icon: "none"
  165. })
  166. if (res.code == 1) {
  167. that.getList('', true)
  168. getCurrentPages().find(v => v.__route__ == 'prsx/select/product/index').uploadList()
  169. }
  170. })
  171. }
  172. })
  173. }
  174. },
  175. deleteItem(e) {
  176. const {
  177. item
  178. } = e.currentTarget.dataset,
  179. that = this;
  180. wx.showModal({
  181. content: `是否确定删除“${item.itemname}”?`,
  182. complete: ({
  183. confirm
  184. }) => {
  185. if (confirm) _Http.basic({
  186. "id": "2025102110202602",
  187. "content": {
  188. sa_hospitaldep_itemid: item.sa_hospitaldep_itemid
  189. },
  190. }).then(res => {
  191. wx.showToast({
  192. title: res.code == 1 ? '删除成功' : res.msg,
  193. icon: "none"
  194. })
  195. if (res.code == 1) {
  196. that.getList('', true)
  197. }
  198. })
  199. }
  200. })
  201. },
  202. toSearch() {
  203. if (this.data.showSearch && this.data.content.where.condition) {
  204. this.data.content.where.condition = '';
  205. this.getList("", true);
  206. } else if (this.data.condition) {
  207. this.data.content.where.condition = this.data.condition;
  208. this.setData({
  209. condition: this.data.condition
  210. })
  211. this.getList("", true);
  212. }
  213. this.setData({
  214. showSearch: !this.data.showSearch
  215. })
  216. setTimeout(() => {
  217. this.setData({
  218. focus: this.data.showSearch
  219. })
  220. }, 300)
  221. },
  222. onChange({
  223. detail
  224. }) {
  225. this.data.condition = detail;
  226. },
  227. onSearch({
  228. detail
  229. }) {
  230. this.data.content.where.condition = detail;
  231. this.getList("", true)
  232. },
  233. }
  234. })