index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. "where": {
  28. "condition": "",
  29. "startdate": "",
  30. "enddate": "",
  31. "type": "",
  32. "stagename": ""
  33. }
  34. }
  35. },
  36. async onLoad() {
  37. getApp().globalData.Language.getLanguagePackage(this);
  38. let templetList = wx.getStorageSync('templetList')
  39. this.setData({
  40. insert: wx.getStorageSync('auth').wdepartment.options.some(v => v == 'insert'), //查询新增权限
  41. classActions: templetList.map((v, i) => {
  42. return {
  43. name: v.templetname,
  44. index: v.templetid,
  45. color: i == 0 ? '#3874F6' : '',
  46. i: i,
  47. }
  48. }),
  49. 'navList[0].label': templetList[0].templetname,
  50. "content.type": templetList[0].templetid,
  51. });
  52. this.getList(true)
  53. let filtratelist = [{
  54. label: "科室类型",
  55. index: null,
  56. showName: "value", //显示字段
  57. valueKey: "type", //返回Key
  58. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  59. value: "", //选中值
  60. list: await _Http.getTypes('depttype', _Http)
  61. }]
  62. this.setData({
  63. filtratelist
  64. })
  65. },
  66. getList(init = false) {
  67. _Http.init(this.data.content, init).then(content => {
  68. _Http.basic({
  69. "id": 2025101409402402,
  70. content
  71. }).then(res => {
  72. console.log("科室列表", res)
  73. this.selectComponent('#ListBox').RefreshToComplete();
  74. if (res.code != '1') return wx.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. })
  78. res.data = res.data.map(v => {
  79. v.totalstage = v.stages.length
  80. v.stage = v.stages.findIndex(s => s.stagename == v.stagename) + 1
  81. v.progress = v.stage / v.totalstage * 100;
  82. return v
  83. })
  84. setTimeout(() => {
  85. if (res.pageNumber == 1 && res.data.length && !this.data.filtratelist.some(v => v.label == '开发阶段')) {
  86. this.data.filtratelist.push({
  87. label: "开发阶段",
  88. index: null,
  89. showName: "stagename", //显示字段
  90. valueKey: "stagename", //返回Key
  91. selectKey: "stagename", //传参 代表选着字段 不传参返回整个选择对象
  92. value: "", //选中值
  93. list: res.data[0].stages
  94. })
  95. this.setData({
  96. filtratelist: this.data.filtratelist
  97. })
  98. }
  99. }, 1500);
  100. this.setData({
  101. content: _Http.paging(content, res),
  102. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  103. })
  104. })
  105. })
  106. },
  107. toAdd() {
  108. wx.navigateTo({
  109. url: '/prsx/department/insert'
  110. })
  111. },
  112. /* 处理筛选 */
  113. handleFilter({
  114. detail
  115. }) {
  116. detail.condition = this.data.content.where.condition;
  117. this.data.content.where = detail;
  118. this.getList(true);
  119. },
  120. /* 顶部条件导航回调 */
  121. navClick({
  122. detail
  123. }) {
  124. switch (detail.id) {
  125. case '1':
  126. this.setData({
  127. classShow: true
  128. })
  129. break;
  130. case '2':
  131. this.setData({
  132. 'filterShow': true
  133. })
  134. break;
  135. case '3':
  136. this.setData({
  137. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  138. });
  139. this.getList(true)
  140. break;
  141. }
  142. },
  143. /* 处理搜索 */
  144. onSearch({
  145. detail
  146. }) {
  147. this.data.content.where.condition = detail;
  148. this.getList(true);
  149. },
  150. classClose() {
  151. this.setData({
  152. classShow: false
  153. })
  154. },
  155. classSelect({
  156. detail
  157. }) {
  158. if (this.data.content.type == detail.index) return this.classClose();
  159. this.setData({
  160. "content.type": detail.index,
  161. 'navList[0].label': detail.name,
  162. classActions: this.data.classActions.map(v => {
  163. v.color = detail.i == v.i ? '#3874F6' : ''
  164. return v
  165. })
  166. })
  167. this.classClose();
  168. this.getList(true)
  169. }
  170. })