opt:配盘直送,配盘出库调整修改,不关联工单,调拨到线边
This commit is contained in:
@@ -2,131 +2,55 @@
|
||||
<div class="page-container direct-page">
|
||||
<van-nav-bar title="配盘直送" left-arrow @click-left="router.push('/')" />
|
||||
<div class="page-content">
|
||||
<!-- 产线选择 -->
|
||||
<!-- 源库区 -->
|
||||
<van-cell-group inset class="scanner-card">
|
||||
<van-field
|
||||
v-model="regionName"
|
||||
v-model="sectName"
|
||||
is-link
|
||||
readonly
|
||||
label="产线"
|
||||
placeholder="请选择产线区域"
|
||||
@click="showRegionPicker = true"
|
||||
label="源库区"
|
||||
placeholder="请选择调出库区"
|
||||
@click="showSectPicker = true"
|
||||
/>
|
||||
</van-cell-group>
|
||||
<van-popup v-model:show="showRegionPicker" position="bottom" round>
|
||||
<van-popup v-model:show="showSectPicker" position="bottom" round>
|
||||
<van-picker
|
||||
:columns="regionColumns"
|
||||
@confirm="onRegionConfirm"
|
||||
@cancel="showRegionPicker = false"
|
||||
:columns="sectColumns"
|
||||
@confirm="onSectConfirm"
|
||||
@cancel="showSectPicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
|
||||
<!-- 上料口扫描 -->
|
||||
<!-- 托盘扫描 -->
|
||||
<van-cell-group inset class="scanner-card">
|
||||
<van-field
|
||||
ref="loadPortInput"
|
||||
v-model.trim="loadPort"
|
||||
label="上料口"
|
||||
placeholder="请扫描或输入上料口编码"
|
||||
ref="palletInput"
|
||||
v-model.trim="vehicleCode"
|
||||
label="托盘码"
|
||||
placeholder="请扫描或输入托盘码"
|
||||
clearable
|
||||
@keyup.enter="openOrderDialog"
|
||||
@keyup.enter="loadPallet"
|
||||
@clear="clearPallet"
|
||||
>
|
||||
<template #right-icon>
|
||||
<van-icon name="scan" class="scan-icon" @click="openOrderDialog" />
|
||||
<van-icon name="scan" class="scan-icon" @click="loadPallet" />
|
||||
</template>
|
||||
</van-field>
|
||||
</van-cell-group>
|
||||
|
||||
<!-- 工单选择 -->
|
||||
<!-- 配送方式 -->
|
||||
<van-cell-group inset class="scanner-card">
|
||||
<van-cell
|
||||
title="工单"
|
||||
:value="selectedOrders.length ? `已选 ${selectedOrders.length} 张` : '未选择'"
|
||||
is-link
|
||||
@click="openOrderDialog"
|
||||
/>
|
||||
<div v-if="selectedOrders.length" class="order-chips">
|
||||
<span
|
||||
v-for="code in selectedOrders"
|
||||
:key="code"
|
||||
class="chip"
|
||||
@click="removeOrder(code)"
|
||||
>
|
||||
{{ code }} ✕
|
||||
</span>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
|
||||
<!-- 工单选择弹窗 -->
|
||||
<van-popup v-model:show="showOrderPicker" position="bottom" round class="order-popup">
|
||||
<div class="popup-header">
|
||||
<span>选择工单({{ regionName || '未选产线' }} / {{ loadPort || '未扫上料口' }})</span>
|
||||
<span class="popup-close" @click="showOrderPicker = false">关闭</span>
|
||||
</div>
|
||||
<div class="popup-body">
|
||||
<van-empty
|
||||
v-if="!dialogLoading && !dialogOrders.length"
|
||||
description="该产线上料口下暂无可直送工单"
|
||||
/>
|
||||
<van-checkbox-group v-model="selectedOrders">
|
||||
<van-cell-group inset>
|
||||
<van-cell
|
||||
v-for="order in dialogOrders"
|
||||
:key="order.order_code"
|
||||
:title="order.order_code"
|
||||
:label="`${order.product_name || '-'} · 计划开工:${order.plan_started_on || '-'}`"
|
||||
clickable
|
||||
@click="toggleOrder(order.order_code)"
|
||||
>
|
||||
<template #right-icon>
|
||||
<van-checkbox :name="order.order_code" @click.stop />
|
||||
</template>
|
||||
<template #value>
|
||||
<span class="order-qty">×{{ order.order_qty ?? '-' }}</span>
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-cell-group>
|
||||
</van-checkbox-group>
|
||||
</div>
|
||||
<div class="popup-footer">
|
||||
<van-button type="primary" block :loading="dialogLoading" @click="confirmOrders">
|
||||
确定(已选 {{ selectedOrders.length }} 张)
|
||||
</van-button>
|
||||
</div>
|
||||
</van-popup>
|
||||
|
||||
<!-- BOM物料明细 -->
|
||||
<div v-if="materials.length" class="section-header">
|
||||
<span>物料明细({{ currentPort }})</span>
|
||||
<span>{{ materials.length }} 种物料</span>
|
||||
</div>
|
||||
<div v-if="materials.length" class="material-card">
|
||||
<div v-for="item in materials" :key="item.material_code" class="material-row">
|
||||
<div>
|
||||
<strong>{{ item.material_code }}</strong>
|
||||
<div class="material-name">{{ item.material_name || '-' }}</div>
|
||||
</div>
|
||||
<div class="material-qty">
|
||||
<div>需求 {{ item.need_qty }} {{ item.unit || '' }}</div>
|
||||
<div class="remain">剩余 {{ item.remain_qty }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- AGV配送开关 -->
|
||||
<van-cell-group inset class="scanner-card">
|
||||
<van-cell center title="AGV配送">
|
||||
<van-cell center title="AGV配送" label="关闭则提交后直接出库过账">
|
||||
<template #right-icon>
|
||||
<van-switch v-model="agvDelivery" size="22" />
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-field
|
||||
ref="vehicleInput"
|
||||
v-model.trim="vehicleCode"
|
||||
label="托盘码"
|
||||
placeholder="请扫描或输入托盘码"
|
||||
v-if="agvDelivery"
|
||||
v-model.trim="siteCode"
|
||||
label="起始点位"
|
||||
placeholder="请扫描起始点位"
|
||||
clearable
|
||||
@keyup.enter="onVehicleEnter"
|
||||
>
|
||||
<template #right-icon>
|
||||
<van-icon name="scan" class="scan-icon" />
|
||||
@@ -134,8 +58,39 @@
|
||||
</van-field>
|
||||
</van-cell-group>
|
||||
|
||||
<!-- 托盘信息 -->
|
||||
<van-loading v-if="loadingPallet" class="page-loading" size="20">读取托盘…</van-loading>
|
||||
<div v-else-if="pallet" class="material-card">
|
||||
<div class="pallet-head">
|
||||
<div>
|
||||
<strong>{{ pallet.pallet_code }}</strong>
|
||||
<div class="material-name">{{ pallet.region_name || '-' }}</div>
|
||||
</div>
|
||||
<div class="pallet-port">
|
||||
<div>上料口 {{ pallet.load_port }}</div>
|
||||
<div class="remain">{{ pallet.port_name || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-header">
|
||||
<span>物料明细</span>
|
||||
<span>{{ (pallet.materials || []).length }} 种</span>
|
||||
</div>
|
||||
<div v-for="item in pallet.materials || []" :key="item.material_code + item.pcsn" class="material-row">
|
||||
<div>
|
||||
<strong>{{ item.material_code }}</strong>
|
||||
<div class="material-name">{{ item.material_name || '-' }}</div>
|
||||
</div>
|
||||
<div class="material-qty">
|
||||
<div>{{ formatQty(item.qty) }} {{ item.unit || '' }}</div>
|
||||
<div class="remain">批次 {{ item.pcsn || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tips">
|
||||
组盘状态的托盘不入库直接配送:生成出库单与LLCK回传EAS;开启AGV配送时自动生成点对点搬运任务。
|
||||
组盘托盘不入库,直接调拨出库到产线上料口:生成「库存调拨」出库单并回传 SAP MM057(311 转储至线边库 X001),线边库库存不在 WMS 管理。
|
||||
<template v-if="agvDelivery">开启 AGV 配送时需扫描起始点位,托盘送达后任务完成并出库过账。</template>
|
||||
<template v-else>未开启 AGV 配送,提交后立即出库过账。</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-bottom">
|
||||
@@ -145,202 +100,125 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {computed, nextTick, onMounted, ref, watch} from 'vue'
|
||||
import {computed, nextTick, onMounted, ref} from 'vue'
|
||||
import {useRouter} from 'vue-router'
|
||||
import {showConfirmDialog, showToast} from 'vant'
|
||||
import request from '@/utils/request'
|
||||
|
||||
const router = useRouter()
|
||||
const loadPortInput = ref()
|
||||
const vehicleInput = ref()
|
||||
const palletInput = ref()
|
||||
|
||||
const regions = ref([])
|
||||
const regionCode = ref('')
|
||||
const regionName = ref('')
|
||||
const showRegionPicker = ref(false)
|
||||
const sects = ref([])
|
||||
const sectCode = ref('')
|
||||
const sectName = ref('')
|
||||
const showSectPicker = ref(false)
|
||||
|
||||
const showOrderPicker = ref(false)
|
||||
const dialogLoading = ref(false)
|
||||
const dialogOrders = ref([])
|
||||
|
||||
const selectedOrders = ref([])
|
||||
|
||||
const loadPort = ref('')
|
||||
const currentPort = ref('')
|
||||
const materials = ref([])
|
||||
const loadingMaterials = ref(false)
|
||||
|
||||
const agvDelivery = ref(true)
|
||||
const vehicleCode = ref('')
|
||||
const siteCode = ref('')
|
||||
const agvDelivery = ref(true)
|
||||
const pallet = ref(null)
|
||||
const loadingPallet = ref(false)
|
||||
const submitting = ref(false)
|
||||
|
||||
const REGION_CACHE_KEY = 'direct_delivery_region_code'
|
||||
const SECT_CACHE_KEY = 'direct_delivery_sect_code'
|
||||
|
||||
const regionColumns = computed(() => {
|
||||
if (!regions.value.length) return [{text: '加载中...', value: ''}]
|
||||
return regions.value.map(r => ({text: r.region_name || r.region_code, value: r.region_code}))
|
||||
const sectColumns = computed(() => {
|
||||
if (!sects.value.length) return [{text: '加载中...', value: ''}]
|
||||
return sects.value.map(s => ({text: s.sect_name || s.sect_code, value: s.sect_code}))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await request.get('/api/pda/directDelivery/regions')
|
||||
regions.value = res.data || []
|
||||
const res = await request.get('/api/pda/directDelivery/sects')
|
||||
sects.value = res.data || []
|
||||
} catch {
|
||||
// 请求拦截器统一提示错误
|
||||
}
|
||||
// 回填缓存产线
|
||||
const cachedCode = localStorage.getItem(REGION_CACHE_KEY)
|
||||
// 回填缓存库区
|
||||
const cachedCode = localStorage.getItem(SECT_CACHE_KEY)
|
||||
if (cachedCode) {
|
||||
const cached = regions.value.find(r => r.region_code === cachedCode)
|
||||
const cached = sects.value.find(s => s.sect_code === cachedCode)
|
||||
if (cached) {
|
||||
regionCode.value = cached.region_code
|
||||
regionName.value = cached.region_name || cached.region_code
|
||||
sectCode.value = cached.sect_code
|
||||
sectName.value = cached.sect_name || cached.sect_code
|
||||
}
|
||||
}
|
||||
nextTick(() => loadPortInput.value?.focus())
|
||||
nextTick(() => palletInput.value?.focus())
|
||||
})
|
||||
|
||||
function onRegionConfirm({selectedOptions}) {
|
||||
function onSectConfirm({selectedOptions}) {
|
||||
const option = selectedOptions[0]
|
||||
if (!option || !option.value) {
|
||||
showRegionPicker.value = false
|
||||
showSectPicker.value = false
|
||||
return
|
||||
}
|
||||
regionCode.value = option.value
|
||||
regionName.value = option.text
|
||||
localStorage.setItem(REGION_CACHE_KEY, option.value)
|
||||
showRegionPicker.value = false
|
||||
resetMaterials()
|
||||
sectCode.value = option.value
|
||||
sectName.value = option.text
|
||||
localStorage.setItem(SECT_CACHE_KEY, option.value)
|
||||
showSectPicker.value = false
|
||||
}
|
||||
|
||||
watch(regionCode, () => {
|
||||
selectedOrders.value = []
|
||||
resetMaterials()
|
||||
})
|
||||
|
||||
// 打开工单选择弹窗:需先选产线并扫描上料口
|
||||
async function openOrderDialog() {
|
||||
if (dialogLoading.value) return
|
||||
if (!regionCode.value) {
|
||||
showToast({message: '请先选择产线', type: 'fail'})
|
||||
showRegionPicker.value = true
|
||||
// 扫描托盘:读取上料口、托盘当前点位与物料明细
|
||||
async function loadPallet() {
|
||||
if (loadingPallet.value) return
|
||||
const code = vehicleCode.value.trim()
|
||||
if (!code) {
|
||||
showToast({message: '请扫描托盘码', type: 'fail'})
|
||||
palletInput.value?.focus()
|
||||
return
|
||||
}
|
||||
const port = loadPort.value.trim()
|
||||
if (!port) {
|
||||
showToast({message: '请先扫描上料口', type: 'fail'})
|
||||
loadPortInput.value?.focus()
|
||||
return
|
||||
}
|
||||
dialogLoading.value = true
|
||||
showOrderPicker.value = true
|
||||
loadingPallet.value = true
|
||||
try {
|
||||
const res = await request.get('/api/pda/directDelivery/workOrders', {
|
||||
params: {regionCode: regionCode.value, loadPort: port},
|
||||
})
|
||||
dialogOrders.value = res.data || []
|
||||
const res = await request.get('/api/pda/directDelivery/pallet', {params: {vehicleCode: code}})
|
||||
pallet.value = res.data || null
|
||||
siteCode.value = (pallet.value && pallet.value.current_point_code) || ''
|
||||
} catch {
|
||||
dialogOrders.value = []
|
||||
pallet.value = null
|
||||
} finally {
|
||||
dialogLoading.value = false
|
||||
loadingPallet.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleOrder(code) {
|
||||
const index = selectedOrders.value.indexOf(code)
|
||||
if (index >= 0) {
|
||||
selectedOrders.value.splice(index, 1)
|
||||
} else {
|
||||
selectedOrders.value.push(code)
|
||||
}
|
||||
function clearPallet() {
|
||||
pallet.value = null
|
||||
siteCode.value = ''
|
||||
}
|
||||
|
||||
function removeOrder(code) {
|
||||
selectedOrders.value = selectedOrders.value.filter(c => c !== code)
|
||||
resetMaterials()
|
||||
}
|
||||
|
||||
// 弹窗确认后加载BOM物料明细
|
||||
async function confirmOrders() {
|
||||
if (!selectedOrders.value.length) {
|
||||
showToast({message: '请至少选择一张工单', type: 'fail'})
|
||||
return
|
||||
}
|
||||
showOrderPicker.value = false
|
||||
await queryMaterials()
|
||||
}
|
||||
|
||||
async function queryMaterials() {
|
||||
if (loadingMaterials.value) return
|
||||
const port = loadPort.value.trim()
|
||||
if (!port) {
|
||||
showToast({message: '请扫描上料口', type: 'fail'})
|
||||
return
|
||||
}
|
||||
if (!selectedOrders.value.length) {
|
||||
showToast({message: '请先选择工单', type: 'fail'})
|
||||
return
|
||||
}
|
||||
loadingMaterials.value = true
|
||||
try {
|
||||
const res = await request.get('/api/pda/directDelivery/bomMaterials', {
|
||||
params: {loadPort: port, workOrders: selectedOrders.value.join(',')},
|
||||
})
|
||||
currentPort.value = port
|
||||
materials.value = res.data || []
|
||||
if (!materials.value.length) {
|
||||
showToast({message: '所选工单在该上料口无BOM物料', type: 'fail'})
|
||||
} else {
|
||||
nextTick(() => vehicleInput.value?.focus())
|
||||
}
|
||||
} catch {
|
||||
materials.value = []
|
||||
} finally {
|
||||
loadingMaterials.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(loadPort, () => {
|
||||
if (loadPort.value.trim() !== currentPort.value) resetMaterials()
|
||||
})
|
||||
|
||||
function resetMaterials() {
|
||||
materials.value = []
|
||||
currentPort.value = ''
|
||||
}
|
||||
|
||||
function onVehicleEnter() {
|
||||
if (vehicleCode.value) onSubmit()
|
||||
function formatQty(value) {
|
||||
if (value === null || value === undefined || value === '') return '0'
|
||||
const num = Number(value)
|
||||
if (isNaN(num)) return value
|
||||
return num.toLocaleString('zh-CN', {maximumFractionDigits: 4})
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
if (submitting.value) return
|
||||
if (!regionCode.value) {
|
||||
showToast({message: '请先选择产线', type: 'fail'})
|
||||
if (!sectCode.value) {
|
||||
showToast({message: '请先选择源库区', type: 'fail'})
|
||||
showSectPicker.value = true
|
||||
return
|
||||
}
|
||||
if (!selectedOrders.value.length) {
|
||||
showToast({message: '请先选择工单', type: 'fail'})
|
||||
return
|
||||
}
|
||||
if (!loadPort.value.trim()) {
|
||||
showToast({message: '请扫描上料口', type: 'fail'})
|
||||
loadPortInput.value?.focus()
|
||||
return
|
||||
}
|
||||
if (!materials.value.length) {
|
||||
showToast({message: '请先选择工单加载物料明细', type: 'fail'})
|
||||
return
|
||||
}
|
||||
if (!vehicleCode.value.trim()) {
|
||||
const code = vehicleCode.value.trim()
|
||||
if (!code) {
|
||||
showToast({message: '请扫描托盘码', type: 'fail'})
|
||||
vehicleInput.value?.focus()
|
||||
palletInput.value?.focus()
|
||||
return
|
||||
}
|
||||
if (!pallet.value || pallet.value.pallet_code !== code) {
|
||||
showToast({message: '请先读取托盘信息', type: 'fail'})
|
||||
await loadPallet()
|
||||
return
|
||||
}
|
||||
if (agvDelivery.value && !siteCode.value.trim()) {
|
||||
showToast({message: '请扫描起始点位', type: 'fail'})
|
||||
return
|
||||
}
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '确认直送',
|
||||
message: `托盘 ${vehicleCode.value} 直送 ${loadPort.value.trim()},出库单将生成并回传LLCK${agvDelivery.value ? ',同时生成AGV配送任务' : ''},确认提交?`,
|
||||
message: agvDelivery.value
|
||||
? `托盘 ${code} 配送至上料口 ${pallet.value.load_port},送达后任务完成并出库过账(MM057调拨X001),确认提交?`
|
||||
: `托盘 ${code} 直接调拨出库至上料口 ${pallet.value.load_port},提交后立即出库过账(MM057调拨X001),确认提交?`,
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
@@ -348,19 +226,19 @@ async function onSubmit() {
|
||||
submitting.value = true
|
||||
try {
|
||||
const res = await request.post('/api/pda/directDelivery/deliver', {
|
||||
region_code: regionCode.value,
|
||||
workOrders: selectedOrders.value,
|
||||
load_port: loadPort.value.trim(),
|
||||
vehicle_code: vehicleCode.value.trim(),
|
||||
vehicle_code: code,
|
||||
sect_code: sectCode.value,
|
||||
agv_delivery: agvDelivery.value,
|
||||
site_code: agvDelivery.value ? siteCode.value.trim() : '',
|
||||
})
|
||||
const data = res.data || {}
|
||||
let message = '直送完成'
|
||||
let message = agvDelivery.value ? '直送任务已生成' : '直送完成,已出库过账'
|
||||
if (data.bill_code) message += `,出库单 ${data.bill_code}`
|
||||
if (data.task_code) message += `,任务 ${data.task_code}`
|
||||
showToast({message, type: 'success'})
|
||||
vehicleCode.value = ''
|
||||
await queryMaterials()
|
||||
clearPallet()
|
||||
nextTick(() => palletInput.value?.focus())
|
||||
} catch {
|
||||
// 请求拦截器统一提示错误
|
||||
} finally {
|
||||
@@ -372,6 +250,7 @@ async function onSubmit() {
|
||||
<style scoped>
|
||||
.direct-page {
|
||||
background: #eef2f3;
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
.scanner-card {
|
||||
@@ -379,68 +258,20 @@ async function onSubmit() {
|
||||
border: 1px solid #dfe7e8;
|
||||
}
|
||||
|
||||
.page-loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 4px 2px 8px;
|
||||
margin: 10px 0 4px;
|
||||
color: #587073;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.order-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 0 16px 10px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
padding: 3px 10px;
|
||||
background: #e8f3ff;
|
||||
border-radius: 12px;
|
||||
color: #1989fa;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.order-popup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 72%;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 16px;
|
||||
color: #323233;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid #eef0f2;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
color: #969799;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
padding: 8px 16px calc(8px + constant(safe-area-inset-bottom));
|
||||
padding-bottom: calc(8px + env(safe-area-inset-bottom));
|
||||
border-top: 1px solid #eef0f2;
|
||||
}
|
||||
|
||||
.order-qty {
|
||||
color: #d36b2c;
|
||||
}
|
||||
|
||||
.material-card {
|
||||
margin-bottom: 14px;
|
||||
padding: 12px 16px;
|
||||
@@ -450,6 +281,22 @@ async function onSubmit() {
|
||||
box-shadow: 0 5px 18px rgba(39, 68, 72, 0.08);
|
||||
}
|
||||
|
||||
.pallet-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #eef0f2;
|
||||
}
|
||||
|
||||
.pallet-port {
|
||||
flex-shrink: 0;
|
||||
margin-left: 12px;
|
||||
text-align: right;
|
||||
color: #587073;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.material-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user