diff --git a/src/api/production/production-return2.js b/src/api/production/production-return2.js index ecf150f..227bfde 100644 --- a/src/api/production/production-return2.js +++ b/src/api/production/production-return2.js @@ -10,3 +10,9 @@ export const validateLabelWithReturn = data => createAPI(`productionReturn/valid export const confirmReturnStorage = data => createAPI(`productionReturn/confirmReturnStorage`, 'post', data) export const getMaterialList = data => createAPI(`productionReturn/getMaterialList`, 'post', data) + +/** + * 获取已扫描标签列表(从缓存表) + * @param {Object} data - 查询参数 {site, buNo, inboundNo} + */ +export const getScannedLabelList = data => createAPI(`productionReturn/getScannedLabelList`, 'post', data) \ No newline at end of file diff --git a/src/views/modules/production/productionReturnStorage.vue b/src/views/modules/production/productionReturnStorage.vue index e3a0c88..f6d2923 100644 --- a/src/views/modules/production/productionReturnStorage.vue +++ b/src/views/modules/production/productionReturnStorage.vue @@ -205,7 +205,8 @@ import { getReturnDetails, validateLabelWithReturn, confirmReturnStorage, - getMaterialList + getMaterialList, + getScannedLabelList } from "@/api/production/production-return2.js"; import { getCurrentWarehouse } from '@/utils' import moment from 'moment'; @@ -242,37 +243,22 @@ export default { this.scanCode = ''; }, - // 验证标签并添加到列表 + // 验证标签并添加到列表(通过存储过程) validateAndAddLabel(labelCode) { const params = { labelCode: labelCode, inboundNo: this.inboundNo, - partNo: this.partNo, - warehouseId: getCurrentWarehouse(), - site: localStorage.getItem('site'), - buNo: this.materialInfo.buNo + site: this.materialInfo.site, + buNo: this.materialInfo.buNo, + operationType: 'I' // I表示添加 }; validateLabelWithReturn(params).then(({ data }) => { if (data && data.code === 0) { - // 检查是否已经扫描过 - const exists = this.labelList.find(item => item.labelCode === labelCode); - if (exists) { - this.$message.warning('该标签已扫描,请勿重复扫描'); - return; - } - - // 添加到列表顶部(最后扫描的在最上面) - this.labelList.unshift({ - id: Date.now(), - labelCode: labelCode, - partNo: data.data.partNo, - quantity: data.data.quantity, - batchNo: data.data.batchNo - }); - this.$message.success('操作成功'); + // 重新加载已扫描标签列表 + this.loadScannedLabelList(); } else { - this.$message.error(data.msg || '该标签与入库单不符,请检查'); + this.$message.error(data.msg || '操作失败'); } }).catch(error => { console.error('标签验证失败:', error); @@ -280,15 +266,27 @@ export default { }); }, - // 通过条码移除标签 + // 通过条码移除标签(通过存储过程) removeLabelByCode(labelCode) { - const index = this.labelList.findIndex(item => item.labelCode === labelCode); - if (index !== -1) { - this.labelList.splice(index, 1); - this.$message.success('操作成功'); - } else { - this.$message.warning('未找到该标签'); - } + const params = { + labelCode: labelCode, + inboundNo: this.inboundNo, + site: this.materialInfo.site, + buNo: this.materialInfo.buNo, + operationType: 'D' // D表示移除 + }; + validateLabelWithReturn(params).then(({ data }) => { + if (data && data.code === 0) { + this.$message.success('操作成功'); + // 重新加载已扫描标签列表 + this.loadScannedLabelList(); + } else { + this.$message.error(data.msg || '操作失败'); + } + }).catch(error => { + console.error('标签移除失败:', error); + this.$message.error('操作失败'); + }); }, // 确认入库 @@ -317,7 +315,7 @@ export default { this.locationCode = ''; }, - // 提交入库 + // 提交入库(通过存储过程) submitInbound() { if (!this.locationCode.trim()) { this.$message.warning('请输入库位号'); @@ -327,13 +325,7 @@ export default { site: this.materialInfo.site, buNo: this.materialInfo.buNo, inboundNo: this.inboundNo, - locationCode: this.locationCode.trim(), - labels: this.labelList.map(label => ({ - labelCode: label.labelCode, - quantity: label.quantity, - batchNo: label.batchNo, - partNo: label.partNo, - })) + locationCode: this.locationCode.trim() }; confirmReturnStorage(params).then(({ data }) => { if (data && data.code === 0) { @@ -429,6 +421,8 @@ export default { getReturnDetails(params).then(({ data }) => { if (data && data.code === 0) { this.materialInfo = data.data; + // 加载入库单详情成功后,加载已扫描标签列表 + this.loadScannedLabelList(); } else { this.$message.error(data.msg || '获取入库单详情失败'); } @@ -436,6 +430,36 @@ export default { console.error('获取入库单详情失败:', error); this.$message.error('获取入库单详情失败'); }); + }, + + // 加载已扫描标签列表(从缓存表) + loadScannedLabelList() { + if (!this.materialInfo.site || !this.materialInfo.buNo || !this.inboundNo) { + return; + } + + const params = { + site: this.materialInfo.site, + buNo: this.materialInfo.buNo, + inboundNo: this.inboundNo + }; + + getScannedLabelList(params).then(({ data }) => { + if (data && data.code === 0) { + // 将查询结果转换为labelList格式 + this.labelList = (data.data || []).map((item, index) => ({ + id: Date.now() + index, + labelCode: item.labelCode, + partNo: item.partNo, + quantity: item.quantity, + buNo: item.buNo + })); + } else { + console.error('获取已扫描标签列表失败:', data.msg); + } + }).catch(error => { + console.error('获取已扫描标签列表失败:', error); + }); } },