index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. list: [],
  5. filtrate: false,
  6. navList: [{
  7. label: "我负责的",
  8. icon: "icon-webxialaxuanxiangjiantou",
  9. color: "",
  10. width: "",
  11. id: "1"
  12. }, {
  13. label: "排序",
  14. icon: "icon-jiangxu1",
  15. color: "",
  16. width: "",
  17. id: "sort"
  18. }, {
  19. label: "筛选",
  20. icon: "icon-shaixuan",
  21. color: "",
  22. width: "",
  23. id: "2"
  24. }],
  25. content: {
  26. nocache: true,
  27. "pageNumber": 1,
  28. "pageSize": 20,
  29. "isExport": 0,
  30. "type": 1,
  31. "where": {
  32. "condition": "",
  33. "startdate": "",
  34. "enddate": ""
  35. },
  36. "sort": [],
  37. total: 0,
  38. },
  39. classShow: false, //type类型
  40. filtratelist: [{
  41. label: "任务状态",
  42. index: null,
  43. showName: "name", //显示字段
  44. valueKey: "status", //返回Key
  45. selectKey: "name", //传参 代表选着字段 不传参返回整个选择对象
  46. value: "", //选中值
  47. list: [{
  48. name: "待执行"
  49. }, {
  50. name: "进行中"
  51. }, {
  52. name: "已完成"
  53. }]
  54. }]
  55. },
  56. onLoad(options) {
  57. getApp().globalData.Language.getLanguagePackage(this, '任务')
  58. let templetList = wx.getStorageSync('templetList')
  59. templetList.splice(6, 0, {
  60. templetname: "我下属创建的",
  61. rowindex: 5,
  62. templetid: 7
  63. })
  64. this.setData({
  65. classActions: templetList.map((v, i) => {
  66. return {
  67. name: v.templetname,
  68. index: v.templetid,
  69. color: i == 0 ? '#3874F6' : '',
  70. i: i,
  71. }
  72. }),
  73. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  74. "content.type": wx.getStorageSync('templetList')[0].templetid,
  75. });
  76. this.getList()
  77. },
  78. /* 导航点击功能 */
  79. navOnClick({
  80. detail
  81. }) {
  82. if (detail.label == '筛选') {
  83. this.setData({
  84. filtrate: true
  85. })
  86. } else if (detail.id == 1) {
  87. this.setData({
  88. classShow: true
  89. })
  90. }
  91. },
  92. /* 处理筛选 */
  93. handleFilter(e) {
  94. this.data.content.where.status = e.detail.status || "";
  95. this.getList(true)
  96. },
  97. /* 去添加 */
  98. toAdd() {
  99. wx.navigateTo({
  100. url: './add'
  101. })
  102. },
  103. getList(init = false) {
  104. _Http.init(this.data.content, init).then(content => {
  105. _Http.basic({
  106. "id": 20220901162901,
  107. content
  108. }).then(res => {
  109. console.log("任务列表", res)
  110. this.selectComponent('#ListBox').RefreshToComplete();
  111. if (res.code != '1') return wx.showToast({
  112. title: res.data,
  113. icon: "none"
  114. })
  115. this.setData({
  116. content: _Http.paging(content, res),
  117. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  118. })
  119. this.getTags();
  120. })
  121. })
  122. },
  123. /* 获取列表标签 */
  124. getTags() {
  125. let list = this.data.list,
  126. ownerids = list.map(v => v.sys_taskid)
  127. _Http.basic({
  128. "id": 20221018102001,
  129. "content": {
  130. "ownertable": "sys_task",
  131. ownerids
  132. }
  133. }).then(res => {
  134. for (let key in res.data) {
  135. let index = list.findIndex(v => v.sys_taskid == key);
  136. list[index].tags = res.data[key]
  137. };
  138. this.setData({
  139. list
  140. })
  141. })
  142. },
  143. /* 顶部条件导航回调 */
  144. navClick({
  145. detail
  146. }) {
  147. switch (detail.id) {
  148. case '1':
  149. this.setData({
  150. classShow: true
  151. })
  152. break;
  153. case '2':
  154. break;
  155. case '3':
  156. this.setData({
  157. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  158. });
  159. this.getList(true)
  160. break;
  161. default:
  162. break;
  163. }
  164. },
  165. /* 处理搜索 */
  166. onSearch({
  167. detail
  168. }) {
  169. this.setData({
  170. "content.where.condition": detail
  171. });
  172. this.getList(true);
  173. },
  174. classClose() {
  175. this.setData({
  176. classShow: false
  177. })
  178. },
  179. classSelect({
  180. detail
  181. }) {
  182. if (this.data.content.type == detail.index) return this.classClose();
  183. this.setData({
  184. "content.type": detail.index,
  185. 'navList[0].label': detail.name,
  186. classActions: this.data.classActions.map(v => {
  187. v.color = detail.i == v.i ? '#3874F6' : ''
  188. return v
  189. })
  190. })
  191. this.classClose();
  192. this.getList(true)
  193. }
  194. })