index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. this.setData({
  59. classActions: wx.getStorageSync('templetList').map((v, i) => {
  60. return {
  61. name: v.templetname,
  62. index: v.templetid,
  63. color: i == 0 ? '#3874F6' : '',
  64. i: i,
  65. }
  66. }),
  67. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  68. "content.type": wx.getStorageSync('templetList')[0].templetid,
  69. });
  70. this.getList()
  71. },
  72. /* 导航点击功能 */
  73. navOnClick({
  74. detail
  75. }) {
  76. if (detail.label == '筛选') {
  77. this.setData({
  78. filtrate: true
  79. })
  80. } else if (detail.id == 1) {
  81. this.setData({
  82. classShow: true
  83. })
  84. }
  85. },
  86. /* 处理筛选 */
  87. handleFilter(e) {
  88. this.data.content.where.status = e.detail.status || "";
  89. this.getList(true)
  90. },
  91. /* 去添加 */
  92. toAdd() {
  93. wx.navigateTo({
  94. url: './add'
  95. })
  96. },
  97. getList(init = false) {
  98. _Http.init(this.data.content, init).then(content => {
  99. _Http.basic({
  100. "id": 20220901162901,
  101. content
  102. }).then(res => {
  103. console.log("任务列表", res)
  104. this.selectComponent('#ListBox').RefreshToComplete();
  105. if (res.msg != '成功') return wx.showToast({
  106. title: res.data,
  107. icon: "none"
  108. })
  109. this.setData({
  110. content: _Http.paging(content, res),
  111. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  112. })
  113. this.getTags();
  114. })
  115. })
  116. },
  117. /* 获取列表标签 */
  118. getTags() {
  119. let list = this.data.list,
  120. ownerids = list.map(v => v.sys_taskid)
  121. _Http.basic({
  122. "id": 20221018102001,
  123. "content": {
  124. "ownertable": "sys_task",
  125. ownerids
  126. }
  127. }).then(res => {
  128. for (let key in res.data) {
  129. let index = list.findIndex(v => v.sys_taskid == key);
  130. list[index].tags = res.data[key]
  131. };
  132. this.setData({
  133. list
  134. })
  135. })
  136. },
  137. /* 顶部条件导航回调 */
  138. navClick({
  139. detail
  140. }) {
  141. switch (detail.id) {
  142. case '1':
  143. this.setData({
  144. classShow: true
  145. })
  146. break;
  147. case '2':
  148. break;
  149. case '3':
  150. this.setData({
  151. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  152. });
  153. this.getList(true)
  154. break;
  155. default:
  156. break;
  157. }
  158. },
  159. /* 处理搜索 */
  160. onSearch({
  161. detail
  162. }) {
  163. this.setData({
  164. "content.where.condition": detail
  165. });
  166. this.getList(true);
  167. },
  168. classClose() {
  169. this.setData({
  170. classShow: false
  171. })
  172. },
  173. classSelect({
  174. detail
  175. }) {
  176. if (this.data.content.type == detail.index) return this.classClose();
  177. this.setData({
  178. "content.type": detail.index,
  179. 'navList[0].label': detail.name,
  180. classActions: this.data.classActions.map(v => {
  181. v.color = detail.i == v.i ? '#3874F6' : ''
  182. return v
  183. })
  184. })
  185. this.classClose();
  186. this.getList(true)
  187. },
  188. onShareAppMessage() {}
  189. })