index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. navList: [{
  5. label: "我负责的",
  6. icon: "icon-webxialaxuanxiangjiantou",
  7. color: "",
  8. width: "",
  9. id: "1"
  10. }, {
  11. label: "排序",
  12. icon: "icon-jiangxu1",
  13. color: "",
  14. width: "",
  15. id: "sort"
  16. }, {
  17. label: "筛选",
  18. icon: "icon-shaixuan",
  19. color: "",
  20. width: "",
  21. id: "2"
  22. }],
  23. content: {
  24. "type": 99,
  25. "pageNumber": 1,
  26. "pageSize": 20,
  27. "isExport": 0,
  28. "where": {
  29. "condition": "",
  30. "startdate": "",
  31. "enddate": "",
  32. "type": "",
  33. "stagename": ""
  34. }
  35. },
  36. filtratelist: []
  37. },
  38. async onLoad(options) {
  39. getApp().globalData.Language.getLanguagePackage(this);
  40. let templetList = wx.getStorageSync('templetList')
  41. if (![0, 21].includes(wx.getStorageSync('userMsg').usertype)) templetList = templetList.filter(v => v.templetid != '99')
  42. this.setData({
  43. insert: wx.getStorageSync('auth').wdepartment.options.some(v => v == 'insert'), //查询新增权限
  44. classActions: templetList.map((v, i) => {
  45. return {
  46. name: v.templetname,
  47. index: v.templetid,
  48. color: i == 0 ? '#3874F6' : '',
  49. i: i,
  50. }
  51. }),
  52. 'navList[0].label': templetList[0].templetname,
  53. "content.type": templetList[0].templetid,
  54. });
  55. this.getList(true)
  56. getApp().globalData.Language.getLanguagePackage(this);
  57. let filtratelist = [{
  58. label: "营销区域",
  59. index: null,
  60. showName: "areaname", //显示字段
  61. valueKey: "sa_saleareaid", //返回Key
  62. selectKey: "sa_saleareaid", //传参 代表选着字段 不传参返回整个选择对象
  63. value: "", //选中值
  64. type: 'multilevelClass',
  65. list: await _Http.basic({
  66. "classname": "webmanage.sale.salearea.salearea",
  67. "method": "query_area",
  68. "content": {},
  69. }).then(res => {
  70. console.log("获取营销区域", res)
  71. return res.code == 1 ? res.data : []
  72. })
  73. }, {
  74. label: "医院等级",
  75. index: null,
  76. showName: "value", //显示字段
  77. valueKey: "grade", //返回Key
  78. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  79. value: "", //选中值
  80. list: await _Http.getTypes('hospitalgrade', _Http)
  81. }, {
  82. label: "医院类型",
  83. index: null,
  84. showName: "value", //显示字段
  85. valueKey: "type", //返回Key
  86. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  87. value: "", //选中值
  88. list: await _Http.getTypes('hospitaltype', _Http)
  89. }, {
  90. label: "开发状态",
  91. index: null,
  92. showName: "value", //显示字段
  93. valueKey: "status", //返回Key
  94. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  95. value: "", //选中值
  96. list: [{
  97. value: '未开发'
  98. }, {
  99. value: '已开发'
  100. }]
  101. }, {
  102. label: "标签",
  103. index: null,
  104. type: "checkbox",
  105. showName: "tag", //显示字段
  106. valueKey: "tag", //返回Key
  107. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  108. value: "", //选中值
  109. list: await _Http.getTypes('tags', _Http)
  110. }]
  111. this.setData({
  112. filtratelist
  113. })
  114. },
  115. getList(init = false) {
  116. _Http.init(this.data.content, init).then(content => {
  117. _Http.basic({
  118. "id": 20221012164402,
  119. content
  120. }).then(res => {
  121. console.log("医院列表", res)
  122. this.selectComponent('#ListBox').RefreshToComplete();
  123. if (res.code != '1') return wx.showToast({
  124. title: res.msg,
  125. icon: "none"
  126. })
  127. res.data = res.data.map(v => {
  128. v.totalstage = v.stages.length
  129. v.stage = v.stages.findIndex(s => s.stagename == v.stagename) + 1
  130. v.progress = v.stage / v.totalstage * 100;
  131. return v
  132. })
  133. setTimeout(() => {
  134. if (res.pageNumber == 1 && res.data.length && !this.data.filtratelist.some(v => v.label == '开发阶段')) {
  135. this.data.filtratelist.push({
  136. label: "开发阶段",
  137. index: null,
  138. showName: "stagename", //显示字段
  139. valueKey: "stagename", //返回Key
  140. selectKey: "stagename", //传参 代表选着字段 不传参返回整个选择对象
  141. value: "", //选中值
  142. list: res.data[0].stages
  143. })
  144. this.setData({
  145. filtratelist: this.data.filtratelist
  146. })
  147. }
  148. }, 1500);
  149. this.setData({
  150. content: _Http.paging(content, res),
  151. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  152. })
  153. })
  154. })
  155. },
  156. toAdd() {
  157. wx.navigateTo({
  158. url: '/prsx/hospital/insert'
  159. })
  160. },
  161. /* 处理筛选 */
  162. handleFilter({
  163. detail
  164. }) {
  165. detail.condition = this.data.content.where.condition;
  166. this.data.content.where = detail;
  167. this.getList(true);
  168. },
  169. /* 顶部条件导航回调 */
  170. navClick({
  171. detail
  172. }) {
  173. switch (detail.id) {
  174. case '1':
  175. this.setData({
  176. classShow: true
  177. })
  178. break;
  179. case '2':
  180. this.setData({
  181. 'filterShow': true
  182. })
  183. break;
  184. case '3':
  185. this.setData({
  186. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  187. });
  188. this.getList(true)
  189. break;
  190. }
  191. },
  192. /* 处理搜索 */
  193. onSearch({
  194. detail
  195. }) {
  196. this.data.content.where.condition = detail;
  197. this.getList(true);
  198. },
  199. classClose() {
  200. this.setData({
  201. classShow: false
  202. })
  203. },
  204. classSelect({
  205. detail
  206. }) {
  207. if (this.data.content.type == detail.index) return this.classClose();
  208. this.setData({
  209. "content.type": detail.index,
  210. 'navList[0].label': detail.name,
  211. classActions: this.data.classActions.map(v => {
  212. v.color = detail.i == v.i ? '#3874F6' : ''
  213. return v
  214. })
  215. })
  216. this.classClose();
  217. this.getList(true)
  218. }
  219. })