cases.ui.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. $(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
  2. {
  3. const dtable = zui.DTable.query();
  4. const checkedList = dtable.$.getChecks();
  5. if(!checkedList.length) return;
  6. const url = $(this).data('url');
  7. const form = new FormData();
  8. let autoRun = false;
  9. checkedList.forEach((id) => {
  10. const caseInfo = dtable.$.getRowInfo(id).data;
  11. form.append('caseIdList[]', caseInfo.case);
  12. if(caseInfo.auto == 'auto') autoRun = true;
  13. });
  14. if($(this).data('account')) form.append('assignedTo', $(this).data('account'));
  15. if($(this).hasClass('batch-run') && autoRun)
  16. {
  17. zui.Modal.confirm({message: runCaseConfirm, onResult: function(result)
  18. {
  19. if(result)
  20. {
  21. const ztfURL = $.createLink('zanode', 'ajaxRunZTFScript', 'scriptID=' + automation);
  22. $.post(ztfURL, form, function(result)
  23. {
  24. if(result.result == 'fail')
  25. {
  26. zui.Modal.alert(result.message);
  27. return false;
  28. }
  29. if($(this).hasClass('ajax-btn'))
  30. {
  31. $.ajaxSubmit({url, data: form});
  32. }
  33. else
  34. {
  35. postAndLoadPage(url, form);
  36. }
  37. }, 'json');
  38. }
  39. }});
  40. }
  41. else
  42. {
  43. if($(this).hasClass('ajax-btn'))
  44. {
  45. $.ajaxSubmit({url, data: form});
  46. }
  47. else
  48. {
  49. postAndLoadPage(url, form);
  50. }
  51. }
  52. });
  53. /**
  54. * 标题列显示额外的内容。
  55. * Display extra content in the title column.
  56. *
  57. * @param object result
  58. * @param object info
  59. * @access public
  60. * @return object
  61. */
  62. window.onRenderCell = function(result, {row, col})
  63. {
  64. if(result)
  65. {
  66. if(col.name == 'title')
  67. {
  68. const data = row.data;
  69. const module = this.options.customData.modules[data.module];
  70. if(module) result.unshift({html: '<span class="label gray-pale rounded-full">' + module + '</span>'}); // 添加模块标签
  71. if(row.data.fromCaseID > 0 && canImportToLib)
  72. {
  73. let caseLink = $.createLink('testcase', 'view', `id=${row.data.fromCaseID}`);
  74. result.push({html: `[<a href=${caseLink} data-app='qa'><i class='icon icon-share'></i> #${row.data.fromCaseID}</a>]`}); // 添加来源用例链接
  75. }
  76. }
  77. }
  78. if((col.name == 'assignedTo' || col.name == 'pri') && row.data.isScene) delete result[0];
  79. if(row.data.isScene && col.name == 'title' && typeof result[0] == 'object')
  80. {
  81. delete result[0].props['href'];
  82. result[0].type = 'span';
  83. }
  84. return result;
  85. }