|
|
|
@ -187,7 +187,7 @@ |
|
|
|
返回修改 |
|
|
|
</el-button> |
|
|
|
<el-button class="btn-confirm" @click="proceedIssueConfirm" :disabled="loading"> |
|
|
|
{{ loading ? '发料中...' : '确定发料' }} |
|
|
|
{{ loading ? '发料中...' : '确定预留发料' }} |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -409,6 +409,7 @@ export default { |
|
|
|
extra: [], |
|
|
|
}, |
|
|
|
pendingIssueParams: null, |
|
|
|
shipmentLine: [], |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
@ -430,6 +431,14 @@ export default { |
|
|
|
} |
|
|
|
return Number.isInteger(num) ? num : Number(num.toFixed(3)) |
|
|
|
}, |
|
|
|
// 精度安全的加法,避免浮点数精度丢失 |
|
|
|
safeAdd(a, b) { |
|
|
|
const num1 = Number(a) || 0 |
|
|
|
const num2 = Number(b) || 0 |
|
|
|
// 将数字转换为整数(保留4位小数精度),相加后再转换回小数 |
|
|
|
const factor = 10000 |
|
|
|
return Math.round((num1 * factor + num2 * factor)) / factor |
|
|
|
}, |
|
|
|
pickFieldValue(item, candidates = [], defaultValue = null) { |
|
|
|
if (!item || !candidates || candidates.length === 0) { |
|
|
|
return defaultValue |
|
|
|
@ -462,7 +471,7 @@ export default { |
|
|
|
qty: 0, |
|
|
|
} |
|
|
|
} |
|
|
|
map[normalizedKey].qty += qtyValue |
|
|
|
map[normalizedKey].qty = this.safeAdd(map[normalizedKey].qty, qtyValue) |
|
|
|
}) |
|
|
|
return map |
|
|
|
}, |
|
|
|
@ -663,8 +672,6 @@ export default { |
|
|
|
this.$message.warning('扫描数量不能大于总发料数量和已发数量的差!') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.pendingIssueParams = this.buildIssueParams() |
|
|
|
this.summaryLoading = true |
|
|
|
try { |
|
|
|
await this.prepareComparisonData() |
|
|
|
@ -678,7 +685,7 @@ export default { |
|
|
|
this.summaryLoading = false |
|
|
|
} |
|
|
|
}, |
|
|
|
buildIssueParams() { |
|
|
|
buildIssueParams() { |
|
|
|
return { |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
workOrderNo: this.orderNo, |
|
|
|
@ -699,9 +706,11 @@ export default { |
|
|
|
wdrNo: label.wdrNo || '*', |
|
|
|
engChgLevel: label.engChgLevel || '1', |
|
|
|
})), |
|
|
|
shipmentLine: this.shipmentLine || [], |
|
|
|
} |
|
|
|
}, |
|
|
|
async prepareComparisonData() { |
|
|
|
this.shipmentLine = [] |
|
|
|
const params = { |
|
|
|
site: localStorage.getItem('site'), |
|
|
|
workOrderNo: this.orderNo, |
|
|
|
@ -712,16 +721,33 @@ export default { |
|
|
|
throw new Error((data && data.msg) || '获取申请单物料失败') |
|
|
|
} |
|
|
|
const materials = data.data || [] |
|
|
|
this.$set(this,'shipmentLine',data.data) |
|
|
|
const labelMap = this.aggregateMaterials( |
|
|
|
this.labelList, |
|
|
|
['partNo'], |
|
|
|
['qtyToIssue', 'quantity', 'issueQty'] |
|
|
|
) |
|
|
|
const orderMap = this.aggregateMaterials( |
|
|
|
materials, |
|
|
|
['INVENTORY_PART_NO'], |
|
|
|
['INVENTORY_QTY', 'QTY_ASSIGNED', 'QTY_PICKED', 'QTY_SHIPPED'] |
|
|
|
) |
|
|
|
// 手动聚合订单物料,计算 INVENTORY_QTY - QTY_ASSIGNED 作为需求数量 |
|
|
|
const orderMap = {} |
|
|
|
materials.forEach((item) => { |
|
|
|
const partNo = this.pickFieldValue(item, ['INVENTORY_PART_NO']) |
|
|
|
const normalizedKey = |
|
|
|
typeof partNo === 'string' ? partNo.trim() : partNo |
|
|
|
if (!normalizedKey) { |
|
|
|
return |
|
|
|
} |
|
|
|
const inventoryQty = Number(this.pickFieldValue(item, ['INVENTORY_QTY'], 0)) || 0 |
|
|
|
const qtyAssigned = Number(this.pickFieldValue(item, ['QTY_ASSIGNED'], 0)) || 0 |
|
|
|
const requiredQty = this.safeAdd(inventoryQty, -qtyAssigned) |
|
|
|
|
|
|
|
if (!orderMap[normalizedKey]) { |
|
|
|
orderMap[normalizedKey] = { |
|
|
|
partNo: normalizedKey, |
|
|
|
qty: 0, |
|
|
|
} |
|
|
|
} |
|
|
|
orderMap[normalizedKey].qty = this.safeAdd(orderMap[normalizedKey].qty, requiredQty) |
|
|
|
}) |
|
|
|
|
|
|
|
const existing = [] |
|
|
|
const missing = [] |
|
|
|
@ -776,7 +802,7 @@ export default { |
|
|
|
} |
|
|
|
this.submitIssue() |
|
|
|
}, |
|
|
|
submitIssue() { |
|
|
|
submitIssue() { |
|
|
|
if (!this.pendingIssueParams) { |
|
|
|
this.$message.error('缺少发料参数,请重新确认') |
|
|
|
return |
|
|
|
@ -798,7 +824,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
let params = this.pendingIssueParams |
|
|
|
params.shipmentType = this.orderType |
|
|
|
params.shipmentType = this.orderType |
|
|
|
|
|
|
|
this.loading = true |
|
|
|
customerIssueConfirm(params) |
|
|
|
|