add:完善配盘配送

This commit is contained in:
zhaoyf
2026-09-17 17:12:47 +08:00
parent 2fb5c278f6
commit ce020e98aa
4 changed files with 117 additions and 2 deletions

View File

@@ -0,0 +1,98 @@
<template>
<div class="page-container">
<van-nav-bar title="托盘配料需求单" left-arrow @click-left="router.push('/')"/>
<div class="page-content">
<van-pull-refresh v-model="refreshing" @refresh="loadDemands">
<van-empty v-if="!demands.length && !loading" description="暂无未完成需求单"/>
<van-cell-group v-else inset>
<van-cell v-for="item in demands" :key="item.id" is-link @click="selectDemand(item.id)">
<template #title><strong>{{ item.demandCode }}</strong>
<div class="sub-text">工单:{{ item.workOrderCode }}</div>
</template>
<template #label>上料口:{{ item.loadPort }} | {{ statusLabel(item.status) }}</template>
</van-cell>
</van-cell-group>
</van-pull-refresh>
<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"/>
</van-cell-group>
<van-field v-model="palletCode" label="托盘编码" placeholder="请扫描或输入托盘编码" clearable/>
<BottomButton text="完成配盘并出库" :loading="submitting" @click="complete"/>
</template>
</div>
</div>
</template>
<script setup>
import {ref, onMounted} from 'vue'
import {useRouter} from 'vue-router'
import {showConfirmDialog, showToast} from 'vant'
import request from '@/utils/request'
import BottomButton from '@/components/BottomButton.vue'
const router = useRouter()
const demands = ref([])
const current = ref(null)
const palletCode = ref('')
const loading = ref(false)
const refreshing = ref(false)
const submitting = ref(false)
function statusLabel(status) {
return ['创建', '配盘中', '完成'][status] || '-'
}
async function loadDemands() {
loading.value = true;
try {
const res = await request.get('/api/pda/platingDemand');
demands.value = res.data || []
} finally {
loading.value = false;
refreshing.value = false
}
}
async function selectDemand(id) {
const res = await request.get(`/api/pda/platingDemand/${id}`);
current.value = res.data;
palletCode.value = ''
}
async function complete() {
if (!palletCode.value) {
showToast({message: '请输入托盘编码', type: 'fail'});
return
}
try {
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;
palletCode.value = '';
await loadDemands()
} finally {
submitting.value = false
}
}
onMounted(loadDemands)
</script>
<style scoped>
.sub-text {
margin-top: 4px;
color: #666;
font-size: 12px;
}
</style>