| | |
| | | <script setup name="NearExpiryReturn"> |
| | | import { ref, reactive, onMounted } from "vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { |
| | | nearExpiryReturnListPage, |
| | | nearExpiryReturnAdd, |
| | | nearExpiryReturnUpdate, |
| | | nearExpiryReturnDel, |
| | | nearExpiryReturnDetail |
| | | } from "@/api/qualityManagement/nearExpiryReturn"; |
| | | // API接口已移除,不再调用后端接口 |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | const { parseTime } = proxy; |
| | |
| | | /** 查询临期退回台账列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | // 使用假数据 |
| | | const mockData = { |
| | | records: [ |
| | | { |
| | | id: 1, |
| | | productName: "维生素C片", |
| | | productSpec: "100mg×30片", |
| | | batchNumber: "VC20240315001", |
| | | productionDate: "2024-03-15", |
| | | expiryDate: "2024-09-15", |
| | | returnQuantity: 50, |
| | | returnReason: "临近保质期", |
| | | returnDate: "2024-09-10", |
| | | status: "1", |
| | | remark: "退回仓库处理" |
| | | }, |
| | | { |
| | | id: 2, |
| | | productName: "阿莫西林胶囊", |
| | | productSpec: "250mg×24粒", |
| | | batchNumber: "AMX20240220002", |
| | | productionDate: "2024-02-20", |
| | | expiryDate: "2024-08-20", |
| | | returnQuantity: 30, |
| | | returnReason: "包装破损且临期", |
| | | returnDate: "2024-08-18", |
| | | status: "2", |
| | | remark: "已销毁处理" |
| | | }, |
| | | { |
| | | id: 3, |
| | | productName: "感冒灵颗粒", |
| | | productSpec: "10g×12袋", |
| | | batchNumber: "GML20240110003", |
| | | productionDate: "2024-01-10", |
| | | expiryDate: "2024-07-10", |
| | | returnQuantity: 25, |
| | | returnReason: "临近保质期", |
| | | returnDate: "2024-07-08", |
| | | status: "0", |
| | | remark: "待重新包装" |
| | | }, |
| | | { |
| | | id: 4, |
| | | productName: "复合维生素片", |
| | | productSpec: "60片/瓶", |
| | | batchNumber: "VB20240405004", |
| | | productionDate: "2024-04-05", |
| | | expiryDate: "2025-04-05", |
| | | returnQuantity: 80, |
| | | returnReason: "临近保质期", |
| | | returnDate: "2024-09-25", |
| | | status: "1", |
| | | remark: "正在联系销售渠道" |
| | | }, |
| | | { |
| | | id: 5, |
| | | productName: "钙片", |
| | | productSpec: "600mg×100片", |
| | | batchNumber: "CA20240301005", |
| | | productionDate: "2024-03-01", |
| | | expiryDate: "2024-09-01", |
| | | returnQuantity: 120, |
| | | returnReason: "包装问题且临期", |
| | | returnDate: "2024-08-30", |
| | | status: "2", |
| | | remark: "已完成退货处理" |
| | | } |
| | | ], |
| | | total: 5 |
| | | }; |
| | | |
| | | // 模拟过滤逻辑 |
| | | let filteredRecords = mockData.records; |
| | | |
| | | if (queryParams.value.productName) { |
| | | filteredRecords = filteredRecords.filter(item => |
| | | item.productName.includes(queryParams.value.productName) |
| | | ); |
| | | } |
| | | |
| | | if (queryParams.value.batchNumber) { |
| | | filteredRecords = filteredRecords.filter(item => |
| | | item.batchNumber.includes(queryParams.value.batchNumber) |
| | | ); |
| | | } |
| | | |
| | | if (queryParams.value.returnDate) { |
| | | filteredRecords = filteredRecords.filter(item => |
| | | item.returnDate === queryParams.value.returnDate |
| | | ); |
| | | } |
| | | |
| | | nearExpiryReturnList.value = filteredRecords; |
| | | total.value = filteredRecords.length; |
| | | // 不调用接口,返回空数据 |
| | | nearExpiryReturnList.value = []; |
| | | total.value = 0; |
| | | loading.value = false; |
| | | } |
| | | |
| | |
| | | /** 修改按钮操作 */ |
| | | function handleUpdate(row) { |
| | | reset(); |
| | | const id = row.id || ids.value; |
| | | |
| | | // 使用假数据获取详情 |
| | | const mockDetail = nearExpiryReturnList.value.find(item => item.id === (Array.isArray(id) ? id[0] : id)); |
| | | if (mockDetail) { |
| | | form.value = { ...mockDetail }; |
| | | // 不调用接口,直接使用传入的数据 |
| | | if (row) { |
| | | form.value = { ...row }; |
| | | open.value = true; |
| | | title.value = "修改临期退回台账"; |
| | | } |
| | |
| | | function submitForm() { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | // 不调用接口,只显示成功提示 |
| | | if (form.value.id != null) { |
| | | // 模拟更新 |
| | | const index = nearExpiryReturnList.value.findIndex(item => item.id === form.value.id); |
| | | if (index !== -1) { |
| | | nearExpiryReturnList.value[index] = { ...form.value }; |
| | | } |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | } else { |
| | | // 模拟新增 |
| | | const newId = Math.max(...nearExpiryReturnList.value.map(item => item.id)) + 1; |
| | | nearExpiryReturnList.value.push({ ...form.value, id: newId }); |
| | | total.value = nearExpiryReturnList.value.length; |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | } |
| | | open.value = false; |
| | | getList(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }).then(function() { |
| | | // 模拟删除 |
| | | if (Array.isArray(deleteIds)) { |
| | | deleteIds.forEach(id => { |
| | | const index = nearExpiryReturnList.value.findIndex(item => item.id === id); |
| | | if (index !== -1) { |
| | | nearExpiryReturnList.value.splice(index, 1); |
| | | } |
| | | }); |
| | | } else { |
| | | const index = nearExpiryReturnList.value.findIndex(item => item.id === deleteIds); |
| | | if (index !== -1) { |
| | | nearExpiryReturnList.value.splice(index, 1); |
| | | } |
| | | } |
| | | getList(); |
| | | // 不调用接口,只显示成功提示 |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | getList(); |
| | | }).catch(() => {}); |
| | | } |
| | | |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download('quality/nearExpiryReturn/export', { |
| | | ...queryParams.value |
| | | }, `临期退回台账_${new Date().getTime()}.xlsx`); |
| | | // 不调用接口,只显示提示 |
| | | proxy.$modal.msgSuccess("导出功能暂未实现"); |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |
| | | </script> |
| | | |