|
|
|
@ -204,7 +204,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getInboundDetails, validateLabelWithInbound, confirmInboundStorage, deleteLabel, getMaterialList } from "@/api/inbound.js"; |
|
|
|
import { getInboundDetails, validateLabelWithInbound, confirmInboundStorage, deleteLabel, getMaterialList, getScannedLabelList } from "@/api/inbound.js"; |
|
|
|
import { getCurrentWarehouse } from '@/utils' |
|
|
|
import moment from 'moment'; |
|
|
|
export default { |
|
|
|
@ -241,37 +241,23 @@ export default { |
|
|
|
this.scanCode = ''; |
|
|
|
}, |
|
|
|
|
|
|
|
// 验证标签并添加到列表 |
|
|
|
// 验证标签并添加到列表(通过存储过程) |
|
|
|
validateAndAddLabel(labelCode) { |
|
|
|
const params = { |
|
|
|
labelCode: labelCode, |
|
|
|
inboundNo: this.inboundNo, |
|
|
|
partNo: this.partNo, |
|
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
site: this.materialInfo.site, |
|
|
|
buNo: this.materialInfo.buNo, |
|
|
|
operationType: 'I' // I表示添加 |
|
|
|
}; |
|
|
|
|
|
|
|
validateLabelWithInbound(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); |
|
|
|
@ -279,15 +265,28 @@ 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表示移除 |
|
|
|
}; |
|
|
|
|
|
|
|
validateLabelWithInbound(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('操作失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 确认入库 |
|
|
|
@ -316,7 +315,7 @@ export default { |
|
|
|
this.locationCode = ''; |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交入库 |
|
|
|
// 提交入库(通过存储过程) |
|
|
|
submitInbound() { |
|
|
|
if (!this.locationCode.trim()) { |
|
|
|
this.$message.warning('请输入库位号'); |
|
|
|
@ -326,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() |
|
|
|
}; |
|
|
|
confirmInboundStorage(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
@ -429,6 +422,8 @@ export default { |
|
|
|
getInboundDetails(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.materialInfo = data.data; |
|
|
|
// 加载入库单详情成功后,加载已扫描标签列表 |
|
|
|
this.loadScannedLabelList(); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '获取入库单详情失败'); |
|
|
|
} |
|
|
|
@ -436,6 +431,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); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|