- 重构物料档案字段:将"序列号件"改为"序列号",描述是否有序列号,与类型独立 - 调整入库页逻辑:按物料"序列号"决定记账方式,类型仅用于页签归属 - 新增通用入库组件 InboundEntry,复用三个类型页签的表单逻辑 - 优化成品入库页面,提交后自动切换到入库列表页签 - 修正物料校验提示文案,统一表述为"是否有序列号"
244 lines
11 KiB
Vue
244 lines
11 KiB
Vue
<template>
|
||
<el-card>
|
||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||
title="工位数以数据库为准。本页可新增工位与改名;每个工位在下方下拉选择启用的工艺即完成绑定;一个工位只能绑定一个工艺;内置工位不允许删除。" />
|
||
|
||
<div style="margin-bottom:12px">
|
||
<el-button v-if="can('produce.station:add')" type="primary" @click="openAdd">新增工位</el-button>
|
||
<span style="margin-left:12px;color:#909399;font-size:12px">虚拟工位(如 0 上线位、13 下线位)类型选「线下位」,不连 PLC、仅记录上下线。</span>
|
||
</div>
|
||
|
||
<el-table :data="rows" border size="small">
|
||
<el-table-column prop="stationNo" label="工位号" width="90" align="center" />
|
||
<el-table-column prop="name" label="工位名称" min-width="170" show-overflow-tooltip />
|
||
<el-table-column label="类型" width="90" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="row.stationType === 'OFFLINE' ? 'info' : 'success'">
|
||
{{ row.stationType === 'OFFLINE' ? '线下位' : '线上位' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="来源" width="90" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="row.isBuiltin ? 'warning' : 'info'">
|
||
{{ row.isBuiltin ? '内置' : '自定义' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="接驳台(实体)" width="100" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="hasDockOf(row.stationNo) ? 'success' : 'info'">{{ hasDockOf(row.stationNo) ? '有' : '无' }}</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="接驳台编码" min-width="170">
|
||
<template #default="{ row }">
|
||
<span v-if="dockCodesOf(row.stationNo)">{{ dockCodesOf(row.stationNo) }}</span>
|
||
<span v-else style="color:#909399">未绑定</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="绑定工艺" min-width="240">
|
||
<template #default="{ row }">
|
||
<el-select :model-value="row.flowId" size="small" placeholder="未绑定" @change="(v) => bindFlow(row, v)" style="width:100%">
|
||
<el-option :value="0" label="未绑定" />
|
||
<el-option v-for="f in flows" :key="f.id" :value="f.id" :label="f.name + (f.status === 'ACTIVE' ? '' : '(停用)')" />
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="终端可见页签" min-width="200">
|
||
<template #default="{ row }">
|
||
<template v-if="row.visibleTabs && row.visibleTabs.length">
|
||
<el-tag v-for="t in row.visibleTabs" :key="t" size="small" style="margin-right:4px">{{ tabLabel(t) }}</el-tag>
|
||
</template>
|
||
<span v-else style="color:#909399">全部显示</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="230" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button v-if="can('produce.station:edit')" size="small" @click="openName(row)">改名</el-button>
|
||
<el-button v-if="can('produce.station:edit')" size="small" @click="openTabs(row)">页签</el-button>
|
||
<el-button v-if="can('produce.station:delete') && !row.isBuiltin" size="small" type="danger" @click="remove(row)">删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
|
||
<el-dialog v-model="dlg.show" :title="dlg.title" width="440px">
|
||
<el-form :model="dlg" label-width="90px">
|
||
<el-form-item label="工位号" required>
|
||
<el-input-number v-model="dlg.stationNo" :min="0" :max="999" :disabled="!dlg.isAdd" style="width:100%" />
|
||
<div v-if="dlg.isAdd" style="color:#909399;font-size:12px;line-height:1.5;margin-top:4px">
|
||
自定义工位号,可与现有工位不连续(如 14、15…);0 为上线位、13 为下线位以外的编号均按物理/虚拟位识别。
|
||
</div>
|
||
</el-form-item>
|
||
<el-form-item label="工位名称" required>
|
||
<el-input v-model="dlg.name" placeholder="如 一号装配工位" />
|
||
</el-form-item>
|
||
<el-form-item label="工位类型">
|
||
<span v-if="dlg.isAdd">线下位(虚拟,不连 PLC,仅记录上下线)</span>
|
||
<template v-else>
|
||
<el-radio-group v-model="dlg.stationType" :disabled="dlg.isBuiltin">
|
||
<el-radio label="LINE">线上位(连 PLC)</el-radio>
|
||
<el-radio label="OFFLINE">线下位(虚拟,不连 PLC)</el-radio>
|
||
</el-radio-group>
|
||
<div v-if="dlg.isBuiltin" style="color:#909399;font-size:12px;line-height:1.5;margin-top:4px">
|
||
内置工位需与 PLC 通讯并按顺序流转,工位类型不可修改。
|
||
</div>
|
||
</template>
|
||
</el-form-item>
|
||
<el-form-item v-if="dlg.hasDock" label="接驳台编码">
|
||
<div style="color:#909399;font-size:12px;line-height:1.5">
|
||
接驳台与工位的 1:1 绑定由系统预置(种子初始化),页面不可更改。
|
||
</div>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="dlg.show = false">取消</el-button>
|
||
<el-button v-if="can('produce.station:edit')" type="primary" @click="save">保存</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
<!-- 终端可见页签配置 -->
|
||
<el-dialog v-model="tabDlg.show" :title="`工位${tabDlg.stationNo} - 终端可见页签`" width="480px">
|
||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||
title="勾选该工位终端允许显示的页签;全部不勾 = 显示全部页签。配置后终端下次拉取任务即生效。" />
|
||
<el-checkbox-group v-model="tabDlg.tabs">
|
||
<el-checkbox v-for="t in TAB_OPTIONS" :key="t.v" :value="t.v">{{ t.l }}</el-checkbox>
|
||
</el-checkbox-group>
|
||
<template #footer>
|
||
<el-button @click="tabDlg.show = false">取消</el-button>
|
||
<el-button v-if="can('produce.station:edit')" type="primary" @click="saveTabs">保存</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</el-card>
|
||
<PageHelp :data="helpStation" page="Station" />
|
||
</template>
|
||
|
||
<script setup>
|
||
import { reactive, ref, computed, onMounted } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import request from '../utils/request'
|
||
import { can } from '../utils/perm'
|
||
import PageHelp from '../components/PageHelp.vue'
|
||
import { helpStation } from '../help'
|
||
|
||
const stations = ref([])
|
||
const flows = ref([])
|
||
// 接驳台主数据(真源在 dock 表):一工位可绑多个接驳台(R1/R2),展示按 dock.station_no 聚合
|
||
const dockByStation = ref({})
|
||
|
||
async function loadDocks() {
|
||
const data = await request.get('/docks', { params: { page: 1, size: 200 } })
|
||
const map = {}
|
||
for (const d of data?.list || []) {
|
||
const no = Number(d.stationNo) || 0
|
||
if (no <= 0) continue
|
||
;(map[no] = map[no] || []).push(d.dockCode)
|
||
}
|
||
dockByStation.value = map
|
||
}
|
||
function dockCodesOf(no) {
|
||
const codes = dockByStation.value[Number(no)] || []
|
||
return codes.length ? codes.join(' / ') : ''
|
||
}
|
||
function hasDockOf(no) {
|
||
return (dockByStation.value[Number(no)] || []).length > 0
|
||
}
|
||
|
||
// 终端页签固定集合(与工位终端 Main.vue 页签一一对应)
|
||
const TAB_OPTIONS = [
|
||
{ v: 'online', l: '上线建档' },
|
||
{ v: 'work', l: '作业' },
|
||
{ v: 'material', l: '物料' },
|
||
{ v: 'move', l: '产线点位(上料/下料)' },
|
||
{ v: 'pdf', l: '工艺文件' },
|
||
{ v: 'inspect', l: '巡检' },
|
||
{ v: 'offline', l: '下线完工' }
|
||
]
|
||
const tabLabel = (v) => (TAB_OPTIONS.find((t) => t.v === v) || {}).l || v
|
||
|
||
const rows = computed(() => {
|
||
return [...stations.value]
|
||
.sort((a, b) => (a.stationNo || 0) - (b.stationNo || 0))
|
||
.map((s) => ({ id: s.id, stationNo: s.stationNo, name: s.name, flowId: s.flowId, flowName: s.flowName, stationType: s.stationType, isBuiltin: !!s.isBuiltin, hasDock: !!s.hasDock, dockCode: s.dockCode || '', visibleTabs: Array.isArray(s.visibleTabs) ? s.visibleTabs : [] }))
|
||
})
|
||
|
||
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'OFFLINE', isBuiltin: false, hasDock: false })
|
||
|
||
// 终端可见页签编辑(空数组 = 显示全部)
|
||
const tabDlg = reactive({ show: false, id: 0, stationNo: 0, name: '', stationType: 'LINE', tabs: [] })
|
||
|
||
function openTabs(row) {
|
||
Object.assign(tabDlg, { show: true, id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', tabs: [...row.visibleTabs] })
|
||
}
|
||
|
||
async function saveTabs() {
|
||
await request.post('/stations', {
|
||
id: tabDlg.id, stationNo: tabDlg.stationNo, name: tabDlg.name,
|
||
stationType: tabDlg.stationType, visibleTabs: tabDlg.tabs
|
||
})
|
||
ElMessage.success('页签配置已保存')
|
||
tabDlg.show = false
|
||
load()
|
||
}
|
||
|
||
async function load() {
|
||
stations.value = (await request.get('/stations')) || []
|
||
}
|
||
|
||
function openAdd() {
|
||
const used = new Set(stations.value.map((s) => s.stationNo))
|
||
let next = 14
|
||
while (used.has(next)) next++
|
||
Object.assign(dlg, { show: true, isAdd: true, title: '新增工位', id: 0, stationNo: next, name: '', stationType: 'OFFLINE', isBuiltin: false, hasDock: false })
|
||
}
|
||
|
||
function openName(row) {
|
||
Object.assign(dlg, { show: true, isAdd: false, title: `工位${row.stationNo} - 修改`, id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', isBuiltin: !!row.isBuiltin, hasDock: !!row.hasDock })
|
||
}
|
||
|
||
async function save() {
|
||
if (!dlg.name) return ElMessage.warning('请输入工位名称')
|
||
if (dlg.isAdd && stations.value.some((s) => s.stationNo === dlg.stationNo)) {
|
||
return ElMessage.warning(`工位${dlg.stationNo} 已存在,请换一个工位号`)
|
||
}
|
||
await request.post('/stations', {
|
||
id: dlg.id, stationNo: dlg.stationNo, name: dlg.name, stationType: dlg.stationType
|
||
})
|
||
ElMessage.success(dlg.isAdd ? '工位已新增' : '已保存')
|
||
dlg.show = false
|
||
load()
|
||
}
|
||
|
||
async function bindFlow(row, fid) {
|
||
try {
|
||
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', flowId: fid })
|
||
ElMessage.success(fid ? '已绑定工艺' : '已解除绑定')
|
||
} catch {
|
||
// 拦截器已提示(如绑定到未启用的流程)
|
||
} finally {
|
||
await load()
|
||
}
|
||
}
|
||
|
||
async function remove(row) {
|
||
try {
|
||
await ElMessageBox.confirm(`确认删除工位${row.stationNo}「${row.name}」?`, '删除工位', { type: 'warning' })
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
await request.delete(`/stations/${row.id}`)
|
||
ElMessage.success('工位已删除')
|
||
} catch {
|
||
// 拦截器已提示(如内置工位不允许删除)
|
||
} finally {
|
||
await load()
|
||
}
|
||
}
|
||
|
||
// ---------- 工位派工已删除:路线由工单「工艺组合」决定,绑定关系即本页下拉选择 ----------
|
||
|
||
onMounted(async () => {
|
||
await Promise.all([load(), loadDocks()])
|
||
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
||
})
|
||
</script>
|