feat: 多系统新增扫码中间件与 AGV 对接,优化拧紧与退库流程
新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
This commit is contained in:
@@ -12,101 +12,8 @@ import PageHelp from '../components/PageHelp.vue'
|
||||
import MaterialSelect from '../components/MaterialSelect.vue'
|
||||
import { helpOutbound } from '../help'
|
||||
|
||||
const activeTab = ref('prep') // prep=备料出库 / general=通用出库 / records=出库记录
|
||||
const activeTab = ref('general') // general=通用出库 / records=出库记录(工单领料出库已随叫料池模型退役,见「叫料队列」)
|
||||
const operator = getRealName()
|
||||
|
||||
/* ===================== 备料出库(WMS 工单备料台账,由 MES 备料单同步) ===================== */
|
||||
const queryForm = reactive({ orderNo: '' })
|
||||
// 目标工位:AGV 配送 toDock 参数,DOCK01~DOCK20 下拉选填(不选默认产线入口 DOCK01)
|
||||
const targetDock = ref('')
|
||||
const dockOptions = Array.from({ length: 20 }, (_, i) => 'DOCK' + String(i + 1).padStart(2, '0'))
|
||||
const loadingPrep = ref(false)
|
||||
const queried = ref(false)
|
||||
const rows = ref([])
|
||||
|
||||
const orders = ref([])
|
||||
const ordersLoading = ref(false)
|
||||
// 工单号来自 MES 实时查询:无输入默认拉「未完成优先」的前 20 条;输入时按工单号模糊远程搜索。
|
||||
async function searchOrders(query) {
|
||||
ordersLoading.value = true
|
||||
try {
|
||||
const data = await request.get('/orders', { params: { orderNo: query || '', limit: 20 } })
|
||||
orders.value = Array.isArray(data) ? data : data?.list || []
|
||||
} catch { orders.value = [] }
|
||||
finally { ordersLoading.value = false }
|
||||
}
|
||||
async function loadOrders() { await searchOrders('') }
|
||||
function orderLabel(o) { return o.productName ? `${o.workOrderNo} ${o.productName}` : o.workOrderNo }
|
||||
// 选中下拉项或手输兜底(allow-create)后直接查该工单台账
|
||||
function onOrderPick(v) { if (v && String(v).trim()) queryPrep() }
|
||||
onMounted(loadOrders)
|
||||
|
||||
const pendingRows = computed(() => rows.value.filter(r => r.status !== '领料完结'))
|
||||
function gapOf(row) { return Math.max((row.totalQty || 0) - (row.outQty || 0), 0) }
|
||||
|
||||
// 一键自动分配批次:合格区 Z02,batchNo 正序 FIFO 凑够缺口
|
||||
async function autoAllocate(row) {
|
||||
const gap = gapOf(row)
|
||||
if (gap <= 0) return
|
||||
const stock = await request.get('/stock/details', { params: { materialCode: row.materialCode, snMode: 2, page: 1, pageSize: 200 } })
|
||||
const batches = (stock?.list || [])
|
||||
.filter(b => b.qualityStatus === '合格' && b.zoneCode === 'Z02')
|
||||
.sort((a, b) => String(a.batchNo).localeCompare(String(b.batchNo)))
|
||||
|
||||
const plan = []
|
||||
let remain = gap
|
||||
for (const b of batches) {
|
||||
if (remain <= 0) break
|
||||
const avail = (b.quantity || 0) - (b.lockedQty || 0)
|
||||
if (avail <= 0) continue
|
||||
const take = Math.min(avail, remain)
|
||||
plan.push({ batchNo: b.batchNo, qty: take, zoneCode: b.zoneCode })
|
||||
remain -= take
|
||||
}
|
||||
if (!plan.length) {
|
||||
ElMessage.warning(`物料 ${row.materialCode} 在合格区(Z02)无可用批次库存`)
|
||||
return
|
||||
}
|
||||
if (remain > 0) {
|
||||
ElMessage.error(`可用量不足:缺口 ${gap},Z02 仅可凑 ${gap - remain},还差 ${remain}`)
|
||||
return
|
||||
}
|
||||
|
||||
const lines = plan.map(p => `· 批次 ${p.batchNo} 出库 ${p.qty}`).join('\n')
|
||||
await ElMessageBox.confirm(
|
||||
`工单 ${row.orderNo} 物料 ${row.materialCode}\n缺口 ${gap},按 FIFO 分配如下:\n${lines}\n\n操作人:${operator}${targetDock.value ? `\n目标口:${targetDock.value}` : ''}`,
|
||||
'确认自动分配出库',
|
||||
{ type: 'warning', confirmButtonText: '确认出库', cancelButtonText: '取消' }
|
||||
)
|
||||
|
||||
const outboundNos = []
|
||||
let lastStatus = ''
|
||||
for (const p of plan) {
|
||||
const res = await request.post('/outbound/create', {
|
||||
orderNo: row.orderNo, materialCode: row.materialCode, batchNo: p.batchNo,
|
||||
qty: p.qty, operator, targetDock: targetDock.value.trim() || undefined
|
||||
})
|
||||
if (res?.outboundNo) outboundNos.push(res.outboundNo)
|
||||
lastStatus = res?.status || lastStatus
|
||||
}
|
||||
const done = lastStatus === '领料完结'
|
||||
ElMessage.success(`出库完成:出库单号 ${outboundNos.join('、')};该物料${done ? '已' : '未'}领料完结`)
|
||||
await queryPrep()
|
||||
}
|
||||
|
||||
function statusTag(s) { return s === '领料完结' ? 'success' : s === '进行中' ? 'primary' : 'info' }
|
||||
|
||||
async function queryPrep() {
|
||||
if (!queryForm.orderNo.trim()) { ElMessage.warning('请输入工单号'); return }
|
||||
loadingPrep.value = true
|
||||
try {
|
||||
const data = await request.get('/ledger/query', { params: { orderNo: queryForm.orderNo.trim(), page: 1, pageSize: 100 } })
|
||||
rows.value = data?.list || []
|
||||
queried.value = true
|
||||
if (!rows.value.length) ElMessage.info('该工单暂无台账记录')
|
||||
} finally { loadingPrep.value = false }
|
||||
}
|
||||
|
||||
/* ===================== 通用出库(手动,不依赖工单) ===================== */
|
||||
// 出库类别:退料/退货/样品/报废/发货/其他(客户诉求 L96-108 + U5)
|
||||
const CATEGORY_OPTIONS = [
|
||||
@@ -397,68 +304,6 @@ onMounted(loadDicts)
|
||||
<template>
|
||||
<div>
|
||||
<el-tabs v-model="activeTab" @tab-change="onTabChange">
|
||||
<!-- ============ 备料出库(WMS 工单备料台账,由 MES 备料单同步) ============ -->
|
||||
<el-tab-pane label="工单领料出库(操作)" name="prep">
|
||||
<el-alert type="info" :closable="false" class="mb12"
|
||||
title="本页按 MES 工单号查询 WMS 工单备料台账(由 MES 备料单同步),按缺口一键领料;工单号下拉来自 MES 实时工单。"
|
||||
description="未启用 MES 或工单未同步时,工单下拉可能为空——此时可直接手输工单号(前提是台账已同步),或改用「通用出库」处理退料/样品/报废/发货等不挂靠工单的场景。" />
|
||||
<el-card shadow="never" class="mb12">
|
||||
<el-form inline label-width="90px" @submit.prevent>
|
||||
<el-form-item label="工单号">
|
||||
<el-select v-model="queryForm.orderNo" filterable remote allow-create default-first-option
|
||||
clearable reserve-keyword :remote-method="searchOrders" :loading="ordersLoading"
|
||||
placeholder="选择或输入工单号(默认未完成优先前20条,可模糊搜索)"
|
||||
style="width:340px" @change="onOrderPick">
|
||||
<el-option v-for="o in orders" :key="o.workOrderNo" :value="o.workOrderNo" :label="orderLabel(o)">
|
||||
<span style="float:left">{{ o.workOrderNo }}</span>
|
||||
<span style="float:right;color:#909399;font-size:12px">{{ o.productName }} {{ o.status }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人">
|
||||
<el-input :model-value="operator" disabled style="width:160px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="目标工位">
|
||||
<el-select v-model="targetDock" placeholder="选填,默认 DOCK01" clearable filterable
|
||||
style="width:180px">
|
||||
<el-option v-for="d in dockOptions" :key="d" :value="d" :label="d" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loadingPrep" @click="queryPrep">查询备料台账</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-if="queried" shadow="never">
|
||||
<template #header>
|
||||
台账明细(共 {{ rows.length }} 行,待补 {{ pendingRows.length }} 行)
|
||||
</template>
|
||||
<el-table :data="rows" border v-loading="loadingPrep">
|
||||
<el-table-column prop="orderNo" label="工单号" min-width="140" />
|
||||
<el-table-column prop="materialCode" label="图号" min-width="150" />
|
||||
<el-table-column prop="materialName" label="物料名称" min-width="140">
|
||||
<template #default="{ row }">{{ row.materialName || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalQty" label="需求总量" width="100" align="center" />
|
||||
<el-table-column prop="outQty" label="已出库" width="90" align="center" />
|
||||
<el-table-column label="缺口" width="90" align="center">
|
||||
<template #default="{ row }"><span :class="{ gap: gapOf(row) > 0 }">{{ gapOf(row) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="110" align="center">
|
||||
<template #default="{ row }"><el-tag :type="statusTag(row.status)" size="small">{{ row.status }}</el-tag></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.status !== '领料完结'" type="primary" size="small" @click="autoAllocate(row)">分配</el-button>
|
||||
<span v-else style="color:#67c23a">已完结</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<el-empty v-else description="请先按工单号查询备料台账" />
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- ============ 通用出库 ============ -->
|
||||
<el-tab-pane label="通用出库" name="general">
|
||||
<el-card shadow="never" class="mb12" header="通用出库(不依赖工单:退料 / 样品 / 报废 / 发货)">
|
||||
|
||||
Reference in New Issue
Block a user