task.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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. }
  34. }