task.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. export default {
  2. methods: {
  3. taskComplete(taskDetail, complete = null) {
  4. if (taskDetail['loadIng'] === true) {
  5. return;
  6. }
  7. this.$set(taskDetail, 'loadIng', true);
  8. this.$set(taskDetail, 'complete', !!complete);
  9. $A.apiAjax({
  10. url: 'project/task/edit',
  11. method: 'post',
  12. data: {
  13. act: complete ? 'complete' : 'unfinished',
  14. taskid: taskDetail.id,
  15. },
  16. complete: () => {
  17. this.$set(taskDetail, 'loadIng', false);
  18. },
  19. error: () => {
  20. this.$set(taskDetail, 'complete', !complete);
  21. alert(this.$L('网络繁忙,请稍后再试!'));
  22. },
  23. success: (res) => {
  24. if (res.ret === 1) {
  25. this.$Message.success(res.msg);
  26. $A.triggerTaskInfoListener(complete ? 'complete' : 'unfinished', res.data);
  27. $A.triggerTaskInfoChange(taskDetail.id);
  28. } else {
  29. this.$set(taskDetail, 'complete', !complete);
  30. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  31. }
  32. }
  33. });
  34. },
  35. renderTaskTitle(h, params) {
  36. return h('div', [
  37. h('Icon', {
  38. props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
  39. style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
  40. on: {
  41. click: () => {
  42. this.taskComplete(params.row, !params.row.complete);
  43. }
  44. }
  45. }),
  46. h('span', {
  47. style: {cursor: 'pointer', textDecoration: params.row.complete ? 'line-through' : ''},
  48. on: {
  49. click: () => {
  50. this.taskDetail(params.row);
  51. }
  52. }
  53. }, params.row.title)
  54. ]);
  55. }
  56. }
  57. }