bug.ui.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /**
  19. * 计算表格Bug信息的统计。
  20. * Set bug summary for table footer.
  21. *
  22. * @param element element
  23. * @param array checkedIDList
  24. * @access public
  25. * @return object
  26. */
  27. window.setStatistics = function(element, checkedIDList)
  28. {
  29. let totalCount = 0;
  30. const rows = element.layout.allRows;
  31. rows.forEach((row) => {
  32. if(checkedIDList.length == 0 || checkedIDList.includes(row.id))
  33. {
  34. totalCount ++;
  35. }
  36. })
  37. const summary = checkedIDList.length > 0 ? checkedSummary.replace('{0}', totalCount) : element.props.summary;
  38. return {html: summary};
  39. }
  40. /**
  41. * 标题列显示额外的内容。
  42. * Display extra content in the title column.
  43. *
  44. * @param object result
  45. * @param object info
  46. * @access public
  47. * @return object
  48. */
  49. window.onRenderCell = function(result, {row, col})
  50. {
  51. if(result && col.name == 'title')
  52. {
  53. if(row.data.color) result[0].props.style = 'color: ' + row.data.color;
  54. const module = this.options.modules[row.data.module];
  55. if(module) result.unshift({html: '<span class="label gray-pale rounded-full nowrap">' + module + '</span>'}); // 添加模块标签
  56. if(parseInt(row.data.case))
  57. {
  58. const caseLink = $.createLink('testcase', 'view', "caseID=" + row.data.case + "&version=" + row.data.caseVersion);
  59. result.push({html: '<a href="' + caseLink + '"class="text-gray" title="' + row.data.case + '">[' + caseCommonLang + '#' + row.data.case + ']</a>'});
  60. }
  61. }
  62. if(col.name == 'deadline' && result[0])
  63. {
  64. const bug = row.data;
  65. if(['resolved', 'closed'].includes(bug.status)) return result;
  66. const yesterday = zui.formatDate(zui.createDate() - 24 * 60 * 60 * 1000, 'yyyy-MM-dd');
  67. if(result[0] <= yesterday) result[0] = {html: '<span class="label danger-pale rounded-full size-sm">' + result[0] + '</span>'};
  68. }
  69. return result;
  70. }