gantt.ui.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. window.clickSubmit = async function(e)
  2. {
  3. const $taskForm = $('[formid=taskEditForm' + taskID + ']');
  4. if(confirmSyncTip.length > 0 && $('[name=story]').length > 0 && $('[name=story]').val() != '' && $('[name=story]').val() != '0' && $('[name=story]').val() != taskStory)
  5. {
  6. await zui.Modal.confirm(confirmSyncTip).then((res) =>
  7. {
  8. $taskForm.find('[name=syncChildren]').remove();
  9. $taskForm.append('<input type="hidden" name="syncChildren" value="' + (res ? '1' : '0') + '" />');
  10. });
  11. }
  12. return checkRelation();
  13. }
  14. async function checkRelation()
  15. {
  16. let confirmParentRelation = false;
  17. if($('[name=parent]').length && $('[name=parent]').val() && $('[name=parent]').val() != task.parent)
  18. {
  19. await $.get($.createLink('task', 'ajaxGetRelation', 'taskIdList=' + $('[name=parent]').val()), function(data)
  20. {
  21. if(data) confirmParentRelation = true;
  22. })
  23. }
  24. let confirmSelfRelation = false;
  25. if($('[name=status]').length && $('[name=status]').val() == 'cancel' && task.status != 'cancel')
  26. {
  27. await $.get($.createLink('task', 'ajaxGetRelation', 'taskIdList=' + task.id), function(data)
  28. {
  29. if(data) confirmSelfRelation = true;
  30. })
  31. }
  32. if(confirmParentRelation || confirmSelfRelation)
  33. {
  34. let unlinkRelationTip = (!confirmSelfRelation && confirmParentRelation) ? unlinkParentRelationTip : unlinkSelfRelationTip;
  35. await zui.Modal.confirm({message: unlinkRelationTip, actions: [{key: 'confirm', text: unlinkLang, btnType: 'primary', class: 'btn-wide'}, {key: 'cancel'}]}).then((res) =>
  36. {
  37. if(!res) return false;
  38. const link = $taskForm.attr('action');
  39. const formData = new FormData($taskForm[0]);
  40. $.ajaxSubmit({url: link, data: formData});
  41. });
  42. return false;
  43. }
  44. return true;
  45. }