index.js 7.2 KB

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