feat: 重构 AGV 对接与在制品查询,新增 PLC 手动监控功能
This commit is contained in:
@@ -49,7 +49,7 @@ import { setAuth } from '../utils/request'
|
||||
const router = useRouter()
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
// null=未加载;0=上线位是合法工位,不能用 falsy 判断
|
||||
// null=未加载;工位号须为正整数,不能用 falsy 判断
|
||||
const fixedStation = ref(null)
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -57,8 +57,8 @@ const loading = ref(false)
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const cfg = await getConfig()
|
||||
// 0=上线位、13=下线位为合法虚拟工位,>=0 都算加载成功
|
||||
if (typeof cfg?.stationNo === 'number' && cfg.stationNo >= 0) fixedStation.value = cfg.stationNo
|
||||
// 工位号为正整数才算加载成功
|
||||
if (typeof cfg?.stationNo === 'number' && cfg.stationNo > 0) fixedStation.value = cfg.stationNo
|
||||
} catch {
|
||||
// 网络异常时保留 0,登录会提示配置未加载
|
||||
}
|
||||
@@ -88,7 +88,15 @@ async function submit() {
|
||||
try {
|
||||
const stats = await getSyncStats()
|
||||
const n = Number(stats?.pendingTotal || 0)
|
||||
if (n > 0) {
|
||||
const d = Number(stats?.deadTotal || 0)
|
||||
if (d > 0) {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: `您有 ${d} 条数据被 MES 拒绝、需人工处理(如点位已被占用):请点顶部「待同步」查看失败原因、重选点位后再次提交`,
|
||||
duration: 8000,
|
||||
showClose: true
|
||||
})
|
||||
} else if (n > 0) {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: `您上次有 ${n} 条报工数据发送失败,仍保留在本机;留意顶部「待同步」即可,系统会自动重发`,
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
<div class="spacer"></div>
|
||||
|
||||
<el-button size="large" :type="pendingTotal ? 'warning' : 'default'" @click="manualFlush">
|
||||
待同步 {{ pendingTotal }}
|
||||
<el-button size="large" :type="pendingTotal || deadTotal ? 'warning' : 'default'" @click="sqRef?.open()">
|
||||
待同步 {{ pendingTotal }}<template v-if="deadTotal"> · 待处理 {{ deadTotal }}</template>
|
||||
</el-button>
|
||||
<el-button size="large" @click="wlRef?.open()">我的工作量</el-button>
|
||||
<span class="user-name">{{ user.name || user.username || '-' }}</span>
|
||||
@@ -52,10 +52,6 @@
|
||||
<el-tab-pane v-if="hasTab('material')" label="物料 / 叫料" name="material">
|
||||
<MaterialPanel />
|
||||
</el-tab-pane>
|
||||
<!-- 页签 key 沿用 'move':兼容存量工位 visibleTabs 配置(历史为移料,现为产线点位上料/下料) -->
|
||||
<el-tab-pane v-if="hasTab('move')" label="产线点位(上料/下料)" name="move">
|
||||
<LinePointPanel />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="hasTab('pdf')" label="工艺文件" name="pdf">
|
||||
<PdfPanel />
|
||||
</el-tab-pane>
|
||||
@@ -65,6 +61,7 @@
|
||||
</el-tabs>
|
||||
|
||||
<WorkloadDialog ref="wlRef" />
|
||||
<SyncQueueDialog ref="sqRef" />
|
||||
|
||||
<!-- 全局帮助:右下角悬浮「?」,内容随当前页签切换 -->
|
||||
<PageHelp :data="helpData" />
|
||||
@@ -77,23 +74,22 @@ import { useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import WorkPanel from './panels/WorkPanel.vue'
|
||||
import MaterialPanel from './panels/MaterialPanel.vue'
|
||||
import LinePointPanel from './panels/LinePointPanel.vue'
|
||||
import PdfPanel from './panels/PdfPanel.vue'
|
||||
import InspectPanel from './panels/InspectPanel.vue'
|
||||
import OnlinePanel from './panels/OnlinePanel.vue'
|
||||
import OfflinePanel from './panels/OfflinePanel.vue'
|
||||
import WorkloadDialog from './panels/WorkloadDialog.vue'
|
||||
import SyncQueueDialog from './panels/SyncQueueDialog.vue'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
import {
|
||||
helpInspect,
|
||||
helpLinePoint,
|
||||
helpMaterial,
|
||||
helpOffline,
|
||||
helpOnline,
|
||||
helpPdf,
|
||||
helpWorkstation
|
||||
} from '../help'
|
||||
import { stationLogout, syncFlush } from '../api'
|
||||
import { stationLogout } from '../api'
|
||||
import { clearAuth } from '../utils/request'
|
||||
import {
|
||||
hasNg,
|
||||
@@ -105,6 +101,7 @@ import {
|
||||
loadTight,
|
||||
loadTask,
|
||||
loadWip,
|
||||
deadTotal,
|
||||
orderNo,
|
||||
paused,
|
||||
pauseReason,
|
||||
@@ -123,10 +120,6 @@ const workRef = ref()
|
||||
const wlRef = ref()
|
||||
const clock = ref('')
|
||||
const stationName = computed(() => state.task?.stationName || '')
|
||||
// 0=上线位、13=下线位为虚拟工位,分别展示上线建档 / 下线完工面板
|
||||
const isOnline = computed(() => Number(stationNo.value) === 0)
|
||||
const isOffline = computed(() => Number(stationNo.value) === 13)
|
||||
const isVirtual = computed(() => isOnline.value || isOffline.value)
|
||||
|
||||
// 任务下发页签配置后,当前页签若被隐藏则切到第一个可见页签
|
||||
watch(visibleTabs, () => {
|
||||
@@ -141,7 +134,6 @@ const HELP_MAP = {
|
||||
offline: helpOffline,
|
||||
work: helpWorkstation,
|
||||
material: helpMaterial,
|
||||
move: helpLinePoint,
|
||||
pdf: helpPdf,
|
||||
inspect: helpInspect
|
||||
}
|
||||
@@ -158,14 +150,6 @@ function tickClock() {
|
||||
clock.value = `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`
|
||||
}
|
||||
|
||||
async function manualFlush() {
|
||||
try {
|
||||
const data = await syncFlush()
|
||||
ElMessage.success(`本轮同步成功 ${data?.count ?? 0} 条`)
|
||||
loadStats()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
// 退出前先本地退出(服务端登出失败也照样退),再按响应提醒本人未发送成功的条数
|
||||
let data = null
|
||||
@@ -175,10 +159,14 @@ async function logout() {
|
||||
clearAuth()
|
||||
router.push('/login')
|
||||
const n = Number(data?.pendingTotal || 0)
|
||||
if (n > 0) {
|
||||
const d = Number(data?.deadTotal || 0)
|
||||
if (n > 0 || d > 0) {
|
||||
const parts = []
|
||||
if (n > 0) parts.push(`${n} 条待自动重传`)
|
||||
if (d > 0) parts.push(`${d} 条待人工处理(被 MES 拒绝,需重选点位后再次提交)`)
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: `您有 ${n} 条报工数据发送失败,仍保留在本机(只有您本人登录可见/可发送),下次登录后请留意「待同步」`,
|
||||
message: `您有数据未上报成功,仍保留在本机(只有您本人登录可见/可发送):${parts.join(';')}。下次登录后请点「待同步」处理。`,
|
||||
duration: 8000,
|
||||
showClose: true
|
||||
})
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
<template>
|
||||
<div class="line-point-panel">
|
||||
<!-- 产线点位图(唯一事实源:每点位当前工件)+ 人工上料/下料登记 -->
|
||||
<section class="card">
|
||||
<div class="card-title">
|
||||
产线点位(上料/下料登记)
|
||||
<el-button size="large" @click="clearSel">清空选择</el-button>
|
||||
<el-button size="large" @click="loadPoints">刷新</el-button>
|
||||
</div>
|
||||
|
||||
<div class="belt">
|
||||
<div
|
||||
v-for="p in beltPoints"
|
||||
:key="p.pointNo"
|
||||
class="pt"
|
||||
:class="[typeClass(p), { sel: selected === p.pointNo, mine: String(p.stationNo) === String(stationNo) }]"
|
||||
@click="onPick(p)"
|
||||
>
|
||||
<div class="pt-name">{{ p.pointNo }}</div>
|
||||
<div class="pt-sn">{{ p.occupied ? p.currentSn : '空' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dock-line" v-if="myDocks.length">
|
||||
<span class="lab">本工位接驳台(AGV 点位)</span>
|
||||
<div v-for="d in myDocks" :key="d.pointNo" class="pt dock">
|
||||
<div class="pt-name">{{ d.pointNo }}</div>
|
||||
<div class="pt-sn">物料</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ops">
|
||||
<div class="sel-text">
|
||||
已选点位:<b>{{ selected || '未选择' }}</b>
|
||||
</div>
|
||||
<el-button size="large" :disabled="!selected" @click="onIn">上料登记</el-button>
|
||||
<el-button type="danger" size="large" :disabled="!selected" @click="onOut">下料释放</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { occupyLinePoint } from '../../api'
|
||||
import {
|
||||
beltPoints,
|
||||
loadPoints,
|
||||
myDocks,
|
||||
orderNo,
|
||||
pointByNo,
|
||||
stationNo
|
||||
} from '../../store/station'
|
||||
|
||||
const selected = ref('')
|
||||
|
||||
function clearSel() {
|
||||
selected.value = ''
|
||||
}
|
||||
|
||||
function typeClass(p) {
|
||||
if (p.pointType === 'STATION') return 't-station'
|
||||
if (p.pointType === 'CACHE') return 't-cache'
|
||||
if (p.pointType === 'FEED') return 't-feed'
|
||||
return 't-end'
|
||||
}
|
||||
|
||||
function onPick(p) {
|
||||
selected.value = p.pointNo
|
||||
}
|
||||
|
||||
async function onIn() {
|
||||
const p = pointByNo(selected.value)
|
||||
if (!p) return
|
||||
if (p.occupied) {
|
||||
ElMessage.warning(p.pointNo + ' 已被 ' + p.currentSn + ' 占用')
|
||||
return
|
||||
}
|
||||
let sn = ''
|
||||
try {
|
||||
const r = await ElMessageBox.prompt('输入要登记到 ' + p.pointNo + ' 的工件SN', '上料登记', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
inputPlaceholder: '工件SN'
|
||||
})
|
||||
sn = (r.value || '').trim()
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (!sn) return
|
||||
try {
|
||||
await occupyLinePoint({ pointNo: p.pointNo, sn, orderNo: orderNo.value || '', action: 'IN' })
|
||||
ElMessage.success('已登记上料')
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
async function onOut() {
|
||||
const p = pointByNo(selected.value)
|
||||
if (!p || !p.occupied) {
|
||||
ElMessage.warning('该点位当前无工件')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认把「${p.currentSn}」从 ${p.pointNo} 下料释放?`, '下料确认', {
|
||||
confirmButtonText: '确认下料',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await occupyLinePoint({ pointNo: p.pointNo, sn: p.currentSn, orderNo: '', action: 'OUT' })
|
||||
ElMessage.success('已释放点位')
|
||||
clearSel()
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.line-point-panel {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
.card {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 14px 16px;
|
||||
box-shadow: 0 1px 6px rgba(0, 21, 41, 0.08);
|
||||
}
|
||||
.card-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.belt {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
.pt {
|
||||
min-width: 78px;
|
||||
border: 2px solid #dcdfe6;
|
||||
border-radius: 8px;
|
||||
padding: 8px 6px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
background: #fafafa;
|
||||
}
|
||||
.pt-name {
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
}
|
||||
.pt-sn {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
margin-top: 4px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.t-station { background: #e8f3ff; border-color: #79bbff; }
|
||||
.t-cache { background: #f4f4f5; border-color: #d3dce6; }
|
||||
.t-end { background: #f3e8ff; border-color: #b488f0; }
|
||||
.t-feed { background: #fff7e6; border-color: #ffc069; }
|
||||
.pt.mine { box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25); }
|
||||
.pt.sel { border-color: #f56c6c; background: #fef0f0; }
|
||||
.dock-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.dock-line .lab {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
}
|
||||
.pt.dock {
|
||||
background: #eafaf1;
|
||||
border-color: #67c23a;
|
||||
min-width: 92px;
|
||||
cursor: default;
|
||||
}
|
||||
.ops {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 14px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.sel-text {
|
||||
font-size: 15px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.belt {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -53,6 +53,17 @@
|
||||
title="存在不合格项,请确认已完成返修/复检后再入库。" style="margin:10px 0"
|
||||
/>
|
||||
|
||||
<div class="form-row" style="margin-top:10px">
|
||||
<span class="lab">下料位置</span>
|
||||
<el-select v-model="pointNo" 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>
|
||||
</el-select>
|
||||
<el-button size="large" @click="refreshPoints">刷新点位</el-button>
|
||||
</div>
|
||||
<div class="point-tip">下料位置 = 完工后工件实际落入的末端下料检测位,完工时自动登记占用;仅空闲位可选。</div>
|
||||
|
||||
<div class="sub-title">工艺时间线</div>
|
||||
<el-table :data="processTimeline" border size="large" max-height="260">
|
||||
<el-table-column label="工艺" min-width="120">
|
||||
@@ -73,14 +84,14 @@
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<!-- ② 下线位在制品 -->
|
||||
<!-- ② 末端待取件工件(已报工至工艺路线末端,scope=end-pending 查询) -->
|
||||
<section class="card">
|
||||
<div class="card-title">
|
||||
下线位待完工工件
|
||||
末端待取件工件
|
||||
<el-tag size="large" effect="plain">{{ wip.length }}</el-tag>
|
||||
<el-button link type="primary" size="large" @click="loadWip(13)">刷新</el-button>
|
||||
<el-button link type="primary" size="large" @click="loadWipScope('end-pending')">刷新</el-button>
|
||||
</div>
|
||||
<el-empty v-if="!wip.length" description="下线位暂无待完工工件" :image-size="70" />
|
||||
<el-empty v-if="!wip.length" description="暂无末端待取件工件" :image-size="70" />
|
||||
<el-table v-else :data="wip" border size="large" max-height="420" @row-click="pickWip">
|
||||
<el-table-column prop="sn" label="工件 SN" min-width="160" />
|
||||
<el-table-column prop="orderNo" label="工单号" min-width="140" />
|
||||
@@ -107,31 +118,79 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getTrace, offlineFinish } from '../../api'
|
||||
import { loadWip, operatorName, wip } from '../../store/station'
|
||||
import { loadPoints, loadWipScope, operatorName, state, wip } from '../../store/station'
|
||||
|
||||
const snInput = ref('')
|
||||
const trace = ref(null)
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
// 下料位置(C/H 3.2):末端下料检测位 G11(上排)/ G12(下排),只列空闲位
|
||||
const pointNo = ref('')
|
||||
|
||||
const workpiece = computed(() => trace.value?.workpiece || {})
|
||||
const processTimeline = computed(() => trace.value?.processTimeline || [])
|
||||
const stepData = computed(() => trace.value?.stepData || [])
|
||||
const torqueRecords = computed(() => trace.value?.torqueRecords || [])
|
||||
|
||||
// 下料位置候选项:END-U=G11(上排)/ END-D=G12(下排),只列空闲位(label=中文名(编号))
|
||||
const endPointGroups = computed(() => {
|
||||
const up = []
|
||||
const down = []
|
||||
for (const p of state.points || []) {
|
||||
if (p.pointType !== 'END' || p.occupied) continue
|
||||
const item = {
|
||||
pointNo: p.pointNo,
|
||||
label: `${p.pointNo === 'END-U' ? '下料检测位 G11' : '下料检测位 G12'}(${p.pointNo === 'END-U' ? '上排' : '下排'})`
|
||||
}
|
||||
if (p.pointNo === 'END-U') up.push(item)
|
||||
else down.push(item)
|
||||
}
|
||||
return [
|
||||
{ label: '上排(G11)', options: up },
|
||||
{ label: '下排(G12)', options: down }
|
||||
].filter((g) => g.options.length)
|
||||
})
|
||||
// 默认落点:按工件所在工位上下排自动选(上排=奇数工位 1/3/5/7/9/11,下排=偶数 2/4/6/8/10/12);
|
||||
// 首选排被占用时回退另一排;都无空闲位返回空(阻断提交)。
|
||||
function autoPickEndPoint() {
|
||||
const wp = trace.value?.workpiece
|
||||
if (!wp || !wp.sn) {
|
||||
pointNo.value = ''
|
||||
return
|
||||
}
|
||||
const st = Number(wp.atStationNo || wp.currentStationNo || 0)
|
||||
const want = st > 0 && st % 2 === 0 ? 'END-D' : 'END-U'
|
||||
const free = endPointGroups.value
|
||||
.flatMap((g) => g.options)
|
||||
.sort((a, b) => (a.pointNo === want ? -1 : b.pointNo === want ? 1 : 0))
|
||||
pointNo.value = free.length ? free[0].pointNo : ''
|
||||
}
|
||||
watch(workpiece, autoPickEndPoint)
|
||||
// 点位台账异步到达 / 刷新后:当前选择失效(被判占用)时重算
|
||||
watch(endPointGroups, () => {
|
||||
const valid = endPointGroups.value.some((g) => g.options.some((o) => o.pointNo === pointNo.value))
|
||||
if (!valid) autoPickEndPoint()
|
||||
})
|
||||
async function refreshPoints() {
|
||||
try {
|
||||
await loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
const doneProcessCount = computed(() => processTimeline.value.length)
|
||||
const torqueTotal = computed(() => torqueRecords.value.length)
|
||||
const torqueOk = computed(() => torqueRecords.value.filter((t) => t.result === 'OK').length)
|
||||
const torqueNg = computed(() => torqueRecords.value.some((t) => t.result === 'NG'))
|
||||
const stepNgCount = computed(() => stepData.value.filter((s) => s.isOK === false).length)
|
||||
|
||||
const canFinish = computed(() => !!snInput.value && !!trace.value && workpiece.value.status !== 'DONE')
|
||||
const canFinish = computed(() => !!snInput.value && !!trace.value && !!pointNo.value && workpiece.value.status !== 'DONE')
|
||||
const blockTip = computed(() => {
|
||||
if (!snInput.value) return '请先扫描工件 SN'
|
||||
if (!trace.value) return '请先查询该工件的完工状态'
|
||||
if (!pointNo.value) return '请选择下料位置(两个末端下料检测位都被占用时请联系班长协调)'
|
||||
if (workpiece.value.status === 'DONE') return '该工件已完工入库'
|
||||
return ''
|
||||
})
|
||||
@@ -185,7 +244,7 @@ async function onFinish() {
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认工件「${snInput.value}」完工入库并回流 WMS 成品库存?`,
|
||||
`确认工件「${snInput.value}」完工入库并回流 WMS 成品库存?下料位置:${pointNo.value}`,
|
||||
'完工入库确认',
|
||||
{ confirmButtonText: '确认入库', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
@@ -198,17 +257,21 @@ async function onFinish() {
|
||||
sn: snInput.value,
|
||||
batchItems: [],
|
||||
serialItems: [],
|
||||
pointNo: pointNo.value,
|
||||
operator: operatorName()
|
||||
})
|
||||
ElMessage.success(data?.queued ? 'MES 暂不可达,已离线缓存,稍后自动重传' : '完工入库成功,已回流 WMS')
|
||||
snInput.value = ''
|
||||
trace.value = null
|
||||
loadWip(13)
|
||||
pointNo.value = ''
|
||||
loadWipScope('end-pending')
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
submitting.value = false
|
||||
}
|
||||
|
||||
loadWip(13)
|
||||
loadWipScope('end-pending')
|
||||
refreshPoints()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -290,6 +353,11 @@ loadWip(13)
|
||||
color: #e6a23c;
|
||||
font-size: 15px;
|
||||
}
|
||||
.point-tip {
|
||||
margin: -4px 0 10px 82px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.offline-panel {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
@@ -29,6 +29,17 @@
|
||||
<el-button v-if="product.snMode === 2" size="large" @click="genSn">自动生成</el-button>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<span class="lab">工件当前位置</span>
|
||||
<el-select v-model="form.pointNo" size="large" class="grow" placeholder="选择工件当前位置(只列空闲点位)" filterable>
|
||||
<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>
|
||||
|
||||
<el-alert
|
||||
:type="product.snMode === 1 ? 'warning' : 'info'"
|
||||
:closable="false"
|
||||
@@ -76,14 +87,14 @@
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<!-- ③ 上线位在制品 -->
|
||||
<!-- ③ 待流转在制品(已建档未分配工位,scope=pending 查询) -->
|
||||
<section class="card">
|
||||
<div class="card-title">
|
||||
上线位在制品
|
||||
待流转在制品
|
||||
<el-tag size="large" effect="plain">{{ onlineWip.length }}</el-tag>
|
||||
<el-button link type="primary" size="large" @click="loadWip(0)">刷新</el-button>
|
||||
<el-button link type="primary" size="large" @click="loadWipScope('pending')">刷新</el-button>
|
||||
</div>
|
||||
<el-empty v-if="!onlineWip.length" description="上线位暂无待流转工件" :image-size="60" />
|
||||
<el-empty v-if="!onlineWip.length" description="暂无待流转工件" :image-size="60" />
|
||||
<el-table v-else :data="onlineWip" border size="large" max-height="300">
|
||||
<el-table-column prop="sn" label="工件 SN" min-width="160" />
|
||||
<el-table-column prop="orderNo" label="工单号" min-width="140" />
|
||||
@@ -118,12 +129,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getBom, mismatchCheck, onlineRegister, queryOrder } from '../../api'
|
||||
import { loadWip, operatorName, wip } from '../../store/station'
|
||||
import { loadPoints, loadWipScope, operatorName, state, wip } from '../../store/station'
|
||||
|
||||
const form = reactive({ orderNo: '', sn: '', materialChecked: false })
|
||||
const form = reactive({ orderNo: '', sn: '', materialChecked: false, pointNo: '' })
|
||||
const product = reactive({ code: '', name: '', workOrderId: 0, snMode: 0 })
|
||||
const bomItems = ref([])
|
||||
const orders = ref([])
|
||||
@@ -145,8 +156,48 @@ const snTip = computed(() => {
|
||||
return '该产品的序列号管理方式未选择:请先在 MES 产品型号/物料档案选择「序列号=是/否」,否则无法建档上线。'
|
||||
})
|
||||
|
||||
// 上线位在制品:in-process 接口 stationNo<=0 返回全部,此处按 currentStation===0 筛选上线位
|
||||
const onlineWip = computed(() => (wip.value || []).filter((r) => Number(r.currentStation) === 0))
|
||||
// 待流转在制品:MES 已按 scope=pending 过滤(ONLINE 未分配工位),此处直接透出
|
||||
const onlineWip = computed(() => wip.value || [])
|
||||
|
||||
// 工件当前位置:按产线点位台账分组(C/H 3.1),只列空闲点位。
|
||||
// 分组 = 上料位(FEED) / 缓存位(CACHE) / 停靠位(DOCK=AGV接驳台) / 工位(STATION);
|
||||
// label = 中文名(编号),value = 编号。
|
||||
const POINT_TYPE_GROUP = { FEED: '上料位', CACHE: '缓存位', DOCK: '停靠位', STATION: '工位' }
|
||||
const startPointGroups = computed(() => {
|
||||
const groups = {}
|
||||
for (const p of state.points || []) {
|
||||
if (!p || p.occupied) continue
|
||||
const g = POINT_TYPE_GROUP[p.pointType]
|
||||
if (!g) continue
|
||||
if (!groups[g]) groups[g] = []
|
||||
groups[g].push({ pointNo: p.pointNo, label: `${p.label || p.pointNo}(${p.pointNo})` })
|
||||
}
|
||||
for (const g of Object.keys(groups)) {
|
||||
groups[g].sort((a, b) => a.pointNo.localeCompare(b.pointNo, 'zh-Hans-CN', { numeric: true }))
|
||||
}
|
||||
return Object.keys(groups).map((label) => ({ label, options: groups[label] }))
|
||||
})
|
||||
|
||||
// 默认位置(按现有口径):本工位点位(空闲)→ 缓存位 C1 → 上料位;都不行返回空(阻断提交)
|
||||
function defaultStartPointNo() {
|
||||
const pts = state.points || []
|
||||
const free = (p) => p && !p.occupied
|
||||
const mine = pts.find((p) => p.pointType === 'STATION' && String(p.pointNo) === String(state.stationNo))
|
||||
if (free(mine)) return mine.pointNo
|
||||
if (free(pts.find((p) => p.pointNo === 'C1'))) return 'C1'
|
||||
if (free(pts.find((p) => p.pointType === 'FEED'))) return pts.find((p) => p.pointType === 'FEED').pointNo
|
||||
return ''
|
||||
}
|
||||
// 点位台账刷新后:未选/已失效(被他人占用)时回填默认值
|
||||
watch(startPointGroups, () => {
|
||||
const valid = (startPointGroups.value || []).some((g) => g.options.some((o) => o.pointNo === form.pointNo))
|
||||
if (!valid) form.pointNo = defaultStartPointNo()
|
||||
})
|
||||
async function refreshPoints() {
|
||||
try {
|
||||
await loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
// 工单下拉:仅展示未完工的活跃工单(CREATED/RELEASED/IN_PROGRESS)
|
||||
const ACTIVE_STATUS = ['CREATED', 'RELEASED', 'IN_PROGRESS']
|
||||
@@ -163,12 +214,14 @@ const orderOptions = computed(() =>
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
!!form.orderNo &&
|
||||
!!form.pointNo &&
|
||||
product.snMode !== 0 &&
|
||||
(product.snMode === 2 || !!form.sn) &&
|
||||
(!bomItems.value.length || form.materialChecked)
|
||||
)
|
||||
const blockTip = computed(() => {
|
||||
if (!form.orderNo) return '请先选择工单号'
|
||||
if (!form.pointNo) return '请选择工件当前位置(无空闲点位时请联系班长协调)'
|
||||
if (product.snMode === 0) return '请先在产品型号/物料档案选择序列号管理方式'
|
||||
if (product.snMode === 1 && !form.sn) return '请扫描来料SN(已在WMS入库登记)'
|
||||
if (bomItems.value.length && !form.materialChecked) return '请勾选「已按物料清单核对领料」'
|
||||
@@ -239,7 +292,7 @@ async function onSubmit() {
|
||||
if (product.snMode === 2 && !form.sn) genSn()
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认建档上线?工件 ${form.sn} · 工单 ${form.orderNo}${product.name ? ' · 产品 ' + product.name : ''}`,
|
||||
`确认建档上线?工件 ${form.sn} · 工单 ${form.orderNo}${product.name ? ' · 产品 ' + product.name : ''} · 位置 ${form.pointNo}`,
|
||||
'上线建档确认',
|
||||
{ confirmButtonText: '确认建档', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
@@ -252,6 +305,7 @@ async function onSubmit() {
|
||||
sn: form.sn,
|
||||
orderNo: form.orderNo,
|
||||
workOrderId: product.workOrderId || undefined,
|
||||
pointNo: form.pointNo || undefined,
|
||||
operator: operatorName()
|
||||
})
|
||||
if (data && data.queued) {
|
||||
@@ -263,14 +317,19 @@ async function onSubmit() {
|
||||
}
|
||||
form.sn = ''
|
||||
form.materialChecked = false
|
||||
loadWip(0)
|
||||
// 建档后该点位已被占用:回填下一个默认空闲位
|
||||
form.pointNo = defaultStartPointNo()
|
||||
loadWipScope('pending')
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
submitting.value = false
|
||||
}
|
||||
|
||||
// 进入面板即拉取工单列表与上线位在制品
|
||||
// 进入面板即拉取工单列表、点位台账与待流转在制品
|
||||
loadOrders()
|
||||
loadWip(0)
|
||||
refreshPoints()
|
||||
loadWipScope('pending')
|
||||
if (!form.pointNo) form.pointNo = defaultStartPointNo()
|
||||
|
||||
// #8 T3 PLC↔MES 对账提示弹窗(两项选择,仅前端确认,不调服务端 override——override 仅管理员级角色)
|
||||
const mmDlg = reactive({ show: false, detail: '', stationNo: 0 })
|
||||
@@ -334,6 +393,11 @@ function ackMismatch(choice) {
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.point-tip {
|
||||
margin: -4px 0 12px 82px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
.action-bar {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="数据重传处理" width="900px" top="6vh" destroy-on-close>
|
||||
<!-- 待自动重传:网络失败类,下轮同步(15 秒)自动发送,无需人工处理 -->
|
||||
<div class="sec-title">待自动重传({{ queue.length }})</div>
|
||||
<el-alert type="info" :closable="false" class="tip">
|
||||
MES 暂不可达导致的数据,网络恢复后按当前登录人身份自动发送(每 15 秒一轮),无需处理。
|
||||
</el-alert>
|
||||
<el-table :data="queue" border size="small" max-height="200">
|
||||
<el-table-column label="类型" width="100" align="center">
|
||||
<template #default="{ row }">{{ kindLabel(row.kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工件SN" width="170" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ brief(row).sn }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工单" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ brief(row).orderNo }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="点位" width="150" align="center">
|
||||
<template #default="{ row }">{{ brief(row).pointNo || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已重试" width="80" align="center">
|
||||
<template #default="{ row }">{{ row.retryCount || 0 }} 次</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="录入时间" width="160">
|
||||
<template #default="{ row }">{{ fmt(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty description="无待自动重传数据" :image-size="40" /></template>
|
||||
</el-table>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<!-- 待处理:MES 业务拒绝(如点位已被占用),自动重传不可能成功,须人工处理后再次提交 -->
|
||||
<div class="sec-title danger">待处理({{ dead.length }})</div>
|
||||
<el-alert type="warning" :closable="false" class="tip">
|
||||
以下记录被 MES 明确拒绝(如所选点位已被其他工件占用),原样重传不可能成功。
|
||||
请按失败原因处理后重新选择空闲点位,再次提交;拒绝是保护,人工重选是出路。
|
||||
</el-alert>
|
||||
<el-table :data="dead" border size="small" max-height="340">
|
||||
<el-table-column label="类型" width="100" align="center">
|
||||
<template #default="{ row }">{{ kindLabel(row.kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工件SN" width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ brief(row).sn }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="工单" min-width="130" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ brief(row).orderNo }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="原选点位" width="130" align="center">
|
||||
<template #default="{ row }">{{ brief(row).pointNo || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="失败原因" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span class="reason">{{ row.lastError || 'MES 业务拒绝' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="280" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="retry-cell" v-if="needPoint(row)">
|
||||
<el-select v-model="picked[row.id]" size="small" style="width:170px"
|
||||
placeholder="重选空闲点位" filterable>
|
||||
<el-option-group v-for="g in pointGroups(row)" :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 type="primary" size="small" :loading="submitting === row.id"
|
||||
:disabled="!picked[row.id]" @click="submitRetry(row)">再次提交</el-button>
|
||||
</div>
|
||||
<el-button v-else type="primary" size="small" :loading="submitting === row.id"
|
||||
@click="submitRetry(row)">重新提交</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty description="无待处理记录" :image-size="40" /></template>
|
||||
</el-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="flushNow">立即同步一轮</el-button>
|
||||
<el-button type="primary" @click="visible = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getLinePoints, getSyncStats, retryQueue, syncFlush } from '../../api'
|
||||
|
||||
const visible = ref(false)
|
||||
const queue = ref([])
|
||||
const dead = ref([])
|
||||
const points = ref([])
|
||||
const picked = ref({})
|
||||
const submitting = ref(0)
|
||||
|
||||
const KIND_LABEL = {
|
||||
process_done: '报工',
|
||||
temp_store: '暂存退库',
|
||||
online_register: '上线建档',
|
||||
offline_finish: '下线完工'
|
||||
}
|
||||
function kindLabel(k) { return KIND_LABEL[k] || k }
|
||||
|
||||
// 解析 payload(JSON 字符串),取出展示字段
|
||||
function brief(row) {
|
||||
try {
|
||||
const p = JSON.parse(row.payload || '{}')
|
||||
return {
|
||||
sn: p.sn || '—',
|
||||
orderNo: p.orderNo || p.workOrderNo || '—',
|
||||
pointNo: p.pointNo || ''
|
||||
}
|
||||
} catch {
|
||||
return { sn: '—', orderNo: '—', pointNo: '' }
|
||||
}
|
||||
}
|
||||
|
||||
// 涉及点位选择的类型(MES CheckPointFree 拒绝的高发场景)
|
||||
function needPoint(row) {
|
||||
return row.kind === 'online_register' || row.kind === 'offline_finish'
|
||||
}
|
||||
|
||||
// 重选点位候选项(只列空闲位):
|
||||
// 上线建档 = 上料位/缓存位/停靠位/工位;下线完工 = 末端下料检测位 END-U(上排)/END-D(下排)
|
||||
function pointGroups(row) {
|
||||
const free = points.value.filter((p) => !p.occupied)
|
||||
if (row.kind === 'offline_finish') {
|
||||
return [{
|
||||
label: '末端下料检测位',
|
||||
options: free.filter((p) => p.pointType === 'END')
|
||||
.sort((a, b) => (a.pointNo || '').localeCompare(b.pointNo || ''))
|
||||
.map((p) => ({
|
||||
pointNo: p.pointNo,
|
||||
label: `${p.pointNo === 'END-U' ? '下料检测位 G11(上排)' : '下料检测位 G12(下排)'}(${p.pointNo})`
|
||||
}))
|
||||
}]
|
||||
}
|
||||
const groups = [
|
||||
{ label: '上料位', type: 'FEED' },
|
||||
{ label: '缓存位', type: 'CACHE' },
|
||||
{ label: '停靠位(AGV接驳台)', type: 'DOCK' },
|
||||
{ label: '工位', type: 'STATION' }
|
||||
]
|
||||
return groups.map((g) => ({
|
||||
label: g.label,
|
||||
options: free.filter((p) => p.pointType === g.type)
|
||||
.sort((a, b) => (a.pointNo || '').localeCompare(b.pointNo || '', 'zh-Hans-CN', { numeric: true }))
|
||||
.map((p) => ({ pointNo: p.pointNo, label: `${p.label || p.pointNo}(${p.pointNo})` }))
|
||||
})).filter((g) => g.options.length)
|
||||
}
|
||||
|
||||
function fmt(ts) {
|
||||
if (!ts) return '—'
|
||||
const d = new Date(Number(ts) * 1000)
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const s = await getSyncStats()
|
||||
queue.value = Array.isArray(s?.queue) ? s.queue : []
|
||||
dead.value = Array.isArray(s?.queueDead) ? s.queueDead : []
|
||||
} catch { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
async function open() {
|
||||
visible.value = true
|
||||
picked.value = {}
|
||||
await Promise.all([
|
||||
load(),
|
||||
getLinePoints().then((d) => {
|
||||
const list = Array.isArray(d) ? d : (Array.isArray(d?.list) ? d.list : [])
|
||||
points.value = list
|
||||
}).catch(() => { points.value = [] })
|
||||
])
|
||||
}
|
||||
|
||||
// 再次提交:修正 payload(重选点位)→ 重置为待重传 → 按当前登录人身份立即发一轮
|
||||
async function submitRetry(row) {
|
||||
let payload
|
||||
try {
|
||||
payload = JSON.parse(row.payload || '{}')
|
||||
} catch {
|
||||
ElMessage.error('上报内容解析失败,无法重传')
|
||||
return
|
||||
}
|
||||
const newPoint = picked.value[row.id]
|
||||
if (needPoint(row)) {
|
||||
if (!newPoint) {
|
||||
ElMessage.warning('请先选择空闲点位')
|
||||
return
|
||||
}
|
||||
payload.pointNo = newPoint
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认重新提交该${kindLabel(row.kind)}记录?\n\n工件:${payload.sn || '—'}\n` +
|
||||
(needPoint(row) ? `点位:${newPoint}\n` : '') +
|
||||
`提交后将按当前登录人身份立即发送;若再次被拒绝会原样留在本列表并显示新原因。`,
|
||||
'再次提交',
|
||||
{ type: 'warning', confirmButtonText: '确认提交', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch { return }
|
||||
submitting.value = row.id
|
||||
try {
|
||||
const res = await retryQueue({ id: row.id, payload })
|
||||
if (res?.status === 'synced') {
|
||||
ElMessage.success('重传成功,已上报 MES')
|
||||
} else if (res?.status === 'rejected') {
|
||||
ElMessage.error(`仍被 MES 拒绝:${res.message || '请查看失败原因'}`)
|
||||
} else {
|
||||
ElMessage.warning(res?.message || 'MES 暂不可达,已留在队列等待下轮自动重传')
|
||||
}
|
||||
await load()
|
||||
} catch { /* 统一错误提示 */ }
|
||||
finally { submitting.value = 0 }
|
||||
}
|
||||
|
||||
// 供外部(Main.vue)在待同步按钮点击时一并冲刷
|
||||
async function flushNow() {
|
||||
try {
|
||||
const data = await syncFlush()
|
||||
ElMessage.success(`本轮同步成功 ${data?.count ?? 0} 条`)
|
||||
} catch { /* 统一错误提示 */ }
|
||||
await load()
|
||||
}
|
||||
|
||||
defineExpose({ open, flushNow })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sec-title { font-weight: 600; margin-bottom: 8px; color: #303133; }
|
||||
.sec-title.danger { color: #e6a23c; }
|
||||
.tip { margin-bottom: 10px; }
|
||||
.reason { color: #f56c6c; }
|
||||
.retry-cell { display: flex; align-items: center; gap: 8px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user