2026-10-17 17:49:47 +08:00
|
|
|
|
<script setup>
|
|
|
|
|
|
defineOptions({ name: 'LineManagement' })
|
|
|
|
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
2026-11-19 08:31:05 +08:00
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-10-17 17:49:47 +08:00
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
|
|
import request from '../utils/request'
|
|
|
|
|
|
import { can } from '../utils/perm'
|
|
|
|
|
|
import { fmtTime } from '../utils/format'
|
|
|
|
|
|
import PageHelp from '../components/PageHelp.vue'
|
|
|
|
|
|
import { helpLineManagement } from '../help'
|
2026-11-10 23:42:50 +08:00
|
|
|
|
import { dockCn } from '../utils/dockLabel'
|
2026-10-17 17:49:47 +08:00
|
|
|
|
|
2026-11-19 08:31:05 +08:00
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
2026-11-17 06:41:41 +08:00
|
|
|
|
// 产线管理(块 E):页面区块
|
2026-11-19 08:31:05 +08:00
|
|
|
|
// ① 接驳台维护(CRUD) ② 工件位置纠正
|
|
|
|
|
|
// 2026-11-18 三菜单职责收口:原「① 工位状态 / ② 缓存状态」48 位点位展示已去重,统一到「PLC管理」页;
|
|
|
|
|
|
// 本页只保留接驳台表格里的「占用状态」一列(仍读同一批 PLC 位信号,供台账维护参考)。
|
|
|
|
|
|
// 2026-11-18 定稿:完工/暂存退库即自动释放点位台账,「末端取件释放」子块整体退役。
|
2026-10-17 17:49:47 +08:00
|
|
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const lastRefresh = ref('')
|
|
|
|
|
|
|
2026-10-20 16:36:26 +08:00
|
|
|
|
// 工件六态映射(2026-10-19:原列直显英文枚举,与全项目口径统一)
|
2026-11-15 12:17:39 +08:00
|
|
|
|
const pieceStatusMap = { NEW: '待上线', ONLINE: '已上线', PROCESSING: '在制', SEMI_STORED: '在制品入库', DONE: '完工', SCRAPPED: '报废' }
|
2026-11-05 19:18:18 +08:00
|
|
|
|
const pieceStatusText = (s) => pieceStatusMap[s] || '—'
|
2026-10-20 16:36:26 +08:00
|
|
|
|
|
2026-11-19 08:31:05 +08:00
|
|
|
|
/* ===================== PLC 点位(仅保留接驳台占用态所需的 dock/jbt 位) ===================== */
|
2026-10-17 17:49:47 +08:00
|
|
|
|
const docksBits = ref([])
|
|
|
|
|
|
const jbt = ref(null)
|
2026-11-19 08:31:05 +08:00
|
|
|
|
// 工件位置核对
|
2026-10-17 17:49:47 +08:00
|
|
|
|
const mismatches = ref([])
|
|
|
|
|
|
|
|
|
|
|
|
async function loadBits() {
|
|
|
|
|
|
const d = await request.get('/plc/monitor/bits')
|
2026-11-19 08:31:05 +08:00
|
|
|
|
// 工位/缓存 48 位点位展示已统一到「PLC管理」页;这里只取接驳台占用态所需
|
2026-10-17 17:49:47 +08:00
|
|
|
|
docksBits.value = d.dock || []
|
|
|
|
|
|
jbt.value = d.jbt || null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function loadPositionCheck() {
|
|
|
|
|
|
const d = await request.get('/plc/monitor/position-check')
|
|
|
|
|
|
mismatches.value = d?.mismatches || []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function refreshAll() {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
2026-11-19 08:31:05 +08:00
|
|
|
|
await Promise.all([loadBits(), loadPositionCheck()])
|
2026-10-17 17:49:47 +08:00
|
|
|
|
lastRefresh.value = new Date().toLocaleString()
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 位置纠正:MES 记录在工位、PLC 该工位无托盘 → 清为不在工位
|
|
|
|
|
|
const correcting = ref(0)
|
|
|
|
|
|
async function correctPosition(row) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(
|
|
|
|
|
|
`确认纠正工件 ${row.sn} 的位置?\n\nMES 记录:在工位 ${row.atStationNo}\nPLC 实际:工位 ${row.atStationNo} 无托盘\n\n纠正后该工件位置将置为「不在工位」,并写入操作日志。`,
|
|
|
|
|
|
'纠正工件位置',
|
|
|
|
|
|
{ type: 'warning', confirmButtonText: '确认纠正', cancelButtonText: '取消' }
|
|
|
|
|
|
)
|
|
|
|
|
|
} catch { return }
|
|
|
|
|
|
correcting.value = row.workpieceId
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.post('/plc/monitor/position-correct', { workpieceId: row.workpieceId })
|
|
|
|
|
|
ElMessage.success('已纠正')
|
|
|
|
|
|
await refreshAll()
|
|
|
|
|
|
} catch { /* 拦截器已提示 */ }
|
|
|
|
|
|
finally { correcting.value = 0 }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ===================== ③ 接驳台维护(CRUD) ===================== */
|
|
|
|
|
|
const list = ref([])
|
|
|
|
|
|
const filter = reactive({ dockCode: '', name: '', dockType: '', status: '' })
|
|
|
|
|
|
const TYPE_LABEL = { line: '产线', store: '库房', other: '其他' }
|
|
|
|
|
|
function typeLabel(t) { return TYPE_LABEL[t] || '其他' }
|
|
|
|
|
|
function tagType(t) { return t === 'line' ? 'success' : (t === 'store' ? 'warning' : 'info') }
|
2026-11-04 19:06:03 +08:00
|
|
|
|
// 显示层统一(2026-10-17 裁定):库房接驳台一律显示「库房接驳台」,不显示 JBT21 编号
|
|
|
|
|
|
// (JBT21 仅作后端映射,T7 2026-11-03 统一代号;PLC 侧对应点位于 PLC 监控页同样只显示「库房接驳台」)
|
2026-11-10 23:42:50 +08:00
|
|
|
|
function dockCodeLabel(code) { return dockCn(code, list.value) }
|
2026-10-17 17:49:47 +08:00
|
|
|
|
|
|
|
|
|
|
async function loadDocks() {
|
|
|
|
|
|
const params = {}
|
|
|
|
|
|
if (filter.dockCode.trim()) params.dockCode = filter.dockCode.trim()
|
|
|
|
|
|
if (filter.name.trim()) params.name = filter.name.trim()
|
|
|
|
|
|
if (filter.dockType) params.dockType = filter.dockType
|
|
|
|
|
|
if (filter.status) params.status = filter.status
|
|
|
|
|
|
const data = await request.get('/docks/maint', { params })
|
|
|
|
|
|
list.value = (data || []).slice().sort((a, b) => String(a.dockCode || '').localeCompare(String(b.dockCode || '')))
|
|
|
|
|
|
}
|
|
|
|
|
|
function search() { loadDocks() }
|
|
|
|
|
|
function reset() {
|
|
|
|
|
|
filter.dockCode = ''
|
|
|
|
|
|
filter.name = ''
|
|
|
|
|
|
filter.dockType = ''
|
|
|
|
|
|
filter.status = ''
|
|
|
|
|
|
loadDocks()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function del(row) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await ElMessageBox.confirm(`确认删除接驳台 ${dockCodeLabel(row.dockCode)}(${row.name})?`, '删除确认',
|
|
|
|
|
|
{ type: 'warning', confirmButtonText: '确认删除', cancelButtonText: '取消' })
|
|
|
|
|
|
} catch { return }
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.delete(`/docks/${row.id}`)
|
|
|
|
|
|
ElMessage.success('已删除')
|
|
|
|
|
|
await loadDocks()
|
|
|
|
|
|
} catch { /* 拦截器已提示 */ }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function toggleStatus(row) {
|
|
|
|
|
|
const next = row.status === 'ENABLED' ? 'DISABLED' : 'ENABLED'
|
|
|
|
|
|
try {
|
|
|
|
|
|
await request.post('/docks/status', { id: row.id, status: next })
|
|
|
|
|
|
ElMessage.success(next === 'ENABLED' ? '已启用' : '已停用')
|
|
|
|
|
|
await loadDocks()
|
|
|
|
|
|
} catch { /* 拦截器已提示 */ }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 接驳台占用态(PLC 实时):按 dockCode 关联 ①/② 中的位信号
|
|
|
|
|
|
const palletByDock = computed(() => {
|
|
|
|
|
|
const m = {}
|
|
|
|
|
|
docksBits.value.forEach((b) => { m[b.code] = b.has })
|
|
|
|
|
|
if (jbt.value) m[jbt.value.code] = jbt.value.has
|
|
|
|
|
|
return m
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-11-19 08:31:05 +08:00
|
|
|
|
onMounted(() => { refreshAll(); loadDocks() })
|
2026-10-17 17:49:47 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="page">
|
|
|
|
|
|
<PageHelp :data="helpLineManagement" page="LineManagement" />
|
|
|
|
|
|
|
2026-11-19 08:31:05 +08:00
|
|
|
|
<el-alert type="info" :closable="false" class="tip" show-icon>
|
|
|
|
|
|
<template #title>本页管什么</template>
|
|
|
|
|
|
这里只管产线的台账与规则:接驳台主数据、这条线能生产哪些产品、工件位置对账。
|
|
|
|
|
|
完工与暂存退库会自动释放点位台账,无需人工释放。
|
|
|
|
|
|
看 PLC 实时点位(哪个位置有托盘、在途指令)请到「<el-link type="primary" :underline="false" @click="router.push('/plc-monitor')">PLC管理</el-link>」,
|
|
|
|
|
|
给工件下发工艺码、撤回或人工完成请到「<el-link type="primary" :underline="false" @click="router.push('/plc-send')">工位下发</el-link>」。
|
|
|
|
|
|
</el-alert>
|
2026-10-17 17:49:47 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- ③ 接驳台维护 -->
|
|
|
|
|
|
<el-card class="block">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
<div class="card-head">
|
|
|
|
|
|
<span>③ 接驳台维护</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-alert type="info" :closable="false" class="tip">
|
|
|
|
|
|
接驳台是产线与库房之间供 AGV 取送货的物理停靠位,为产线主数据(真源在 MES)。占用状态由 PLC 传感器实时读取,不可人工维护。
|
|
|
|
|
|
</el-alert>
|
|
|
|
|
|
<el-form inline :model="filter">
|
|
|
|
|
|
<el-form-item label="接驳台编码">
|
|
|
|
|
|
<el-input v-model="filter.dockCode" clearable style="width:160px" placeholder="精确匹配,如 DOCK01" @keyup.enter="search" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="接驳台名称">
|
|
|
|
|
|
<el-input v-model="filter.name" clearable style="width:180px" placeholder="名称模糊匹配" @keyup.enter="search" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="类型">
|
|
|
|
|
|
<el-select v-model="filter.dockType" clearable style="width:120px" placeholder="全部">
|
|
|
|
|
|
<el-option label="产线" value="line" />
|
|
|
|
|
|
<el-option label="库房" value="store" />
|
|
|
|
|
|
<el-option label="其他" value="other" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="状态">
|
|
|
|
|
|
<el-select v-model="filter.status" clearable style="width:110px" placeholder="全部">
|
|
|
|
|
|
<el-option label="启用" value="ENABLED" />
|
|
|
|
|
|
<el-option label="停用" value="DISABLED" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button type="primary" @click="search">查询</el-button>
|
|
|
|
|
|
<el-button @click="reset">重置</el-button>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<el-table :data="list" border size="small">
|
|
|
|
|
|
<el-table-column label="接驳台编码" width="140">
|
|
|
|
|
|
<template #default="{ row }">{{ dockCodeLabel(row.dockCode) }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="name" label="接驳台名称" min-width="200" show-overflow-tooltip />
|
|
|
|
|
|
<el-table-column label="类型" width="100" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag size="small" :type="tagType(row.dockType)">{{ typeLabel(row.dockType) }}</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="绑定工位" width="110" align="center">
|
|
|
|
|
|
<template #default="{ row }">{{ row.stationNo > 0 ? '工位' + row.stationNo : '—' }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="占用状态" width="110" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag size="small" :type="palletByDock[row.dockCode] ? 'warning' : 'info'">
|
|
|
|
|
|
{{ palletByDock[row.dockCode] ? '有托盘' : '空闲' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column prop="palletRef" label="托盘关联" min-width="160" show-overflow-tooltip>
|
|
|
|
|
|
<template #default="{ row }">{{ row.palletRef || '—' }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="启用状态" width="90" align="center">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-tag size="small" :type="row.status === 'ENABLED' ? 'success' : 'info'">
|
|
|
|
|
|
{{ row.status === 'ENABLED' ? '启用' : '停用' }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="创建时间" width="170">
|
|
|
|
|
|
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" width="150" align="center" fixed="right">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-button v-if="can('produce.line.manage')" link size="small"
|
|
|
|
|
|
:type="row.status === 'ENABLED' ? 'warning' : 'success'"
|
|
|
|
|
|
@click="toggleStatus(row)">{{ row.status === 'ENABLED' ? '停用' : '启用' }}</el-button>
|
|
|
|
|
|
<el-popconfirm v-if="can('produce.line.manage')" :title="`确认删除接驳台 ${dockCodeLabel(row.dockCode)}?`" @confirm="del(row)">
|
|
|
|
|
|
<template #reference>
|
|
|
|
|
|
<el-button link type="danger" size="small">删除</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popconfirm>
|
|
|
|
|
|
<span v-if="!can('produce.line.manage')">—</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<template #empty>
|
|
|
|
|
|
<el-empty description="暂无接驳台数据" />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
2026-11-17 06:41:41 +08:00
|
|
|
|
<!-- ⑤ 工件位置纠正 -->
|
2026-10-17 17:49:47 +08:00
|
|
|
|
<el-card class="block">
|
|
|
|
|
|
<template #header>
|
|
|
|
|
|
<div class="card-head">
|
2026-11-19 08:31:05 +08:00
|
|
|
|
<span>④ 工件位置纠正</span>
|
2026-10-17 17:49:47 +08:00
|
|
|
|
<el-button size="small" :loading="loading" @click="refreshAll">核对</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<el-alert type="info" :closable="false" class="tip">
|
|
|
|
|
|
核对「MES 记录的工件物理位置」与「PLC 实际托盘位」:MES 记录工件在工位 n,但 PLC 工位 n 无托盘
|
|
|
|
|
|
⇒ 记录已过期/错位,可一键纠正为「不在工位」。纠正写入操作日志(plc_position_correct)。
|
|
|
|
|
|
当前待纠正 {{ mismatches.length }} 条。最后核对时间:{{ lastRefresh || '—' }}
|
|
|
|
|
|
</el-alert>
|
|
|
|
|
|
<el-table :data="mismatches" border size="small">
|
2026-11-05 19:18:18 +08:00
|
|
|
|
<el-table-column prop="sn" label="工件序列号" width="200" show-overflow-tooltip />
|
2026-10-17 17:49:47 +08:00
|
|
|
|
<el-table-column prop="orderNo" label="所属工单" min-width="150" show-overflow-tooltip />
|
2026-10-20 16:36:26 +08:00
|
|
|
|
<el-table-column prop="status" label="工件状态" width="110" align="center">
|
|
|
|
|
|
<template #default="{ row }">{{ pieceStatusText(row.status) }}</template>
|
|
|
|
|
|
</el-table-column>
|
2026-10-17 17:49:47 +08:00
|
|
|
|
<el-table-column label="记录位置" width="110" align="center">
|
|
|
|
|
|
<template #default="{ row }">工位 {{ row.atStationNo }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="PLC 实际" width="110" align="center">
|
|
|
|
|
|
<template #default="{ row }">无托盘</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="业务位置" width="120" align="center">
|
|
|
|
|
|
<template #default="{ row }">{{ row.curStationNo > 0 ? '工位 ' + row.curStationNo : '—' }}</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" width="120" align="center" fixed="right">
|
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
<el-button v-if="can('produce.line.manage')" link type="warning" size="small"
|
|
|
|
|
|
:loading="correcting === row.workpieceId" @click="correctPosition(row)">纠正</el-button>
|
|
|
|
|
|
<span v-else>—</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<template #empty>
|
|
|
|
|
|
<el-empty description="无待纠正工件(MES 记录与 PLC 实际一致)" />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.block { margin-bottom: 16px; }
|
|
|
|
|
|
.card-head { display: flex; justify-content: space-between; align-items: center; }
|
|
|
|
|
|
.tip { margin-bottom: 12px; }
|
|
|
|
|
|
</style>
|