longle.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2020-12-28 14:41:49
  5. * @FilePath: \cld\global\gridManager\dashboard\longle.js
  6. */
  7. // 表格唯一标识
  8. const gridManagerName = 'test';
  9. const demo1 = {
  10. /**
  11. * 初始化搜索区域
  12. */
  13. initSearch: function () {
  14. // 渲染下拉框
  15. // var typeSelect = document.querySelector('.search-area select[name="type"]');
  16. // for(let key in TYPE_MAP) {
  17. // const option = document.createElement('option');
  18. // option.value = key;
  19. // option.innerText = TYPE_MAP[key];
  20. // typeSelect.appendChild(option);
  21. // }
  22. // 绑定搜索事件
  23. document.querySelector('.search-action').addEventListener('change', function () {
  24. var _query = {
  25. year: this.value,
  26. // staffId: sid,
  27. };
  28. console.log(_query);
  29. table.GM('setQuery', _query, function () {
  30. console.log('setQuery执行成功');
  31. });
  32. });
  33. // 绑定重置
  34. // document.querySelector('.reset-action').addEventListener('click', function () {
  35. // var now = new Date();
  36. // document.querySelector('[name="kw"]').value = '';
  37. // document.querySelector('[name="categoryId"]').value = '';
  38. // document.querySelector('[name="year"]').value = now.getFullYear();
  39. // document.querySelector('[name="month"]').value = '';
  40. // document.querySelector('[name="staffId"]').value = '';
  41. // document.querySelector('[name="feeType"]').value = '';
  42. // });
  43. },
  44. /**
  45. * 初始化表格
  46. */
  47. initGM: function () {
  48. new window.GridManager(table, {
  49. gridManagerName: 'test',
  50. width: '100%',
  51. height: '520px',
  52. // 初始渲染时是否加载数据
  53. // firstLoading: false,
  54. supportAutoOrder: false,
  55. // 自动序号配置
  56. // autoOrderConfig: {
  57. // // 固定列
  58. // fixed: 'left'
  59. // },
  60. supportCheckbox: false,
  61. // 选择框配置
  62. // checkboxConfig: {
  63. // // 使用单选
  64. // // useRadio: true,
  65. // // 使用行选中
  66. // // useRowCheck: true,
  67. // key: 'id',
  68. // // 复选时最大可选数
  69. // // max: 2,
  70. // // 固定列
  71. // fixed: 'left'
  72. // },
  73. // 是否使用无总条数模式
  74. // useNoTotalsMode: true,
  75. // 是否开启分页
  76. supportAjaxPage: false,
  77. // 排序模式,single(升降序单一触发) overall(升降序整体触发)
  78. sortMode: 'single',
  79. // 右键菜单
  80. supportMenu: false,
  81. // 禁用缓存
  82. disableCache: false,
  83. ajaxData: function (settings, params) {
  84. // document.querySelector('[name="categoryId"]').value = params.categoryId || "";
  85. return '/json/dashboard/software/count?staffId='+sid;
  86. },
  87. emptyTemplate: settings => {
  88. return `<div style="text-align: center;">${settings.query.title ? '搜索为空' : '暂无数据'}</div>`;
  89. },
  90. columnData: [
  91. {
  92. key: 'date',
  93. width: '160px',
  94. text: '时间',
  95. disableMoveRow: true,
  96. // 使用函数返回 dom node
  97. // template: function (title, row) {
  98. // var titleNode = document.createElement('a');
  99. // titleNode.setAttribute('href', `/expensesDoc/10`);
  100. // titleNode.setAttribute('title', title);
  101. // titleNode.setAttribute('target', '_blank');
  102. // titleNode.innerText = title;
  103. // titleNode.title = `点击阅读[${row.title}]`;
  104. // titleNode.classList.add('plugin-action');
  105. // return titleNode;
  106. // }
  107. },
  108. {
  109. key: 'lend',
  110. // remind: '报销单,借款,对公汇款,培训班',
  111. width: '160px',
  112. text: '借出',
  113. disableMoveRow: true
  114. },
  115. {
  116. key: 'sale',
  117. width: '160px',
  118. text: '销售',
  119. disableMoveRow: true
  120. },
  121. {
  122. key: 'give',
  123. width: '160px',
  124. text: '赠送',
  125. disableMoveRow: true
  126. },
  127. {
  128. key: 'upgrade',
  129. // width: '140px',
  130. text: '升级',
  131. disableMoveRow: true,
  132. },
  133. ]
  134. }, query => {
  135. // 渲染完成后的回调函数
  136. // console.log('渲染完成后的回调函数:', query);
  137. });
  138. },
  139. /**
  140. * 编辑功能
  141. */
  142. editRowData: function (dom) {
  143. window.GridManager.updateRowData('test', 'id', { id: window.parseInt(dom.getAttribute('data-id')), lastDate: new Date().getTime() });
  144. }
  145. };
  146. // GridManager 渲染
  147. const table = document.querySelector('#feeList');
  148. demo1.initSearch(table);
  149. demo1.initGM(table);
  150. //demo1.initFN();