linkstory.ui.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. $(document).off('click','.batch-btn').on('click', '.batch-btn', function(e)
  2. {
  3. const $modal = $(e.target).closest('.modal');
  4. const dtable = zui.DTable.query($(this).target);
  5. const checkedList = dtable.$.getChecks();
  6. if(!checkedList.length) return;
  7. const url = $(this).data('url');
  8. const form = new FormData();
  9. checkedList.forEach((id) => form.append('stories[]', id));
  10. headers = {};
  11. if($modal.length > 0) headers = {'X-Zui-Modal': true};
  12. if($(this).hasClass('ajax-btn'))
  13. {
  14. $.ajaxSubmit({url: url, data: form, headers: headers});
  15. }
  16. else
  17. {
  18. postAndLoadPage(url, form);
  19. }
  20. });
  21. /**
  22. * 渲染分支字段。
  23. * Render branch field.
  24. *
  25. * @param array result
  26. * @param object row
  27. * @param object col
  28. * @access public
  29. * @return void
  30. */
  31. window.onRenderLinkStoryCell = function(result, {row, col})
  32. {
  33. if(col.name == 'title')
  34. {
  35. const story = row.data;
  36. const gradeLabel = gradeGroup[story.type][story.grade];
  37. if(typeof gradeLabel != 'undefined')
  38. {
  39. const html = "<span class='label gray-pale rounded-xl clip'>" + gradeLabel + "</span> ";
  40. if(html) result.unshift({html});
  41. }
  42. }
  43. if(col.name !== 'branch')
  44. {
  45. return result;
  46. }
  47. if(branchGroups[row.data.product] && branchGroups[row.data.product][row.data.branch])
  48. {
  49. return [branchGroups[row.data.product][row.data.branch]];
  50. }
  51. return [''];
  52. };
  53. window.onSearchLinks = function(type, result)
  54. {
  55. loadComponent('#table-execution-linkstory', {url: result.load, component: 'dtable', partial: true});
  56. };