my_task.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. date: app.globalData.month,
  6. activeIndex: 1,
  7. page: 1,
  8. toList: [], // 放今天待完成
  9. list: [],
  10. showZp: false,//显示sx选择
  11. parameter: { //我指派的参数
  12. pt_id: 0,//类型
  13. status: 'running',//状态
  14. sort: 'publish',//排序
  15. },
  16. },
  17. onLoad(e) {
  18. that = this;
  19. if (e.index) {
  20. this.setData({
  21. activeIndex: e.index,
  22. })
  23. }
  24. dd.setNavigationBar({ title: "我的任务" });
  25. },
  26. onShow() {
  27. if (app.globalData.userData) {
  28. if (this.data.page == 1) {
  29. dd.hideLoading();
  30. that.getToDay();
  31. that.getData();
  32. }
  33. } else {
  34. app.login(app.globalData.corpId, function (is) {
  35. if (is) {
  36. that.getToDay();
  37. if (that.data.page == 1) {
  38. dd.hideLoading();
  39. that.getData();
  40. }
  41. } else {
  42. dd.reLaunch({
  43. url: '../noJurisdiction/noJurisdiction'
  44. })
  45. }
  46. },function(){})
  47. }
  48. },
  49. onReset() {
  50. this.setData({
  51. page: 1,
  52. isVal: false,
  53. searchName: ''
  54. })
  55. this.getData(this.data.activeIndex);
  56. },
  57. bindKeyInput(e) {
  58. this.setData({
  59. page: 1,
  60. isVal: e.detail.value ? true : false,
  61. searchName: e.detail.value ? e.detail.value : '',
  62. })
  63. this.getData(this.data.activeIndex);
  64. this.getToDay()
  65. },
  66. //显示选择员工
  67. selectSx() {
  68. this.setData({ showZp: true })
  69. },
  70. //关闭弹窗
  71. onClose() {
  72. this.setData({
  73. showZp: false,
  74. })
  75. },
  76. //选择筛选
  77. onConfirmSx(data) {
  78. this.setData({
  79. sxObj: data,
  80. page: 1,
  81. parameter: { //我指派的参数
  82. pt_id: data[0],//类型
  83. status: this.data.parameter.status,
  84. sort: data[2]
  85. }
  86. })
  87. this.getData();
  88. },
  89. //今天完成的任务
  90. getToDay() {
  91. app.$get('api/integral/work/list', { status: 'running', today: '1', page: '1', page_size: '50', sort: 'publish', source_type: 0, pt_id: 0 ,content: that.data.searchName,}).then((res) => {
  92. this.setData({
  93. toList: res.data.data.list
  94. })
  95. })
  96. },
  97. getData(is) {
  98. var parameter = this.data.parameter;
  99. var data = {
  100. page: that.data.page,
  101. page_size: 20,
  102. source_type: 0,//作来源种类 0-全部 1-直接指派(任务池领取以外的类型) 2-任务池领取 3-任务模板指派 4-每月绩效任务包
  103. pt_id: parameter.pt_id,//类型
  104. status: parameter.status,//工作状态 all-全部 running-进行中 complete-工作已完成 refuse-拒绝 reviewed-已审批 revocation-发布者撤回
  105. sort: parameter.sort,//排序种类 expire-过期时间倒序 publish-指派时间倒序
  106. content:that.data.searchName,
  107. }
  108. app.$get('api/integral/work/list', data).then((res) => {
  109. var data = res.data.data.list;
  110. data.forEach(item => {
  111. item.isCs = item.expire_time < app.globalData.allDate;
  112. })
  113. if(that.data.page==1){
  114. this.setData({
  115. list: []
  116. })
  117. }
  118. var list = that.data.list;
  119. data.forEach(element => {
  120. if (element.pt_id) {
  121. element.pt_name = app.getTypesItem(element.pt_id).name
  122. }
  123. });
  124. if (is) {
  125. if (data.length < 20) {
  126. this.setData({
  127. list: list.concat(data),
  128. isData: true
  129. })
  130. } else {
  131. this.setData({
  132. list: list.concat(data)
  133. })
  134. }
  135. } else {
  136. this.setData({
  137. list: data,
  138. isData: false
  139. })
  140. }
  141. })
  142. },
  143. activeItem(e) {
  144. var index = e.target.dataset.index;
  145. var status = "";
  146. if (index == 1) {
  147. status = "running"
  148. } else if (index == 2) {
  149. status = "complete"
  150. } else {
  151. status = "reviewed"
  152. }
  153. this.setData({
  154. activeIndex: index,
  155. page: 1,
  156. list: [],
  157. sxObj: [],
  158. parameter: {
  159. pt_id: 0,//类型
  160. status: status,//状态
  161. sort: 'publish',//排序
  162. }
  163. })
  164. this.getData();
  165. },
  166. openPerform(e) {
  167. var id = e.target.dataset.item.id;
  168. var is = e.target.dataset.is ? true : false
  169. dd.navigateTo({
  170. url: '../openPerform/openPerform?id=' + id + '&is=' + is
  171. })
  172. },
  173. //过滤List,通常用于删除了某条数据,刷新列表
  174. filtrationList(index, id) {
  175. if (index == 1) {
  176. this.getToDay()
  177. } else if (index == 2 && this.data.page != 1) {
  178. var list = this.data.list;
  179. for (let i in list) {
  180. if (list[i].id == id) {
  181. list.splice(i, 1)
  182. }
  183. }
  184. this.setData({ list: list })
  185. }
  186. },
  187. openDetail(e) {
  188. var id = e.target.dataset.item.id;
  189. dd.navigateTo({
  190. url: '../workDetail/workDetail?id=' + id
  191. })
  192. },
  193. //上啦加载
  194. onScrollToLower() {
  195. if (!that.data.isData) {
  196. this.setData({ page: ++that.data.page })
  197. this.getData(true);
  198. }
  199. },
  200. });