incomeCollect.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /*
  2. * @description:
  3. * @Author: CP
  4. * @Date: 2020-12-28 14:41:49
  5. * @FilePath: \cld\global\gridManager\fee\incomeCollect.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/income/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: 'bankDepositPrice',
  190. remind: '利息收入',
  191. align: 'center',
  192. width: '120px',
  193. text: '银行存款',
  194. template: function (title, row) {
  195. if(row.bankDepositPrice==0){
  196. return "";
  197. }
  198. return row.bankDepositPrice;
  199. }
  200. // children: [
  201. // {
  202. // key: 'username',
  203. // text: '银行存款',
  204. // align: 'center',
  205. // },
  206. // {
  207. // key: 'username2',
  208. // text: '活期理财收益',
  209. // align: 'center',
  210. // },
  211. // {
  212. // key: 'username3',
  213. // text: '固定理财收益',
  214. // align: 'center',
  215. // },
  216. // {
  217. // key: 'username4',
  218. // text: '个人借款',
  219. // align: 'center',
  220. // },
  221. // {
  222. // key: 'username5',
  223. // text: '小计',
  224. // align: 'center',
  225. // },
  226. // ],
  227. },
  228. {
  229. key: 'currentFinancPrice',
  230. remind: '利息收入',
  231. align: 'center',
  232. width: '120px',
  233. text: '活期理财收益',
  234. template: function (title, row) {
  235. if(row.currentFinancPrice==0){
  236. return "";
  237. }
  238. return row.currentFinancPrice;
  239. },
  240. },
  241. {
  242. key: 'fixedFinancPrice',
  243. remind: '利息收入',
  244. align: 'center',
  245. width: '120px',
  246. text: '固定理财收益',
  247. template: function (title, row) {
  248. if(row.fixedFinancPrice==0){
  249. return "";
  250. }
  251. return row.fixedFinancPrice;
  252. },
  253. },
  254. {
  255. key: 'personalLoanPrice',
  256. remind: '利息收入',
  257. align: 'center',
  258. width: '120px',
  259. text: '个人借款',
  260. template: function (title, row) {
  261. if(row.personalLoanPrice==0){
  262. return "";
  263. }
  264. return row.personalLoanPrice;
  265. },
  266. },
  267. {
  268. key: 'interestSubtotalPrice',
  269. remind: '利息收入',
  270. align: 'center',
  271. width: '120px',
  272. text: '小计',
  273. template: function (title, row) {
  274. if(row.interestSubtotalPrice==0){
  275. return "";
  276. }
  277. return row.interestSubtotalPrice;
  278. },
  279. },
  280. {
  281. key: 'socialSecurity',
  282. remind: '补贴收入',
  283. align: 'center',
  284. width: '120px',
  285. text: '社保',
  286. template: function (title, row) {
  287. if(row.socialSecurity==0){
  288. return "";
  289. }
  290. return row.socialSecurity;
  291. },
  292. },
  293. {
  294. key: 'finance',
  295. remind: '补贴收入',
  296. align: 'center',
  297. width: '120px',
  298. text: '财政',
  299. template: function (title, row) {
  300. if(row.finance==0){
  301. return "";
  302. }
  303. return row.finance;
  304. },
  305. },
  306. {
  307. key: 'subsidySubtotal',
  308. remind: '补贴收入',
  309. align: 'center',
  310. width: '120px',
  311. text: '小计',
  312. template: function (title, row) {
  313. if(row.subsidySubtotal==0){
  314. return "";
  315. }
  316. return row.subsidySubtotal;
  317. },
  318. },
  319. // {
  320. // key: 'typeShow',
  321. // width: '240px',
  322. // text: '补贴收入',
  323. // children: [
  324. // {
  325. // key: 'username',
  326. // text: '社保',
  327. // align: 'center',
  328. // },
  329. // {
  330. // key: 'username2',
  331. // text: '财政',
  332. // align: 'center',
  333. // },
  334. // {
  335. // key: 'username5',
  336. // text: '小计',
  337. // align: 'center',
  338. // },
  339. // ],
  340. // },
  341. {
  342. key: 'reserveFund',
  343. remind: '借款收回',
  344. align: 'center',
  345. width: '120px',
  346. text: '备用金',
  347. template: function (title, row) {
  348. if(row.reserveFund==0){
  349. return "";
  350. }
  351. return row.reserveFund;
  352. },
  353. },
  354. {
  355. key: 'privateBorrow',
  356. remind: '借款收回',
  357. align: 'center',
  358. width: '120px',
  359. text: '私人借款',
  360. template: function (title, row) {
  361. if(row.privateBorrow==0){
  362. return "";
  363. }
  364. return row.privateBorrow;
  365. },
  366. },
  367. {
  368. key: 'loanSubtotal',
  369. remind: '借款收回',
  370. align: 'center',
  371. width: '120px',
  372. text: '小计',
  373. template: function (title, row) {
  374. if(row.loanSubtotal==0){
  375. return "";
  376. }
  377. return row.loanSubtotal;
  378. },
  379. },
  380. // {
  381. // key: 'priceShow',
  382. // width: '240px',
  383. // text: '借款收回',
  384. // children: [
  385. // {
  386. // key: 'username',
  387. // text: '备用金',
  388. // align: 'center',
  389. // },
  390. // {
  391. // key: 'username2',
  392. // text: '私人借款',
  393. // align: 'center',
  394. // },
  395. // {
  396. // key: 'username5',
  397. // text: '小计',
  398. // align: 'center',
  399. // },
  400. // ],
  401. // },
  402. {
  403. key: 'zongheng',
  404. width: '120px',
  405. align: 'center',
  406. text: '纵横知道',
  407. template: function (title, row) {
  408. if(row.zongheng==0){
  409. return "";
  410. }
  411. return row.zongheng;
  412. },
  413. },
  414. {
  415. key: 'returnRemittance',
  416. width: '120px',
  417. text: '退汇',
  418. disableMoveRow: true,
  419. template: function (title, row) {
  420. if(row.returnRemittance==0){
  421. return "";
  422. }
  423. return row.returnRemittance;
  424. },
  425. },
  426. {
  427. key: 'bond',
  428. text: '保证金',
  429. width: '120px',
  430. disableMoveRow: true,
  431. template: function (title, row) {
  432. if(row.bond==0){
  433. return "";
  434. }
  435. return row.bond;
  436. },
  437. },
  438. {
  439. key: 'other',
  440. text: '其他',
  441. width: '120px',
  442. disableMoveRow: true,
  443. template: function (title, row) {
  444. if(row.other==0){
  445. return "";
  446. }
  447. return row.other;
  448. },
  449. },
  450. {
  451. key: 'subtotal',
  452. text: '合计',
  453. width: '100px',
  454. fixed: 'right',
  455. disableMoveRow: true,
  456. disableRowCheck: true,
  457. template: function (title, row) {
  458. if(row.subtotal==0){
  459. return "";
  460. }
  461. return row.subtotal;
  462. },
  463. },
  464. ]
  465. }, query => {
  466. // 渲染完成后的回调函数
  467. });
  468. },
  469. /**
  470. * 编辑功能
  471. */
  472. editRowData: function (dom) {
  473. window.GridManager.updateRowData('test', 'id', { id: window.parseInt(dom.getAttribute('data-id')), lastDate: new Date().getTime() });
  474. }
  475. };
  476. // GridManager 渲染
  477. const table = document.querySelector('#feeList');
  478. demo1.initSearch(table);
  479. demo1.initGM(table);
  480. //demo1.initFN();