import DialogForm from '@/components/DialogForm/index.vue'; export default { components: { DialogForm }, data() { return { // 遮罩层 loading: true, // 导出遮罩层 exportLoading: false, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 质量检测信息基础列表 list: [], // 弹出层标题 title: '', // 是否显示弹出层 open: false, // 列表数据 tableData: [], // 弹窗的表单 // form: {}, // 占位 // 搜索框需要的 keys // searchBarKeys: [], // 占位 // tableProps: [], // 占位 // tableBtn: [], // 占位 // searchBarFormConfig: [], // 占位 // // 弹窗表单配置 // dialogFormConfig: [], // updateUrl: '', addUrl: '', pageUrl: '', infoUrl: '', deleteUrl: '', basePath: '', form: {} }; }, computed: { addPath() { return this.basePath + '/create' }, updatePath() { return this.basePath + '/update' }, deletePath() { return this.basePath + '/delete' }, infoPath() { return this.basePath + '/get' }, pagePath() { return this.basePath + '/page' } }, methods: { // utils http(url, method, payload) { return this.$axios({ url, method, params: (method === 'get' || method === 'delete') ? payload : null, data: (method === 'get' || method === 'delete') ? null : payload }) }, put(payload) { return this.http(this.updateUrl == '' ? this.updatePath : this.updateUrl, 'put', payload); }, post(payload) { return this.http(this.addUrl == '' ? this.addPath : this.addUrl, 'post', payload); }, recv(payload) { return this.http(this.pageUrl == '' ? this.pagePath : this.pageUrl, 'get', payload); }, info(payload) { return this.http(this.infoUrl == '' ? this.infoPath : this.infoUrl, 'get', payload); }, del(payload) { return this.http(this.deleteUrl == '' ? this.deletePath : this.deleteUrl, 'delete', payload); }, // 过滤后端传回的详情数据 filterData(data, keys) { const obj = {}; keys.forEach((key) => { if (/time/i.test(key)) { obj[key] = new Date(data[key]); } else { obj[key] = data[key]; } }); return obj; }, // 处理表格按钮 handleTableBtnClick({ data, type }) { switch (type) { case 'edit': this.handleUpdate(data); break; case 'delete': this.handleDelete(data); break; case 'detail': this.handleDetail(data); break; } }, // 处理搜索栏按钮 handleSearchBarBtnClick(btn) { // const keys = ['name', 'createTime']; // timeVal // 已被 searchBarKeys 替代 switch (btn.btnName) { case 'search': this.searchBarKeys.forEach((key) => { if (key == 'timeVal') { this.queryParams['startTime'] = btn.timeVal[0]; this.queryParams['endTime'] = btn.timeVal[1]; return; } this.queryParams[key] = btn[key] || null; }); this.handleQuery(); break; case 'add': this.handleAdd(); break; case 'export': this.handleExport(); break; case 'reset': this.$refs['search-bar'].resetForm(); this.resetQuery(); break; } }, handleEmitFun(val) { console.log('emit unf', val); switch (val.action) { // 查看详情 case 'show-detail': this.viewDetail(val.value); // 交由每个组件自己实现 break; } }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNo = 1; this.getList(); }, /** 重置按钮操作 */ resetQuery() { this.resetForm('queryForm'); this.handleQuery(); }, /** 取消按钮 */ cancel() { this.open = false; this.reset(); }, }, };