feat: AGV点位锁与缓存迁移 + 工位终端去离线队列 + WMS出入库增强
【MES】 - AGV点位/线路点位/AGV任务/工单 ent schema 重构(全量重生成 ent 代码) - 新增派车锁 agv_point_lock.go:目标点位占用即拒车,JBT21 库房接驳台卸货后保持锁定待库管手动解锁 - 新增进程内 TTL 缓存 cache.go,由 Redis 看板缓存迁移至内存(singleflight 防击穿,去除外部依赖) - AGV 三段链安全机制、车辆状态/接驳台左右互换、补料损耗闭环完善 - 来料检/工序卡/工单/质检/日排产/AGV 前端与帮助文档更新 - 新增 migrations/、sql/ 目录 【WMS】 - 出库、Excel 导出、物料、路由处理增强 - 配置与 DB 初始化调整;基础数据/成品入库/入库前端调整 【工位终端】 - 移除离线同步队列(syncer 包、sync.go、SyncQueueDialog.vue),改为实时直连上报 MES(断网即失败报错),以本人身份操作 - 本地 SQLite 仅保留操作日志 + 内置账号 + 登录态;保留空闲自动登出 【文档】 - 删除 AGV海康litev1.5.md;案例.md 更新
This commit is contained in:
@@ -95,7 +95,7 @@ const statusOptions = [
|
||||
const statusText = (s) => (statusOptions.find((x) => x.v === s) || {}).l || '—'
|
||||
const statusTag = (s) =>
|
||||
s === '9' ? 'success' : s === 'ARRIVED' ? 'danger' : s === 'FAILED' || s === '5' ? 'info' : s === '2' ? 'warning' : s === '1' ? 'primary' : ''
|
||||
const kindText = (k) => ({ GO_LOAD: '空车去程', TRANSPORT: '重载运输', EMPTY_RETURN: '空车回充', FREE: '自由调度' }[k] || '—')
|
||||
const kindText = (k) => ({ GO_LOAD: '空车去程', TRANSPORT: '重载运输', EMPTY_RETURN: '空车回充', FREE: '自由调度', MANUAL: '手动节点' }[k] || '—')
|
||||
|
||||
/* ===================== 到位待令确认(2026-11-03 三层安全机制) ===================== */
|
||||
// 到位即停:GO_LOAD 段→「确认装车并送货」;TRANSPORT 段→「卸货完成并放行」(放行后空车自动回充);
|
||||
@@ -114,10 +114,10 @@ async function confirmLoadGo(row) {
|
||||
inputValue: def, inputPlaceholder: '如 DOCK03 或 AGV-WAIT01', type: 'warning',
|
||||
inputValidator: (v) => !!v || '目标必填'
|
||||
})
|
||||
await confirmAgv(row, 'load_go', (value || '').trim())
|
||||
await confirmAgv(row, 'load_go', (value || '').trim(), await confirmForcePickTargets([(value || '').trim()]))
|
||||
} catch { /* 取消 */ }
|
||||
}
|
||||
async function confirmAgv(row, action, nextDock) {
|
||||
async function confirmAgv(row, action, nextDock, confirmForcePick) {
|
||||
const tips = {
|
||||
load_go: '确认已装车并送货?AGV 将背着托盘前往目标接驳台。',
|
||||
unload_release: '确认卸货完成并放行?托盘将落位当前接驳台,AGV 空车自动回充电位。',
|
||||
@@ -133,7 +133,7 @@ async function confirmAgv(row, action, nextDock) {
|
||||
} catch { return }
|
||||
confirmBusy.value = true
|
||||
try {
|
||||
await request.post('/agv/confirm', { taskNo: row.taskNo, action, nextDock: nextDock || '' })
|
||||
await request.post('/agv/confirm', { taskNo: row.taskNo, action, nextDock: nextDock || '', confirmForcePick: confirmForcePick === null ? '' : (confirmForcePick || '') })
|
||||
ElMessage.success('已确认')
|
||||
loadTasks()
|
||||
} catch (e) {
|
||||
@@ -142,12 +142,14 @@ async function confirmAgv(row, action, nextDock) {
|
||||
}
|
||||
async function freeDispatch(target) {
|
||||
if (!target) { ElMessage.warning('请选择目标点位'); return }
|
||||
const forceOk = await confirmForcePickTargets([target])
|
||||
if (forceOk === null) return
|
||||
try {
|
||||
await ElMessageBox.confirm('请确保路径畅通无杂物,确认后 AGV 出发前往 ' + (pointLabel(target) || target) + '。', '开始 AGV 搬运', { type: 'warning' })
|
||||
} catch { return }
|
||||
confirmBusy.value = true
|
||||
try {
|
||||
await request.post('/agv/free-dispatch', { target, source: freeSource.value || '' })
|
||||
await request.post('/agv/free-dispatch', { target, source: freeSource.value || '', confirmForcePick: forceOk })
|
||||
ElMessage.success('已派车')
|
||||
loadTasks()
|
||||
} catch (e) {
|
||||
@@ -237,9 +239,12 @@ async function submitAgv() {
|
||||
} catch { return }
|
||||
}
|
||||
const lines = groupPreview.value.map((g) => `· ${g.dock}:${g.n} 行`).join('\n')
|
||||
// 强提风险点位人工二次确认(2026-11-06 拍板)
|
||||
const forceOk = await confirmForcePickTargets(rows.map((r) => r.targetDock))
|
||||
if (forceOk === null) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认对 ${rows.length} 行叫料单手动派车?\n\n按目标点位分组:\n${lines}\n\n源点:${pointLabel(sourceDock.value)}\n操作人:${operator.value}\n\n注:仓库完成备料时系统已自动派车,本操作用于补派或对失败任务重试。`,
|
||||
`确认对 ${rows.length} 行手动派车?\n\n按目标点位分组:\n${lines}\n\n源点:${pointLabel(sourceDock.value)}\n操作人:${operator.value}\n\n注:第一段由 RCS 自动派车;AGV 到位后在下方「任务进行中」面板点「下一个节点」(全程同一台车)逐段推进,全部送完点「结束任务」。`,
|
||||
'手动派车确认',
|
||||
{ type: 'warning', confirmButtonText: '确认派车', cancelButtonText: '取消' }
|
||||
)
|
||||
@@ -249,11 +254,11 @@ async function submitAgv() {
|
||||
{ rows: rows.map((r) => ({
|
||||
requestNo: r.requestNo, materialCode: r.materialCode, materialName: r.materialName,
|
||||
unit: r.unit, qty: Number(r.reqQty || 0), targetDock: r.targetDock
|
||||
})), sourceDock: sourceDock.value },
|
||||
})), sourceDock: sourceDock.value, confirmForcePick: forceOk },
|
||||
withOperator())
|
||||
ElMessage.success(`已创建 ${res?.created || 0} 个 AGV 任务`)
|
||||
ElMessage.success(`已创建 ${res?.created || 0} 个手动多段任务,请在下方「任务进行中」面板逐节点推进`)
|
||||
selected.value = []
|
||||
loadMrs(); loadTasks(); loadDocks()
|
||||
loadMrs(); loadTasks(); loadDocks(); loadChains()
|
||||
} catch { /* 拦截器已提示 */ }
|
||||
}
|
||||
|
||||
@@ -324,7 +329,7 @@ async function loadMode() {
|
||||
} catch { /* 忽略 */ }
|
||||
}
|
||||
|
||||
onMounted(() => { loadDocks(); loadTasks(); loadMode(); loadAgvPoints(); loadVehicles(); loadVehicleStates() })
|
||||
onMounted(() => { loadDocks(); loadTasks(); loadMode(); loadAgvPoints(); loadVehicles(); loadVehicleStates(); loadChains() })
|
||||
|
||||
// 车辆状态只读(海康 3.1.7,2026-11-03 拍板:纯只读展示,不干预调度)
|
||||
const vehicles = ref([])
|
||||
@@ -380,14 +385,136 @@ async function addManualState(hasPallet) {
|
||||
}
|
||||
const stateSourceCn = (s) => ({ AUTO_LOAD: '取货确认', AUTO_UNLOAD: '卸货确认', MANUAL: '人工维护' }[s] || s)
|
||||
|
||||
/* ===================== 点位锁定管理(派车锁 2026-11-06 拍板) ===================== */
|
||||
// system 锁=派车自动置/任务终态自动释放(JBT21 例外手动解锁);manual 锁=人工锁定仅人工解锁;
|
||||
// 强提标记=PLC 离线强提叫料点位,派车需人工二次确认,确认现场安全后可在此清除。
|
||||
async function lockPoint(p, locked) {
|
||||
let reason = ''
|
||||
if (locked) {
|
||||
try {
|
||||
const r = await ElMessageBox.prompt('锁定后该点位拒绝一切派车(含自动派车),直至人工解锁。请填写锁定原因:', '人工锁定点位 ' + p.positionCode, {
|
||||
type: 'warning', confirmButtonText: '确认锁定', cancelButtonText: '取消',
|
||||
inputPlaceholder: '锁定原因(必填)', inputValidator: (v) => !!v || '原因必填'
|
||||
})
|
||||
reason = r.value || ''
|
||||
} catch { return }
|
||||
} else {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认解锁点位 ${p.positionCode}?解锁后恢复接受派车。`, '人工解锁点位', { type: 'warning' })
|
||||
} catch { return }
|
||||
}
|
||||
try {
|
||||
await request.post(`/agv/points/${p.id}/lock`, locked ? { locked: true, reason } : { unlock: true }, withOperator())
|
||||
ElMessage.success(locked ? '已锁定' : '已解锁')
|
||||
loadAgvPoints()
|
||||
} catch { /* 拦截器已提示 */ }
|
||||
}
|
||||
async function clearPointForcePick(p) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认清除 ${p.positionCode} 的强提风险标记?请确认现场安全。`, '清除强提标记', { type: 'warning' })
|
||||
} catch { return }
|
||||
try {
|
||||
await request.post(`/agv/points/${p.id}/lock`, { clearForcePick: true }, withOperator())
|
||||
ElMessage.success('已清除强提标记')
|
||||
loadAgvPoints()
|
||||
} catch { /* 拦截器已提示 */ }
|
||||
}
|
||||
|
||||
// 强提风险点位人工二次确认:目标带标记时先弹确认,确认后请求带 confirmForcePick="1" 下发
|
||||
async function confirmForcePickTargets(codes) {
|
||||
const hits = [...new Set(codes)].filter((c) => pointMap.value[c] && pointMap.value[c].forcePick)
|
||||
if (!hits.length) return ''
|
||||
const names = hits.map((c) => pointLabel(c)).join('、')
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`目标点位 ${names} 带强提风险标记(PLC 离线期间强行提交过叫料)。请确认现场安全(无人员/障碍/托盘异常)后继续。`,
|
||||
'强提风险二次确认', { type: 'warning', confirmButtonText: '确认现场安全,继续', cancelButtonText: '取消' }
|
||||
)
|
||||
return '1'
|
||||
} catch { return null }
|
||||
}
|
||||
|
||||
/* ===================== 手动多段链(任务进行中面板,2026-11-06 拍板) ===================== */
|
||||
// 流程:第一段 RCS 自由派车 → 到位点「刷新状态」拿到分车结果 → 用户逐节点「下一个节点」
|
||||
//(全程锁同一台车,段数不确定,目标由用户自选)→ 全部送完点「结束任务」(校验车无托盘)。
|
||||
const chains = ref([])
|
||||
const loadingChains = ref(false)
|
||||
const chainBusy = ref(false)
|
||||
async function loadChains() {
|
||||
loadingChains.value = true
|
||||
try {
|
||||
const d = await request.get('/agv/chain/list')
|
||||
chains.value = d?.list || []
|
||||
} catch { chains.value = [] }
|
||||
loadingChains.value = false
|
||||
}
|
||||
// 先轮询 RCS 回写 agvCode/到位状态,再取链列表(到位/分车都靠这次刷新落库)
|
||||
async function refreshChains() {
|
||||
chainBusy.value = true
|
||||
try { await request.post('/agv/refresh', {}, withOperator()) } catch { /* 忽略 */ }
|
||||
await loadChains(); loadTasks(); loadDocks()
|
||||
chainBusy.value = false
|
||||
}
|
||||
// 链内当前节点=最新非终态段
|
||||
function chainCurrent(c) {
|
||||
const segs = c.segments || []
|
||||
for (let i = segs.length - 1; i >= 0; i--) {
|
||||
if (segs[i].status !== '9' && segs[i].status !== '5') return segs[i]
|
||||
}
|
||||
return null
|
||||
}
|
||||
const chainSegText = (seg) => `${pointLabel(seg.sourceDock)} → ${pointLabel(seg.targetDock)}`
|
||||
// 下一节点弹窗(用户自选下一段去哪;起点可空=沿用上一节点落点)
|
||||
const nextNode = reactive({ visible: false, chainNo: '', source: '', target: '' })
|
||||
function openNextNode(c) {
|
||||
nextNode.chainNo = c.chainNo
|
||||
nextNode.source = ''
|
||||
nextNode.target = ''
|
||||
nextNode.visible = true
|
||||
}
|
||||
async function submitNextNode() {
|
||||
if (!nextNode.target) return ElMessage.warning('请选择下一节点目标点位')
|
||||
const forceOk = await confirmForcePickTargets([nextNode.target])
|
||||
if (forceOk === null) return
|
||||
chainBusy.value = true
|
||||
try {
|
||||
await request.post('/agv/chain/next',
|
||||
{ chainNo: nextNode.chainNo, source: nextNode.source || '', target: nextNode.target, confirmForcePick: forceOk },
|
||||
withOperator())
|
||||
ElMessage.success('下一节点已下发(同一台 AGV 继续执行)')
|
||||
nextNode.visible = false
|
||||
await loadChains(); loadTasks(); loadDocks()
|
||||
} catch { /* 拦截器已提示 */ }
|
||||
chainBusy.value = false
|
||||
}
|
||||
// 结束任务弹窗:勾选「人工确认无托盘」可在 RCS 状态查询失败时强制结束(后端留痕)
|
||||
const endDialog = reactive({ visible: false, chainNo: '', agvCode: '', force: false })
|
||||
function openEndChain(c) {
|
||||
endDialog.chainNo = c.chainNo
|
||||
endDialog.agvCode = c.agvCode || ''
|
||||
endDialog.force = false
|
||||
endDialog.visible = true
|
||||
}
|
||||
async function submitEndChain() {
|
||||
chainBusy.value = true
|
||||
try {
|
||||
await request.post('/agv/chain/end', { chainNo: endDialog.chainNo, force: endDialog.force }, withOperator())
|
||||
ElMessage.success('任务已结束,AGV 空车自动回充')
|
||||
endDialog.visible = false
|
||||
await loadChains(); loadTasks(); loadDocks()
|
||||
} catch { /* 拦截器已提示 */ }
|
||||
chainBusy.value = false
|
||||
}
|
||||
|
||||
// 切 tab 重新加载对应数据(2026-10-19:lazy 页签切回不 reload,状态/叫料单会停留在旧数据)
|
||||
function onTabChange(name) {
|
||||
if (name === 'docks') loadDocks()
|
||||
else if (name === 'tasks') loadTasks()
|
||||
else if (name === 'dispatch') loadMrs()
|
||||
else if (name === 'dispatch') { loadMrs(); loadChains() }
|
||||
else if (name === 'points') loadAgvPoints()
|
||||
else if (name === 'vehicles') { loadVehicles(); loadVehicleStates() }
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -521,7 +648,6 @@ function onTabChange(name) {
|
||||
<template #default="{ row }">{{ row.createdAt ? fmtTime(row.createdAt) : '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="operator" label="下发人" width="100" />
|
||||
<el-table-column prop="hikTaskCode" label="RCS任务码" width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="remark" label="备注" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
@@ -580,7 +706,7 @@ function onTabChange(name) {
|
||||
<el-option label="已取消" value="CANCELLED" />
|
||||
</el-select>
|
||||
<el-button @click="loadMrs()">查询</el-button>
|
||||
<span class="tip">勾选叫料单行 → 行内可改目标点位 → 派车</span>
|
||||
<span class="tip">勾选叫料单行 → 行内可改目标点位 → 派车(人工多段任务:到位后在本页「任务进行中」逐节点推进)</span>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<el-select v-model="sourceDock" style="width: 150px" placeholder="请选择源点位">
|
||||
@@ -613,6 +739,69 @@ function onTabChange(name) {
|
||||
<el-empty description="暂无叫料单" />
|
||||
</template>
|
||||
</el-table>
|
||||
|
||||
<!-- 任务进行中(手动多段链):第一段 RCS 自由派车;之后每节点锁同一台车;
|
||||
用户点「下一个节点」走下一段(段数不确定、目标自选),点「结束任务」才算完 -->
|
||||
<div class="toolbar" style="margin-top:20px">
|
||||
<span class="chain-title">任务进行中(手动多段任务)</span>
|
||||
<el-button size="small" type="primary" :loading="chainBusy" @click="refreshChains">刷新状态</el-button>
|
||||
<span class="tip">AGV 到位后点「刷新状态」拿到分车结果 → 「下一个节点」选目标继续(同一台车)→ 全部送完点「结束任务」</span>
|
||||
</div>
|
||||
<el-empty v-if="!chains.length && !loadingChains" description="暂无手动多段任务(上方派车后在此逐节点推进)" :image-size="60" />
|
||||
<div v-for="c in chains" :key="c.chainNo" class="chain-card">
|
||||
<div class="chain-head">
|
||||
<span class="chain-no">{{ c.chainNo }}</span>
|
||||
<el-tag :type="c.active ? 'warning' : 'success'" size="small">{{ c.active ? '进行中' : '已结束' }}</el-tag>
|
||||
<span class="chain-agv">当前 AGV:<b :class="{ 'agv-unknown': !c.agvCode }">{{ c.agvCode || '待RCS分车' }}</b></span>
|
||||
</div>
|
||||
<div class="chain-segs">
|
||||
<div v-for="seg in c.segments" :key="seg.taskNo" class="chain-seg">
|
||||
<el-tag size="small" :type="statusTag(seg.status)">{{ statusText(seg.status) }}</el-tag>
|
||||
{{ chainSegText(seg) }}
|
||||
<span class="tip" v-if="seg.agvCode">(执行车 {{ seg.agvCode }})</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="c.active" class="chain-ops">
|
||||
<span class="tip" v-if="!c.agvCode">尚未识别车辆:AGV 到位后点「刷新状态」再操作</span>
|
||||
<template v-else>
|
||||
<span class="tip">当前节点:{{ chainCurrent(c) ? chainSegText(chainCurrent(c)) + '(' + statusText(chainCurrent(c).status) + ')' : '—' }}</span>
|
||||
<el-button size="small" type="primary" :disabled="chainBusy" @click="openNextNode(c)">下一个节点</el-button>
|
||||
<el-button size="small" type="danger" :disabled="chainBusy" @click="openEndChain(c)">结束任务</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 下一节点弹窗:用户自选下一段去哪(起点可空=沿用上一节点落点) -->
|
||||
<el-dialog v-model="nextNode.visible" title="下发下一节点(同一台 AGV)" width="460px">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="起点">
|
||||
<el-select v-model="nextNode.source" style="width:100%" placeholder="默认=上一节点落点" clearable>
|
||||
<el-option v-for="d in pointOptions" :key="d" :label="pointLabel(d)" :value="d" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="目标点位" required>
|
||||
<el-select v-model="nextNode.target" style="width:100%" placeholder="选择下一节点去哪">
|
||||
<el-option v-for="d in pointOptions" :key="d" :label="pointLabel(d)" :value="d" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="nextNode.visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="chainBusy" @click="submitNextNode">确认下发</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 结束任务弹窗:提示确保车上无托盘;RCS 查询失败时可勾选「人工确认无托盘」强制结束(留痕) -->
|
||||
<el-dialog v-model="endDialog.visible" title="结束任务" width="460px">
|
||||
<el-alert type="warning" :closable="false" show-icon
|
||||
:title="'请确保 AGV 上没有托盘!' + (endDialog.agvCode ? '(当前 AGV:' + endDialog.agvCode + ')' : '(当前车辆待识别)')"
|
||||
description="结束后该车将空车自动回充电位。" />
|
||||
<el-checkbox v-model="endDialog.force" style="margin-top:12px">我确认 AGV 上无托盘(RCS 查询失败时使用)</el-checkbox>
|
||||
<template #footer>
|
||||
<el-button @click="endDialog.visible = false">取消</el-button>
|
||||
<el-button type="danger" :loading="chainBusy" @click="submitEndChain">确认结束</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- ④ AGV 点位管理(独立点位表:硬件映射编码/接驳台绑定不可改,仅显示名与启用可编辑) -->
|
||||
@@ -640,14 +829,34 @@ function onTabChange(name) {
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="派车锁" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.locked" :type="row.lockedBy === 'manual' ? 'danger' : 'warning'">
|
||||
{{ row.lockedBy === 'manual' ? '人工锁定' : '任务锁定' }}
|
||||
</el-tag>
|
||||
<el-tag v-else type="success">空闲</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="锁定原因" width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.lockedReason || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="强提标记" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.forcePick" type="danger">强提</el-tag>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="启用" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-switch :model-value="row.enabled" :loading="savingPoint === row.id" @change="(v) => { row.enabled = v; savePoint(row) }" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90" align="center">
|
||||
<el-table-column label="操作" width="230" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button size="small" type="primary" :loading="savingPoint === row.id" @click="savePoint(row)">保存</el-button>
|
||||
<el-button v-if="!row.locked" size="small" type="warning" @click="lockPoint(row, true)">锁定</el-button>
|
||||
<el-button v-else size="small" type="success" @click="lockPoint(row, false)">解锁</el-button>
|
||||
<el-button v-if="row.forcePick" size="small" type="danger" @click="clearPointForcePick(row)">清强提</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -681,4 +890,14 @@ function onTabChange(name) {
|
||||
.veh-meta { font-size: 12px; color: #909399; margin-top: 6px; }
|
||||
.mono { font-family: Consolas, Monaco, monospace; }
|
||||
.disabled-text { color: #909399; }
|
||||
.chain-title { font-weight: 700; font-size: 14px; }
|
||||
.chain-card { border: 1px solid #e4e7ed; border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
|
||||
.chain-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
|
||||
.chain-no { font-family: Consolas, Monaco, monospace; font-weight: 600; }
|
||||
.chain-agv { margin-left: auto; font-size: 13px; }
|
||||
.chain-agv b { color: #409eff; }
|
||||
.chain-agv b.agv-unknown { color: #909399; font-weight: 400; }
|
||||
.chain-segs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
|
||||
.chain-seg { font-size: 13px; display: flex; align-items: center; gap: 6px; }
|
||||
.chain-ops { display: flex; align-items: center; gap: 8px; border-top: 1px dashed #ebeef5; padding-top: 8px; }
|
||||
</style>
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品型号"><el-input :model-value="dialog.productType" disabled placeholder="随产品工号自动带出" /></el-form-item>
|
||||
<el-form-item label="产品序号"><el-input :model-value="dialog.productCode" disabled placeholder="随产品工号自动带出" /></el-form-item>
|
||||
<el-form-item label="图号"><el-input :model-value="dialog.productCode" disabled placeholder="随产品工号自动带出" /></el-form-item>
|
||||
<el-form-item label="产品名称"><el-input :model-value="dialog.productName" disabled placeholder="随产品工号自动带出" /></el-form-item>
|
||||
<el-form-item label="工单数量"><el-input :model-value="dialog.woQty" disabled placeholder="随产品工号自动带出" /></el-form-item>
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
<template #header>待完工检成品(完工确认后未录完工检,只读)</template>
|
||||
<el-table :data="finalPending.list" border stripe size="small" v-loading="finalPending.loading">
|
||||
<el-table-column prop="orderNo" label="产品工号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品序号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="图号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="sn" label="成品序列号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="doneAt" label="完工时间" width="170" />
|
||||
<el-table-column label="操作" width="90" align="center">
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<el-table-column prop="workOrderNo" label="产品工号" min-width="190" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品型号" width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="productSerial" label="成品序列号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="状态" width="100" align="center">
|
||||
<template #default="{ row }">{{ row.status || '-' }}</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
title="产品工艺 = 某产品的加工工序顺序(第1道、第2道…)。新建工单选产品型号后,系统按这里的工序顺序,自动为每道工序推荐一个工位:后道工位号必须大于前道(工件在产线上单向流转、不回头),每道可改,改后后续候选自动更新。本页同时可打印路线卡给车间使用。" />
|
||||
<el-form inline>
|
||||
<el-form-item label="产品">
|
||||
<el-input v-model="query.productCode" placeholder="产品序号/名称 模糊" clearable style="width:170px" @keyup.enter="load" />
|
||||
<el-input v-model="query.productCode" placeholder="图号/名称 模糊" clearable style="width:170px" @keyup.enter="load" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工艺名称">
|
||||
<el-input v-model="query.name" placeholder="产品工艺名称 模糊" clearable style="width:170px" @keyup.enter="load" />
|
||||
@@ -36,7 +36,7 @@
|
||||
<el-table :data="rows" border stripe size="small" v-loading="loading">
|
||||
<el-table-column prop="id" label="ID" width="55" />
|
||||
<el-table-column prop="name" label="产品工艺名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品序号" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="图号" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column label="工艺顺序" min-width="260">
|
||||
<template #default="{ row }">
|
||||
@@ -105,7 +105,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="工艺名称" required>
|
||||
<el-input v-model="dlg.name" readonly placeholder="选择产品后自动生成(格式:产品序号 产品名称 工艺)" />
|
||||
<el-input v-model="dlg.name" readonly placeholder="选择产品后自动生成(格式:图号 产品名称 工艺)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工艺顺序" required>
|
||||
<div style="width:100%">
|
||||
@@ -228,7 +228,7 @@ async function loadOptions() {
|
||||
|
||||
defineExpose({ reload: () => { load(); loadOptions() } })
|
||||
|
||||
const dlg = reactive({ show: false, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null, createdRefs: 0 })
|
||||
const dlg = reactive({ show: false, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null })
|
||||
|
||||
function onProductChange(code) {
|
||||
const p = products.value.find((x) => x.code === code)
|
||||
@@ -237,16 +237,16 @@ function onProductChange(code) {
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
Object.assign(dlg, { show: true, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null, createdRefs: 0 })
|
||||
Object.assign(dlg, { show: true, id: 0, productCode: '', productName: '', name: '', remark: '', flows: [], pickFlow: null })
|
||||
}
|
||||
|
||||
function openEdit(row) {
|
||||
// 规则1(2026-10-20):仅运行中工单(执行中/已暂停)引用才锁死;未开工引用允许编辑、保存前警告
|
||||
// 规则1(2026-10-20 拍板,2026-11-05 修订):有未完成工单(未开工/执行中/已暂停)引用即锁死编辑;
|
||||
// runningByWorkOrders 后端已按未完成口径统计,前端禁入与后端守卫一致
|
||||
if (row.runningByWorkOrders > 0) return
|
||||
Object.assign(dlg, {
|
||||
show: true, id: row.id, productCode: row.productCode, productName: row.productName,
|
||||
name: row.name, remark: row.remark || '',
|
||||
createdRefs: row.createdByWorkOrders || 0,
|
||||
flows: (row.flows || []).map((it) => it.flowId), pickFlow: null
|
||||
})
|
||||
}
|
||||
@@ -273,15 +273,6 @@ async function save() {
|
||||
if (!dlg.name) return ElMessage.warning('请填写产品工艺名称')
|
||||
if (!dlg.productCode) return ElMessage.warning('请选择产品')
|
||||
if (!dlg.flows.length) return ElMessage.warning('请先勾选加入工艺,再用上下移按钮排好执行顺序')
|
||||
// 规则1:被未开工工单引用 → 保存前警告确认(组合是快照,改模板不影响已有工单,但需操作者知情)
|
||||
if (dlg.id > 0 && dlg.createdRefs > 0) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`该工艺正被 ${dlg.createdRefs} 张未开工工单引用。修改模板不影响这些工单已保存的工艺组合,但新开工单将按新模板带出。确认修改?`,
|
||||
'修改确认', { type: 'warning' }
|
||||
)
|
||||
} catch { return }
|
||||
}
|
||||
await request.post('/product-processes', {
|
||||
id: dlg.id, productCode: dlg.productCode, productName: dlg.productName,
|
||||
name: dlg.name, remark: dlg.remark,
|
||||
|
||||
@@ -259,34 +259,50 @@ async function downloadTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
// Excel 导入(2026-11-02 条目16:与 WMS 物料档案导入同风格):
|
||||
// 选文件 → 二次确认(文件名+影响说明)→ 上传 → 结构化结果(成功条数 / 失败行明细弹窗)→ 刷新列表
|
||||
// Excel 导入(三阶段统一标准,2026-11-05 拍板:预检→确认→正式写入,整批事务全成功或全失败):
|
||||
// 选文件 → 预检(只读校验,展示 总行数/将成功/失败/逐行原因)→ 确认 → 正式写入(任一行失败整批不写)
|
||||
const importInput = ref(null)
|
||||
const importing = ref(false)
|
||||
function triggerImport() { importInput.value && importInput.value.click() }
|
||||
function importErrLines(errs) {
|
||||
return errs.slice(0, 10).map((x) => `第${x.row}行 ${x.materialCode || ''}:${x.message}`).join(';')
|
||||
}
|
||||
async function onImportFile(e) {
|
||||
const file = e.target.files && e.target.files[0]
|
||||
if (e.target.value) e.target.value = '' // 允许重复选同一文件
|
||||
if (!file) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认导入物料文件「${file.name}」?导入将批量写入物料档案,失败行明细将在导入后逐行列出。`,
|
||||
'批量导入确认', { type: 'warning', confirmButtonText: '确认导入', cancelButtonText: '取消' })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
importing.value = true
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
try {
|
||||
// 阶段1 预检(只读,不写任何数据)
|
||||
const p = (await request.post('/product-types/import/preview', fd, { headers: { 'Content-Type': 'multipart/form-data' } })) || {}
|
||||
const perrs = p.errors || []
|
||||
if (perrs.length) {
|
||||
const extra = perrs.length > 10 ? ` …(共 ${perrs.length} 条失败明细,请修正后重新预检)` : '(请修正后重新预检)'
|
||||
ElMessageBox.alert(
|
||||
importErrLines(perrs) + extra,
|
||||
`预检未通过:共 ${p.total || 0} 行,将成功 0 行,失败 ${perrs.length} 行(未写入任何数据)`,
|
||||
{ type: 'warning', confirmButtonText: '知道了' }
|
||||
).catch(() => {})
|
||||
return
|
||||
}
|
||||
// 阶段2 确认
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`预检通过:共 ${p.total || 0} 行,将成功导入 ${p.success || 0} 行。正式写入为整批事务(全成功或全失败,并发冲突时整批回滚)。`,
|
||||
'预检通过,确认导入', { type: 'info', confirmButtonText: '正式导入', cancelButtonText: '取消' })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
// 阶段3 正式写入
|
||||
const res = await request.post('/product-types/import', fd, { headers: { 'Content-Type': 'multipart/form-data' } })
|
||||
const r = res || {}
|
||||
const errs = r.errors || []
|
||||
if (errs.length) {
|
||||
const lines = errs.slice(0, 10).map((x) => `第${x.row}行 ${x.materialCode || ''}:${x.message}`).join(';')
|
||||
ElMessageBox.alert(
|
||||
lines + (errs.length > 10 ? ` …(共 ${errs.length} 条失败明细,请修正后重新导入失败行)` : '(请修正后重新导入失败行)'),
|
||||
`导入完成:成功 ${r.success || 0} 行,失败 ${errs.length} 行`,
|
||||
importErrLines(errs) + (errs.length > 10 ? ` …(共 ${errs.length} 条,请修正后重新预检导入)` : '(请修正后重新预检导入)'),
|
||||
`写入被拒绝:共 ${r.total || 0} 行,失败 ${errs.length} 行(未写入任何数据)`,
|
||||
{ type: 'warning', confirmButtonText: '知道了' }
|
||||
).catch(() => {})
|
||||
} else {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<template #header>待完工检成品(完工确认后未录完工检)</template>
|
||||
<el-table :data="pending.list" border stripe size="small" v-loading="pending.loading">
|
||||
<el-table-column prop="orderNo" label="产品工号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品序号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="图号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="sn" label="成品序列号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="doneAt" label="完工时间" width="170" />
|
||||
</el-table>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<el-table :data="filtered" border stripe size="small" v-loading="loading" :row-class-name="rowClass">
|
||||
<el-table-column prop="sn" label="工件序列号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="orderNo" label="产品工号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品序号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="图号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="currentStationName" label="当前工位" width="130" />
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
<el-table-column prop="contractNo" label="归属编号" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.contractNo || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="productSerial" label="产品序号" min-width="100" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.productSerial || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="quantity" label="数量" width="70">
|
||||
<template #default="{ row }">{{ row.quantity ?? 0 }}</template>
|
||||
</el-table-column>
|
||||
@@ -127,7 +124,6 @@
|
||||
<el-input v-model="dialog.contractNo"
|
||||
:placeholder="dialog.ownershipType === 'project' ? '科技项目号(必填)' : dialog.ownershipType === 'other' ? '选「其他」可不填' : '合同号(必填)'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品序号"><el-input v-model="dialog.productSerial" placeholder="本工单内每台产品的序号" /></el-form-item>
|
||||
<el-form-item label="产品工艺">
|
||||
<div style="width:100%">
|
||||
<el-select v-model="dialog.productProcessId" clearable placeholder="选择后按工序自动推荐工位(可逐道改)" style="width:100%" @change="applyProductProcess">
|
||||
@@ -340,7 +336,6 @@
|
||||
<el-descriptions-item label="状态">{{ statusText(detail.row.status) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="已排产量">{{ detail.row.scheduledQty ?? 0 }} 台</el-descriptions-item>
|
||||
<el-descriptions-item label="剩余未排产量">{{ detail.row.remainQty ?? 0 }} 台</el-descriptions-item>
|
||||
<el-descriptions-item label="产品序号">{{ detail.row.productSerial || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计划完成">{{ fmtDateOnly(detail.row.planEnd) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计划开始">{{ fmtDateOnly(detail.row.planStart) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计划完成">{{ fmtDateOnly(detail.row.planEnd) }}</el-descriptions-item>
|
||||
@@ -371,14 +366,14 @@
|
||||
<template #default="{ row }">{{ stepReqText(row) }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="detail-subtitle">工件序列号列表({{ detail.total }} 台,按产品序号升序)</div>
|
||||
<div class="detail-subtitle">工件序列号列表({{ detail.total }} 台,按SN升序)</div>
|
||||
<div class="piece-toolbar">
|
||||
<el-select v-model="pieceQuery.status" clearable placeholder="状态:全部" style="width:140px" @change="onPieceFilter">
|
||||
<el-option v-for="(l, v) in pieceStatusMap" :key="v" :label="l" :value="v" />
|
||||
</el-select>
|
||||
</div>
|
||||
<el-table :data="detail.pieces" border size="small" v-loading="detail.loading" empty-text="该工单暂无工件进线记录">
|
||||
<el-table-column label="产品序号" width="80" align="center">
|
||||
<el-table-column label="SN末段" width="90" align="center">
|
||||
<template #default="{ row }">{{ pieceSerialText(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sn" label="SN" min-width="160" show-overflow-tooltip />
|
||||
@@ -649,10 +644,10 @@ async function openUsage(row) {
|
||||
|
||||
// ---------- 工单详情(只读:字段汇总 + 工件SN列表) ----------
|
||||
// 工件SN列表:GET /workpieces?orderNo=&page=&pageSize=&status= 后端 SQL 分页(2026-10-20),
|
||||
// 按 SN 升序(预生成 SN={产品工号}-{3位序号},即产品序号小号在前);产品序号列取 SN 末段序号。
|
||||
// 按 SN 升序(预生成 SN={产品工号}-{3位序号},小号在前);SN末段列取 SN 末段序号。
|
||||
const detail = reactive({ show: false, row: null, pieces: [], total: 0, loading: false, snMode: 0 })
|
||||
const pieceQuery = reactive({ page: 1, pageSize: 100, status: '' })
|
||||
// 产品序号=SN 末段数字(如 WO-20260918-001-001 → 1);扫入 SN(序列号=是)无该结构时显示 -
|
||||
// SN末段=SN 末段数字(如 WO-20260918-001-001 → 1);扫入 SN(序列号=是)无该结构时显示 -
|
||||
function pieceSerialText(row) {
|
||||
const m = String(row.sn || '').match(/-(\d{1,4})$/)
|
||||
return m ? String(parseInt(m[1], 10)) : '-'
|
||||
@@ -742,7 +737,7 @@ function stepReqText(row) {
|
||||
return parts.length ? parts.join(';') : '—'
|
||||
}
|
||||
|
||||
const dialog = reactive({ show: false, id: 0, workOrderNo: '', productTypeId: null, productCode: '', productName: '', contractNo: '', ownershipType: '', productSerial: '', quantity: 1, planStart: '', planEnd: '', status: 'CREATED', productProcessId: 0 })
|
||||
const dialog = reactive({ show: false, id: 0, workOrderNo: '', productTypeId: null, productCode: '', productName: '', contractNo: '', ownershipType: '', quantity: 1, planStart: '', planEnd: '', status: 'CREATED', productProcessId: 0 })
|
||||
|
||||
// ---------- 产品工艺(2026-10-09):建单选产品自动带出默认产品工艺,自动填工艺组合(快捷选择+偏差提示) ----------
|
||||
const productProcesses = ref([])
|
||||
@@ -812,7 +807,7 @@ function genOrderNo() {
|
||||
const ymd = `${d.getFullYear()}${String(d.getMonth() + 1).padStart(2, '0')}${String(d.getDate()).padStart(2, '0')}`
|
||||
return `WO-${ymd}-001`
|
||||
}
|
||||
// Q1=A:选产品型号后自动带出图号/名称(只读,避免手填错位;图号=产品序号,同值)
|
||||
// Q1=A:选产品型号后自动带出图号/名称(只读,避免手填错位;图号=产品编码,同值)
|
||||
// 2026-10-09:同时带出该产品的产品工艺(默认优先),自动填工艺组合
|
||||
function onProductTypeChange(id) {
|
||||
const p = productTypes.value.find((x) => x.id === id)
|
||||
@@ -826,7 +821,7 @@ function onProductTypeChange(id) {
|
||||
loadProductProcesses()
|
||||
}
|
||||
function openCreate() {
|
||||
Object.assign(dialog, { show: true, id: 0, workOrderNo: genOrderNo(), productTypeId: null, productCode: '', productName: '', contractNo: '', ownershipType: '', productSerial: '', quantity: 1, planStart: '', planEnd: '', status: 'CREATED', productProcessId: 0 })
|
||||
Object.assign(dialog, { show: true, id: 0, workOrderNo: genOrderNo(), productTypeId: null, productCode: '', productName: '', contractNo: '', ownershipType: '', quantity: 1, planStart: '', planEnd: '', status: 'CREATED', productProcessId: 0 })
|
||||
productProcesses.value = []
|
||||
ppWarnings.value = []
|
||||
processRows.value = []
|
||||
@@ -834,7 +829,7 @@ function openCreate() {
|
||||
comboStaleWarn.value = ''
|
||||
}
|
||||
async function openEdit(row) {
|
||||
Object.assign(dialog, { show: true, id: row.id, workOrderNo: row.workOrderNo, productTypeId: row.productTypeId, productCode: row.productCode, productName: row.productName, contractNo: row.contractNo || '', ownershipType: row.ownershipType || '', productSerial: row.productSerial || '', quantity: row.quantity, planStart: row.planStart ? String(row.planStart).slice(0, 10) : '', planEnd: row.planEnd ? String(row.planEnd).slice(0, 10) : '', status: row.status, productProcessId: row.productProcessId || 0 })
|
||||
Object.assign(dialog, { show: true, id: row.id, workOrderNo: row.workOrderNo, productTypeId: row.productTypeId, productCode: row.productCode, productName: row.productName, contractNo: row.contractNo || '', ownershipType: row.ownershipType || '', quantity: row.quantity, planStart: row.planStart ? String(row.planStart).slice(0, 10) : '', planEnd: row.planEnd ? String(row.planEnd).slice(0, 10) : '', status: row.status, productProcessId: row.productProcessId || 0 })
|
||||
// 编辑:带出该产品可选的产品工艺(不自动重填组合,保留已保存组合)
|
||||
productProcesses.value = []
|
||||
ppWarnings.value = []
|
||||
@@ -861,7 +856,7 @@ async function save() {
|
||||
}
|
||||
// 建单不强制工艺组合(工单≠开工):排产/开工时由后端校验组合非空
|
||||
if (!flowCombination.value.length) ElMessage.warning('未选择工艺组合:排产/开工前须配置')
|
||||
const body = { id: dialog.id, workOrderNo: dialog.workOrderNo, productTypeId: dialog.productTypeId, productCode: dialog.productCode, productName: dialog.productName, contractNo: dialog.contractNo, ownershipType: dialog.ownershipType, productSerial: dialog.productSerial, quantity: dialog.quantity, planStart: dialog.planStart, planEnd: dialog.planEnd, flowCombination: flowCombination.value, productProcessId: dialog.productProcessId || 0 }
|
||||
const body = { id: dialog.id, workOrderNo: dialog.workOrderNo, productTypeId: dialog.productTypeId, productCode: dialog.productCode, productName: dialog.productName, contractNo: dialog.contractNo, ownershipType: dialog.ownershipType, quantity: dialog.quantity, planStart: dialog.planStart, planEnd: dialog.planEnd, flowCombination: flowCombination.value, productProcessId: dialog.productProcessId || 0 }
|
||||
let resp = null
|
||||
if (dialog.id) resp = await request.put('/work-orders', body)
|
||||
else resp = await request.post('/work-orders', body)
|
||||
|
||||
Reference in New Issue
Block a user