add:配盘出库,工单下发根据产线修改bom仓库,点对点任务优化

This commit is contained in:
zhaoyf
2026-09-19 15:11:07 +08:00
parent ce020e98aa
commit 26552ec765
12 changed files with 274 additions and 148 deletions

View File

@@ -17,9 +17,16 @@
<template v-if="current">
<van-divider>需求物料</van-divider>
<van-cell-group inset>
<van-cell v-for="item in current.items" :key="item.id" :title="item.materialCode"
:label="item.materialName + (item.spec ? ' ' + item.spec : '') + (item.warehouseName ? ' | ' + item.warehouseName : '')"
:value="item.demandQty + ' ' + item.unit"/>
<div v-for="item in current.items" :key="item.id" class="material-card">
<van-cell :title="item.materialCode"
:label="item.materialName + (item.spec ? ' ' + item.spec : '') + (item.warehouseName ? ' | ' + item.warehouseName : '')"
:value="'剩余 ' + remainingQty(item) + ' ' + item.unit"/>
<van-field v-model="item.inputQty" type="number" label="本次数量" :disabled="item.ignore || item.ignored === 1" placeholder="请输入本托盘数量"/>
<van-cell title="现场无料,忽略该物料">
<template #right-icon><van-switch v-model="item.ignore" :disabled="item.ignored === 1" size="22"/></template>
</van-cell>
<div class="progress-text">需求 {{ item.demandQty }},已配 {{ item.allocatedQty || 0 }}</div>
</div>
</van-cell-group>
<van-field v-model="palletCode" label="托盘编码" placeholder="请扫描或输入托盘编码" clearable/>
<BottomButton text="完成配盘并出库" :loading="submitting" @click="complete"/>
@@ -60,27 +67,52 @@ async function loadDemands() {
async function selectDemand(id) {
const res = await request.get(`/api/pda/platingDemand/${id}`);
current.value = res.data;
current.value = {
...res.data,
items: (res.data.items || []).map(item => ({
...item,
inputQty: item.ignored === 1 ? '0' : String(remainingQty(item)),
ignore: item.ignored === 1,
})),
};
palletCode.value = ''
}
function remainingQty(item) {
return Math.max(0, Number(item.demandQty || 0) - Number(item.allocatedQty || 0))
}
async function complete() {
if (!palletCode.value) {
const items = current.value.items
.filter(item => item.ignored !== 1 && remainingQty(item) > 0)
.map(item => ({
itemId: item.id,
qty: item.ignore ? 0 : Number(item.inputQty || 0),
ignored: item.ignore,
}))
if (!items.some(item => item.ignored || item.qty > 0)) {
showToast({message: '请填写本次配盘数量或选择忽略物料', type: 'fail'});
return
}
if (items.some(item => item.qty > 0) && !palletCode.value) {
showToast({message: '请输入托盘编码', type: 'fail'});
return
}
try {
await showConfirmDialog({title: '确认完成', message: '将按需求数量生产出库并创建回传单,确认继续?'})
await showConfirmDialog({title: '确认提交', message: '将按本次填写数量执行当前托盘出库,确认继续?'})
} catch {
return
}
submitting.value = true
try {
await request.post(`/api/pda/platingDemand/${current.value.id}/complete`, {palletCode: palletCode.value});
showToast({message: '配盘完成', type: 'success'});
current.value = null;
const demandId = current.value.id
await request.post(`/api/pda/platingDemand/${demandId}/complete`, {palletCode: palletCode.value, items});
showToast({message: '本托盘配盘成功', type: 'success'});
palletCode.value = '';
await loadDemands()
const unfinished = demands.value.some(item => item.id === demandId)
if (unfinished) await selectDemand(demandId)
else current.value = null
} finally {
submitting.value = false
}
@@ -95,4 +127,15 @@ onMounted(loadDemands)
color: #666;
font-size: 12px;
}
.material-card {
padding-bottom: 8px;
border-bottom: 1px solid #eee;
}
.progress-text {
padding: 0 16px 8px;
color: #999;
font-size: 12px;
}
</style>