allTask.js 5.6 KB

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