feat: 退料闭环定稿(损耗台账/备料清单/退料AGV自动派车/剩余量参考)+ 工位托盘守卫
- MES 新增损耗台账 loss_ledger,差异确认损耗接口 ConfirmReceiveLoss(按工单归集) - 备料清单 preparation:MES 按 日计划×工单×工位×物料 实时计算,WMS 只读展示 PreparationList - 退料闭环:N5 工位托盘守卫(未完成禁止退料)、退料 AGV 自动派车(JBT21 空位判定 + 托盘回收链路)、退料参考剩余量接口(应剩余=实备-已耗-已退-已损) - 新增 AGV 车辆状态表 agv_vehicle_state 及查询 - 整合接驳台/叫料池/库存锁既有闭环,清理 sql 目录注释生成脚本与 catalog,更新文档
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
<el-card>
|
||||
<h3>托盘工作台</h3>
|
||||
<el-alert type="info" :closable="false" show-icon
|
||||
title="库管托盘回收闭环:工位接驳台「有托盘」的行 = 待处理(库管可先确认现场状况,再派 AGV 回收空托盘,或到「退库单」页代工位退料)。派车为业务自动触发(空车前往工位接驳台免弹窗);AGV 到位后进「到位待令」,在 MES AGV 配送页点「确认装车并送货」才拉走——防止库管不知现场状况被误拖。" />
|
||||
title="库管托盘回收闭环:工位接驳台「有托盘」的行 = 待处理(库管可先确认现场状况,再派 AGV 回收空托盘;托盘带余料时可直接在本页「代发起退料」——拍板 R14:库管在托盘工作台看余料并代退料)。派车为业务自动触发(空车前往工位接驳台免弹窗);AGV 到位后进「到位待令」,在 MES AGV 配送页点「确认装车并送货」才拉走——防止库管不知现场状况被误拖。库房接驳台(JBT21)无空位时不允许派车(2026-11-04 拍板:拉回来的托盘没地方放)。" />
|
||||
<el-alert v-if="!jbt21.free" type="error" :closable="false" show-icon class="mt"
|
||||
:title="'库房接驳台(JBT21)暂无空位:' + jbt21.reason + '——「派 AGV 回收」按钮已禁用,请先卸走库房接驳台上的托盘。'" />
|
||||
<el-button class="mt" :loading="loading" @click="load">刷新接驳台台账</el-button>
|
||||
</el-card>
|
||||
<el-card class="mt">
|
||||
@@ -25,20 +27,77 @@
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">{{ row.status === 'DISABLED' ? '已停用' : '启用' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="170" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="260" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.hasPallet && row.dockType === 'line'" size="small" type="warning" :loading="dispatching === row.dockCode"
|
||||
@click="dispatchRecovery(row)">派 AGV 回收</el-button>
|
||||
<template v-if="row.hasPallet && row.dockType === 'line'">
|
||||
<!-- 2026-11-04 定稿 Q5:JBT21 无空位 → 按钮禁用并提示,后端同样拒绝 -->
|
||||
<el-tooltip :disabled="jbt21.free" :content="'库房接驳台无空位:' + jbt21.reason" placement="top">
|
||||
<span style="display:inline-block">
|
||||
<el-button size="small" type="warning" :disabled="!jbt21.free" :loading="dispatching === row.dockCode"
|
||||
@click="dispatchRecovery(row)">派 AGV 回收</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<!-- R14(2026-11-03 拍板):托盘带余料时代发起退料(入口收敛到本页,免跳退库单页) -->
|
||||
<el-button size="small" type="primary" plain @click="openManual(row)">代发起退料</el-button>
|
||||
</template>
|
||||
<span v-else style="color:#999">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<!-- R14:托盘工作台代发起退料(与「退库单」页代工位退料同一接口 /return-order/manual) -->
|
||||
<el-dialog v-model="manual.visible" title="代发起退料(托盘工作台)" width="620px" :close-on-click-modal="false">
|
||||
<el-alert type="info" :closable="false" show-icon class="mb12"
|
||||
title="替工位发起退料(托盘带余料回收)。退料接驳台必选(托盘放置位置);运输方式选 AGV 时,传感器检测到接驳台有托盘且库房接驳台有空位即自动派车拉运。提交后到「退库单」页确认收货。" />
|
||||
<!-- E4(2026-11-04 拍板):自动带出该接驳台托盘余料明细(最近 AGV 送达的物料清单),库管核对后可一键带入 -->
|
||||
<el-alert v-if="manual.residuals.length" type="warning" :closable="false" class="mb12"
|
||||
:title="'该接驳台托盘余料(自动带出,共 ' + manual.residuals.length + ' 项)'"
|
||||
:description="manual.residuals.map(r => r.materialCode + ' ' + (r.materialName || '') + ' × ' + r.qty + (r.unit || '')).join(';') + '。点击「带入首项」可自动填表,也可手工修改。'" />
|
||||
<el-alert v-else-if="manual.residualLoaded" type="info" :closable="false" class="mb12"
|
||||
title="未查到该接驳台的 AGV 送达物料记录,请手工填写退料内容。" />
|
||||
<el-form label-width="110px">
|
||||
<el-form-item label="工位号"><el-input-number v-model="manual.stationNo" :min="1" :max="99" @change="onStationChange" /></el-form-item>
|
||||
<el-form-item label="产品工号"><el-input v-model="manual.orderNo" placeholder="可空(余料关联叫料单的工单自动带出)" /></el-form-item>
|
||||
<el-form-item label="图号(必填)"><el-input v-model="manual.materialCode" /></el-form-item>
|
||||
<el-form-item label="物料名称"><el-input v-model="manual.materialName" /></el-form-item>
|
||||
<!-- G(2026-11-04 定稿):余量参考值=应剩余量−已退余量−已损耗;仅展示不阻断提交 -->
|
||||
<el-form-item v-if="manualRef" label="余量参考值">
|
||||
<el-alert type="warning" :closable="false" style="width:100%"
|
||||
:title="`工单 ${manualRef.orderNo || '-'}:备料 ${manualRef.preparedQty},已消耗 ${manualRef.consumedQty},已退 ${manualRef.returnedQty},已损耗 ${manualRef.lossQty},剩余参考值 ${manualRef.refLeft}${manualRef.unit || ''}`"
|
||||
:description="manualRef.refLeft < 0 ? '参考值为负=已退加损耗已超应剩余量,请现场核实后再退。' : '参考值仅供核对,实际退量以现场为准,不阻断提交。'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数量 / 单位">
|
||||
<el-input-number v-model="manual.qty" :min="1" />
|
||||
<el-input v-model="manual.unit" style="width:80px;margin-left:8px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="退料接驳台">
|
||||
<el-select v-model="manual.returnDock" placeholder="先填工位号带出左/右,必选" style="width:100%">
|
||||
<el-option v-for="d in stationDocks" :key="d.code" :label="d.label" :value="d.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="运输方式">
|
||||
<el-radio-group v-model="manual.transportMode">
|
||||
<el-radio value="agv">AGV 拉运(传感器自动派车)</el-radio>
|
||||
<el-radio value="manual">人工搬运(不派 AGV)</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="退库原因(必填)"><el-input v-model="manual.reason" /></el-form-item>
|
||||
<el-form-item label="损耗原因(必填)">
|
||||
<el-input v-model="manual.lossReason" type="textarea" :rows="2" placeholder="必填:说明退料损耗情况(随退库单留存可查)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button v-if="manual.residuals.length" @click="applyFirstResidual">带入首项</el-button>
|
||||
<el-button @click="manual.visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="manual.submitting" @click="submitManual">提交退料</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
@@ -48,6 +107,17 @@ defineOptions({ name: 'PalletWorkbench' })
|
||||
const rows = ref([])
|
||||
const loading = ref(false)
|
||||
const dispatching = ref('')
|
||||
// 2026-11-04 定稿 Q5:库房接驳台 JBT21 空位(无空位 → 派 AGV 回收按钮禁用并提示)
|
||||
const jbt21 = reactive({ free: true, reason: '' })
|
||||
async function loadJbt21() {
|
||||
try {
|
||||
const d = await request.get('/pallet/jbt21-free')
|
||||
jbt21.free = d?.free !== false
|
||||
jbt21.reason = d?.reason || ''
|
||||
} catch {
|
||||
jbt21.free = true // MES 不可达时不误拦人工派车(后端 pallet-dispatch 仍有 guard)
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
@@ -58,6 +128,15 @@ async function load() {
|
||||
}
|
||||
|
||||
async function dispatchRecovery(row) {
|
||||
// 提交前二次确认空位(防止页面停留期间 JBT21 被占用)
|
||||
try {
|
||||
const d = await request.get('/pallet/jbt21-free')
|
||||
if (d?.free === false) {
|
||||
ElMessage.error('库房接驳台(JBT21)暂无空位:' + (d.reason || '') + ',暂不能派车')
|
||||
jbt21.free = false; jbt21.reason = d?.reason || ''
|
||||
return
|
||||
}
|
||||
} catch { /* MES 不可达交由后端 pallet-dispatch guard 拦截 */ }
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认派 AGV 前往 ${row.name} 回收托盘?\n\n流程:AGV 空车前往(免确认)→ 到位后停住(到位待令)→ 请在 MES「AGV 配送」页点「确认装车并送货」→ 送回库房接驳台 → 确认卸货。`,
|
||||
@@ -72,9 +151,120 @@ async function dispatchRecovery(row) {
|
||||
dispatching.value = ''
|
||||
}
|
||||
|
||||
/* ===================== R14:本页代发起退料(拍板 2026-11-03;2026-11-04 加损耗原因/运输方式/参考值) ===================== */
|
||||
// G5 口径:代退料表单无理论量字段 → 损耗原因一律必填。
|
||||
// 2026-11-04 定稿:运输方式必选(AGV=传感器自动派车;人工=无 AGV);余量参考值仅展示不阻断(G2)。
|
||||
const manual = reactive({ visible: false, submitting: false, stationNo: 1, orderNo: '', materialCode: '', materialName: '', unit: '个', qty: 1, returnDock: '', reason: '', lossReason: '', transportMode: 'agv', residuals: [], residualLoaded: false, residualDock: '' })
|
||||
const stationDocks = ref([])
|
||||
const refRows = ref([])
|
||||
const manualRef = computed(() => refRows.value.find(r => r.materialCode === manual.materialCode) || null)
|
||||
|
||||
async function loadReference() {
|
||||
if (!manual.stationNo) { refRows.value = []; return }
|
||||
try {
|
||||
const d = await request.get('/return-order/reference', { params: { stationNo: manual.stationNo } })
|
||||
refRows.value = Array.isArray(d) ? d : d?.rows || []
|
||||
} catch { refRows.value = [] }
|
||||
}
|
||||
|
||||
function openManual(row) {
|
||||
manual.visible = true
|
||||
manual.stationNo = Number(row.stationNo) || 1
|
||||
manual.orderNo = ''; manual.materialCode = ''; manual.materialName = ''
|
||||
manual.unit = '个'; manual.qty = 1; manual.returnDock = ''; manual.reason = ''; manual.lossReason = ''
|
||||
manual.transportMode = 'agv'
|
||||
manual.residuals = []; manual.residualLoaded = false
|
||||
loadStationDocks()
|
||||
loadReference()
|
||||
// E4(2026-11-04 拍板):自动带出该接驳台托盘余料明细(只读转发 MES)
|
||||
loadResidual(row.dockCode)
|
||||
}
|
||||
|
||||
function onStationChange() { loadStationDocks(); loadReference() }
|
||||
|
||||
async function loadResidual(dockCode) {
|
||||
if (!dockCode) return
|
||||
manual.residualDock = dockCode
|
||||
try {
|
||||
const d = await request.get('/pallet/residual', { params: { dock: dockCode } })
|
||||
manual.residuals = Array.isArray(d) ? d : (d?.list || [])
|
||||
} catch {
|
||||
manual.residuals = []
|
||||
} finally {
|
||||
manual.residualLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
// 一键带入首项余料到表单(可再手工改)
|
||||
function applyFirstResidual() {
|
||||
const r = manual.residuals[0]
|
||||
if (!r) return
|
||||
manual.materialCode = r.materialCode || ''
|
||||
manual.materialName = r.materialName || ''
|
||||
manual.unit = r.unit || '个'
|
||||
manual.qty = Math.max(1, Math.round(Number(r.qty) || 1))
|
||||
if (r.requestNo) {
|
||||
// 余料关联叫料单号,产品工号留空(叫料单不绑工单)
|
||||
manual.orderNo = manual.orderNo || ''
|
||||
}
|
||||
}
|
||||
|
||||
async function loadStationDocks() {
|
||||
if (!manual.stationNo) return
|
||||
try {
|
||||
const d = await request.get('/pallet/station-docks', { params: { stationNo: manual.stationNo } })
|
||||
stationDocks.value = d?.docks || []
|
||||
manual.returnDock = '' // 不隐式默认选第一项,由库管显式选择左/右(与 G3 同口径)
|
||||
} catch { stationDocks.value = [] }
|
||||
}
|
||||
|
||||
// 拍板2(2026-11-04):PLC 离线退料拦截降级为提示+警戒,人工强行确认走此风险提示(code=2409)
|
||||
const RETURN_FORCE_RISK = 'PLC 离线,无法确认工件已完工。\n\n风险提示:若物料仍在工人手中或正在装机,强行退料可能导致账实不符。\n\n是否确认强行退料?'
|
||||
async function doSubmitManual(forceConfirm) {
|
||||
await request.post('/return-order/manual', { ...manual, visible: undefined, submitting: undefined, forceConfirm })
|
||||
}
|
||||
async function submitManual() {
|
||||
if (!manual.materialCode || manual.qty <= 0 || !manual.returnDock || !manual.reason) {
|
||||
ElMessage.warning('图号、数量、退料接驳台、原因均必填')
|
||||
return
|
||||
}
|
||||
if (!String(manual.lossReason || '').trim()) {
|
||||
ElMessage.warning('损耗原因必填(代退料无理论量,一律必填)')
|
||||
return
|
||||
}
|
||||
if (manual.transportMode !== 'agv' && manual.transportMode !== 'manual') {
|
||||
ElMessage.warning('运输方式必选(AGV / 人工)')
|
||||
return
|
||||
}
|
||||
manual.submitting = true
|
||||
try {
|
||||
await doSubmitManual(false)
|
||||
ElMessage.success('代退料已提交,待确认收货')
|
||||
manual.visible = false
|
||||
load()
|
||||
} catch (e) {
|
||||
// 拍板2(2026-11-04):PLC 离线(业务码 2409)→ 弹风险提示,人工确认后强行提交
|
||||
if (e?.code === 2409) {
|
||||
try {
|
||||
await ElMessageBox.confirm(RETURN_FORCE_RISK, 'PLC 离线:强行退料确认',
|
||||
{ type: 'warning', confirmButtonText: '强行退料', cancelButtonText: '取消' })
|
||||
} catch { return }
|
||||
try {
|
||||
await doSubmitManual(true)
|
||||
ElMessage.success('已强行提交,待确认收货')
|
||||
manual.visible = false
|
||||
load()
|
||||
} catch {}
|
||||
return
|
||||
}
|
||||
} finally { manual.submitting = false }
|
||||
}
|
||||
|
||||
load()
|
||||
loadJbt21()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mt { margin-top: 12px; }
|
||||
.mb12 { margin-bottom: 12px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user