feat: 看板管理屏专属面板与追溯查询三合一 + AGV状态WS实时推送 + 数据库错误友好文案分层
This commit is contained in:
@@ -141,6 +141,9 @@ export const getBom = (params) => request.get('/api/bom', { params })
|
||||
// 工单查询(选工单带出产品编码/名称):{orderNo}
|
||||
export const queryOrder = (params) => request.get('/api/order/query', { params })
|
||||
|
||||
// 扫 SN 秒认工单(上线建档只需扫 SN,自动带出工单/产品/归属只读信息):{sn}
|
||||
export const queryOrderBySn = (params) => request.get('/api/order/by-sn', { params })
|
||||
|
||||
// 工件追溯(下线完工扫SN展示状态/工艺时间线/拧紧):{sn}
|
||||
export const getTrace = (params) => request.get('/api/trace', { params })
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<!-- 固定模式:服务端配置了工位(stationNo>0),不允许选择 -->
|
||||
<span v-if="fixedStation" class="station-fixed">工位 {{ fixedStation }}</span>
|
||||
<!-- 选择模式(2026-11-11 多会话拍板):终端未配置工位=虚拟工位专用机,只允许选虚拟工位 -->
|
||||
<el-select v-else v-model="pickedStation" class="station-el" :placeholder="stationGroups.OFFLINE.length ? '请选择虚拟工位' : '未查到可用的虚拟工位,请先在 MES 工位管理中配置'" size="large">
|
||||
<el-select v-else v-model="pickedStation" filterable class="station-el" :placeholder="stationGroups.OFFLINE.length ? '请选择虚拟工位' : '未查到可用的虚拟工位,请先在 MES 工位管理中配置'" size="large">
|
||||
<el-option-group v-if="stationGroups.OFFLINE.length" label="虚拟工位">
|
||||
<el-option v-for="s in stationGroups.OFFLINE" :key="s.stationNo" :label="stationLabel(s)" :value="s.stationNo" />
|
||||
</el-option-group>
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
<el-input v-model="ret.sn" placeholder="可空" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!isVirtual" label="接驳台(必选)">
|
||||
<el-select v-model="ret.returnDock" placeholder="请选择退料接驳台" style="width:100%">
|
||||
<el-select v-model="ret.returnDock" filterable placeholder="请选择退料接驳台" style="width:100%">
|
||||
<el-option v-for="d in dockOptions" :key="d.code" :label="d.label" :value="d.code" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<span class="lab">叫料日:</span>
|
||||
<el-date-picker v-model="callDate" type="date" value-format="YYYY-MM-DD" :clearable="false" size="large" style="width:150px" />
|
||||
<span class="lab" style="margin-left:16px">期望接驳台(可空):</span>
|
||||
<el-select v-model="expectedDock" size="large" clearable placeholder="配送时仓库可改" style="width:200px">
|
||||
<el-select v-model="expectedDock" filterable size="large" clearable placeholder="配送时仓库可改" style="width:200px">
|
||||
<el-option v-for="d in dockOptions" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
@@ -220,7 +220,7 @@
|
||||
title="物理拉回仓库,不是退料:物料账仍挂本工位、库存不变、托盘按空托盘处理(盘上有无料都不管)。下班走本功能即可不用退料,下一个人登录仍能看到这些物料。" />
|
||||
<el-form label-width="110px">
|
||||
<el-form-item label="接驳台">
|
||||
<el-select v-model="prDlg.dock" style="width:220px">
|
||||
<el-select v-model="prDlg.dock" filterable style="width:220px">
|
||||
<el-option v-for="d in dockOptions" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<div class="form-row" style="margin-top:10px">
|
||||
<span class="lab">下料位置</span>
|
||||
<el-select v-model="pointNo" size="large" class="grow" placeholder="选择末端下料检测位(只列空闲位)">
|
||||
<el-select v-model="pointNo" filterable size="large" class="grow" placeholder="选择末端下料检测位(只列空闲位)">
|
||||
<el-option-group v-for="g in endPointGroups" :key="g.label" :label="g.label">
|
||||
<el-option v-for="p in g.options" :key="p.pointNo" :label="p.label" :value="p.pointNo" />
|
||||
</el-option-group>
|
||||
|
||||
@@ -1,54 +1,46 @@
|
||||
<template>
|
||||
<div class="online-panel">
|
||||
<!-- ① 建档:选工单 + 扫/生成 SN -->
|
||||
<!-- ① 建档:扫 SN 秒认工单(建单时 SN 已预生成并绑定工单,无需手选工单) -->
|
||||
<section class="card">
|
||||
<div class="card-title">上线建档</div>
|
||||
|
||||
<div class="form-row">
|
||||
<span class="lab">工单号</span>
|
||||
<!-- 2026-11-10 改动15c/15d/15e:去掉「刷新工单」按钮(进入页面即实时读后台);
|
||||
下拉改远程搜索,默认只展示 10 条活跃工单,输入关键字时实时查后台,不一次拉全量 -->
|
||||
<el-select
|
||||
v-model="form.orderNo" size="large" class="grow"
|
||||
placeholder="选择工单(可输入工单号/产品名搜索)"
|
||||
filterable remote clearable reserve-keyword
|
||||
:remote-method="remoteOrders" :loading="loadingOrder"
|
||||
@change="onOrderChange" @focus="loadOrders()">
|
||||
<el-option v-for="o in orderOptions" :key="o.value" :label="o.label" :value="o.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<!-- 15b:建档区只留一行产品摘要,数量等基本信息移到下方「工单详情」 -->
|
||||
<div v-if="product.name" class="product-line">
|
||||
产品:<b>{{ product.name }}</b>
|
||||
<span class="code">{{ product.code }}</span>
|
||||
<el-button link type="primary" size="small" @click="showDetail = !showDetail">
|
||||
{{ showDetail ? '收起工单详情' : '工单详情' }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<span class="lab">工件序列号</span>
|
||||
<el-input
|
||||
v-model.trim="form.sn"
|
||||
size="large"
|
||||
class="grow"
|
||||
:placeholder="snPlaceholder"
|
||||
placeholder="扫描工件 SN(建档即识别工单)"
|
||||
clearable
|
||||
@keyup.enter="onSnScan"
|
||||
@blur="onSnScan"
|
||||
/>
|
||||
<el-button v-if="product.snMode === 2" size="large" @click="genSn">自动生成</el-button>
|
||||
<el-button size="large" type="primary" :loading="looking" @click="onSnScan">识别工单</el-button>
|
||||
</div>
|
||||
<div class="point-tip">扫 SN 后自动识别工单;一个 SN 对应一台工件,重复建档会被拦下。</div>
|
||||
|
||||
<div class="form-row">
|
||||
<!-- 扫 SN 识别出的工单信息:只读文本,不让工人再选 -->
|
||||
<div v-if="form.orderNo" class="wo-card">
|
||||
<div class="wo-row"><span class="wo-lab">工单号</span><b>{{ form.orderNo }}</b></div>
|
||||
<div class="wo-row"><span class="wo-lab">产品名称</span><span>{{ product.name || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">成品编码</span><span>{{ product.code || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">归属类型</span><span>{{ ownershipText }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">归属编号</span><span>{{ product.ownershipNo || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">工单数量</span><span>{{ product.quantity > 0 ? product.quantity : '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">工单状态</span><span>{{ product.statusText || '—' }}</span></div>
|
||||
</div>
|
||||
<div v-else class="wo-empty">尚未识别工单,请先扫描工件 SN。</div>
|
||||
|
||||
<div class="form-row" style="margin-top:12px">
|
||||
<span class="lab">工件当前位置</span>
|
||||
<el-select v-model="form.pointNo" size="large" class="grow" placeholder="选择工件当前位置(系统台账已占用的点位不可选)" filterable @change="onPointChange">
|
||||
<el-select v-model="form.pointNo" size="large" class="grow" placeholder="选择工件当前位置(台账被占用的点位不可选)" filterable @change="onPointChange">
|
||||
<el-option-group v-for="g in startPointGroups" :key="g.label" :label="g.label">
|
||||
<el-option v-for="p in g.options" :key="p.pointNo" :label="p.label" :value="p.pointNo" />
|
||||
</el-option-group>
|
||||
</el-select>
|
||||
<el-button size="large" @click="refreshPoints">刷新点位</el-button>
|
||||
</div>
|
||||
<div class="point-tip">当前位置=给这台工件登记的产线点位;只有系统台账标记被「其他工件」占用的点位不能选;选定点位后会核对传感器,若该位置没有实物要先放好实物再提交建档;系统不会因传感器状态自动推进流转,仍按扫码/报工流转。</div>
|
||||
<div class="point-tip">台账被占用的点位不可选;选后核对传感器,先放实物再提交。</div>
|
||||
<div v-if="form.pointNo && sensor.checked && sensor.pointNo === form.pointNo"
|
||||
class="sensor-tip"
|
||||
:class="sensor.plcOk ? (sensor.hasGoods ? 'sensor-ok' : 'sensor-missing') : 'sensor-unknown'">
|
||||
@@ -56,38 +48,8 @@
|
||||
<template v-else-if="sensor.plcOk && sensor.hasGoods">所选位置 {{ form.pointNo }} 已检测到实物</template>
|
||||
<template v-else>当前读不到该位置传感器状态,请自行确认实物已放在 {{ form.pointNo }} 位置</template>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
:type="product.snMode === 1 ? 'warning' : 'info'"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="snTip"
|
||||
style="margin-top:6px"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<!-- ② 工单详情(15b:默认折叠,数量等基本信息不再占大块;展开后仍可查) -->
|
||||
<section v-if="showDetail && form.orderNo" class="card">
|
||||
<div class="card-title">工单详情</div>
|
||||
<div class="wo-row"><span class="wo-lab">工单号</span><b>{{ form.orderNo }}</b></div>
|
||||
<div class="wo-row"><span class="wo-lab">产品名称</span><span>{{ product.name || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">产品编码</span><span>{{ product.code || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">工单数量</span><span>{{ product.quantity > 0 ? product.quantity : '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">工艺路线</span><span>{{ product.route || '—' }}</span></div>
|
||||
<div class="wo-row"><span class="wo-lab">工单状态</span><span>{{ product.statusText || '—' }}</span></div>
|
||||
</section>
|
||||
|
||||
<!-- ③ 15a:删除「待流转在制品」独立模块——重复建档由 PLC↔MES 对账弹窗与 MES 重复拦截提示,
|
||||
不再单独展示列表,避免工人误以为要在这里再点一次建档 -->
|
||||
|
||||
<!-- ④ 建档提交 -->
|
||||
<footer class="action-bar">
|
||||
<el-button type="success" size="large" class="big-btn" :loading="submitting" :disabled="!canSubmit" @click="onSubmit">
|
||||
确认建档上线
|
||||
</el-button>
|
||||
<div class="block-tip" v-if="blockTip">{{ blockTip }}</div>
|
||||
</footer>
|
||||
|
||||
<!-- #8 T3 PLC↔MES 对账提示(建档提交命中,弹两项,提示不拦) -->
|
||||
<el-dialog v-model="mmDlg.show" title="PLC↔MES 对账提示" width="540px" :close-on-click-modal="false" append-to-body>
|
||||
<div class="mm-detail">{{ mmDlg.detail }}</div>
|
||||
@@ -96,79 +58,126 @@
|
||||
<el-button size="large" @click="ackMismatch('bind_known')">绑定已知(关联到已有工件)</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- ③ 建档提交 -->
|
||||
<footer class="action-bar">
|
||||
<el-button type="success" size="large" class="big-btn" :loading="submitting" :disabled="!canSubmit" @click="onSubmit">
|
||||
确认建档上线
|
||||
</el-button>
|
||||
<div class="block-tip" v-if="blockTip">{{ blockTip }}</div>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { onlineRegister, queryOrder, getPointSensor } from '../../api'
|
||||
import { onlineRegister, queryOrderBySn, getPointSensor } from '../../api'
|
||||
import { loadPoints, operatorName, state } from '../../store/station'
|
||||
|
||||
const form = reactive({ orderNo: '', sn: '', pointNo: '' })
|
||||
const product = reactive({ code: '', name: '', workOrderId: 0, snMode: 0, quantity: 0, route: '', statusText: '' })
|
||||
const orders = ref([])
|
||||
const loadingOrder = ref(false)
|
||||
const product = reactive({
|
||||
code: '', name: '', workOrderId: 0, snMode: 0, quantity: 0, route: '', statusText: '',
|
||||
ownershipType: '', ownershipNo: '', flowCombination: []
|
||||
})
|
||||
const looking = ref(false)
|
||||
const submitting = ref(false)
|
||||
const showDetail = ref(false) // 15b:工单详情默认折叠
|
||||
|
||||
// 建档前点位传感器实物核对(只读):选定点位后核对所选位置是否有实物。
|
||||
// plcOk=false 表示 PLC 不可达/模拟/无法映射,前端降级为人工确认,不阻断页面。
|
||||
const sensor = reactive({ pointNo: '', hasGoods: false, plcOk: false, checked: false, code: '' })
|
||||
|
||||
// 15d:工单下拉默认 10 条;输入关键字时走远程搜索实时查后台(不一次拉全量)
|
||||
const ORDER_PAGE_SIZE = 10
|
||||
const STATUS_TEXT = { CREATED: '已创建', RELEASED: '已下发', IN_PROGRESS: '生产中', PAUSED: '已暂停' }
|
||||
const OWN_TEXT = { workorder: '合同号', project: '科技项目号', other: '其他' }
|
||||
const ownershipText = computed(() => OWN_TEXT[product.ownershipType] || '—')
|
||||
|
||||
// SN 口径按成品档案「序列号(是/否)」分流(2026-09-30 解耦定稿;2026-11-16 术语统一为成品档案):
|
||||
// 1=序列号=是:SN 输入必填,扫已在 WMS 入库登记的序列号,工件序列号=所扫序列号(不自动发号);
|
||||
// 2=序列号=否:提交后系统自动发号(提交时若未填则本地自动生成);
|
||||
// 0=未选择:不可建档,提示先去 MES 成品档案设置「序列号(是/否)」。
|
||||
const snPlaceholder = computed(() => {
|
||||
if (product.snMode === 1) return '请扫描产品序列号(已在WMS入库登记)'
|
||||
if (product.snMode === 2) return '提交后系统自动发号'
|
||||
return '请先在成品档案设置「序列号(是/否)」'
|
||||
})
|
||||
const snTip = computed(() => {
|
||||
if (product.snMode === 1) return '该产品为「序列号=是」:请扫描产品序列号(需已在 WMS 入库登记),建档后工件序列号 = 所扫序列号,不再自动发号。'
|
||||
if (product.snMode === 2) return '该产品为「序列号=否」:提交后系统自动发号,全程可追溯;成品 产品序号(SN) 与工件序列号 一致。'
|
||||
return '该产品未设置「序列号(是/否)」:请先在 MES 成品档案设置,否则无法建档上线。'
|
||||
})
|
||||
// 扫 SN → MES 秒认工单 → 只读展示工单/产品/归属(SN 在建单时已预生成并绑定工单)。
|
||||
// 2026-11-16 纠偏:强校验拦截——反查不到 SN 或工单状态不可生产时,弹窗报错且不展示任何只读工单信息。
|
||||
const PRODUCIBLE_STATUS = ['IN_PROGRESS', 'RELEASED']
|
||||
async function onSnScan() {
|
||||
const sn = String(form.sn || '').trim()
|
||||
if (!sn) return
|
||||
if (form.orderNo && product.scannedSn === sn) return // 同一 SN 已识别,避免 @blur/@enter 重复请求
|
||||
looking.value = true
|
||||
try {
|
||||
const d = await queryOrderBySn({ sn })
|
||||
const st = String((d && d.workOrderStatus) || '')
|
||||
if (!PRODUCIBLE_STATUS.includes(st)) {
|
||||
clearRecognition()
|
||||
ElMessageBox.alert('当前工单状态不可生产,请联系计划员', '禁止建档').catch(() => {})
|
||||
return
|
||||
}
|
||||
applyWo(d || {})
|
||||
product.scannedSn = sn
|
||||
} catch (e) {
|
||||
// 反查不到 SN:清空识别信息并弹窗硬拦截(拦截器另有具体原因提示)
|
||||
clearRecognition()
|
||||
ElMessageBox.alert('该序列号未登记或未分配工单,禁止建档', '禁止建档').catch(() => {})
|
||||
} finally {
|
||||
looking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 15a:待流转在制品列表已删除;重复建档由 MES 唯一约束拦截 + PLC↔MES 对账弹窗提示
|
||||
function clearRecognition() {
|
||||
form.orderNo = ''
|
||||
product.scannedSn = ''
|
||||
product.code = ''
|
||||
product.name = ''
|
||||
product.workOrderId = 0
|
||||
product.snMode = 0
|
||||
product.quantity = 0
|
||||
product.route = ''
|
||||
product.statusText = ''
|
||||
product.ownershipType = ''
|
||||
product.ownershipNo = ''
|
||||
product.flowCombination = []
|
||||
}
|
||||
|
||||
// 业务口径(2026-11-06 条20 拍板):工件位置下拉的「工位」分组按当前选中工单的工艺组合候选工位过滤;
|
||||
// 未选工单时不显示工位分组(提示走 blockTip「请先选择工单号」)。
|
||||
// 工艺组合数据源=工单列表接口自带 flowCombination[{flowId,stationNo}],前端本地过滤(改动最小)。
|
||||
function applyWo(d) {
|
||||
form.orderNo = d.orderNo || ''
|
||||
product.code = d.productCode || ''
|
||||
product.name = d.productName || ''
|
||||
product.workOrderId = d.workOrderId || 0
|
||||
product.snMode = Number(d.productSnMode) || 0
|
||||
product.quantity = Number(d.quantity) || 0
|
||||
product.statusText = STATUS_TEXT[d.workOrderStatus] || d.workOrderStatus || ''
|
||||
product.ownershipType = d.ownershipType || ''
|
||||
product.ownershipNo = d.ownershipNo || ''
|
||||
const combo = Array.isArray(d.flowCombination) ? d.flowCombination : []
|
||||
product.flowCombination = combo
|
||||
const stations = []
|
||||
for (const it of combo) {
|
||||
const n = Number(it && it.stationNo)
|
||||
if (!Number.isNaN(n) && n > 0 && !stations.includes(n)) stations.push(n)
|
||||
}
|
||||
stations.sort((a, b) => a - b)
|
||||
product.route = stations.length ? stations.map((n) => '工位 ' + n).join(' → ') : ''
|
||||
}
|
||||
|
||||
// 工件位置下拉「工位」分组:按已识别工单的工艺组合候选工位过滤。
|
||||
const routeStations = computed(() => {
|
||||
if (!form.orderNo) return null
|
||||
const opt = orderOptions.value.find((o) => o.value === form.orderNo)
|
||||
const combo = (opt && opt.raw && opt.raw.flowCombination) || []
|
||||
const set = new Set()
|
||||
for (const it of combo) {
|
||||
for (const it of product.flowCombination || []) {
|
||||
const n = Number(it && it.stationNo)
|
||||
if (!Number.isNaN(n)) set.add(n)
|
||||
}
|
||||
return set
|
||||
})
|
||||
|
||||
// 工件当前位置:按产线点位台账分组(主线位置编址版 2026-11-05),按系统台账占用状态过滤。
|
||||
// 分组 = 停靠位(STOP=C1/C4/C7/C10/C13/C15,不缓存) / 缓存位(CACHE=C2/C3/C5/C6/C8/C9/C11/C12/C14) / 工位(STATION);
|
||||
// 文档无独立上料点位(上料=放主线任意位置或任意工位),FEED"上料位"已废弃删除;接驳台(DOCK=AGV 点位)不作落点、不进下拉。
|
||||
// 工件当前位置:按产线点位台账分组,按系统台账占用状态过滤。
|
||||
const POINT_TYPE_GROUP = { STOP: '停靠位', CACHE: '缓存位', STATION: '工位' }
|
||||
const startPointGroups = computed(() => {
|
||||
const groups = {}
|
||||
const selfSn = String(form.sn || '').trim()
|
||||
for (const p of state.points || []) {
|
||||
if (!p) continue
|
||||
// 与后端 CheckPointFree 对齐:台账已占用的点位,只有被「其他工件」占用才不能选;
|
||||
// 本工件自己占用的点位允许重选。form.sn 尚未生成(如未选工单/未发号)时不放开占用点位。
|
||||
if (p.occupied && (!selfSn || String(p.currentSn || '').trim() !== selfSn)) continue
|
||||
const g = POINT_TYPE_GROUP[p.pointType]
|
||||
if (!g) continue
|
||||
if (p.pointType === 'STATION') {
|
||||
if (!routeStations.value) continue // 未选工单:不显示工位分组
|
||||
if (!routeStations.value.has(Number(p.stationNo))) continue // 不在本工单工艺组合内
|
||||
if (!routeStations.value) continue
|
||||
if (!routeStations.value.has(Number(p.stationNo))) continue
|
||||
}
|
||||
if (!groups[g]) groups[g] = []
|
||||
groups[g].push({ pointNo: p.pointNo, label: `${p.label || p.pointNo}(${p.pointNo})` })
|
||||
@@ -179,8 +188,6 @@ const startPointGroups = computed(() => {
|
||||
return Object.keys(groups).map((label) => ({ label, options: groups[label] }))
|
||||
})
|
||||
|
||||
// 默认位置(2026-11-05 拍板):默认选中停靠位 C1(空闲;文档"上料位默认C1");
|
||||
// C1 不可用(被占/不存在)时回退本工位点位;都不行返回空(阻断提交,不传 0——提交必须为已选项)
|
||||
function defaultStartPointNo() {
|
||||
const pts = state.points || []
|
||||
const free = (p) => p && !p.occupied
|
||||
@@ -189,7 +196,6 @@ function defaultStartPointNo() {
|
||||
if (free(mine)) return mine.pointNo
|
||||
return ''
|
||||
}
|
||||
// 点位台账刷新后:未选/已失效(被他人占用)时回填默认值
|
||||
watch(startPointGroups, () => {
|
||||
const valid = (startPointGroups.value || []).some((g) => g.options.some((o) => o.pointNo === form.pointNo))
|
||||
if (!valid) form.pointNo = defaultStartPointNo()
|
||||
@@ -200,8 +206,6 @@ async function refreshPoints() {
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
// 选定点位后核对传感器:PLC 可达且该位置无实物 → 前端拦截提示先放实物;
|
||||
// 读不到(异常/模拟/无法映射)→ plcOk=false 降级为人工确认,不抛错阻断页面。
|
||||
async function checkPointSensor() {
|
||||
const no = String(form.pointNo || '')
|
||||
sensor.pointNo = no
|
||||
@@ -226,8 +230,6 @@ async function checkPointSensor() {
|
||||
sensor.checked = true
|
||||
}
|
||||
|
||||
// 选定点位后:先复查点位台账(占用变化),再核对所选位置传感器是否有实物;
|
||||
// 可读且没放实物时立即拦截提示,放好后再提交建档。
|
||||
async function onPointChange() {
|
||||
await refreshPoints()
|
||||
await checkPointSensor()
|
||||
@@ -236,118 +238,20 @@ async function onPointChange() {
|
||||
}
|
||||
}
|
||||
|
||||
// 15e 工单下拉(2026-11-16 死结7 统一口径):仅进行中(IN_PROGRESS)工单,不限排产日期,
|
||||
// 状态过滤下推 MES 后端(不再前端 slice 后过滤);stationNo 下推按「第1道工序候选工位含本工位」
|
||||
// 过滤(与建档落点资格校验同口径),干不了的单不出现在下拉里。
|
||||
const orderOptions = computed(() =>
|
||||
orders.value.slice(0, ORDER_PAGE_SIZE).map((o) => ({
|
||||
value: o.workOrderNo,
|
||||
label: `${o.workOrderNo}${o.productName ? ' · ' + o.productName : ''} · ${STATUS_TEXT[o.status] || o.status || '进行中'}`,
|
||||
raw: o
|
||||
}))
|
||||
)
|
||||
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
!!form.orderNo &&
|
||||
!!form.pointNo &&
|
||||
product.snMode !== 0 &&
|
||||
(product.snMode === 2 || !!form.sn)
|
||||
)
|
||||
const canSubmit = computed(() => !!form.orderNo && !!form.sn && !!form.pointNo)
|
||||
const blockTip = computed(() => {
|
||||
if (!form.orderNo) return '请先选择工单号'
|
||||
if (!form.sn) return '请扫描工件 SN'
|
||||
if (!form.orderNo) return 'SN 未识别到工单,请确认 SN 是否正确'
|
||||
if (!form.pointNo) return '请选择工件当前位置(无可选用点位时请联系班长协调)'
|
||||
if (product.snMode === 0) return '请先在成品档案设置「序列号(是/否)」'
|
||||
if (product.snMode === 1 && !form.sn) return '请扫描产品序列号(已在WMS入库登记)'
|
||||
return ''
|
||||
})
|
||||
|
||||
// 15c/15d:进入页面即实时从后台读;下拉远程搜索也走这里(keyword 空时取默认 10 条)
|
||||
async function loadOrders(keyword = '') {
|
||||
loadingOrder.value = true
|
||||
try {
|
||||
const list = await queryOrder({
|
||||
keyword: String(keyword || '').trim(),
|
||||
limit: ORDER_PAGE_SIZE,
|
||||
status: 'IN_PROGRESS',
|
||||
stationNo: Number(state.stationNo) > 0 ? Number(state.stationNo) : undefined
|
||||
})
|
||||
orders.value = Array.isArray(list) ? list : (list && list.list ? list.list : [])
|
||||
// 业务口径(2026-11-06 条19 拍板):活跃工单只有一个时默认选中,工人少点一步
|
||||
if (!form.orderNo && orderOptions.value.length === 1 && !keyword) {
|
||||
form.orderNo = orderOptions.value[0].value
|
||||
onOrderChange(form.orderNo)
|
||||
}
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
loadingOrder.value = false
|
||||
}
|
||||
|
||||
// el-select remote-method:输入关键字实时查后台,300ms 防抖;清空关键字恢复默认 10 条
|
||||
let remoteTimer = null
|
||||
function remoteOrders(keyword) {
|
||||
clearTimeout(remoteTimer)
|
||||
remoteTimer = setTimeout(() => loadOrders(keyword), 300)
|
||||
}
|
||||
|
||||
// 选工单 → 带出产品编码/名称/数量/工艺路线/序列号口径
|
||||
// 工单数量取工单自带 quantity;工艺路线由工单自带 flowCombination 的工位号升序拼出,
|
||||
// MES 工单无独立「路线名称」字段,组合为空时显示「—」。
|
||||
function onOrderChange(orderNo) {
|
||||
product.code = ''
|
||||
product.name = ''
|
||||
product.workOrderId = 0
|
||||
product.snMode = 0
|
||||
product.quantity = 0
|
||||
product.route = ''
|
||||
product.statusText = ''
|
||||
form.sn = ''
|
||||
if (!orderNo) return
|
||||
const opt = orderOptions.value.find((o) => o.value === orderNo)
|
||||
const wo = opt && opt.raw
|
||||
if (wo) {
|
||||
product.code = wo.productCode || ''
|
||||
product.name = wo.productName || ''
|
||||
product.workOrderId = wo.id || 0
|
||||
product.snMode = Number(wo.productSnMode) || 0
|
||||
product.quantity = Number(wo.quantity) || 0
|
||||
product.statusText = STATUS_TEXT[wo.status] || wo.status || ''
|
||||
const combo = Array.isArray(wo.flowCombination) ? wo.flowCombination : []
|
||||
const stations = []
|
||||
for (const it of combo) {
|
||||
const n = Number(it && it.stationNo)
|
||||
if (!Number.isNaN(n) && n > 0 && !stations.includes(n)) stations.push(n)
|
||||
}
|
||||
stations.sort((a, b) => a - b)
|
||||
product.route = stations.length ? stations.map((n) => '工位 ' + n).join(' → ') : ''
|
||||
}
|
||||
// 序列号=否:进入即自动生成 SN(提交后系统发号口径),工人无需手填
|
||||
if (product.snMode === 2) genSn()
|
||||
}
|
||||
|
||||
function genSn() {
|
||||
const d = new Date()
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
const stamp = `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`
|
||||
const src = product.code || 'SN'
|
||||
let prefix = ''
|
||||
for (const ch of src) {
|
||||
const c = ch.charCodeAt(0)
|
||||
if ((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)) prefix += ch
|
||||
}
|
||||
prefix = prefix.slice(0, 12) || 'SN'
|
||||
const rand = String(Math.floor(Math.random() * 9000) + 1000)
|
||||
form.sn = `${prefix}-${stamp}-${rand}`
|
||||
}
|
||||
|
||||
// 业务口径(2026-11-06 拍板):断网时上线建档直接失败报错,不排队、不自动重试——
|
||||
// 工人看到失败会重做;静默重试会造成重复建档。
|
||||
// 业务口径(2026-11-06 拍板):断网时上线建档直接失败报错,不排队、不自动重试。
|
||||
async function onSubmit() {
|
||||
if (!canSubmit.value) {
|
||||
ElMessage.warning(blockTip.value || '当前不满足建档条件')
|
||||
return
|
||||
}
|
||||
// 序列号=否:提交时兜底自动发号(序列号=是必须扫来料序列号,不自动生成)
|
||||
if (product.snMode === 2 && !form.sn) genSn()
|
||||
|
||||
// ① 复查点位台账:选点后该位置若被其他工件占用,拦下来,不许悄悄提交
|
||||
const chosenNo = form.pointNo
|
||||
@@ -397,22 +301,24 @@ async function onSubmit() {
|
||||
operator: operatorName()
|
||||
})
|
||||
ElMessage.success('建档上线成功')
|
||||
// #8 T3(建档提交):MES 已附 PLC↔MES 对账结果,命中则弹「两项」提示(不拦)
|
||||
if (data && data.hasMismatch) showMismatch(data)
|
||||
// 建档成功:清空本次识别,准备下一台
|
||||
form.sn = ''
|
||||
// 建档后该点位已被占用:回填下一个默认空闲位
|
||||
form.orderNo = ''
|
||||
product.scannedSn = ''
|
||||
product.code = ''; product.name = ''; product.workOrderId = 0
|
||||
product.snMode = 0; product.quantity = 0; product.route = ''; product.statusText = ''
|
||||
product.ownershipType = ''; product.ownershipNo = ''; product.flowCombination = []
|
||||
form.pointNo = defaultStartPointNo()
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
submitting.value = false
|
||||
}
|
||||
|
||||
// 进入面板即实时拉取工单列表与点位台账(15c/15d:默认 10 条,输入关键字远程搜索)
|
||||
loadOrders()
|
||||
refreshPoints()
|
||||
if (!form.pointNo) form.pointNo = defaultStartPointNo()
|
||||
|
||||
// #8 T3 PLC↔MES 对账提示弹窗(两项选择,仅前端确认,不调服务端 override——override 仅管理员级角色)
|
||||
// #8 T3 PLC↔MES 对账提示弹窗(两项选择,仅前端确认)
|
||||
const mmDlg = reactive({ show: false, detail: '', stationNo: 0 })
|
||||
function showMismatch(mm) {
|
||||
mmDlg.detail =
|
||||
@@ -428,9 +334,6 @@ function ackMismatch(choice) {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 2026-11-11 修复:原两列栅格在「工单详情」默认折叠(v-if 不渲染)时,
|
||||
footer 变成第 2 个子元素被 nth-child(2) 规则错位拉伸,右列大留白;
|
||||
改单列流式布局:工单选择 → 工单详情(展开时) → 提交区,紧凑无空置 */
|
||||
.online-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -452,18 +355,25 @@ function ackMismatch(choice) {
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.wo-card {
|
||||
margin: 4px 0 0 82px;
|
||||
padding: 6px 12px;
|
||||
background: #f5f9ff;
|
||||
border: 1px solid #d9e8ff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.wo-empty {
|
||||
color: #909399;
|
||||
font-size: 15px;
|
||||
padding: 12px 0;
|
||||
font-size: 14px;
|
||||
padding: 10px 0 0 82px;
|
||||
}
|
||||
.wo-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 12px;
|
||||
padding: 9px 0;
|
||||
border-bottom: 1px solid #f0f2f5;
|
||||
font-size: 16px;
|
||||
padding: 7px 0;
|
||||
border-bottom: 1px solid #e4ecf7;
|
||||
font-size: 15px;
|
||||
}
|
||||
.wo-row:last-child {
|
||||
border-bottom: none;
|
||||
@@ -486,15 +396,6 @@ function ackMismatch(choice) {
|
||||
.grow {
|
||||
flex: 1;
|
||||
}
|
||||
.product-line {
|
||||
margin: -4px 0 12px 82px;
|
||||
font-size: 15px;
|
||||
color: #606266;
|
||||
}
|
||||
.product-line .code {
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.point-tip {
|
||||
margin: -4px 0 12px 82px;
|
||||
font-size: 13px;
|
||||
|
||||
@@ -66,25 +66,8 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ② 任务区(工单 + 流程) -->
|
||||
<section class="card task-card">
|
||||
<div class="card-title">工艺</div>
|
||||
<div class="task-grid">
|
||||
<div class="kv">
|
||||
<span>工艺名称</span>
|
||||
<b>{{ flowName }}</b>
|
||||
<el-tag :type="flowActive ? 'success' : 'info'" size="large" effect="dark">
|
||||
{{ flowActive ? '启用' : '停用' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="kv">
|
||||
<span>工单号</span>
|
||||
<el-select v-model="orderNo" size="large" class="order-el" placeholder="选择工单号">
|
||||
<el-option v-for="(o, i) in orderNos" :key="i" :label="o" :value="o" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- 2026-11-16 作业页去冗余:删除原「工单号选择框 + 工艺名称全称」任务区。
|
||||
工单由扫码件归属确定(扫错单红字硬拦截),步骤采集才是本页唯一职责。 -->
|
||||
|
||||
<!-- ③ 步骤采集:未选工件时整区置灰不可填,避免工人以为已开工。
|
||||
2026-11-10 交互改版:全量步骤(含 NONE 仅记录)按 seq 依次展示,当前步高亮 + 顶部进度,
|
||||
@@ -284,9 +267,7 @@ import {
|
||||
canReport,
|
||||
criterionOk,
|
||||
displaySteps,
|
||||
flowActive,
|
||||
flowId,
|
||||
flowName,
|
||||
goNextFrom,
|
||||
hasNg,
|
||||
loadBind,
|
||||
@@ -551,9 +532,10 @@ watch(sn, (v) => {
|
||||
})
|
||||
|
||||
const blockTip = computed(() => {
|
||||
if (wrongOrderBlock.value) return '错单已拦截:该件属于其他工单,请拿到所属工单工位重扫(当前件 ' + wrongOrderBlock.value + ')'
|
||||
if (paused.value) return '已停止接单' + (state.pauseReason ? ':' + state.pauseReason : '') + ',恢复接单后才能报工'
|
||||
if (!sn.value) return '请先扫描工件序列号'
|
||||
if (!orderNo.value) return '请选择工单号'
|
||||
if (!orderNo.value) return '本工位尚未加载到工单,请稍候或联系班组长核对工位任务'
|
||||
if (!flowId.value) return '本工位未绑定工艺流程,无法报工'
|
||||
if (bindBlocking.value) return '装配物料未绑齐:' + (state.bindPanel?.missing || '缺料')
|
||||
if (missingSteps.value.length) return '还有步骤未录入:' + (missingSteps.value[0].name || '未命名步骤')
|
||||
@@ -622,39 +604,28 @@ watch(
|
||||
() => { if (sn.value && torqueStepCount.value) focusNextTorque() }
|
||||
)
|
||||
|
||||
// 扫码错单确认(2026-11-16 工位物理互斥配套):扫 SN 查追溯(SN→工单号),属于其他工单时
|
||||
// 不再静默切换——弹窗让工人明确确认「切换工单」或「保持当前工单」,杜绝扫错件静默记错账。
|
||||
// 报工提交仍带当前 orderNo,后端会做第二道一致性强校验(不一致直接拒绝)。
|
||||
async function autoSwitchOrder(snVal) {
|
||||
// 扫码错单硬拦截(2026-11-16 工位物理互斥 + 主控包项7):扫 SN 查追溯(SN→工单号),
|
||||
// 属于其他工单时【不弹切换确认框、不自动切单】——直接红字报错拦截并阻止本件在本工位继续作业/报工,
|
||||
// 杜绝"扫错件顺手切单→记错账"。工人须把件拿到其所属工单的工位重扫。
|
||||
// 后端 workpiece.go 报工仍有第二道一致性强校验(不一致直接拒绝),前端是第一道硬闸。
|
||||
const wrongOrderBlock = ref('') // 当前被错单拦截的 SN(非空时禁止上料/报工)
|
||||
async function checkScanOrder(snVal) {
|
||||
wrongOrderBlock.value = ''
|
||||
let wo = ''
|
||||
try {
|
||||
const data = await getTrace({ sn: snVal })
|
||||
wo = data?.workpiece?.orderNo || ''
|
||||
} catch {
|
||||
return // 产品序号(SN) 无追溯数据(尚未上线的新件)不打扰
|
||||
return true // 无追溯数据(尚未上线的新件)放行,由后端建档时校验
|
||||
}
|
||||
if (!wo || wo === orderNo.value) return
|
||||
if (!orderNos.value.includes(wo)) {
|
||||
ElMessage.warning(`扫码件 ${snVal} 属于工单 ${wo},不在本工位可选工单中;已保持当前工单 ${orderNo.value}`)
|
||||
return
|
||||
}
|
||||
let switched = false
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`扫码件 ${snVal} 属于工单 ${wo},与当前作业工单 ${orderNo.value} 不一致。是否切换到工单 ${wo}?`,
|
||||
'工单不一致确认',
|
||||
{ confirmButtonText: '切换到 ' + wo, cancelButtonText: '保持当前工单', type: 'warning' }
|
||||
)
|
||||
switched = true
|
||||
} catch {
|
||||
/* 工人选择保持 */
|
||||
}
|
||||
if (!switched) {
|
||||
ElMessage.info(`已保持当前工单 ${orderNo.value},未切换`)
|
||||
return
|
||||
}
|
||||
orderNo.value = wo
|
||||
ElMessage.success('已切换到工单 ' + wo)
|
||||
if (!wo || wo === orderNo.value) return true
|
||||
wrongOrderBlock.value = snVal
|
||||
const inStation = orderNos.value.includes(wo)
|
||||
ElMessage.error(
|
||||
`错误:该件属于工单 ${wo},当前工位为工单 ${orderNo.value || '未确定'},请核对后重扫;` +
|
||||
(inStation ? '本件不能在本工位作业。' : '该工单也不在本工位可选范围内。')
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
// 扫码后:若 SN 已在本工位直接开干;否则提示去"上料/取料"
|
||||
@@ -662,7 +633,8 @@ async function onScan() {
|
||||
const v = scanInput.value.trim()
|
||||
if (!v) return
|
||||
scanInput.value = ''
|
||||
autoSwitchOrder(v)
|
||||
// 错单硬拦截:属于其他工单的件直接红字报错并停止装载(项7)
|
||||
if (!(await checkScanOrder(v))) return
|
||||
const onPoint = state.points.find((p) => p.currentSn === v && p.occupied)
|
||||
if (onPoint && String(onPoint.pointNo) === String(stationNo.value)) {
|
||||
setCurrentSn(v)
|
||||
@@ -686,6 +658,8 @@ async function onTakeIn() {
|
||||
focusScan()
|
||||
return
|
||||
}
|
||||
// 错单硬拦截(项7):上料前再查一次归属,防止未走 onScan 直接点「上料/取料」
|
||||
if (!(await checkScanOrder(v))) return
|
||||
taking.value = true
|
||||
try {
|
||||
// 扫码即到位凭证:不再下发移料指令,直接记账到本工位
|
||||
@@ -816,6 +790,10 @@ function onSignCancel() {
|
||||
}
|
||||
|
||||
async function onProcessDone() {
|
||||
if (wrongOrderBlock.value) {
|
||||
ElMessage.error(`错误:该件属于其他工单(当前件 ${wrongOrderBlock.value}),请拿到所属工单工位重扫,本工位禁止报工`)
|
||||
return
|
||||
}
|
||||
if (!canReport.value) {
|
||||
ElMessage.warning(blockTip.value || '当前不满足报工条件')
|
||||
return
|
||||
@@ -1109,20 +1087,6 @@ defineExpose({ focusScan })
|
||||
margin-top: 10px;
|
||||
color: #606266;
|
||||
}
|
||||
.task-grid .kv {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.task-grid .kv span {
|
||||
color: #909399;
|
||||
min-width: 72px;
|
||||
}
|
||||
.order-el {
|
||||
flex: 1;
|
||||
}
|
||||
.steps-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<el-dialog v-model="visible" title="我的工作量" width="80%" top="6vh" destroy-on-close>
|
||||
<div class="wl-filter">
|
||||
<span class="lab">工位</span>
|
||||
<el-select v-model="wlStation" size="large" class="sel" placeholder="全部工位">
|
||||
<el-select v-model="wlStation" filterable size="large" class="sel" placeholder="全部工位">
|
||||
<el-option label="全部工位" :value="0" />
|
||||
<el-option v-for="s in stationOptions" :key="s" :label="'工位 ' + s" :value="s" />
|
||||
</el-select>
|
||||
|
||||
@@ -96,6 +96,7 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodGet, Path: "/api/wip", Handler: wipHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/bom", Handler: bomHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/order/query", Handler: orderQueryHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/order/by-sn", Handler: snOrderLookupHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/trace", Handler: traceHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/workpiece/online", Handler: onlineHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/workpiece/done", Handler: doneHandler(ctx)},
|
||||
|
||||
@@ -83,6 +83,38 @@ func orderQueryHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// snOrderLookupHandler GET /api/order/by-sn?sn= —— 扫 SN 秒认工单。
|
||||
// 2026-11-16 拍板:建工单时已预生成全部 SN,上线建档只需扫 SN,不再让工人手选工单。
|
||||
// 代理 MES /api/internal/workpiece/lookup,返回工单号/产品/归属/数量/工艺组合/skN 口径。
|
||||
func snOrderLookupHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
sn := strings.TrimSpace(r.URL.Query().Get("sn"))
|
||||
if sn == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少 sn 参数")
|
||||
return
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/workpiece/lookup", url.Values{"sn": {sn}})
|
||||
if err != nil {
|
||||
var bizErr *mes.BizError
|
||||
if errors.As(err, &bizErr) {
|
||||
msg := mesRespCode(bizErr.Body)
|
||||
if msg == "" {
|
||||
msg = bizErr.Error()
|
||||
}
|
||||
fail(w, http.StatusConflict, msg)
|
||||
return
|
||||
}
|
||||
failMes(w, err, "MES 服务不可达,无法核对 SN,请检查网络后重试")
|
||||
return
|
||||
}
|
||||
if msg := mesRespCode(body); msg != "" {
|
||||
fail(w, http.StatusConflict, msg)
|
||||
return
|
||||
}
|
||||
passJSON(w, body)
|
||||
}
|
||||
}
|
||||
|
||||
// traceHandler GET /api/trace?sn= —— 代理 MES /api/internal/workpiece/trace。
|
||||
// 下线完工面板扫 SN 后展示工件状态/工序时间线/拧紧等追溯信息。
|
||||
func traceHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>工位终端</title>
|
||||
<!-- 系统图标:工位终端屏(内联 SVG,避免依赖外部文件) -->
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='6' fill='%231668dc'/><rect x='6' y='7' width='20' height='14' rx='2' fill='none' stroke='%23fff' stroke-width='2'/><path d='M12 25h8M16 21v4' stroke='%23fff' stroke-width='2' stroke-linecap='round'/></svg>">
|
||||
<script type="module" crossorigin src="/assets/index-DOqmD9pu.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DSAMO4Xc.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D2ePuXyL.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user