admin.ui.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. };
  24. window.toTask = function()
  25. {
  26. const projectID = $('[name="taskProjects"]').val();
  27. const executionID = $('[name="executions"]').val() ? $('[name="executions"]').val() : 0;
  28. const feedbackID = $('#feedbackID').val();
  29. if(projectID && executionID != 0)
  30. {
  31. zui.Modal.hide('#toTask');
  32. const url = $.createLink('task', 'create', 'executionID=' + executionID + '&storyID=0&moduleID=0&taskID=0&todoID=0&extra=projectID=' + projectID + ',feedbackID=' + feedbackID);
  33. loadPage(url);
  34. }
  35. else if(projectID == 0)
  36. {
  37. zui.Modal.alert(errorNoProject);
  38. }
  39. else
  40. {
  41. zui.Modal.alert(errorNoExecution);
  42. }
  43. };
  44. function getProjects(productID)
  45. {
  46. const link = $.createLink('feedback', 'ajaxGetProjects', 'productID=' + productID + '&field=taskProjects');
  47. $.getJSON(link, function(data)
  48. {
  49. if(data)
  50. {
  51. let $projectPicker = $('[name=taskProjects]').zui('picker');
  52. $projectPicker.render(data);
  53. $projectPicker.$.setValue('');
  54. }
  55. });
  56. }
  57. function changeTaskProjects(event)
  58. {
  59. const projectID = event != undefined ? $(event.target).val() : $('[name="taskProjects"]').val();
  60. if(!projectID) return;
  61. const link = $.createLink('feedback', 'ajaxGetExecutions', 'projectID=' + projectID);
  62. $.getJSON(link, function(data)
  63. {
  64. if(data)
  65. {
  66. let $executionPicker = $('[name=executions]').zui('picker');
  67. $executionPicker.render(data);
  68. $executionPicker.$.setValue(data.defaultValue);
  69. }
  70. });
  71. }
  72. window.firstRendered = false;
  73. window.toggleCheckRows = function(idList)
  74. {
  75. if(!idList?.length || firstRendered) return;
  76. firstRendered = true;
  77. const dtable = zui.DTable.query($('#feedbacks'));
  78. dtable.$.toggleCheckRows(idList.split(','), true);
  79. }
  80. window.checkedChange = function(changes)
  81. {
  82. if(!this._checkedRows) this._checkedRows = {};
  83. Object.keys(changes).forEach((rowID) =>
  84. {
  85. const row = this.getRowInfo(rowID);
  86. if(row !== undefined) this._checkedRows[rowID] = row.data;
  87. });
  88. }
  89. window.insertListToDoc = function()
  90. {
  91. const dtable = zui.DTable.query($('#feedbacks'));
  92. const myTable = dtable.$;
  93. const checkedList = Object.keys(myTable.state.checkedRows);
  94. if(!checkedList.length) return;
  95. let {cols} = dtable.options;
  96. const data = checkedList.map(rowID => myTable._checkedRows[rowID]).filter(item => item != undefined);
  97. const docID = getDocApp()?.docID;
  98. const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=feedback&blockID=${blockID}`);
  99. const formData = new FormData();
  100. formData.append('cols', JSON.stringify(cols));
  101. formData.append('data', JSON.stringify(data));
  102. formData.append('idList', checkedList.join(','));
  103. formData.append('url', insertListLink);
  104. $.post(url, formData, function(resp)
  105. {
  106. resp = JSON.parse(resp);
  107. if(resp.result == 'success')
  108. {
  109. const oldBlockID = resp.oldBlockID;
  110. const newBlockID = resp.newBlockID;
  111. zui.Modal.hide();
  112. window.insertZentaoList && window.insertZentaoList('feedback', newBlockID, null, oldBlockID) ;
  113. }
  114. });
  115. }
  116. window.renderCell = function(result, info)
  117. {
  118. if(info.col.name == 'title' && result)
  119. {
  120. const module = this.options.modules[info.row.data.module];
  121. if(module) result.unshift({html: '<span class="label gray-pale rounded-full whitespace-nowrap w-auto">' + module + '</span>'}); // 添加模块标签
  122. }
  123. if(info.col.name == 'status' && result)
  124. {
  125. result[0].props.children = info.row.data.realStatus;
  126. }
  127. return result;
  128. };