allTask.js 5.7 KB

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