| | |
| | | import {onMounted, ref} from "vue"; |
| | | import FormDia from "@/views/customerService/expiryAfterSales/components/formDia.vue"; |
| | | import {ElMessageBox} from "element-plus"; |
| | | // import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js"; // 暂时注释掉,使用假数据 |
| | | import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js"; |
| | | import useUserStore from "@/store/modules/user.js"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const userStore = useUserStore() |
| | |
| | | label: "处理状态", |
| | | prop: "status", |
| | | width: "", |
| | | slot: true, |
| | | dataType: "slot", |
| | | slot: "status", |
| | | }, |
| | | { |
| | | label: "处理人", |
| | |
| | | { |
| | | label: "操作", |
| | | prop: "operation", |
| | | slot: true, |
| | | dataType: "slot", |
| | | slot: "operation", |
| | | width: "200", |
| | | }, |
| | | ], |
| | |
| | | // 获取列表数据 |
| | | const getList = () => { |
| | | tableLoading.value = true; |
| | | // 构造查询参数,映射前端字段到后端字段 |
| | | const queryParams = { |
| | | expireDate: searchForm.value.expiryDate, |
| | | disDate: searchForm.value.handleDate, |
| | | status: searchForm.value.status, |
| | | current: page.value.current, |
| | | size: page.value.size |
| | | }; |
| | | |
| | | // 模拟异步请求 |
| | | setTimeout(() => { |
| | | // 假数据 |
| | | const mockData = [ |
| | | { |
| | | id: 1, |
| | | productName: "维生素C片", |
| | | batchNumber: "VC20240801", |
| | | expiryDate: "2024-12-15", |
| | | stockQuantity: 150, |
| | | customerName: "张三药店", |
| | | problemDesc: "临近保质期需要处理", |
| | | status: 1, |
| | | handlerName: "", |
| | | handleDate: "", |
| | | }, |
| | | { |
| | | id: 2, |
| | | productName: "阿莫西林胶囊", |
| | | batchNumber: "AM20240715", |
| | | expiryDate: "2024-11-20", |
| | | stockQuantity: 80, |
| | | customerName: "李四医院", |
| | | problemDesc: "库存积压,临期处理", |
| | | status: 2, |
| | | handlerName: "王五", |
| | | handleDate: "2024-09-25", |
| | | }, |
| | | { |
| | | id: 3, |
| | | productName: "感冒灵颗粒", |
| | | batchNumber: "GM20240620", |
| | | expiryDate: "2024-10-30", |
| | | stockQuantity: 200, |
| | | customerName: "赵六诊所", |
| | | problemDesc: "季节性药品,需要清理库存", |
| | | status: 1, |
| | | handlerName: "", |
| | | handleDate: "", |
| | | }, |
| | | { |
| | | id: 4, |
| | | productName: "复合维生素片", |
| | | batchNumber: "FH20240510", |
| | | expiryDate: "2024-12-01", |
| | | stockQuantity: 300, |
| | | customerName: "钱七连锁", |
| | | problemDesc: "临期产品退换申请", |
| | | status: 2, |
| | | handlerName: "孙八", |
| | | handleDate: "2024-09-20", |
| | | }, |
| | | { |
| | | id: 5, |
| | | productName: "板蓝根颗粒", |
| | | batchNumber: "BL20240430", |
| | | expiryDate: "2024-11-10", |
| | | stockQuantity: 120, |
| | | customerName: "周九药房", |
| | | problemDesc: "批次问题,需要召回", |
| | | status: 1, |
| | | handlerName: "", |
| | | handleDate: "", |
| | | } |
| | | ]; |
| | | |
| | | // 简单的搜索过滤 |
| | | let filteredData = mockData; |
| | | |
| | | if (searchForm.value.status !== "" && searchForm.value.status !== null) { |
| | | filteredData = filteredData.filter(item => item.status === searchForm.value.status); |
| | | } |
| | | |
| | | if (searchForm.value.expiryDate) { |
| | | filteredData = filteredData.filter(item => item.expiryDate === searchForm.value.expiryDate); |
| | | } |
| | | |
| | | if (searchForm.value.handleDate) { |
| | | filteredData = filteredData.filter(item => item.handleDate === searchForm.value.handleDate); |
| | | } |
| | | |
| | | // 分页处理 |
| | | const start = (page.value.current - 1) * page.value.size; |
| | | const end = start + page.value.size; |
| | | const paginatedData = filteredData.slice(start, end); |
| | | |
| | | expiryAfterSalesListPage(queryParams).then(res => { |
| | | // 映射后端返回数据到前端表格 |
| | | tableData.value = res.data.records.map(item => ({ |
| | | id: item.id, |
| | | productName: item.productName, |
| | | batchNumber: item.batchNumber, |
| | | expiryDate: item.expireDate, |
| | | stockQuantity: item.stockQuantity, |
| | | customerName: item.customerName, |
| | | contactPhone: item.contactPhone, |
| | | problemDesc: item.disRes, |
| | | status: item.status, |
| | | handlerId: item.disposeUserId, |
| | | handlerName: item.disposeNickName, |
| | | handleResult: item.disposeResult, |
| | | handleDate: item.disDate |
| | | })); |
| | | page.value.total = res.data.total; |
| | | tableLoading.value = false; |
| | | tableData.value = paginatedData; |
| | | page.value.total = filteredData.length; |
| | | }, 500); // 模拟网络延迟 |
| | | }).catch(error => { |
| | | console.error('获取列表数据失败:', error); |
| | | tableLoading.value = false; |
| | | proxy.$modal.msgError('获取数据失败,请稍后重试'); |
| | | }); |
| | | }; |
| | | |
| | | // 打开弹框 |
| | |
| | | }) |
| | | .then(() => { |
| | | tableLoading.value = true; |
| | | |
| | | // 模拟删除操作 |
| | | setTimeout(() => { |
| | | tableLoading.value = false; |
| | | expiryAfterSalesDelete(ids).then(() => { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | console.log("模拟删除的数据ID:", ids); |
| | | getList(); // 重新获取数据 |
| | | }, 300); |
| | | getList(); |
| | | }).finally(() => { |
| | | tableLoading.value = false; |
| | | }); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |