index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. },
  38. classShow: false, //type类型
  39. filtratelist: [{
  40. label: "任务状态",
  41. index: null,
  42. showName: "name", //显示字段
  43. valueKey: "status", //返回Key
  44. selectKey: "name", //传参 代表选着字段 不传参返回整个选择对象
  45. value: "", //选中值
  46. list: [{
  47. name: "待执行"
  48. }, {
  49. name: "进行中"
  50. }, {
  51. name: "已完成"
  52. }]
  53. }]
  54. },
  55. onLoad(options) {
  56. this.setData({
  57. classActions: wx.getStorageSync('templetList').map(v => {
  58. return {
  59. name: v.templetname,
  60. index: v.templetid
  61. }
  62. }),
  63. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  64. "content.type": wx.getStorageSync('templetList')[0].templetid,
  65. });
  66. this.getList()
  67. },
  68. /* 导航点击功能 */
  69. navOnClick({
  70. detail
  71. }) {
  72. if (detail.label == '筛选') {
  73. this.setData({
  74. filtrate: true
  75. })
  76. } else if (detail.id == 1) {
  77. this.setData({
  78. classShow: true
  79. })
  80. }
  81. },
  82. /* 处理筛选 */
  83. handleFilter(e) {
  84. this.data.content.where.status = e.detail.status || "";
  85. this.getList(true)
  86. },
  87. /* 去添加 */
  88. toAdd() {
  89. wx.navigateTo({
  90. url: './add'
  91. })
  92. },
  93. /* 筛选状态选择 */
  94. selectStatus(e) {
  95. const {
  96. item
  97. } = e.currentTarget.dataset;
  98. this.setData({
  99. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  100. })
  101. },
  102. /* 筛选日期范围 */
  103. changeDate(e) {
  104. const name = e.currentTarget.dataset.name,
  105. value = e.detail.value;
  106. this.setData({
  107. [`filter.${name}`]: value
  108. })
  109. },
  110. getList(init = false) {
  111. //init 用于初始化分页
  112. if (init.detail != undefined) init = init.detail;
  113. let content = this.data.content;
  114. if (init) content.pageNumber = 1;
  115. if (content.pageNumber > content.pageTotal) return;
  116. _Http.basic({
  117. "id": 20220901162901,
  118. content
  119. }).then(res => {
  120. console.log("任务列表", res)
  121. this.selectComponent('#ListBox').RefreshToComplete();
  122. if (res.msg != '成功') return wx.showToast({
  123. title: res.data,
  124. icon: "none"
  125. })
  126. this.setData({
  127. 'content.pageNumber': res.pageNumber + 1,
  128. 'content.pageTotal': res.pageTotal,
  129. 'content.total': res.total,
  130. 'content.sort': res.sort,
  131. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  132. })
  133. this.getTags();
  134. })
  135. },
  136. /* 获取列表标签 */
  137. getTags() {
  138. let list = this.data.list,
  139. ownerids = list.map(v => v.sys_taskid)
  140. _Http.basic({
  141. "id": 20221018102001,
  142. "content": {
  143. "ownertable": "sys_task",
  144. ownerids
  145. }
  146. }).then(res => {
  147. for (let key in res.data) {
  148. let index = list.findIndex(v => v.sys_taskid == key);
  149. list[index].tags = res.data[key]
  150. };
  151. this.setData({
  152. list
  153. })
  154. })
  155. },
  156. /* 顶部条件导航回调 */
  157. navClick({
  158. detail
  159. }) {
  160. switch (detail.id) {
  161. case '1':
  162. this.setData({
  163. classShow: true
  164. })
  165. break;
  166. case '2':
  167. this.setData({
  168. 'filter.show': true
  169. })
  170. break;
  171. case '3':
  172. this.setData({
  173. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  174. });
  175. this.getList(true)
  176. break;
  177. default:
  178. break;
  179. }
  180. },
  181. /* 处理搜索 */
  182. onSearch({
  183. detail
  184. }) {
  185. this.setData({
  186. "content.where.condition": detail
  187. });
  188. this.getList(true);
  189. },
  190. classClose() {
  191. this.setData({
  192. classShow: false
  193. })
  194. },
  195. classSelect({
  196. detail
  197. }) {
  198. if (this.data.content.type == detail.index) return this.classClose();
  199. this.setData({
  200. "content.type": detail.index,
  201. 'navList[0].label': detail.name
  202. })
  203. this.classClose();
  204. this.getList(true)
  205. },
  206. onReady() {
  207. this.selectComponent("#ListBox").setHeight(".total", this);
  208. },
  209. onShareAppMessage() {}
  210. })