bug.ui.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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('bugIdList[]', 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.onRenderBugNameCell = function(result, info)
  19. {
  20. if(info.col.name === 'title' && info.row.data.case && info.row.data.case != '0')
  21. {
  22. result[result.length] = {html: '<a href=\'' + testcaseLink.replace('{case}', info.row.data.case).replace('{caseVersion}', info.row.data.caseVersion) + '\' title=\'' + info.row.data.case + '\'>' + testcaseTitle.replace('{case}', info.row.data.case) + '</a>'};
  23. }
  24. if(info.col.name == 'deadline' && result[0])
  25. {
  26. const bug = info.row.data;
  27. if(['resolved', 'closed'].includes(bug.status)) return result;
  28. const yesterday = zui.formatDate(zui.createDate() - 24 * 60 * 60 * 1000, 'yyyy-MM-dd');
  29. if(result[0] <= yesterday) result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + result[0] + '</span>'};
  30. }
  31. return result;
  32. }
  33. /**
  34. * 计算表格信息的统计。
  35. * Set summary for table footer.
  36. *
  37. * @param element element
  38. * @param array checks
  39. * @access public
  40. * @return object
  41. */
  42. window.setStatistics = function(element, checks)
  43. {
  44. if(checks.length) return checkedSummary.replace('{checked}', checks.length);
  45. return element.options.customData ? element.options.customData.pageSummary : null;
  46. }