browse.ui.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if($(this).hasClass('batch-delete-btn'))
  12. {
  13. zui.Modal.confirm(confirmBatchDelete).then((res) => {if(res) $.ajaxSubmit({url, data:form});});
  14. }
  15. else
  16. {
  17. $.ajaxSubmit({url, data:form});
  18. }
  19. }
  20. else
  21. {
  22. postAndLoadPage(url, form);
  23. }
  24. });
  25. /**
  26. * 标题列显示额外的内容。
  27. * Display extra content in the title column.
  28. *
  29. * @param object result
  30. * @param object info
  31. * @access public
  32. * @return object
  33. */
  34. window.onRenderCell = function(result, {row, col})
  35. {
  36. if(result)
  37. {
  38. if(col.name == 'title')
  39. {
  40. const data = row.data;
  41. const module = this.options.customData.modules[data.module];
  42. if(data.color) result[0].props.style = 'color: ' + data.color;
  43. if(module) result.unshift({html: '<span class="label gray-pale rounded-full">' + module + '</span>'}); // 添加模块标签
  44. }
  45. }
  46. return result;
  47. }
  48. window.firstRendered = false;
  49. window.toggleCheckRows = function(idList)
  50. {
  51. if(!idList?.length || firstRendered) return;
  52. firstRendered = true;
  53. const dtable = zui.DTable.query($('#caselib'));
  54. dtable.$.toggleCheckRows(idList.split(','), true);
  55. }