testcase.ui.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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('caseIdList[]', 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. * 设置表格的统计信息。
  20. * Set 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, checks)
  28. {
  29. let failCount = 0;
  30. checks.forEach((checkID) => {
  31. const caseInfo = element.getRowInfo(checkID).data;
  32. if(caseInfo.lastRunResult != unexecuted && caseInfo.lastRunResult != 'pass') failCount ++;
  33. })
  34. if(checks.length) return {html: element.options.checkedSummary.replaceAll('%total%', `${checks.length}`).replaceAll('%fail%', failCount)};
  35. return zui.formatString(element.options.defaultSummary);
  36. }