| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- /*
- * @description:
- * @Author: CP
- * @Date: 2020-12-28 14:41:49
- * @FilePath: \cld\global\gridManager\fee\expensesCollect.js
- */
- // 表格唯一标识
- const gridManagerName = 'test';
- const demo1 = {
- /**
- * 初始化搜索区域
- */
- initSearch: function () {
- // 渲染下拉框
- // var typeSelect = document.querySelector('.search-area select[name="type"]');
- // for(let key in TYPE_MAP) {
- // const option = document.createElement('option');
- // option.value = key;
- // option.innerText = TYPE_MAP[key];
- // typeSelect.appendChild(option);
- // }
- // 绑定搜索事件
- document.querySelector('.search-action').addEventListener('click', function () {
- var _query = {
-
- year: document.querySelector('[name="year"]').value,
- month: document.querySelector('[name="month"]').value,
- // expensesType: document.querySelector('[name="expensesType"]').value,
-
- };
- table.GM('setQuery', _query, function () {
- console.log('setQuery执行成功');
- });
- });
- // 绑定重置
- document.querySelector('.reset-action').addEventListener('click', function () {
- var now = new Date();
-
- document.querySelector('[name="year"]').value = now.getFullYear();
- document.querySelector('[name="month"]').value = '';
- // document.querySelector('[name="expensesType"]').value = '';
-
- });
- },
- /**
- * 初始化表格
- */
- initGM: function () {
- new window.GridManager(table, {
- gridManagerName: 'test',
- width: '100%',
- height: '100%',
-
- supportAutoOrder: false,
- supportCheckbox: false,
- // 选择框配置
- // checkboxConfig: {
- // // 使用单选
- // // useRadio: true,
- // // 使用行选中
- // // useRowCheck: true,
- // key: 'id',
- // // 复选时最大可选数
- // // max: 2,
- // // 固定列
- // fixed: 'left'
- // },
- // 是否使用无总条数模式
- // useNoTotalsMode: true,
- // 是否开启分页
- supportAjaxPage: false,
- // 排序模式,single(升降序单一触发) overall(升降序整体触发)
- sortMode: 'single',
- // supportAdjust: false,
- // 右键菜单
- supportMenu: true,
- // menuHandler: list => {
- // list.unshift({
- // content: '自定义菜单',
- // line: true,
- // onClick: _ => {
- // alert(_);
- // }
- // });
- // return list;
- // },
- // 禁用分割线
- // disableLine: true,
- // 设置表头的icon图标是否跟随文本
- // isIconFollowText: true,
- // 组合排序
- // isCombSorting: true,
- // 合并排序
- // mergeSort: true,
- // 禁用边框线
- // disableBorder: true,
- // 行移动
- // supportMoveRow: true,
- // moveRowConfig: {
- // key: 'priority',
- // useSingleMode: true,
- // fixed: 'left',
- // handler: (list, tableData) => {
- // //console.log(list, tableData);
- // }
- // },
- // 禁用缓存
- disableCache: false,
- ajaxData: function (settings, params) {
- // document.querySelector('[name="categoryId"]').value = params.categoryId || "";
- return '/json/expenses/collect';
- },
- // 导出配置
- exportConfig: {
- fileName: query => {
- const date = new Date();
- let fileName = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
- for (let key in query) {
- fileName = `${fileName}-${key}=${query[key]}`;
- }
- return fileName;
- },
- suffix: 'xls'
- },
- ajaxType: 'GET',
- // 选择事件执行前事件
- checkedBefore: function (checkedList, isChecked, row) {
- console.log('checkedBefore==', checkedList, isChecked, row);
- if (row && row.id === 90) {
- alert('该节点在checkedBefore中配置为不可选');
- }
- return row && row.id !== 90;
- },
- // 执行请求后执行程序
- // responseHandler: res => {
- // res.data.forEach(item => {
- // // 用id模拟优先级字段
- // item.priority = item.id;
- // });
- // return res;
- // },
- // 单行数据渲染时执行程序
- // rowRenderHandler: (row, index) => {
- // // if (row.id === 90) {
- // // row.gm_checkbox = true;
- // // }
- // // 指定第92行不可选中
- // if (row.id === 92) {
- // // row.gm_checkbox = true;
- // row.gm_checkbox_disabled = true;
- // row.gm_row_class_name = 'test-row-class';
- // }
- // return row;
- // },
- emptyTemplate: settings => {
- return `<div style="text-align: center;">${settings.query.title ? '搜索为空' : '暂无数据'}</div>`;
- },
- // 单个td的hover事件
- // cellClick: (row, rowIndex, colIndex) => {
- // // console.log(row, rowIndex, colIndex);
- // return {
- // text: '这里有个提示',
- // position: 'left'
- // };
- // },
- // rowHover: (a, b, c) => {
- // return {
- // text: '这里有个提示',
- // position: 'right'
- // };
- // },
- // useWordBreak: true,
- // fullColumn: {
- // useFold: true,
- // fixed: 'left', // 折叠事件列固定方向
- // openState: false,
- // bottomTemplate: function(row, index){
- // return `
- // <p>费用说明</p>
- // <pre>${row.explanation}</pre>`;
- // }
- // },
- columnData: [
- {
- key: 'month',
- width: '60px',
- fixed: 'left',
- align: 'center',
- disableMoveRow: true,
- disableRowCheck: true,
- text: '月/日',
- },
- {
- key: 'bankCharges',
- align: 'center',
- width: '120px',
- text: '银行手续费',
- template: function (title, row) {
- if(row.bankCharges==0){
- return "";
- }
- return row.bankCharges;
- }
- },
- {
- key: 'telephoneRate',
- align: 'center',
- width: '120px',
- text: '总部电话费',
- template: function (title, row) {
- if(row.telephoneRate==0){
- return "";
- }
- return row.telephoneRate;
- }
- },
- {
- key: 'addedTax',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '增值税',
- template: function (title, row) {
- if(row.addedTax==0){
- return "";
- }
- return row.addedTax;
- },
- },
- {
- key: 'surcharges',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '税金附加',
- template: function (title, row) {
- if(row.surcharges==0){
- return "";
- }
- return row.surcharges;
- },
- },
- {
- key: 'corporateIncomeTax',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '企业所得税',
- template: function (title, row) {
- if(row.corporateIncomeTax==0){
- return "";
- }
- return row.corporateIncomeTax;
- },
- },
- {
- key: 'socialSecurity',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '工会费',
- template: function (title, row) {
- if(row.socialSecurity==0){
- return "";
- }
- return row.socialSecurity;
- },
- },
- {
- key: 'unionFees',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '社保',
- template: function (title, row) {
- if(row.unionFees==0){
- return "";
- }
- return row.unionFees;
- },
- },
- {
- key: 'personalIncomeTax',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '个税',
- template: function (title, row) {
- if(row.personalIncomeTax==0){
- return "";
- }
- return row.personalIncomeTax;
- },
- },
- {
- key: 'stampDuty',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '印花税',
- template: function (title, row) {
- if(row.stampDuty==0){
- return "";
- }
- return row.stampDuty;
- },
- },{
- key: 'payTaxesSubtotal',
- remind: '缴税',
- align: 'center',
- width: '120px',
- text: '小计',
- template: function (title, row) {
- if(row.payTaxesSubtotal==0){
- return "";
- }
- return row.payTaxesSubtotal;
- },
- },
- {
- key: 'bond',
- width: '120px',
- align: 'center',
- text: '保证金',
- template: function (title, row) {
- if(row.bond==0){
- return "";
- }
- return row.bond;
- },
- },
- {
- key: 'wenku',
- align: 'center',
- width: '120px',
- text: '纵横文库提现',
- template: function (title, row) {
- if(row.wenku==0){
- return "";
- }
- return row.wenku;
- },
- },
- {
- key: 'other',
- align: 'center',
- width: '120px',
- text: '其他',
- template: function (title, row) {
- if(row.other==0){
- return "";
- }
- return row.other;
- },
- },
-
- {
- key: 'subtotal',
- text: '合计',
- width: '100px',
- fixed: 'right',
- disableMoveRow: true,
- disableRowCheck: true,
- template: function (title, row) {
- if(row.subtotal==0){
- return "";
- }
- return row.subtotal;
- },
- },
- ]
- }, query => {
- // 渲染完成后的回调函数
- });
- },
- /**
- * 编辑功能
- */
- editRowData: function (dom) {
- window.GridManager.updateRowData('test', 'id', { id: window.parseInt(dom.getAttribute('data-id')), lastDate: new Date().getTime() });
- }
- };
- // GridManager 渲染
- const table = document.querySelector('#feeList');
- demo1.initSearch(table);
- demo1.initGM(table);
- //demo1.initFN();
|