expensesCollect.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2020-12-28 14:41:49
  5. * @FilePath: \cld\global\gridManager\fee\expensesCollect.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('click', function () {
  24. var _query = {
  25. year: document.querySelector('[name="year"]').value,
  26. month: document.querySelector('[name="month"]').value,
  27. // expensesType: document.querySelector('[name="expensesType"]').value,
  28. };
  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="year"]').value = now.getFullYear();
  37. document.querySelector('[name="month"]').value = '';
  38. // document.querySelector('[name="expensesType"]').value = '';
  39. });
  40. },
  41. /**
  42. * 初始化表格
  43. */
  44. initGM: function () {
  45. new window.GridManager(table, {
  46. gridManagerName: 'test',
  47. width: '100%',
  48. height: '100%',
  49. supportAutoOrder: false,
  50. supportCheckbox: false,
  51. // 选择框配置
  52. // checkboxConfig: {
  53. // // 使用单选
  54. // // useRadio: true,
  55. // // 使用行选中
  56. // // useRowCheck: true,
  57. // key: 'id',
  58. // // 复选时最大可选数
  59. // // max: 2,
  60. // // 固定列
  61. // fixed: 'left'
  62. // },
  63. // 是否使用无总条数模式
  64. // useNoTotalsMode: true,
  65. // 是否开启分页
  66. supportAjaxPage: false,
  67. // 排序模式,single(升降序单一触发) overall(升降序整体触发)
  68. sortMode: 'single',
  69. // supportAdjust: false,
  70. // 右键菜单
  71. supportMenu: true,
  72. // menuHandler: list => {
  73. // list.unshift({
  74. // content: '自定义菜单',
  75. // line: true,
  76. // onClick: _ => {
  77. // alert(_);
  78. // }
  79. // });
  80. // return list;
  81. // },
  82. // 禁用分割线
  83. // disableLine: true,
  84. // 设置表头的icon图标是否跟随文本
  85. // isIconFollowText: true,
  86. // 组合排序
  87. // isCombSorting: true,
  88. // 合并排序
  89. // mergeSort: true,
  90. // 禁用边框线
  91. // disableBorder: true,
  92. // 行移动
  93. // supportMoveRow: true,
  94. // moveRowConfig: {
  95. // key: 'priority',
  96. // useSingleMode: true,
  97. // fixed: 'left',
  98. // handler: (list, tableData) => {
  99. // //console.log(list, tableData);
  100. // }
  101. // },
  102. // 禁用缓存
  103. disableCache: false,
  104. ajaxData: function (settings, params) {
  105. // document.querySelector('[name="categoryId"]').value = params.categoryId || "";
  106. return '/json/expenses/collect';
  107. },
  108. // 导出配置
  109. exportConfig: {
  110. fileName: query => {
  111. const date = new Date();
  112. let fileName = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
  113. for (let key in query) {
  114. fileName = `${fileName}-${key}=${query[key]}`;
  115. }
  116. return fileName;
  117. },
  118. suffix: 'xls'
  119. },
  120. ajaxType: 'GET',
  121. // 选择事件执行前事件
  122. checkedBefore: function (checkedList, isChecked, row) {
  123. console.log('checkedBefore==', checkedList, isChecked, row);
  124. if (row && row.id === 90) {
  125. alert('该节点在checkedBefore中配置为不可选');
  126. }
  127. return row && row.id !== 90;
  128. },
  129. // 执行请求后执行程序
  130. // responseHandler: res => {
  131. // res.data.forEach(item => {
  132. // // 用id模拟优先级字段
  133. // item.priority = item.id;
  134. // });
  135. // return res;
  136. // },
  137. // 单行数据渲染时执行程序
  138. // rowRenderHandler: (row, index) => {
  139. // // if (row.id === 90) {
  140. // // row.gm_checkbox = true;
  141. // // }
  142. // // 指定第92行不可选中
  143. // if (row.id === 92) {
  144. // // row.gm_checkbox = true;
  145. // row.gm_checkbox_disabled = true;
  146. // row.gm_row_class_name = 'test-row-class';
  147. // }
  148. // return row;
  149. // },
  150. emptyTemplate: settings => {
  151. return `<div style="text-align: center;">${settings.query.title ? '搜索为空' : '暂无数据'}</div>`;
  152. },
  153. // 单个td的hover事件
  154. // cellClick: (row, rowIndex, colIndex) => {
  155. // // console.log(row, rowIndex, colIndex);
  156. // return {
  157. // text: '这里有个提示',
  158. // position: 'left'
  159. // };
  160. // },
  161. // rowHover: (a, b, c) => {
  162. // return {
  163. // text: '这里有个提示',
  164. // position: 'right'
  165. // };
  166. // },
  167. // useWordBreak: true,
  168. // fullColumn: {
  169. // useFold: true,
  170. // fixed: 'left', // 折叠事件列固定方向
  171. // openState: false,
  172. // bottomTemplate: function(row, index){
  173. // return `
  174. // <p>费用说明</p>
  175. // <pre>${row.explanation}</pre>`;
  176. // }
  177. // },
  178. columnData: [
  179. {
  180. key: 'month',
  181. width: '60px',
  182. fixed: 'left',
  183. align: 'center',
  184. disableMoveRow: true,
  185. disableRowCheck: true,
  186. text: '月/日',
  187. },
  188. {
  189. key: 'bankCharges',
  190. align: 'center',
  191. width: '120px',
  192. text: '银行手续费',
  193. template: function (title, row) {
  194. if(row.bankCharges==0){
  195. return "";
  196. }
  197. return row.bankCharges;
  198. }
  199. },
  200. {
  201. key: 'telephoneRate',
  202. align: 'center',
  203. width: '120px',
  204. text: '总部电话费',
  205. template: function (title, row) {
  206. if(row.telephoneRate==0){
  207. return "";
  208. }
  209. return row.telephoneRate;
  210. }
  211. },
  212. {
  213. key: 'addedTax',
  214. remind: '缴税',
  215. align: 'center',
  216. width: '120px',
  217. text: '增值税',
  218. template: function (title, row) {
  219. if(row.addedTax==0){
  220. return "";
  221. }
  222. return row.addedTax;
  223. },
  224. },
  225. {
  226. key: 'surcharges',
  227. remind: '缴税',
  228. align: 'center',
  229. width: '120px',
  230. text: '税金附加',
  231. template: function (title, row) {
  232. if(row.surcharges==0){
  233. return "";
  234. }
  235. return row.surcharges;
  236. },
  237. },
  238. {
  239. key: 'corporateIncomeTax',
  240. remind: '缴税',
  241. align: 'center',
  242. width: '120px',
  243. text: '企业所得税',
  244. template: function (title, row) {
  245. if(row.corporateIncomeTax==0){
  246. return "";
  247. }
  248. return row.corporateIncomeTax;
  249. },
  250. },
  251. {
  252. key: 'socialSecurity',
  253. remind: '缴税',
  254. align: 'center',
  255. width: '120px',
  256. text: '工会费',
  257. template: function (title, row) {
  258. if(row.socialSecurity==0){
  259. return "";
  260. }
  261. return row.socialSecurity;
  262. },
  263. },
  264. {
  265. key: 'unionFees',
  266. remind: '缴税',
  267. align: 'center',
  268. width: '120px',
  269. text: '社保',
  270. template: function (title, row) {
  271. if(row.unionFees==0){
  272. return "";
  273. }
  274. return row.unionFees;
  275. },
  276. },
  277. {
  278. key: 'personalIncomeTax',
  279. remind: '缴税',
  280. align: 'center',
  281. width: '120px',
  282. text: '个税',
  283. template: function (title, row) {
  284. if(row.personalIncomeTax==0){
  285. return "";
  286. }
  287. return row.personalIncomeTax;
  288. },
  289. },
  290. {
  291. key: 'stampDuty',
  292. remind: '缴税',
  293. align: 'center',
  294. width: '120px',
  295. text: '印花税',
  296. template: function (title, row) {
  297. if(row.stampDuty==0){
  298. return "";
  299. }
  300. return row.stampDuty;
  301. },
  302. },{
  303. key: 'payTaxesSubtotal',
  304. remind: '缴税',
  305. align: 'center',
  306. width: '120px',
  307. text: '小计',
  308. template: function (title, row) {
  309. if(row.payTaxesSubtotal==0){
  310. return "";
  311. }
  312. return row.payTaxesSubtotal;
  313. },
  314. },
  315. {
  316. key: 'bond',
  317. width: '120px',
  318. align: 'center',
  319. text: '保证金',
  320. template: function (title, row) {
  321. if(row.bond==0){
  322. return "";
  323. }
  324. return row.bond;
  325. },
  326. },
  327. {
  328. key: 'wenku',
  329. align: 'center',
  330. width: '120px',
  331. text: '纵横文库提现',
  332. template: function (title, row) {
  333. if(row.wenku==0){
  334. return "";
  335. }
  336. return row.wenku;
  337. },
  338. },
  339. {
  340. key: 'other',
  341. align: 'center',
  342. width: '120px',
  343. text: '其他',
  344. template: function (title, row) {
  345. if(row.other==0){
  346. return "";
  347. }
  348. return row.other;
  349. },
  350. },
  351. {
  352. key: 'subtotal',
  353. text: '合计',
  354. width: '100px',
  355. fixed: 'right',
  356. disableMoveRow: true,
  357. disableRowCheck: true,
  358. template: function (title, row) {
  359. if(row.subtotal==0){
  360. return "";
  361. }
  362. return row.subtotal;
  363. },
  364. },
  365. ]
  366. }, query => {
  367. // 渲染完成后的回调函数
  368. });
  369. },
  370. /**
  371. * 编辑功能
  372. */
  373. editRowData: function (dom) {
  374. window.GridManager.updateRowData('test', 'id', { id: window.parseInt(dom.getAttribute('data-id')), lastDate: new Date().getTime() });
  375. }
  376. };
  377. // GridManager 渲染
  378. const table = document.querySelector('#feeList');
  379. demo1.initSearch(table);
  380. demo1.initGM(table);
  381. //demo1.initFN();