edit.ui.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. $(document).on('change', 'select[name^=branch]', function()
  2. {
  3. let newBranch = $('select[name^=branch]').val() ? $('select[name^=branch]').val().toString() : '';
  4. $.get($.createLink('productplan', 'ajaxGetConflict', 'planID=' + planID + '&newBranch=' + newBranch), function(conflictStories)
  5. {
  6. if(conflictStories != '')
  7. {
  8. zui.Modal.confirm(conflictStories).then((res) => {
  9. if(!res)
  10. {
  11. const $branchPicker = $('select[name^=branch]').zui('picker');
  12. $branchPicker.$.setValue(oldBranch[planID].split(','));
  13. }
  14. });
  15. }
  16. });
  17. });
  18. $(document).on('change', 'input[name=begin],input[name=end]', function()
  19. {
  20. $("input[name='delta']").prop('checked', false);
  21. });
  22. $(document).on('click', 'button[type=submit]', function()
  23. {
  24. const parentPlan = $('input[name=parent]').val();
  25. const branches = $('[name^=branch]').val();
  26. const branchIdList = branches ? branches.toString() : '';
  27. const title = $('input[name=title]').val();
  28. const begin = $('input[name=begin]').val();
  29. const end = $('input[name=end]').val();
  30. const parentBegin = typeof parentList[parentPlan] !== 'undefined' ? parentList[parentPlan]['begin'] : '';
  31. const parentEnd = typeof parentList[parentPlan] !== 'undefined' ? parentList[parentPlan]['end'] : '';
  32. const errorBegin = parentBegin && begin && begin < parentBegin;
  33. const errorEnd = parentEnd && end && end > parentEnd;
  34. if(parentPlan > 0 && branchIdList !== '' && title && !errorBegin && !errorEnd)
  35. {
  36. const link = $.createLink('productplan', 'ajaxGetDiffBranchesTip', "produtID=" + productID + "&parentID=" + parentPlan + "&branches=" + branchIdList);
  37. $.get(link, function(diffBranchesTip)
  38. {
  39. const $form = $('#editForm').find('form');
  40. const formUrl = $form.attr('action');
  41. const formData = new FormData($form[0]);
  42. if(diffBranchesTip != '')
  43. {
  44. zui.Modal.confirm(diffBranchesTip).then((res) => {
  45. if(res) $.ajaxSubmit({url: formUrl, data: formData})
  46. });
  47. }
  48. else
  49. {
  50. $.ajaxSubmit({url: formUrl, data: formData});
  51. }
  52. });
  53. return false;
  54. }
  55. });