all.ui.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 $target = $(this);
  7. if($target.hasClass('batch-close-btn'))
  8. {
  9. const getNonClosableLink = $.createLink('execution', 'ajaxGetNonClosableExecutions', 'executionID=' + checkedList.join(','));
  10. $.getJSON(getNonClosableLink, function(exeuctions)
  11. {
  12. if(!exeuctions || exeuctions.length == 0)
  13. {
  14. postBatchBtn($target, checkedList);
  15. return;
  16. }
  17. const confirmCloseTip = confirmBatchCloseExecution.replace('%s', exeuctions.join(', '));
  18. zui.Modal.confirm(confirmCloseTip).then((res) =>
  19. {
  20. if(res) postBatchBtn($target, checkedList);
  21. });
  22. });
  23. }
  24. else
  25. {
  26. postBatchBtn($target, checkedList);
  27. }
  28. });
  29. const today = zui.formatDate(new Date(), 'yyyy-MM-dd');
  30. window.onRenderCell = function(result, {col, row})
  31. {
  32. if(col.name == 'nameCol')
  33. {
  34. const executionLink = $.createLink('execution', 'task', `executionID=${row.data.rawID}`);
  35. const executionType = typeList[row.data.type];
  36. let executionName = `<span class='label secondary-pale flex-none'>${executionType}</span> `;
  37. executionName += '<div class="ml-1 clip" style="width: max-content;">';
  38. executionName += (!row.data.isParent) ? `<a href="${executionLink}" class="text-primary">${row.data.name}</a>` : row.data.name;
  39. executionName += '</div>';
  40. executionName += (row.data.delay > 0) ? '<span class="label danger-pale ml-1 flex-none">' + delayWarning.replace('%s', row.data.delay) + '</span>' : '';
  41. result.push({html: executionName, className: 'w-full flex items-center'});
  42. return result;
  43. }
  44. if(['estimate', 'consumed','left'].includes(col.name) && result) result[0] = {html: result[0] + ' h'};
  45. return result;
  46. }
  47. function postBatchBtn($target, checkedList)
  48. {
  49. const url = $target.data('url');
  50. const form = new FormData();
  51. checkedList.forEach((id) => form.append('executionIDList[]', id.replace("pid", '')));
  52. if($target.hasClass('ajax-btn'))
  53. {
  54. $.ajaxSubmit({url, data: form});
  55. }
  56. else
  57. {
  58. postAndLoadPage(url, form);
  59. }
  60. }