task.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.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. $A.triggerTaskInfoListener(complete ? 'complete' : 'unfinished', 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) {
  34. return h('div', [
  35. h('Icon', {
  36. props: { type: params.row.complete ? 'md-checkbox-outline' : 'md-square-outline' },
  37. style: {marginRight: '4px', cursor: 'pointer', fontSize: '15px'},
  38. on: {
  39. click: () => {
  40. this.taskComplete(params.row, !params.row.complete);
  41. }
  42. }
  43. }),
  44. h('span', {
  45. style: {cursor: 'pointer', textDecoration: params.row.complete ? 'line-through' : ''},
  46. on: {
  47. click: () => {
  48. this.taskDetail(params.row);
  49. }
  50. }
  51. }, params.row.title)
  52. ]);
  53. }
  54. }
  55. }