my_task.js 4.9 KB

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