|
|
@ -163,7 +163,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { getReturnDetails, validateLabelWithReturn, confirmPurchaseReturn, getMaterialList } from "@/api/purchase/purchase-return.js"; |
|
|
|
|
|
|
|
|
import { getReturnDetails, validateLabelWithReturn, confirmPurchaseReturn, getMaterialList, getScannedLabelList } from "@/api/purchase/purchase-return.js"; |
|
|
import { getCurrentWarehouse } from '@/utils' |
|
|
import { getCurrentWarehouse } from '@/utils' |
|
|
import moment from 'moment'; |
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
|
@ -174,6 +174,9 @@ export default { |
|
|
returnInfo: {}, |
|
|
returnInfo: {}, |
|
|
labelList: [], |
|
|
labelList: [], |
|
|
returnNo: '', |
|
|
returnNo: '', |
|
|
|
|
|
relatedNo: '', |
|
|
|
|
|
relatedLineNo: '', |
|
|
|
|
|
buNo: '', |
|
|
showMaterialDialog: false, |
|
|
showMaterialDialog: false, |
|
|
materialList: [], |
|
|
materialList: [], |
|
|
materialListLoading: false, |
|
|
materialListLoading: false, |
|
|
@ -199,33 +202,22 @@ export default { |
|
|
this.scanCode = ''; |
|
|
this.scanCode = ''; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 验证标签并添加到列表 |
|
|
|
|
|
|
|
|
// 验证标签并添加到列表(调用存储过程) |
|
|
validateAndAddLabel(labelCode) { |
|
|
validateAndAddLabel(labelCode) { |
|
|
const params = { |
|
|
const params = { |
|
|
labelCode: labelCode, |
|
|
labelCode: labelCode, |
|
|
returnNo: this.returnNo, |
|
|
returnNo: this.returnNo, |
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
|
|
|
|
|
relatedNo: this.relatedNo, |
|
|
|
|
|
relatedLineNo: this.relatedLineNo, |
|
|
site: localStorage.getItem('site'), |
|
|
site: localStorage.getItem('site'), |
|
|
buNo: this.buNo |
|
|
|
|
|
|
|
|
buNo: this.buNo, |
|
|
|
|
|
operationType: 'I' // 添加标签 |
|
|
}; |
|
|
}; |
|
|
validateLabelWithReturn(params).then(({ data }) => { |
|
|
validateLabelWithReturn(params).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
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, |
|
|
|
|
|
locationId: data.data.locationId |
|
|
|
|
|
}); |
|
|
|
|
|
this.$message.success('操作成功'); |
|
|
|
|
|
|
|
|
this.$message.success('标签添加成功'); |
|
|
|
|
|
// 重新加载已扫描标签列表 |
|
|
|
|
|
this.loadScannedLabelList(); |
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(data.msg || '该标签与退货单不符,请检查'); |
|
|
this.$message.error(data.msg || '该标签与退货单不符,请检查'); |
|
|
} |
|
|
} |
|
|
@ -235,18 +227,32 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 通过条码移除标签 |
|
|
|
|
|
|
|
|
// 通过条码移除标签(调用存储过程) |
|
|
removeLabelByCode(labelCode) { |
|
|
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, |
|
|
|
|
|
returnNo: this.returnNo, |
|
|
|
|
|
relatedNo: this.relatedNo, |
|
|
|
|
|
relatedLineNo: this.relatedLineNo, |
|
|
|
|
|
site: localStorage.getItem('site'), |
|
|
|
|
|
buNo: this.buNo, |
|
|
|
|
|
operationType: '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('移除失败'); |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 确认退货 |
|
|
|
|
|
|
|
|
// 确认退货(调用存储过程) |
|
|
confirmReturn() { |
|
|
confirmReturn() { |
|
|
if (this.labelList.length === 0) { |
|
|
if (this.labelList.length === 0) { |
|
|
this.$message.warning('请先扫描标签'); |
|
|
this.$message.warning('请先扫描标签'); |
|
|
@ -256,14 +262,9 @@ export default { |
|
|
site: this.returnInfo.site, |
|
|
site: this.returnInfo.site, |
|
|
buNo: this.returnInfo.buNo, |
|
|
buNo: this.returnInfo.buNo, |
|
|
returnNo: this.returnNo, |
|
|
returnNo: this.returnNo, |
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
|
|
labels: this.labelList.map(label => ({ |
|
|
|
|
|
labelCode: label.labelCode, |
|
|
|
|
|
partNo: label.partNo, |
|
|
|
|
|
quantity: label.quantity, |
|
|
|
|
|
batchNo: label.batchNo, |
|
|
|
|
|
locationId: label.locationId |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
relatedNo: this.relatedNo, |
|
|
|
|
|
relatedLineNo: this.relatedLineNo, |
|
|
|
|
|
locationCode: getCurrentWarehouse() // 库位号 |
|
|
} |
|
|
} |
|
|
confirmPurchaseReturn(params).then(({ data }) => { |
|
|
confirmPurchaseReturn(params).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
@ -358,6 +359,8 @@ export default { |
|
|
getReturnDetails(params).then(({ data }) => { |
|
|
getReturnDetails(params).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
this.returnInfo = data.data; |
|
|
this.returnInfo = data.data; |
|
|
|
|
|
// 加载已扫描标签列表 |
|
|
|
|
|
this.loadScannedLabelList(); |
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(data.msg || '获取退货单详情失败'); |
|
|
this.$message.error(data.msg || '获取退货单详情失败'); |
|
|
} |
|
|
} |
|
|
@ -365,6 +368,35 @@ export default { |
|
|
console.error('获取退货单详情失败:', error); |
|
|
console.error('获取退货单详情失败:', error); |
|
|
this.$message.error('获取退货单详情失败'); |
|
|
this.$message.error('获取退货单详情失败'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 加载已扫描标签列表(从缓存表) |
|
|
|
|
|
loadScannedLabelList() { |
|
|
|
|
|
const params = { |
|
|
|
|
|
site: localStorage.getItem('site'), |
|
|
|
|
|
buNo: this.buNo, |
|
|
|
|
|
returnNo: this.returnNo, |
|
|
|
|
|
relatedNo: this.relatedNo, |
|
|
|
|
|
relatedLineNo: this.relatedLineNo |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -372,6 +404,9 @@ export default { |
|
|
// 获取路由参数 |
|
|
// 获取路由参数 |
|
|
this.returnNo = this.$route.params.returnNo; |
|
|
this.returnNo = this.$route.params.returnNo; |
|
|
this.buNo = this.$route.params.buNo; |
|
|
this.buNo = this.$route.params.buNo; |
|
|
|
|
|
this.relatedNo = this.$route.params.relatedNo || ''; |
|
|
|
|
|
this.relatedLineNo = this.$route.params.relatedLineNo || ''; |
|
|
|
|
|
|
|
|
if (!this.returnNo || !this.buNo) { |
|
|
if (!this.returnNo || !this.buNo) { |
|
|
this.$message.error('参数错误'); |
|
|
this.$message.error('参数错误'); |
|
|
this.$router.back(); |
|
|
this.$router.back(); |
|
|
|