task.js 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. export default {
  2. methods: {
  3. taskComplete(taskDetail, complete, callback = null) {
  4. if (taskDetail['loadIng'] === true) {
  5. return;
  6. }
  7. this.$set(taskDetail, 'loadIng', true);
  8. this.$set(taskDetail, 'complete', !!complete);
  9. $A.aAjax({
  10. url: 'project/task/edit',
  11. data: {
  12. act: complete ? 'complete' : 'unfinished',
  13. taskid: taskDetail.id,
  14. },
  15. complete: () => {
  16. this.$set(taskDetail, 'loadIng', false);
  17. },
  18. error: () => {
  19. this.$set(taskDetail, 'complete', !complete);
  20. alert(this.$L('网络繁忙,请稍后再试!'));
  21. },
  22. success: (res) => {
  23. if (res.ret === 1) {
  24. this.$Message.success(res.msg);
  25. typeof callback === "function" && callback(res.data);
  26. } else {
  27. this.$set(taskDetail, 'complete', !complete);
  28. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  29. }
  30. }
  31. });
  32. },
  33. renderTaskTitle(h, params, callback) {
  34. let taskDetail = params.row;
  35. return h('div', [
  36. h('Icon', {
  37. props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
  38. style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
  39. on: {
  40. click: () => {
  41. this.taskComplete(params.row, !params.row.complete, (detail) => {
  42. this.$emit("change", detail.complete ? 'complete' : 'unfinished', detail);
  43. typeof callback === "function" && callback(detail.complete ? 'complete' : 'unfinished', detail);
  44. });
  45. }
  46. }
  47. }),
  48. h('span', {
  49. style: {cursor: 'pointer'},
  50. on: {
  51. click: () => {
  52. this.taskDetail(taskDetail, (act, detail) => {
  53. for (let key in detail) {
  54. if (detail.hasOwnProperty(key)) {
  55. this.$set(taskDetail, key, detail[key])
  56. }
  57. }
  58. //
  59. if (typeof callback === "function") {
  60. callback(act, detail);
  61. } else {
  62. switch (act) {
  63. case "username": // 负责人
  64. case "delete": // 删除任务
  65. case "archived": // 归档
  66. this.lists.some((task, i) => {
  67. if (task.id == detail.id) {
  68. this.lists.splice(i, 1);
  69. return true;
  70. }
  71. });
  72. break;
  73. case "unarchived": // 取消归档
  74. let has = false;
  75. this.lists.some((task) => {
  76. if (task.id == detail.id) {
  77. return has = true;
  78. }
  79. });
  80. if (!has) {
  81. this.lists.unshift(detail);
  82. }
  83. break;
  84. }
  85. }
  86. //
  87. this.$emit("change", act, detail);
  88. });
  89. }
  90. }
  91. }, taskDetail.title)
  92. ]);
  93. }
  94. }
  95. }