feat: 会话令牌与守卫、看板组件及工位终端功能完善
- 用户表扩展:MES/WMS user 实体新增字段,新增 active_token 迁移 SQL(2026-11-11) - 会话机制:MES 新增 session_guard,重构 token/auth/jwt/perm 与路由;WMS/工作站同步令牌续签与鉴权 - 看板(board):调整 MES 看板产线/生产/侧栏/仓库组件及样式;WMS 看板展示页同步调整 - 工位终端后端:完善报警流、绑定、PLC 对账、拧紧、proxy、上报、站点告警/操作等 handler,补充 mes client/store - 工位终端前端:登录/主界面/各操作面板调整,新增滚动分页与多语言 yaml 文案,刷新构建产物 - MES 业务:新增流程链 logic,调整待审核/产能支撑/产品工艺/设置页、PLC 监控与帮助文档,刷新构建产物 - 更新问题记录文档
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
<el-table-column label="操作工签字时间" min-width="160">
|
||||
<template #default="{ row }">{{ row.operatorSignedAt || row.signedAt || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<!-- 2026-11-11 修复:130px 装不下两个 size=small 按钮(74+12+74=160)导致换行错位,加宽到 175 -->
|
||||
<el-table-column label="操作" width="175" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="success" size="small" :loading="row._doing" @click="approve(row)">审核通过</el-button>
|
||||
<el-button type="warning" size="small" :loading="row._doing" @click="reject(row)">退回重做</el-button>
|
||||
|
||||
@@ -28,34 +28,47 @@ function strText(v) {
|
||||
return v
|
||||
}
|
||||
|
||||
// 滚动分页:初始化 20 行,滚到底再追加 20 行
|
||||
// 2026-11-11:滚动分页改 el-pagination 标准分页 + 搜索条件(工单号/成品编码关键字,本地过滤)
|
||||
const PAGE_SIZE = 20
|
||||
const orderVisible = ref(PAGE_SIZE)
|
||||
const visibleOrders = computed(() => orders.value.slice(0, orderVisible.value))
|
||||
function onOrderScroll(e) {
|
||||
const el = e.target
|
||||
if (!el) return
|
||||
if (el.scrollTop + el.clientHeight >= el.scrollHeight - 24 && orderVisible.value < orders.value.length) {
|
||||
orderVisible.value = Math.min(orderVisible.value + PAGE_SIZE, orders.value.length)
|
||||
}
|
||||
}
|
||||
const orderKeyword = ref('')
|
||||
const orderPage = ref(1)
|
||||
const filteredOrders = computed(() => {
|
||||
const kw = orderKeyword.value.trim().toLowerCase()
|
||||
if (!kw) return orders.value
|
||||
return orders.value.filter((o) =>
|
||||
String(o.workOrderNo || '').toLowerCase().includes(kw) ||
|
||||
String(o.productCode || '').toLowerCase().includes(kw))
|
||||
})
|
||||
const pagedOrders = computed(() => filteredOrders.value.slice((orderPage.value - 1) * PAGE_SIZE, orderPage.value * PAGE_SIZE))
|
||||
function onOrderPage(p) { orderPage.value = p }
|
||||
|
||||
// 逐日消耗模拟抽屉
|
||||
const dailyDlg = reactive({ show: false, workOrderNo: '', rows: [], visible: PAGE_SIZE })
|
||||
const visibleDailyRows = computed(() => dailyDlg.rows.slice(0, dailyDlg.visible))
|
||||
function openDaily(row) {
|
||||
// 逐日消耗模拟抽屉(2026-11-11:打开即重新向后端计算——后端每次实时取 WMS 可用量,
|
||||
// 抽屉里的消耗/剩余量跟随实时库存变化,而不是页面加载时刻的快照)
|
||||
const dailyDlg = reactive({ show: false, workOrderNo: '', rows: [], loading: false, page: 1 })
|
||||
const pagedDailyRows = computed(() => dailyDlg.rows.slice((dailyDlg.page - 1) * PAGE_SIZE, dailyDlg.page * PAGE_SIZE))
|
||||
async function openDaily(row) {
|
||||
dailyDlg.workOrderNo = row.workOrderNo || ''
|
||||
dailyDlg.rows = Array.isArray(row.dailyRows) ? row.dailyRows : []
|
||||
dailyDlg.visible = PAGE_SIZE
|
||||
dailyDlg.page = 1
|
||||
dailyDlg.show = true
|
||||
}
|
||||
function onDailyScroll(e) {
|
||||
const el = e.target
|
||||
if (!el) return
|
||||
if (el.scrollTop + el.clientHeight >= el.scrollHeight - 24 && dailyDlg.visible < dailyDlg.rows.length) {
|
||||
dailyDlg.visible = Math.min(dailyDlg.visible + PAGE_SIZE, dailyDlg.rows.length)
|
||||
dailyDlg.loading = true
|
||||
try {
|
||||
const data = await request.get('/production/producible-support')
|
||||
const fresh = (Array.isArray(data?.orders) ? data.orders : []).find((o) => o.workOrderNo === row.workOrderNo)
|
||||
if (fresh && Array.isArray(fresh.dailyRows)) dailyDlg.rows = fresh.dailyRows
|
||||
// 顺带把总览统计刷成最新(支撑天数/计算时间等随库存实时变化)
|
||||
supportDays.value = data?.supportDays || 0
|
||||
supportUntil.value = data?.supportUntil || ''
|
||||
shortBoardMaterial.value = data?.shortBoardMaterial || ''
|
||||
computedAt.value = data?.computedAt || 0
|
||||
if (Array.isArray(data?.orders)) orders.value = data.orders
|
||||
} catch {
|
||||
// 拦截器已提示;保留旧数据展示
|
||||
} finally {
|
||||
dailyDlg.loading = false
|
||||
}
|
||||
}
|
||||
function onDailyPage(p) { dailyDlg.page = p }
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
@@ -122,60 +135,61 @@ onMounted(load)
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 唯一一张工单表:可产套数 / 瓶颈物料 / 撑到哪天,逐日模拟走抽屉 -->
|
||||
<!-- 唯一一张工单表:可产套数 / 瓶颈物料 / 撑到哪天,逐日模拟走抽屉(2026-11-11 改标准分页+搜索) -->
|
||||
<el-card shadow="never" header="各工单排产支撑(可产套数 / 瓶颈物料 / 撑到哪天;点「逐日消耗」查看每天消耗与剩余)" v-loading="loading" class="mb12">
|
||||
<div class="scroll-list" @scroll="onOrderScroll">
|
||||
<el-table :data="visibleOrders" border size="small" empty-text="暂无工单排产支撑数据" row-key="workOrderNo">
|
||||
<el-table-column label="工单号" min-width="150">
|
||||
<template #default="{ row }">{{ strText(row.workOrderNo) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="成品编码" min-width="140">
|
||||
<template #default="{ row }">{{ strText(row.productCode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可生产套数" width="120" align="center" sortable prop="producibleQty">
|
||||
<template #default="{ row }"><span :class="Number(row.producibleQty) > 0 ? 'ok' : 'warn'" class="qty">{{ numText(row.producibleQty) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="瓶颈物料" min-width="150">
|
||||
<template #default="{ row }">{{ strText(row.bottleneckMaterial) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="撑到哪天" width="130">
|
||||
<template #default="{ row }">{{ strText(row.supportUntil) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="openDaily(row)">逐日消耗</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="scroll-hint">
|
||||
已显示 {{ visibleOrders.length }} / {{ orders.length }} 条<span v-if="visibleOrders.length < orders.length">,继续向下滚动加载更多</span>
|
||||
</div>
|
||||
<div class="list-toolbar">
|
||||
<el-input v-model="orderKeyword" placeholder="搜索工单号 / 成品编码" clearable style="width:260px"
|
||||
@input="orderPage = 1" />
|
||||
<span class="toolbar-total">共 {{ filteredOrders.length }} 条</span>
|
||||
</div>
|
||||
<el-table :data="pagedOrders" border size="small" empty-text="暂无工单排产支撑数据" row-key="workOrderNo">
|
||||
<el-table-column label="工单号" min-width="150">
|
||||
<template #default="{ row }">{{ strText(row.workOrderNo) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="成品编码" min-width="140">
|
||||
<template #default="{ row }">{{ strText(row.productCode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可生产套数" width="120" align="center" sortable prop="producibleQty">
|
||||
<template #default="{ row }"><span :class="Number(row.producibleQty) > 0 ? 'ok' : 'warn'" class="qty">{{ numText(row.producibleQty) }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="瓶颈物料" min-width="150">
|
||||
<template #default="{ row }">{{ strText(row.bottleneckMaterial) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="撑到哪天" width="130">
|
||||
<template #default="{ row }">{{ strText(row.supportUntil) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="130" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="openDaily(row)">逐日消耗</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-if="filteredOrders.length > PAGE_SIZE" style="margin-top:12px;justify-content:flex-end"
|
||||
layout="prev,pager,next,total" :total="filteredOrders.length" :page-size="PAGE_SIZE"
|
||||
:current-page="orderPage" @current-change="onOrderPage" />
|
||||
</el-card>
|
||||
|
||||
<!-- 逐日消耗模拟抽屉:每天消耗多少、扣减前可用量、剩余多少 -->
|
||||
<!-- 逐日消耗模拟抽屉:每天消耗多少、扣减前可用量、剩余多少(打开即按实时库存重算) -->
|
||||
<el-drawer v-model="dailyDlg.show" :title="`工单 ${dailyDlg.workOrderNo} · 逐日消耗模拟`" size="60%" direction="rtl">
|
||||
<div class="drawer-tip">按日排产逐日扣减库存可用量;排产排满后的日期为按近 3 天平均需求外推。剩余量变负即该物料当天见底。</div>
|
||||
<div class="drawer-scroll" @scroll="onDailyScroll">
|
||||
<el-table :data="visibleDailyRows" border size="small" empty-text="该工单暂无逐日模拟数据">
|
||||
<el-table-column prop="date" label="日期" width="130" />
|
||||
<el-table-column label="物料编码" min-width="160">
|
||||
<template #default="{ row: d }">{{ strText(d.materialCode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="当日消耗" width="120" align="center">
|
||||
<template #default="{ row: d }">{{ numText(d.consumed) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="扣减前可用" width="130" align="center">
|
||||
<template #default="{ row: d }">{{ numText(d.before) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剩余量" width="120" align="center">
|
||||
<template #default="{ row: d }"><span :class="Number(d.remain) < 0 ? 'warn' : 'ok'">{{ numText(d.remain) }}</span></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="scroll-hint">
|
||||
已显示 {{ visibleDailyRows.length }} / {{ dailyDlg.rows.length }} 条<span v-if="visibleDailyRows.length < dailyDlg.rows.length">,继续向下滚动加载更多</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="drawer-tip">按日排产逐日扣减库存可用量;排产排满后的日期为按近 3 天平均需求外推。剩余量变负即该物料当天见底。每次打开都会按<b>当前实时库存</b>重新计算。</div>
|
||||
<el-table v-loading="dailyDlg.loading" :data="pagedDailyRows" border size="small" empty-text="该工单暂无逐日模拟数据">
|
||||
<el-table-column prop="date" label="日期" width="130" />
|
||||
<el-table-column label="物料编码" min-width="160">
|
||||
<template #default="{ row: d }">{{ strText(d.materialCode) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="当日消耗" width="120" align="center">
|
||||
<template #default="{ row: d }">{{ numText(d.consumed) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="扣减前可用" width="130" align="center">
|
||||
<template #default="{ row: d }">{{ numText(d.before) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剩余量" width="120" align="center">
|
||||
<template #default="{ row: d }"><span :class="Number(d.remain) < 0 ? 'warn' : 'ok'">{{ numText(d.remain) }}</span></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination v-if="dailyDlg.rows.length > PAGE_SIZE" style="margin-top:12px;justify-content:flex-end"
|
||||
layout="prev,pager,next,total" :total="dailyDlg.rows.length" :page-size="PAGE_SIZE"
|
||||
:current-page="dailyDlg.page" @current-change="onDailyPage" />
|
||||
</el-drawer>
|
||||
|
||||
<PageHelp :data="helpProducible" page="ProducibleSupport" />
|
||||
@@ -192,8 +206,7 @@ onMounted(load)
|
||||
.stat-label { font-size: 12px; color: #909399; margin-top: 6px; }
|
||||
.bottleneck-tip { margin-top: 10px; font-size: 13px; color: #e6a23c; }
|
||||
.qty { font-size: 18px; font-weight: 700; }
|
||||
.scroll-list { max-height: 520px; overflow-y: auto; }
|
||||
.drawer-scroll { max-height: calc(100vh - 190px); overflow-y: auto; }
|
||||
.scroll-hint { text-align: center; color: #909399; font-size: 12px; padding: 8px 0; }
|
||||
.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
|
||||
.toolbar-total { font-size: 12px; color: #909399; }
|
||||
.drawer-tip { font-size: 12px; color: #909399; line-height: 1.6; margin-bottom: 10px; }
|
||||
</style>
|
||||
|
||||
@@ -207,37 +207,55 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="排序规则">
|
||||
<div class="tip" style="line-height:1.7">
|
||||
按工位号升序=产线单向执行顺序,工序整体递增不回头(同一道工序的所有工位必须连在一起,不能与别的工序交错)。<br>
|
||||
勾选=要套用的工位;拖住行首的手柄可上下调序;「绑定工艺」可换选。保存时会按规则校验,不合格会逐条指出。
|
||||
产线只能往一个方向走:工位号小的先做、大的后做,同一道工序的工位必须排在一起,不能被别的工序隔开。<br>
|
||||
勾选=要套用的工位;拖住行首手柄或点 ↑↓ 调整先后顺序;「绑定工艺」可换选。<b>选不了的工位会直接置灰</b>(悬停看原因);下方会实时显示当前流水线是否走通。
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="工位→工艺" label-width="110px">
|
||||
<el-table ref="tplTableRef" :data="tplDlg.stations" border size="small" row-key="stationNo"
|
||||
empty-text="所选产品工艺无可绑定工位" @selection-change="onTplStationSelect">
|
||||
<el-table-column type="selection" width="42" align="center" />
|
||||
<el-table-column width="44" align="center">
|
||||
<template #default>
|
||||
<span class="tpl-drag" title="按住拖动调序">⠿</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stationNo" label="工位" width="80" align="center" />
|
||||
<el-table-column label="绑定工艺" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.flowId" size="small" style="width:100%" placeholder="选择工艺">
|
||||
<el-option v-for="f in flows" :key="f.id" :label="f.name" :value="f.id" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="来源产品工艺" min-width="170" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fromNames || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="调整" width="90" align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link size="small" :disabled="$index === 0" @click="moveTplStation($index, -1)">↑</el-button>
|
||||
<el-button link size="small" :disabled="$index === tplDlg.stations.length - 1" @click="moveTplStation($index, 1)">↓</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="width:100%">
|
||||
<!-- 实时流水线预览 + 校验结果(2026-11-11:所见即所得,不用等保存报错) -->
|
||||
<div class="tpl-preview">
|
||||
<span class="tpl-preview-label">当前流水线:</span>
|
||||
<span v-if="tplPreview">{{ tplPreview }}</span>
|
||||
<span v-else class="tip">尚未勾选工位</span>
|
||||
</div>
|
||||
<el-alert v-if="tplCheck.err" type="error" :closable="false" show-icon style="margin-top:6px" :title="tplCheck.err" />
|
||||
<el-alert v-else-if="tplDlg.selectedStations.length" type="success" :closable="false" show-icon style="margin-top:6px"
|
||||
title="当前勾选与顺序满足流水线规则,可以直接保存。" />
|
||||
<el-table ref="tplTableRef" :data="tplDlg.stations" border size="small" row-key="stationNo"
|
||||
empty-text="所选产品工艺无可绑定工位" @selection-change="onTplStationSelect">
|
||||
<el-table-column type="selection" width="42" align="center" :selectable="tplSelectable" />
|
||||
<el-table-column width="44" align="center">
|
||||
<template #default>
|
||||
<span class="tpl-drag" title="按住拖动调序">⠿</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工位" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip v-if="row._dis" :content="row._disReason" placement="top" :show-after="150">
|
||||
<span style="color:#c0c4cc;text-decoration:line-through;cursor:not-allowed">{{ row.stationNo }}</span>
|
||||
</el-tooltip>
|
||||
<span v-else>{{ row.stationNo }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="绑定工艺" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.flowId" size="small" style="width:100%" placeholder="选择工艺">
|
||||
<el-option v-for="f in flows" :key="f.id" :label="f.name" :value="f.id" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="来源产品工艺" min-width="170" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.fromNames || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="调整" width="90" align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button link size="small" :disabled="$index === 0" @click="moveTplStation($index, -1)">↑</el-button>
|
||||
<el-button link size="small" :disabled="$index === tplDlg.stations.length - 1" @click="moveTplStation($index, 1)">↓</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="满足产品工艺">
|
||||
<div>{{ tplDlg.processNames.join('、') || '—' }}</div>
|
||||
@@ -452,14 +470,63 @@ const selectedRows = ref([])
|
||||
function onSelectionChange(rows) { selectedRows.value = rows || [] }
|
||||
const tplDlg = reactive({ show: false, name: '', productCode: '', stations: [], processNames: [], selectedStations: [] })
|
||||
const tplTableRef = ref(null)
|
||||
function onTplStationSelect(rows) { tplDlg.selectedStations = rows || [] }
|
||||
function onTplStationSelect(rows) {
|
||||
tplDlg.selectedStations = rows || []
|
||||
refreshTplCheck()
|
||||
}
|
||||
function moveTplStation(i, delta) {
|
||||
const j = i + delta
|
||||
if (j < 0 || j >= tplDlg.stations.length) return
|
||||
const arr = tplDlg.stations
|
||||
;[arr[i], arr[j]] = [arr[j], arr[i]]
|
||||
refreshTplCheck()
|
||||
}
|
||||
|
||||
// ---------- 实时校验/置灰(2026-11-11) ----------
|
||||
// 产线物理顺序固定=工位号升序,所以「勾选集按工位号升序后同一工序是否被打断」决定了
|
||||
// 这套勾选到底能不能成立(打断 = 怎么拖拽调序都救不回来);当前显示顺序乱但升序后合法的,
|
||||
// 不禁选,只黄条提示调序。
|
||||
const tplCheck = reactive({ err: '' })
|
||||
const tplPreview = computed(() => {
|
||||
const chosen = (tplDlg.selectedStations.length ? tplDlg.selectedStations : tplDlg.stations)
|
||||
.slice().sort((a, b) => a.stationNo - b.stationNo)
|
||||
const groups = []
|
||||
for (const s of chosen) {
|
||||
const last = groups[groups.length - 1]
|
||||
if (last && last.flowId === s.flowId) last.nos.push(s.stationNo)
|
||||
else groups.push({ flowId: s.flowId, nos: [s.stationNo] })
|
||||
}
|
||||
return groups.map((g) => `${flowNameOf(g.flowId)} 工位${g.nos.join('/')}`).join(' → ')
|
||||
})
|
||||
// sorted flowId 序列中某工艺出现后又断了 = 打断(与 validateTemplateStations 同判定)
|
||||
function tplBroken(ids) {
|
||||
const closed = new Set()
|
||||
let cur = null
|
||||
for (const f of ids) {
|
||||
if (f === cur) continue
|
||||
if (cur !== null) closed.add(cur)
|
||||
if (closed.has(f)) return true
|
||||
cur = f
|
||||
}
|
||||
return false
|
||||
}
|
||||
function tplSelectable(row) { return !row._dis }
|
||||
function refreshTplCheck() {
|
||||
const chosen = tplDlg.selectedStations
|
||||
const canonical = (rows) => rows.slice().sort((a, b) => a.stationNo - b.stationNo)
|
||||
for (const row of tplDlg.stations) {
|
||||
if (chosen.includes(row)) { row._dis = false; row._disReason = ''; continue }
|
||||
const ids = canonical([...chosen, row]).map((s) => s.flowId)
|
||||
row._dis = tplBroken(ids)
|
||||
row._disReason = row._dis
|
||||
? `勾上工位${row.stationNo}(${flowNameOf(row.flowId)})后,${flowNameOf(row.flowId)} 的工位会与已选的其他工序工位互相穿插——流水线要来回走,怎么调序都救不回来。请取消其它工位,或把这一行的「绑定工艺」换掉。`
|
||||
: ''
|
||||
}
|
||||
tplDlg.stations = [...tplDlg.stations] // 替换引用触发表格重估 selectable
|
||||
tplCheck.err = chosen.length ? validateTemplateStations(chosen) : ''
|
||||
}
|
||||
watch(() => tplDlg.stations.map((s) => s.flowId).join(','), refreshTplCheck)
|
||||
|
||||
// 原生 HTML5 拖拽调序(不引入第三方拖拽库):事件委托挂在 tbody 上,行重渲染不影响。
|
||||
let tplDragFrom = -1
|
||||
function bindTplDrag() {
|
||||
@@ -524,7 +591,12 @@ function openTemplateDialog() {
|
||||
}
|
||||
}
|
||||
if (conflicts.length) {
|
||||
ElMessageBox.alert(conflicts.join(';'), '无法生成工位模板', { type: 'warning', confirmButtonText: '知道了' })
|
||||
// 2026-11-11:同工位异工艺冲突 → 人话 + 自动分段判定
|
||||
const x = analyzeCrossProduct(selectedRows.value)
|
||||
const msg = x.seg
|
||||
? `${humanizeStationConflicts(conflicts)}\n\n不过两个产品可以前后分段生产:${x.msg}`
|
||||
: humanizeStationConflicts(conflicts)
|
||||
ElMessageBox.alert(msg, '无法生成工位模板', { type: 'warning', confirmButtonText: '知道了', customStyle: { whiteSpace: 'pre-wrap' } })
|
||||
return
|
||||
}
|
||||
const stations = [...byStation.values()].sort((a, b) => a.stationNo - b.stationNo)
|
||||
@@ -540,10 +612,67 @@ function openTemplateDialog() {
|
||||
bindTplDrag()
|
||||
ensureTplRowsDraggable()
|
||||
tplTableRef.value?.toggleAllSelection?.() // 默认全选,与 selectedStations 初值一致
|
||||
refreshTplCheck()
|
||||
})
|
||||
if (shared.length) ElMessage.warning(shared.join(';'))
|
||||
}
|
||||
|
||||
// ---------- 跨产品合并分析(2026-11-11) ----------
|
||||
// 把每个产品工艺的工序链(工序顺序→工位组)放到工位号轴上:
|
||||
// ① 每条链自身方向必须与工位号同向;② 两条链可归并 ⇔ 按工位号升序后各链工序序号不回退;
|
||||
// ③ 不可归并时按工位号断点找分段方案(每条链完整落在一段)→ 可分段给建议,否则完全冲突。
|
||||
function analyzeCrossProduct(pps) {
|
||||
const chains = []
|
||||
for (const pp of pps) {
|
||||
const fs = Array.isArray(pp.flows) ? pp.flows : []
|
||||
const groups = []
|
||||
for (const it of fs) {
|
||||
const f = flows.value.find((x) => x.id === it.flowId)
|
||||
const nos = (Array.isArray(f?.stations) ? f.stations : []).map(Number).filter((n) => n > 0).sort((a, b) => a - b)
|
||||
if (nos.length) groups.push(nos)
|
||||
}
|
||||
if (groups.length) chains.push({ name: pp.name, code: pp.productCode, groups })
|
||||
}
|
||||
if (chains.length < 2) return { ok: true, seg: false, msg: '' }
|
||||
const flat = (c) => c.groups.flat()
|
||||
const describeChain = (c) => c.groups.map((g, i) => `工序${i + 1} 工位${g.join('/')}`).join(' → ')
|
||||
for (const c of chains) {
|
||||
for (let i = 0; i < c.groups.length - 1; i++) {
|
||||
if (Math.max(...c.groups[i]) >= Math.min(...c.groups[i + 1])) {
|
||||
return { ok: false, seg: false, msg: `产品「${c.name}」的工序顺序与工位号方向相反(${describeChain(c)})——这条产品工艺本身在产线上走不通,请先修正它的工位绑定。` }
|
||||
}
|
||||
}
|
||||
}
|
||||
const seq = []
|
||||
chains.forEach((c, ci) => c.groups.forEach((g, gi) => g.forEach((no) => seq.push({ no, ci, gi }))))
|
||||
seq.sort((a, b) => a.no - b.no)
|
||||
const lastGi = new Map()
|
||||
let crossed = false
|
||||
for (const s of seq) {
|
||||
const prev = lastGi.get(s.ci)
|
||||
if (prev !== undefined && s.gi < prev) { crossed = true; break }
|
||||
lastGi.set(s.ci, s.gi)
|
||||
}
|
||||
if (!crossed) return { ok: true, seg: false, msg: '' }
|
||||
const minNo = seq[0].no
|
||||
const maxNo = seq[seq.length - 1].no
|
||||
for (let k = minNo; k < maxNo; k++) {
|
||||
const front = chains.filter((c) => flat(c).every((n) => n <= k))
|
||||
const back = chains.filter((c) => flat(c).every((n) => n > k))
|
||||
if (front.length && back.length && front.length + back.length === chains.length) {
|
||||
const f = front.map((c) => `「${c.name}」用 ${describeChain(c)}`).join(',')
|
||||
const b = back.map((c) => `「${c.name}」用 ${describeChain(c)}`).join(',')
|
||||
return { ok: false, seg: true, msg: `前段:${f};后段:${b}。请分开生成两个模板(各勾选对应产品的产品工艺),两个工单分段生产、互不影响。` }
|
||||
}
|
||||
}
|
||||
return { ok: false, seg: false, msg: `${chains.map((c) => `「${c.name}」${describeChain(c)}`).join(';')}——两个产品的工序方向在相同工位段上互相交叉,方向相反,同一组工位没办法同时满足。请只勾选其中一个产品的工艺生成模板,或调整工位绑定错开两个产品。` }
|
||||
}
|
||||
function humanizeStationConflicts(conflicts) {
|
||||
// conflicts 现为程序化短句,统一转人话前缀
|
||||
return conflicts.map((c) => c.replace(/工位(\d+)被工艺(.+?)和(.+?)要求不同工序(同一工位只能绑一道工艺)/,
|
||||
'工位 $1 被两个产品同时要求做不同的工序(「$2」和「$3」)——一个工位同一时刻只能干一道工序。')).join('\n')
|
||||
}
|
||||
|
||||
// 三层校验(对齐 internal/logic/route.go:218-263,265-352,363-380 的工单组合口径):
|
||||
// ① 每道被选工序至少有一个工位;② 按工位号升序后同工序必须连续、区间整体递增不回头;
|
||||
// ③ 同工序内工位号不重复(一个工位只能出现一次)。
|
||||
@@ -567,7 +696,7 @@ function validateTemplateStations(stations) {
|
||||
const last = lastIdx.get(f)
|
||||
for (let i = first; i <= last; i++) {
|
||||
if (flowIds[i] !== f) {
|
||||
return `工序整体递增不回头:${flowNameOf(f)} 的工位被 ${flowNameOf(flowIds[i])} 打断(工位${stations[i].stationNo}),请调整顺序或改绑工艺`
|
||||
return `${flowNameOf(f)} 的工位被 ${flowNameOf(flowIds[i])}(工位${stations[i].stationNo})隔开了——同一道工序的工位必须排在一起,流水线不能往回走。请拖动/点 ↑↓ 把 ${flowNameOf(f)} 的工位调到一起,或取消勾选工位${stations[i].stationNo}。`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,4 +743,11 @@ onMounted(async () => {
|
||||
.pp-chain { line-height: 1.6; }
|
||||
.pp-arrow { color: #909399; }
|
||||
.pp-tip { font-size: 12px; color: #909399; margin-top: 6px; line-height: 1.5; }
|
||||
/* 2026-11-11 模板弹窗:实时流水线预览条 */
|
||||
.tpl-preview {
|
||||
font-size: 15px; font-weight: 600; color: #303133;
|
||||
background: #f5f7fa; border: 1px solid #ebeef5; border-radius: 6px;
|
||||
padding: 8px 12px; word-break: break-all;
|
||||
}
|
||||
.tpl-preview-label { font-weight: 400; color: #909399; margin-right: 6px; }
|
||||
</style>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<el-radio value="physical">物理优先(默认)</el-radio>
|
||||
<el-radio value="strict">严格隔离</el-radio>
|
||||
</el-radio-group>
|
||||
<div class="tip">物理优先(默认):目标接驳台/缓存位实际无托盘即可卸货;严格隔离:多工单物料禁止共位,目标位被其他工单占用时报错/另选点位</div>
|
||||
<div class="tip">控制报工后工件流转遇下游工位被占时,是否允许进缓存区排队:strict=允许(工件进入可达的第一个空闲缓存位等位,缓存满则报警并滞留原地);physical=堵在原地不动。本策略同时约束「PLC管理」页手动下发可缓存 C 位的共位校验</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="AGV 卸货超时报警(分钟)">
|
||||
<el-input-number v-model="form.agvUnloadTimeoutMinutes" :min="1" :max="1440" />
|
||||
|
||||
Reference in New Issue
Block a user