execution.ui.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. $(document).off('click', '#showTask').on('click', '#showTask', function()
  2. {
  3. const show = $(this).is(':checked') ? 1 : 0;
  4. $.cookie.set('showTask', show, {expires:config.cookieLife, path:config.webRoot});
  5. if(show == 0 && status == 'bysearch')
  6. {
  7. loadPage($.createLink('project', 'execution', 'status=undone&projectID=' + projectID));
  8. }
  9. else
  10. {
  11. reloadPage();
  12. }
  13. });
  14. $(document).off('click', '#showStage').on('click', '#showStage', function()
  15. {
  16. const show = $(this).is(':checked') ? 1 : 0;
  17. $.cookie.set('showStage', show, {expires:config.cookieLife, path:config.webRoot});
  18. reloadPage();
  19. });
  20. $(document).off('click','.batch-btn').on('click', '.batch-btn', function()
  21. {
  22. const dtable = zui.DTable.query($(this).target);
  23. const checkedList = dtable.$.getChecks();
  24. if(!checkedList.length) return;
  25. const url = $(this).data('url');
  26. const form = new FormData();
  27. checkedList.forEach((id) => form.append('executionIDList[]', id.replace("pid", '')));
  28. if($(this).hasClass('ajax-btn'))
  29. {
  30. $.ajaxSubmit({url, data:form});
  31. }
  32. else
  33. {
  34. postAndLoadPage(url, form);
  35. }
  36. });
  37. const today = zui.formatDate(new Date(), 'yyyy-MM-dd');
  38. window.onRenderCell = function(result, {col, row})
  39. {
  40. const data = row.data;
  41. if(col.name == 'nameCol')
  42. {
  43. const executionType = typeList[data.type];
  44. let html = '';
  45. if(typeof executionType != 'undefined') html += `<span class='label secondary-pale rounded-full mr-1 whitespace-nowrap'>${executionType}</span> `;
  46. if(typeof result[0] == 'object')
  47. {
  48. result[0].props.className = 'overflow-hidden';
  49. result[0].props.children = data.type == 'point' ? '' : data.name;
  50. if(data.id.indexOf('tid') > -1 && data.type != 'point')
  51. {
  52. result[0].props.children = data.rawName;
  53. result[0].props.href = $.createLink('task', 'view', 'taskID=' + data.rawID);
  54. html += data.prefixLabel;
  55. }
  56. if(data.type == 'point' || (executionType !== undefined && data.isParent) || (data.type == 'kanban' && data.isTpl == '1'))
  57. {
  58. if(result[0].props.href !== undefined) delete result[0].props.href;
  59. result[0].type = 'span';
  60. if(data.type == 'point') html += data.name;
  61. }
  62. }
  63. if(typeof result[0] == 'string')
  64. {
  65. if(data.id.indexOf('tid') > -1 && data.type != 'point')
  66. {
  67. result[0] = data.rawName;
  68. html += data.prefixLabel;
  69. }
  70. if(data.type == 'point')
  71. {
  72. result[0] = '';
  73. html += data.name;
  74. }
  75. }
  76. result[1].attrs.title = typeof data.rawName != 'undefined' && data.rawName ? data.rawName : data.name;
  77. if(html) result.unshift({className: 'flex items-center', html: html});
  78. if(typeof data.delay != 'undefined' && data.delay > 0 && data.type != 'point' && data.end != '' && data.end != '0000-00-00' && today > data.end)
  79. {
  80. result.push({html: '<span class="label danger-pale ml-1 flex-none nowrap">' + delayWarning.replace('%s', data.delay) + '</span>', className: 'flex items-end', style: { flexDirection: "column" } });
  81. }
  82. return result;
  83. }
  84. if(col.name == 'rawID' && data.parent && !data.isExecution) result.push({className: 'ml-5'});
  85. if(['estimate', 'consumed', 'left', 'totalEstimate', 'totalConsumed', 'totalLeft'].includes(col.name) && result && typeof result[0] != 'undefined') result[0] = data.type == 'point' ? '' : {html: result[0] + ' h'};
  86. if(col.name == 'progress' && data.type == 'point') result[0] = '';
  87. return result;
  88. }
  89. window.footerSummary = function(element, checkedIdList)
  90. {
  91. const rows = element.layout.rows;
  92. var totalCount = 0;
  93. var waitCount = 0;
  94. var doingCount = 0;
  95. rows.forEach(function(data)
  96. {
  97. if(data.id.indexOf('tid') > -1) return;
  98. if(checkedIdList.length > 0 && checkedIdList.indexOf(data.id) > -1)
  99. {
  100. if(data.data.status == 'wait') waitCount ++;
  101. if(data.data.status == 'doing') doingCount ++;
  102. totalCount ++;
  103. }
  104. else if(checkedIdList.length == 0)
  105. {
  106. if(data.data.status == 'wait') waitCount ++;
  107. if(data.data.status == 'doing') doingCount ++;
  108. totalCount ++;
  109. }
  110. });
  111. return {html: (checkedIdList.length > 0 ? checkedExecSummary : pageExecSummary).replace('%total%', totalCount).replace('%wait%', waitCount).replace('%doing%', doingCount)};
  112. };
  113. window.confirmCreateStage = function(projectID, productID, executionID, hasChild)
  114. {
  115. if(hasChild) loadPage($.createLink('programplan', 'create', `projectID=${projectID}&productID=${productID}&planID=${executionID}`));
  116. const link = $.createLink('project', 'ajaxCheckHasStageData', `executionID=${executionID}`);
  117. $.get(link, function(hasData)
  118. {
  119. if(hasData)
  120. {
  121. zui.Modal.confirm(confirmCreateStage).then((res) =>
  122. {
  123. if(res) loadPage($.createLink('programplan', 'create', `projectID=${projectID}&productID=${productID}&planID=${executionID}&executionType=stage&from=&syncData=1`));
  124. });
  125. }
  126. else
  127. {
  128. loadPage($.createLink('programplan', 'create', `projectID=${projectID}&productID=${productID}&planID=${executionID}`));
  129. }
  130. })
  131. }