|
|
|
@ -167,7 +167,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getOutboundDetails, validateLabelWithOutbound, confirmProductionPicking, getOutboundMaterialList } from "@/api/production.js"; |
|
|
|
import { getOutboundDetails, validateLabelWithOutbound, confirmProductionPicking, getOutboundMaterialList, getScannedLabelList } from "@/api/production.js"; |
|
|
|
import { getCurrentWarehouse } from '@/utils' |
|
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
@ -204,41 +204,24 @@ export default { |
|
|
|
this.scanCode = ''; |
|
|
|
}, |
|
|
|
|
|
|
|
// 验证标签并添加到列表 |
|
|
|
// 验证标签并添加到列表(调用存储过程) |
|
|
|
validateAndAddLabel(labelCode) { |
|
|
|
const params = { |
|
|
|
labelCode: labelCode, |
|
|
|
outboundNo: this.outboundNo, |
|
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
relatedNo: this.relatedNo, |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
buNo: this.buNo, |
|
|
|
relatedNo: this.relatedNo |
|
|
|
operationType: 'I' // 添加标签 |
|
|
|
}; |
|
|
|
|
|
|
|
validateLabelWithOutbound(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
const resultList = data.data; |
|
|
|
// 检查是否已经扫描过 |
|
|
|
const exists = this.labelList.find(item => item.labelCode === labelCode); |
|
|
|
if (exists) { |
|
|
|
this.$message.warning('该标签已扫描,请勿重复扫描'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 将所有结果添加到列表 |
|
|
|
resultList.forEach(result => { |
|
|
|
this.labelList.push({ |
|
|
|
id: Date.now() + Math.random(), // 确保ID唯一 |
|
|
|
labelCode: result.labelCode, |
|
|
|
partNo: result.partNo, |
|
|
|
quantity: result.quantity, |
|
|
|
batchNo: result.batchNo, |
|
|
|
locationId: result.locationId |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.$message.success(`标签验证成功,共添加 ${resultList.length} 条记录`); |
|
|
|
this.$message.success('标签添加成功'); |
|
|
|
// 重新加载已扫描标签列表 |
|
|
|
this.loadScannedLabelList(); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '该标签不符合退货条件,请检查'); |
|
|
|
this.$message.error(data.msg || '该标签不符合条件,请检查'); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('标签验证失败:', error); |
|
|
|
@ -246,18 +229,32 @@ 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, |
|
|
|
outboundNo: this.outboundNo, |
|
|
|
relatedNo: this.relatedNo, |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
buNo: this.buNo, |
|
|
|
operationType: 'D' // 移除标签 |
|
|
|
}; |
|
|
|
|
|
|
|
validateLabelWithOutbound(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('移除失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 确认出库 |
|
|
|
// 确认出库(调用存储过程) |
|
|
|
confirmOutbound() { |
|
|
|
if (this.labelList.length === 0) { |
|
|
|
this.$message.warning('请先扫描标签'); |
|
|
|
@ -267,26 +264,19 @@ export default { |
|
|
|
site: this.outboundInfo.site, |
|
|
|
buNo: this.buNo, |
|
|
|
outboundNo: this.outboundNo, |
|
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
relatedNo: this.relatedNo, |
|
|
|
labels: this.labelList.map(label => ({ |
|
|
|
labelCode: label.labelCode, |
|
|
|
quantity: label.quantity, |
|
|
|
batchNo: label.batchNo, |
|
|
|
partNo: label.partNo, |
|
|
|
locationId: label.locationId |
|
|
|
})) |
|
|
|
locationCode: getCurrentWarehouse() // 库位号 |
|
|
|
} |
|
|
|
confirmProductionPicking(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.$message.success('操作成功'); |
|
|
|
this.$message.success('领料成功'); |
|
|
|
this.$router.back(); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '操作失败'); |
|
|
|
this.$message.error(data.msg || '领料失败'); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('出库确认失败:', error); |
|
|
|
this.$message.error('操作失败'); |
|
|
|
this.$message.error('领料失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
@ -372,6 +362,8 @@ export default { |
|
|
|
getOutboundDetails(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.outboundInfo = data.data; |
|
|
|
// 加载已扫描标签列表 |
|
|
|
this.loadScannedLabelList(); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '获取出库单详情失败'); |
|
|
|
} |
|
|
|
@ -379,6 +371,34 @@ export default { |
|
|
|
console.error('获取出库单详情失败:', error); |
|
|
|
this.$message.error('获取出库单详情失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载已扫描标签列表(从缓存表) |
|
|
|
loadScannedLabelList() { |
|
|
|
const params = { |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
buNo: this.buNo, |
|
|
|
outboundNo: this.outboundNo, |
|
|
|
relatedNo: this.relatedNo |
|
|
|
}; |
|
|
|
|
|
|
|
getScannedLabelList(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
// 格式化数据以匹配UI需求 |
|
|
|
this.labelList = (data.data || []).map(item => ({ |
|
|
|
id: Date.now() + Math.random(), // 生成唯一ID |
|
|
|
labelCode: item.labelCode, |
|
|
|
partNo: item.partNo, |
|
|
|
quantity: item.quantity, |
|
|
|
batchNo: item.batchNo || '', |
|
|
|
locationId: item.locationId || '' |
|
|
|
})); |
|
|
|
} else { |
|
|
|
console.error('获取已扫描标签列表失败:', data.msg); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('获取已扫描标签列表失败:', error); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|