feat: 重构 AGV 对接与在制品查询,新增 PLC 手动监控功能
This commit is contained in:
@@ -50,6 +50,9 @@ export const stationLogout = (data) => request.post('/api/station/logout', data)
|
||||
// 待同步统计
|
||||
export const getSyncStats = () => request.get('/api/sync/stats')
|
||||
|
||||
// 人工重传处理:修正 payload(如重选点位)后按当前登录人身份再次提交
|
||||
export const retryQueue = (data) => request.post('/api/sync/retry-queue', data)
|
||||
|
||||
// 工艺文件免鉴权直链(iframe / window.open 用):query 传名,支持日期子目录文件名
|
||||
export const pdfOpenUrl = (name) => '/pdfview?name=' + encodeURIComponent(name)
|
||||
|
||||
@@ -107,7 +110,7 @@ export const qtyReport = (data) => request.post('/api/qty-report', data)
|
||||
export const returnMaterial = (data) => request.post('/api/return-material', data)
|
||||
|
||||
// ---------- 在制品 / 0-13 上下线建档完工 / 物料清单领料 / 追溯(代理 MES 内部 API) ----------
|
||||
// 在制品列表:{stationNo}(<=0/空=全部, 0=上线位, 13=下线位, 其余物理工位)→ {list}
|
||||
// 在制品列表:{stationNo}(>0=停在该工位)/ {scope}(pending=待流转 / end-pending=末端待取件)→ {list}
|
||||
export const getWip = (params) => request.get('/api/wip', { params })
|
||||
|
||||
// 物料清单(上线建档「领料确认」应领料):{productCode, bomName}
|
||||
|
||||
@@ -12,7 +12,8 @@ export const helpWorkstation = {
|
||||
overview: '顶部显示当前工位号、登录人、离线同步状态。',
|
||||
fields: [
|
||||
{ name: '工位号', source: '下拉选择/固定。数据来自本机配置或固定的 DOCK01~21。', purpose: '当前所在工位,决定读取哪道工艺的任务', fill: '固定工位由配置锁定不可改;否则选与实际工位一致编号' },
|
||||
{ name: '待同步 N 条', source: '系统统计。数据来自本地 SQLite 中尚未上传的记录数。', purpose: '标记有拧紧/工艺数据没上报 MES(离线缓存)', fill: '点「重试同步」立即补传;消红为正常' },
|
||||
{ name: '待同步 N 条', source: '系统统计。数据来自本地 SQLite 中尚未上传的记录数。', purpose: '标记有拧紧/工艺数据没上报 MES(离线缓存)', fill: '点开「重传处理」可立即补传(立即同步一轮)' },
|
||||
{ name: '待处理 N 条', source: '系统统计。被 MES 明确拒绝(如所选点位已被其他工件占用)的记录。', purpose: '提醒有数据需人工处理后才能上报', fill: '点开「重传处理」查看失败原因 → 重选空闲点位 → 再次提交;拒绝是保护,人工重选是出路' },
|
||||
{ name: '登录人', source: '登录账号。来自工位终端登录时输入。', purpose: '当前操作员,上报记录会带此名字溯源', fill: '开机登入本人账号,勿共用' }
|
||||
]
|
||||
},
|
||||
@@ -56,7 +57,7 @@ export const helpWorkstation = {
|
||||
fields: [
|
||||
{ name: '报工完成', source: '按钮操作 + 确认框。数据上报到 MES。', purpose: '本工位这道工艺做完,通知 MES 流转到下一工位', fill: '点「报工完成」二次确认;联网失败自动离线缓存' },
|
||||
{ name: '暂存退库', source: '按钮操作 + 确认框。数据上报到 MES(记录已完成工艺)。', purpose: '工件本工艺不做完,退回库房暂存', fill: '点击并二次确认;系统记录已完成工艺,重上线从下一工位继续' },
|
||||
{ name: '重试同步', source: '按钮操作。数据从本地 SQLite 补传到 MES。', purpose: '把离线缓存的数据立即补传给 MES', fill: '看到「待同步」非 0 时点一下即可' }
|
||||
{ name: '待同步(顶部按钮)', source: '按钮操作。打开「重传处理」。', purpose: '查看/处理未上报数据:立即同步一轮、或对 MES 拒绝的记录重选点位后再次提交', fill: '看到「待同步」或「待处理」非 0 时点开处理' }
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -84,7 +85,7 @@ export const helpPdf = {
|
||||
export const helpOnline = {
|
||||
title: '上线建档 使用说明',
|
||||
overview:
|
||||
'上线建档在配置了「上线建档」页签的工位终端执行(原虚拟位 0/13 已废弃,任意授权工位均可操作)。成品在此登记建档、按物料清单核对领料,建档上线后流转到下一道装配工位。\n\n标准流程:①选工单(带出产品、序列号口径与物料清单)→ ②按物料清单核对应领料 → ③按口径录入工件 SN(序列号=是扫来料SN / 序列号=否自动发号)→ ④点「确认建档上线」。\n\n数据链路:工单/物料清单/序列号口径(MES) → 建档上线(MES 生成在制工件) → 流转到装配工位。',
|
||||
'上线建档在配置了「上线建档」页签的工位终端执行(原虚拟位 0/13 已废弃,任意授权工位均可操作)。成品在此登记建档、按物料清单核对领料,建档上线后流转到下一道装配工位。\n\n标准流程:①选工单(带出产品、序列号口径与物料清单)→ ②选工件当前位置 → ③按物料清单核对应领料 → ④按口径录入工件 SN(序列号=是扫来料SN / 序列号=否自动发号)→ ⑤点「确认建档上线」。\n\n数据链路:工单/物料清单/序列号口径(MES) → 建档上线(MES 生成在制工件,并按所选位置登记产线点位占用) → 流转到装配工位。',
|
||||
sections: [
|
||||
{
|
||||
title: '选工单与产品',
|
||||
@@ -94,6 +95,13 @@ export const helpOnline = {
|
||||
{ name: '产品', source: 'MES 工单带出。选定工单后自动显示。', purpose: '确认正在上线的产品型号,避免上错料', fill: '只读,随工单自动带出' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '工件当前位置',
|
||||
overview: '建档时登记工件此刻实际所在的产线点位,建档成功后该点位自动标记为被本工件占用(产线点位台账为唯一事实源)。',
|
||||
fields: [
|
||||
{ name: '工件当前位置', source: 'MES 产线点位台账(只列空闲点位)。', purpose: '记录工件物理位置,供产线点位图/看板/位置核对使用', fill: '分组下拉(上料位/缓存位/停靠位/工位),默认本工位可用位,无则 C1/上料位;点位被他人占用后自动失效需重选' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '领料确认(按物料清单核对)',
|
||||
overview: '按产品物料清单列出本台应领物料,操作员逐项核对后勾选确认。',
|
||||
@@ -107,7 +115,7 @@ export const helpOnline = {
|
||||
overview: 'SN 是成品唯一编号,按产品档案「序列号」口径分流:序列号=是须扫已在 WMS 入库登记的来料SN(不再自动发号);序列号=否提交后系统自动发号,全程可追溯。',
|
||||
fields: [
|
||||
{ name: '工件 SN', source: '序列号=是:扫码枪扫来料SN(需已在 WMS 入库登记);序列号=否:系统自动生成。', purpose: '唯一识别本台成品,拧紧/工艺/追溯都挂在此 SN 下', fill: '序列号=是=扫描来料SN(必填,MES 校验其在 WMS 库存);序列号=否=无需手填,提交后系统自动发号' },
|
||||
{ name: '上线位在制品', source: 'MES 实时查询。工位号 0 的在制工件。', purpose: '看清已建档待流转的工件,防止重复建档', fill: '只读展示,点「刷新」更新' },
|
||||
{ name: '待流转在制品', source: 'MES 实时查询。已建档、尚未分配到工位的工件。', purpose: '看清已建档待流转的工件,防止重复建档', fill: '只读展示,点「刷新」更新' },
|
||||
{ name: '确认建档上线', source: '按钮操作 + 确认框。数据上报到 MES。', purpose: '正式建档上线,工件进入产线待第 1 工位加工', fill: '满足工单/SN/领料核对后点击并二次确认;MES 不可达时自动离线缓存重传' }
|
||||
]
|
||||
}
|
||||
@@ -118,23 +126,24 @@ export const helpOnline = {
|
||||
export const helpOffline = {
|
||||
title: '下线完工 使用说明',
|
||||
overview:
|
||||
'下线完工运行在产线出料口(工位号 13)。工件走完全部装配工艺后在此核对完工状态、终检结果,确认合格后入库并回流 WMS 成品库存。\n\n标准流程:①扫描工件 SN → ②查看完工状态/工艺时间线/拧紧结果/步骤不合格项 → ③确认合格后点「确认完工入库(回流 WMS)」。\n\n数据链路:追溯/拧紧/工艺(MES) → 完工确认(MES 置 DONE) → 成品库存回流(WMS)。',
|
||||
'下线完工运行在产线出料口(工位号 13)。工件走完全部装配工艺后在此核对完工状态、终检结果,确认合格后入库并回流 WMS 成品库存。\n\n标准流程:①扫描工件 SN → ②查看完工状态/工艺时间线/拧紧结果/步骤不合格项 → ③选择下料位置(末端下料检测位)→ ④确认合格后点「确认完工入库(回流 WMS)」。\n\n数据链路:追溯/拧紧/工艺(MES) → 完工确认(MES 置 DONE,按下料位置登记产线点位占用) → 成品库存回流(WMS)。',
|
||||
sections: [
|
||||
{
|
||||
title: '完工状态核对',
|
||||
overview: '扫描 SN 后汇总展示该工件的全流程完工情况,作为入库判定依据。',
|
||||
fields: [
|
||||
{ name: '工件状态', source: 'MES 查询。工件当前流转状态。', purpose: '确认工件是否已完工,避免重复入库', fill: '只读;显示「已完工」则无需再操作' },
|
||||
{ name: '下料位置', source: 'MES 产线点位台账(只列空闲的末端下料检测位)。', purpose: '登记完工后工件实际落入的末端下料检测位(G11 上排 / G12 下排)', fill: '查询工件后按所在工位上下排自动预选(上排=奇数工位,下排=偶数工位),可改选另一排' },
|
||||
{ name: '已完成工艺', source: 'MES 工艺时间线。', purpose: '核对是否走完全部应做工艺', fill: '只读;工艺数应与工艺路线一致' },
|
||||
{ name: '拧紧 N/M 合格', source: 'MES 拧紧记录汇总。', purpose: '确认全部螺丝拧紧合格', fill: '只读;有不合格需先返修复检再入库' },
|
||||
{ name: '步骤不合格 N 项', source: 'MES 步骤采集数据。', purpose: '提示过程检中是否存在不合格步骤', fill: '只读;大于 0 时须确认已处理再入库' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '下线位工件与入库',
|
||||
overview: '列出已到下线位待完工的工件,可点击带入 SN,核对后确认入库回流 WMS。',
|
||||
title: '末端取件待处理',
|
||||
overview: '列出已到产线末端待取件完工的工件,可点击带入 SN,核对后确认入库回流 WMS。',
|
||||
fields: [
|
||||
{ name: '下线位待完工工件', source: 'MES 实时查询。工位号 13 的在制工件。', purpose: '看清已到出料口待入库的工件,防止漏件', fill: '点某一行即带入该 SN 并自动查询完工状态' },
|
||||
{ name: '末端待取件工件', source: 'MES 实时查询。已报工至工艺路线末端的在制工件。', purpose: '看清已到出料口待入库的工件,防止漏件', fill: '点某一行即带入该 SN 并自动查询完工状态' },
|
||||
{ name: '确认完工入库(回流 WMS)', source: '按钮操作 + 确认框。MES 置工件 DONE 并推送 WMS 成品库存。', purpose: '正式完工入库,成品进入 WMS 库存可发货', fill: '核对无不合格后点击并二次确认;MES 不可达时自动离线缓存重传' }
|
||||
]
|
||||
}
|
||||
@@ -168,31 +177,6 @@ export const helpMaterial = {
|
||||
]
|
||||
}
|
||||
|
||||
// 产线点位(上料/下料)页(页签 key 沿用历史 'move',原移料指令功能已删除)
|
||||
export const helpLinePoint = {
|
||||
title: '产线点位(上料/下料) 使用说明',
|
||||
overview:
|
||||
'本页以产线点位图为唯一事实源,实时显示每个点位当前占用的工件;用于人工上料登记与下料释放(扫码到位后由作业页自动记账,本页处理补登记/异常释放)。',
|
||||
sections: [
|
||||
{
|
||||
title: '产线点位',
|
||||
overview: '查看产线各点位(上料位/工位/缓存位/末端/接驳台)的实时占用情况。',
|
||||
fields: [
|
||||
{ name: '点位图', source: 'MES 产线点位台账。实时反映每点位占用情况。', purpose: '看清工件在产线上的实时位置', fill: '只读展示,点「刷新」更新;高亮框为本工位点位' },
|
||||
{ name: '本工位接驳台', source: 'MES 产线点位台账(AGV 点位)。', purpose: '查看叫料物料送达的接驳台', fill: '只读展示' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '上料登记 / 下料释放',
|
||||
overview: '人工维护点位占用:上料登记把工件 SN 记到点位,下料释放清空点位。',
|
||||
fields: [
|
||||
{ name: '上料登记', source: '按钮操作。更新点位占用。', purpose: '首件上线或补登记时把工件记到所选点位', fill: '点选空闲点位 → 点「上料登记」→ 按提示输入 SN' },
|
||||
{ name: '下料释放', source: '按钮操作。更新点位占用。', purpose: '工件已物理离开点位时释放占用', fill: '点选占用点位 → 点「下料释放」并确认' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// 巡检 / 异常页
|
||||
export const helpInspect = {
|
||||
title: '巡检 / 异常 使用说明',
|
||||
|
||||
@@ -92,7 +92,7 @@ export const missingTorqueSteps = computed(
|
||||
() => torqueSteps.value.filter((s) => !torqueRowOfStep(s.id))
|
||||
)
|
||||
export const orderNos = computed(() => (Array.isArray(state.task?.orderNos) ? state.task.orderNos : []))
|
||||
// 终端可见页签(按工位配置;空=全部显示)。可选值 online/work/material/move(产线点位:上料/下料,历史 key 沿用)/pdf/inspect/offline
|
||||
// 终端可见页签(按工位配置;空=全部显示)。可选值 online/offline/work/material/pdf/inspect
|
||||
export const visibleTabs = computed(() => (Array.isArray(state.task?.tabs) ? state.task.tabs : []))
|
||||
// 页签是否显示:未配置(空数组)一律显示
|
||||
export const hasTab = (name) => !visibleTabs.value.length || visibleTabs.value.includes(name)
|
||||
@@ -136,6 +136,8 @@ export const manualNg = computed(() =>
|
||||
export const autoNg = computed(() => state.tightRows.some((r) => r.result === 'NG'))
|
||||
export const hasNg = computed(() => manualNg.value || autoNg.value)
|
||||
export const pendingTotal = computed(() => (state.stats.pendingTorque || 0) + (state.stats.pendingQueue || 0))
|
||||
// 待处理(死信):MES 业务拒绝、自动重传不可能成功,须人工重传处理
|
||||
export const deadTotal = computed(() => Number(state.stats.deadTotal || 0))
|
||||
|
||||
// 未勾选"检测确认"的步骤(needCheck=true 必须人工确认后才允许报工)
|
||||
export const missingChecks = computed(() =>
|
||||
@@ -202,7 +204,7 @@ export function stepDisplay(s) {
|
||||
export async function loadConfig() {
|
||||
try {
|
||||
const cfg = await getConfig()
|
||||
// 0=上线位、13=下线位为虚拟工位,需允许 stationNo=0(不能用 >0 否则上线位被当未配置)
|
||||
// 工位号允许为 0(内部标识=待流转),用 >=0 防止被当成未配置
|
||||
if (cfg && typeof cfg.stationNo === 'number' && cfg.stationNo >= 0) state.stationNo = cfg.stationNo
|
||||
// 本工位固定接驳台(服务端配置,只读展示用)
|
||||
if (cfg && typeof cfg.dock === 'string' && cfg.dock) state.dock = cfg.dock
|
||||
@@ -210,7 +212,7 @@ export async function loadConfig() {
|
||||
}
|
||||
|
||||
export async function loadTask() {
|
||||
// 0=上线位是合法工位,不能用 falsy 判断,否则上线位永远不拉任务
|
||||
// 工位号 0 是合法值,不能用 falsy 判断,否则永远不拉任务
|
||||
if (state.stationNo == null || state.stationNo === '') return
|
||||
try {
|
||||
state.task = await getTaskCurrent(state.stationNo)
|
||||
@@ -294,7 +296,8 @@ export async function loadStats() {
|
||||
}
|
||||
|
||||
// loadWip 拉取停在本工位的未完工在制品(5.2 默认展示)。
|
||||
// stationNo 传本工位号;上线位(0)/下线位(13) 面板同样复用。
|
||||
// stationNo 传本工位号(正整数字符串/数字)。
|
||||
// loadWipScope 按业务语义拉取:pending=待流转(已建档未分配工位)/ end-pending=末端待取件(已报工至工艺末端)。
|
||||
export async function loadWip(atStation) {
|
||||
const code = atStation === undefined ? state.stationNo : atStation
|
||||
try {
|
||||
@@ -305,6 +308,15 @@ export async function loadWip(atStation) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function loadWipScope(scope) {
|
||||
try {
|
||||
const data = await getWip({ scope })
|
||||
state.wip = (data && data.list) ? data.list : (Array.isArray(data) ? data : [])
|
||||
} catch {
|
||||
state.wip = []
|
||||
}
|
||||
}
|
||||
|
||||
export function refreshAll() {
|
||||
return Promise.all([loadTask(), loadTight(), loadStats(), loadPoints(), loadWip(), loadStationState()])
|
||||
}
|
||||
@@ -392,7 +404,7 @@ export function touch() {
|
||||
refreshToken().catch(() => { /* MES 不可达时静默,下个节流窗口重试 */ })
|
||||
}
|
||||
|
||||
// flowId 随任务到达后再触发一次绑定加载(上线位/首次拉到任务时 flowId 才有值)
|
||||
// flowId 随任务到达后再触发一次绑定加载(首次拉到任务时 flowId 才有值)
|
||||
watch(flowId, (v) => {
|
||||
if (v > 0 && state.currentSn && !state.bindPanel) loadBind()
|
||||
})
|
||||
|
||||
@@ -48,6 +48,34 @@ service.interceptors.request.use((config) => {
|
||||
return config
|
||||
})
|
||||
|
||||
/**
|
||||
* 登录路径(/api/auth/login)错误业务化映射:
|
||||
* 断网/连接拒绝 → MES 服务不可达;超时 → MES 服务响应超时;401/403 → 工号或密码错误;其他 → 登录失败。
|
||||
* 技术细节只写 console,不展示给操作员。
|
||||
*/
|
||||
function isLoginPath(url) {
|
||||
return typeof url === 'string' && url.indexOf('/api/auth/login') !== -1
|
||||
}
|
||||
|
||||
function mapLoginError(error) {
|
||||
if (error.response) {
|
||||
const status = error.response.status
|
||||
const serverMsg = error.response.data && error.response.data.message
|
||||
if (status === 401 || status === 403) return '工号或密码错误'
|
||||
if (status === 400 || status === 422) return serverMsg || '输入信息有误,请检查后重试'
|
||||
if (status >= 500) return 'MES 服务不可达,请检查网络或联系管理员'
|
||||
return serverMsg || '登录失败,请联系管理员'
|
||||
}
|
||||
const code = error.code || ''
|
||||
if (code === 'ECONNABORTED' || code === 'ETIMEDOUT') return 'MES 服务响应超时,请稍后重试'
|
||||
return 'MES 服务不可达,请检查网络或联系管理员'
|
||||
}
|
||||
|
||||
// toastError 登录等关键动作的提示不节流(用户主动操作,必须即时反馈)
|
||||
function toastError(msg) {
|
||||
ElMessage.error(msg)
|
||||
}
|
||||
|
||||
service.interceptors.response.use(
|
||||
(response) => {
|
||||
// 滑动续签:后端剩余有效期不足一半时下发新 token
|
||||
@@ -58,6 +86,12 @@ service.interceptors.response.use(
|
||||
if (d && typeof d === 'object' && 'code' in d) {
|
||||
if (d.code !== 0) {
|
||||
const err = new Error(d.message || '请求失败')
|
||||
if (isLoginPath(response.config && response.config.url)) {
|
||||
// 登录业务拒绝(密码错误/账号停用/工位不符):直接透传 MES 中文原因,不清空登录态、不跳转
|
||||
const msg = d.message || '登录失败,请联系管理员'
|
||||
toastError(msg)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
showErrThrottled(err.message)
|
||||
return Promise.reject(err)
|
||||
}
|
||||
@@ -66,6 +100,13 @@ service.interceptors.response.use(
|
||||
return d
|
||||
},
|
||||
(error) => {
|
||||
if (isLoginPath(error.config && error.config.url)) {
|
||||
// 登录失败:业务化提示 + 技术细节只记日志,不清空登录态、不跳转(本就在登录页)
|
||||
console.error('[login] 技术细节:', error.config?.url, error.code, error.message, error.response?.data)
|
||||
const msg = mapLoginError(error)
|
||||
toastError(msg)
|
||||
return Promise.reject(new Error(msg))
|
||||
}
|
||||
if (error.response && error.response.status === 401) {
|
||||
clearAuth()
|
||||
window.location.hash = '#/login'
|
||||
|
||||
@@ -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