| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- /*
- * @description:
- * @Author: CP
- * @Date: 2020-12-28 14:41:49
- * @FilePath: \cld\global\gridManager\dashboard\longle.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('change', function () {
- var _query = {
-
- year: this.value,
-
- // staffId: sid,
- };
- console.log(_query);
- table.GM('setQuery', _query, function () {
- console.log('setQuery执行成功');
- });
- });
- // 绑定重置
- // document.querySelector('.reset-action').addEventListener('click', function () {
- // var now = new Date();
- // document.querySelector('[name="kw"]').value = '';
- // document.querySelector('[name="categoryId"]').value = '';
- // document.querySelector('[name="year"]').value = now.getFullYear();
- // document.querySelector('[name="month"]').value = '';
- // document.querySelector('[name="staffId"]').value = '';
- // document.querySelector('[name="feeType"]').value = '';
- // });
- },
-
- /**
- * 初始化表格
- */
- initGM: function () {
- new window.GridManager(table, {
- gridManagerName: 'test',
- width: '100%',
- height: '520px',
- // 初始渲染时是否加载数据
- // firstLoading: false,
- supportAutoOrder: false,
- // 自动序号配置
- // autoOrderConfig: {
- // // 固定列
- // fixed: 'left'
- // },
- supportCheckbox: false,
- // 选择框配置
- // checkboxConfig: {
- // // 使用单选
- // // useRadio: true,
- // // 使用行选中
- // // useRowCheck: true,
- // key: 'id',
- // // 复选时最大可选数
- // // max: 2,
- // // 固定列
- // fixed: 'left'
- // },
- // 是否使用无总条数模式
- // useNoTotalsMode: true,
- // 是否开启分页
- supportAjaxPage: false,
- // 排序模式,single(升降序单一触发) overall(升降序整体触发)
- sortMode: 'single',
-
- // 右键菜单
- supportMenu: false,
-
- // 禁用缓存
- disableCache: false,
- ajaxData: function (settings, params) {
- // document.querySelector('[name="categoryId"]').value = params.categoryId || "";
- return '/json/dashboard/software/count?staffId='+sid;
- },
-
- emptyTemplate: settings => {
- return `<div style="text-align: center;">${settings.query.title ? '搜索为空' : '暂无数据'}</div>`;
- },
-
- columnData: [
- {
- key: 'date',
- width: '160px',
- text: '时间',
-
- disableMoveRow: true,
- // 使用函数返回 dom node
- // template: function (title, row) {
- // var titleNode = document.createElement('a');
- // titleNode.setAttribute('href', `/expensesDoc/10`);
- // titleNode.setAttribute('title', title);
- // titleNode.setAttribute('target', '_blank');
- // titleNode.innerText = title;
- // titleNode.title = `点击阅读[${row.title}]`;
- // titleNode.classList.add('plugin-action');
- // return titleNode;
- // }
- },
- {
- key: 'lend',
- // remind: '报销单,借款,对公汇款,培训班',
- width: '160px',
- text: '借出',
- disableMoveRow: true
- },
- {
- key: 'sale',
- width: '160px',
- text: '销售',
- disableMoveRow: true
- },
- {
- key: 'give',
- width: '160px',
- text: '赠送',
- disableMoveRow: true
- },
- {
- key: 'upgrade',
- // width: '140px',
- text: '升级',
- disableMoveRow: true,
-
- },
-
-
- ]
- }, query => {
- // 渲染完成后的回调函数
- // console.log('渲染完成后的回调函数:', 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();
|