feedback.ui.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. $(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
  2. {
  3. const dtable = zui.DTable.query($(this).target);
  4. const checkedList = dtable.$.getChecks();
  5. if(!checkedList.length) return;
  6. const url = $(this).data('url');
  7. const form = new FormData();
  8. checkedList.forEach((id) => form.append('feedbackIDList[]', id));
  9. if($(this).hasClass('ajax-btn'))
  10. {
  11. $.ajaxSubmit({url, data:form});
  12. }
  13. else
  14. {
  15. postAndLoadPage(url, form);
  16. }
  17. });
  18. window.clickTotask = function(event)
  19. {
  20. const params = $(event.target).closest('a').attr('href').split('&');
  21. $('#feedbackID').val(params[0]);
  22. getProjects(params[1]);
  23. changeTaskProjects();
  24. };
  25. window.toTask = function()
  26. {
  27. const projectID = $('[name="taskProjects"]').val();
  28. const executionID = $('[name="executions"]').val() ? $('[name="executions"]').val() : 0;
  29. const feedbackID = $('#feedbackID').val();
  30. changeTaskProjects();
  31. if(projectID && executionID != 0)
  32. {
  33. zui.Modal.hide('#toTask');
  34. const url = $.createLink('task', 'create', 'executionID=' + executionID + '&storyID=0&moduleID=0&taskID=0&todoID=0&extra=projectID=' + projectID + ',feedbackID=' + feedbackID);
  35. openPage(url, 'execution');
  36. }
  37. else if(projectID == 0)
  38. {
  39. zui.Modal.alert(errorNoProject);
  40. }
  41. else
  42. {
  43. zui.Modal.alert(errorNoExecution);
  44. }
  45. };
  46. function getProjects(productID)
  47. {
  48. const link = $.createLink('feedback', 'ajaxGetProjects', 'productID=' + productID + '&field=taskProjects');
  49. $.getJSON(link, function(data)
  50. {
  51. if(data)
  52. {
  53. let $projectPicker = $('[name=taskProjects]').zui('picker');
  54. $projectPicker.render(data);
  55. $projectPicker.$.setValue('');
  56. }
  57. });
  58. }
  59. function changeTaskProjects(event)
  60. {
  61. const projectID = event != undefined ? $(event.target).val() : $('[name="taskProjects"]').val();
  62. const link = $.createLink('feedback', 'ajaxGetExecutions', 'projectID=' + projectID);
  63. $.getJSON(link, function(data)
  64. {
  65. if(data)
  66. {
  67. let $executionPicker = $('[name=executions]').zui('picker');
  68. $executionPicker.render(data);
  69. $executionPicker.$.setValue('');
  70. }
  71. });
  72. }