|
|
|
@ -47,14 +47,24 @@ |
|
|
|
<!-- 物料编码 --> |
|
|
|
<div class="input-item material-code-item"> |
|
|
|
<span class="input-label">物料编码</span> |
|
|
|
<el-input |
|
|
|
<el-select |
|
|
|
v-model="materialCode" |
|
|
|
placeholder="请输入物料编码" |
|
|
|
@keyup.enter.native="handleMaterialInput" |
|
|
|
@blur="handleMaterialInput" |
|
|
|
ref="materialInput" |
|
|
|
class="input-field" clearable |
|
|
|
/> |
|
|
|
placeholder="请选择物料" |
|
|
|
filterable |
|
|
|
@change="handleMaterialSelect" |
|
|
|
ref="materialSelect" |
|
|
|
class="input-field" |
|
|
|
> |
|
|
|
<el-option |
|
|
|
v-for="item in materialOptions" |
|
|
|
:key="item.materialCode" |
|
|
|
:label="`${item.materialCode} - ${item.materialName}`" |
|
|
|
:value="item.materialCode" |
|
|
|
> |
|
|
|
<span style="float: left">{{ item.materialCode }}</span> |
|
|
|
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.materialName }}</span> |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 单位 --> |
|
|
|
@ -126,7 +136,7 @@ |
|
|
|
class="list-item" |
|
|
|
> |
|
|
|
<div class="col-no">{{ materialList.length - index }}</div> |
|
|
|
<div class="col-label">{{ item.labelCode || item.materialCode }}</div> |
|
|
|
<div class="col-label">{{ item.labelCode }}</div> |
|
|
|
<div class="col-part">{{ item.materialCode }}</div> |
|
|
|
<div class="col-batch">{{ item.batchNo || '-' }}</div> |
|
|
|
<div class="col-qty">{{ item.actualQty }}</div> |
|
|
|
@ -233,7 +243,7 @@ |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
|
|
|
|
import { getOtherInboundDetails, validateMaterialWithInbound, confirmOtherInbound, getMaterialList, addMaterialToInbound } from "@/api/other-inbound/other-inbound.js"; |
|
|
|
import { getOtherInboundDetails, getMaterialList, validateLabelWithOtherInbound, confirmOtherInbound, getScannedLabelList } from "@/api/other-inbound/other-inbound.js"; |
|
|
|
import { getCurrentWarehouse } from '@/utils' |
|
|
|
import moment from 'moment'; |
|
|
|
|
|
|
|
@ -246,6 +256,7 @@ export default { |
|
|
|
inboundInfo: {}, |
|
|
|
materialList: [], |
|
|
|
originalMaterialList: [], |
|
|
|
materialOptions: [], // 物料下拉选项 |
|
|
|
currentMaterial: {}, |
|
|
|
inboundNo: '', |
|
|
|
buNo: '', |
|
|
|
@ -260,45 +271,58 @@ export default { |
|
|
|
return date ? moment(date).format('YYYY-MM-DD') : ''; |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理物料编码输入 |
|
|
|
handleMaterialInput() { |
|
|
|
if (!this.materialCode.trim()) { |
|
|
|
// 处理物料选择 |
|
|
|
handleMaterialSelect() { |
|
|
|
if (!this.materialCode) { |
|
|
|
this.currentMaterial = {}; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.validateMaterial(this.materialCode.trim()); |
|
|
|
// 从选项中找到对应的物料信息 |
|
|
|
const material = this.materialOptions.find(m => m.materialCode === this.materialCode); |
|
|
|
if (material) { |
|
|
|
this.currentMaterial = { |
|
|
|
materialCode: material.materialCode, |
|
|
|
materialName: material.materialName, |
|
|
|
unit: material.unit |
|
|
|
}; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 验证物料 |
|
|
|
validateMaterial(materialCode) { |
|
|
|
// 加载物料选项(从入库明细获取) |
|
|
|
loadMaterialOptions() { |
|
|
|
if (!this.inboundInfo.site || !this.inboundInfo.buNo || !this.inboundNo) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const params = { |
|
|
|
materialCode: materialCode, |
|
|
|
site: this.inboundInfo.site, |
|
|
|
buNo: this.inboundInfo.buNo, |
|
|
|
inboundNo: this.inboundNo, |
|
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
buNo: this.buNo |
|
|
|
documentType: '其他入库' // 单据类型 |
|
|
|
}; |
|
|
|
|
|
|
|
validateMaterialWithInbound(params).then(({ data }) => { |
|
|
|
getMaterialList(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.currentMaterial = data.data; |
|
|
|
this.materialOptions = (data.data || []).map(item => ({ |
|
|
|
materialCode: item.materialCode, |
|
|
|
materialName: item.materialName, |
|
|
|
unit: item.unit |
|
|
|
})); |
|
|
|
} else { |
|
|
|
this.currentMaterial = {}; |
|
|
|
this.$message.error(data.msg || '该物料与入库单不符,请检查'); |
|
|
|
console.error('获取物料选项失败:', data.msg); |
|
|
|
this.materialOptions = []; |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('物料验证失败:', error); |
|
|
|
this.currentMaterial = {}; |
|
|
|
this.$message.error('该物料与入库单不符,请检查'); |
|
|
|
console.error('获取物料选项失败:', error); |
|
|
|
this.materialOptions = []; |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 添加物料到列表 |
|
|
|
// 添加物料到列表(通过存储过程GetScanLabelVerification) |
|
|
|
handleAddMaterial() { |
|
|
|
if (!this.materialCode.trim()) { |
|
|
|
this.$message.warning('请输入物料编码'); |
|
|
|
this.$refs.materialInput.focus(); |
|
|
|
this.$message.warning('请选择物料编码'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -313,57 +337,36 @@ export default { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否已经添加过该物料 |
|
|
|
// const exists = this.materialList.find(item => |
|
|
|
// item.materialCode === this.materialCode.trim() |
|
|
|
// ); |
|
|
|
// if (exists) { |
|
|
|
// this.$message.warning('该物料已添加,请勿重复添加'); |
|
|
|
// return; |
|
|
|
// } |
|
|
|
|
|
|
|
// 调用后台接口添加物料 |
|
|
|
// 调用存储过程GetScanLabelVerification |
|
|
|
const params = { |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
buNo: this.buNo, |
|
|
|
site: this.inboundInfo.site, |
|
|
|
buNo: this.inboundInfo.buNo, |
|
|
|
inboundNo: this.inboundNo, |
|
|
|
materialCode: this.materialCode.trim(), |
|
|
|
actualQty: parseFloat(this.actualQty), |
|
|
|
batchNo: this.batchNo.trim(), |
|
|
|
warehouseId: getCurrentWarehouse() |
|
|
|
warehouseId: getCurrentWarehouse(), |
|
|
|
operationType: 'I', // I表示添加 |
|
|
|
documentType: '其他入库' // 单据类型 |
|
|
|
}; |
|
|
|
|
|
|
|
addMaterialToInbound(params).then(({ data }) => { |
|
|
|
validateLabelWithOtherInbound(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
const materialData = data.data; |
|
|
|
|
|
|
|
// 添加到列表顶部(最后添加的在最上面) |
|
|
|
this.materialList.unshift({ |
|
|
|
id: Date.now(), |
|
|
|
materialCode: materialData.materialCode, |
|
|
|
materialName: materialData.materialName, |
|
|
|
unit: materialData.unit, |
|
|
|
actualQty: materialData.actualQty, |
|
|
|
batchNo: this.batchNo.trim(), |
|
|
|
labelCode: materialData.labelCode |
|
|
|
}); |
|
|
|
this.$message.success('操作成功'); |
|
|
|
// 重新加载已扫描标签列表 |
|
|
|
this.loadScannedLabelList(); |
|
|
|
|
|
|
|
// 清空输入 |
|
|
|
this.materialCode = ''; |
|
|
|
this.actualQty = ''; |
|
|
|
this.batchNo = '*'; |
|
|
|
this.currentMaterial = {}; |
|
|
|
|
|
|
|
// 聚焦到物料编码输入框 |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.materialInput.focus(); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '添加物料失败'); |
|
|
|
this.$message.error(data.msg || '操作失败'); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('添加物料失败:', error); |
|
|
|
this.$message.error('添加物料失败'); |
|
|
|
this.$message.error('操作失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
@ -392,7 +395,7 @@ export default { |
|
|
|
this.locationCode = ''; |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交入库 |
|
|
|
// 提交入库(通过存储过程GetSaveLabelVerification) |
|
|
|
submitInbound() { |
|
|
|
if (!this.locationCode.trim()) { |
|
|
|
this.$message.warning('请输入库位号'); |
|
|
|
@ -403,13 +406,8 @@ export default { |
|
|
|
buNo: this.inboundInfo.buNo, |
|
|
|
inboundNo: this.inboundNo, |
|
|
|
locationCode: this.locationCode.trim(), |
|
|
|
materials: this.materialList.map(material => ({ |
|
|
|
materialCode: material.materialCode, |
|
|
|
actualQty: material.actualQty, |
|
|
|
batchNo: material.batchNo, |
|
|
|
labelCode: material.labelCode |
|
|
|
})) |
|
|
|
} |
|
|
|
documentType: '其他入库' // 单据类型 |
|
|
|
}; |
|
|
|
confirmOtherInbound(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.$message.success('入库成功'); |
|
|
|
@ -494,6 +492,9 @@ export default { |
|
|
|
getOtherInboundDetails(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.inboundInfo = data.data; |
|
|
|
// 加载入库单详情成功后,加载物料选项和已扫描标签列表 |
|
|
|
this.loadMaterialOptions(); |
|
|
|
this.loadScannedLabelList(); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg || '获取入库单详情失败'); |
|
|
|
} |
|
|
|
@ -501,6 +502,41 @@ export default { |
|
|
|
console.error('获取入库单详情失败:', error); |
|
|
|
this.$message.error('获取入库单详情失败'); |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载已扫描标签列表(从ScannedRollTempTable缓存表) |
|
|
|
loadScannedLabelList() { |
|
|
|
if (!this.inboundInfo.site || !this.inboundInfo.buNo || !this.inboundNo) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const params = { |
|
|
|
site: this.inboundInfo.site, |
|
|
|
buNo: this.inboundInfo.buNo, |
|
|
|
inboundNo: this.inboundNo, |
|
|
|
documentType: '其他入库' // 单据类型 |
|
|
|
}; |
|
|
|
|
|
|
|
getScannedLabelList(params).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
// 将查询结果转换为materialList格式 |
|
|
|
this.materialList = (data.data || []).map((item, index) => ({ |
|
|
|
id: Date.now() + index, |
|
|
|
labelCode: item.labelCode, |
|
|
|
materialCode: item.materialCode, |
|
|
|
actualQty: item.actualQty, |
|
|
|
batchNo: item.batchNo |
|
|
|
})); |
|
|
|
|
|
|
|
// 更新入库信息卡片的统计数据 |
|
|
|
this.inboundInfo.totalLabels = this.materialList.length; |
|
|
|
this.inboundInfo.totalQty = this.materialList.reduce((sum, item) => sum + parseFloat(item.actualQty || 0), 0); |
|
|
|
} else { |
|
|
|
console.error('获取已扫描标签列表失败:', data.msg); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('获取已扫描标签列表失败:', error); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
@ -519,13 +555,6 @@ export default { |
|
|
|
this.actualQty = ''; |
|
|
|
this.batchNo = '*'; |
|
|
|
|
|
|
|
// 聚焦物料编码输入框 |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.materialInput) { |
|
|
|
this.$refs.materialInput.focus(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 加载入库单详情 |
|
|
|
this.loadInboundDetails(); |
|
|
|
} |
|
|
|
|