/* * @Author: zwq * @Date: 2022-08-24 11:19:43 * @LastEditors: zwq * @LastEditTime: 2024-04-02 09:33:29 * @Description: */ export default { data() { /* eslint-disable */ return { urlOptions: { getDataListURL: '', //获取table接口 deleteURL: '', //删除接口 exportURL: '' //导出接口 }, tableData: [], //table数据 listQuery: { //分页 pageSize: 10, pageNo: 1, total: 1, }, exportLoading: false, //导出完成的加载状态是否开启 dataListLoading: false, //获取table的加载状态是否开启 addOrEditTitle: '', //dialog的title addOrUpdateVisible: false, //dialog状态 } }, created() { }, mounted() { this.getDataList() }, methods: { // 获取数据列表 getDataList() { this.dataListLoading = true; this.urlOptions.getDataListURL(this.listQuery).then(response => { this.tableData = response.data.list; this.listQuery.total = response.data.total; this.dataListLoading = false; }); }, // 每页数 sizeChangeHandle(val) { this.listQuery.pageSize = val; this.listQuery.pageNo = 1; this.getDataList(); }, // 当前页 currentChangeHandle(val) { this.listQuery.pageNo = val; this.getDataList(); }, // 新增 addOrUpdateHandle(id) { this.addOrEditTitle = "新增"; this.addOrUpdateVisible = true; this.$nextTick(() => { this.$refs.addOrUpdate.init(id); }); }, //tableBtn点击 handleClick(val) { if (val.type === "edit") { this.addOrUpdateVisible = true; this.addOrEditTitle = "编辑"; this.$nextTick(() => { this.$refs.addOrUpdate.init(val.data.id); }); } else if (val.type === "delete") { this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex) } else { this.otherMethods(val) } }, // 删除 deleteHandle(id, name, index) { this.$confirm(`是否确认删除${name ? '名称为"' + name + '"' : '序号为"' + index + '"'}的数据项?`, "系统提示", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning", }) .then(() => { this.urlOptions.deleteURL(id).then(({ data }) => { this.$message({ message: "操作成功", type: "success", duration: 1500, onClose: () => { this.getDataList(); }, }); }); }) .catch(() => { }); }, // dialog取消 handleCancel() { this.$refs.addOrUpdate.formClear() this.addOrUpdateVisible = false this.addOrEditTitle = '' }, // dialog确定 handleConfirm() { this.$refs.addOrUpdate.dataFormSubmit() }, // dialog的父组件方法this.$emit("refreshDataList"); successSubmit() { this.handleCancel() this.getDataList() }, /** 导出按钮操作 */ handleExport() { // 处理查询参数 let params = { ...this.queryParams }; params.pageNo = undefined; params.pageSize = undefined; this.$modal.confirm('是否确认导出所有数据项?').then(() => { this.exportLoading = true; return this.urlOptions.exportURL(params); }).then(response => { this.$download.excel(response, '报表.xls'); this.exportLoading = false; }).catch(() => { }); } } }