refactor: 重构产线工位与备料流程,移除冗余字段
1. 移除工单、工件、日排产中的冗余工位组合/接驳台字段 2. 新增工位接驳台编码字段与唯一约束,关联WMS接驳台主数据 3. 重构日排产为工位产量分配模式,替代原接驳台列表 4. 新增备料单工位级字段与分批出库支持 5. 移除定时同步可生产数量,改为WMS实时拉取接口 6. 过滤操作日志,排除登录/退出相关日志 7. 调整仪表盘工序展示逻辑为今日派工路线 8. 新增接驳台维护菜单与基础数据
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
<div style="margin-bottom:12px">
|
||||
<el-button v-if="can('produce.station:add')" type="primary" @click="openAdd">新增工位</el-button>
|
||||
<el-button v-if="can('produce.station:dispatch')" type="warning" plain @click="openDispatch">工位派工</el-button>
|
||||
<span style="margin-left:12px;color:#909399;font-size:12px">虚拟工位(如 0 上线位、13 下线位)类型选「线下位」,不连 PLC、仅记录上下线。</span>
|
||||
</div>
|
||||
|
||||
@@ -25,11 +26,19 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="接驳台" width="90" align="center">
|
||||
<el-table-column label="接驳台(实体)" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.hasDock ? 'success' : 'info'">{{ row.hasDock ? '有' : '无' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="接驳台编码" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-select :model-value="row.dockCode" size="small" clearable placeholder="未绑定" style="width:130px"
|
||||
:disabled="!row.hasDock" @change="(v) => bindDock(row, v || '')">
|
||||
<el-option v-for="d in dockOptions" :key="d" :label="d" :value="d" />
|
||||
</el-select>
|
||||
</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%">
|
||||
@@ -66,12 +75,55 @@
|
||||
内置工位需与 PLC 通讯并按顺序流转,工位类型不可修改。
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dlg.isBuiltin && dlg.hasDock" label="接驳台编码">
|
||||
<el-select v-model="dlg.dockCode" clearable placeholder="未绑定接驳台" style="width:100%">
|
||||
<el-option v-for="d in dockOptions" :key="d" :label="d" :value="d" />
|
||||
</el-select>
|
||||
<div style="color:#909399;font-size:12px;line-height:1.5;margin-top:4px">
|
||||
绑定到 WMS 接驳台主数据,与工位 1:1(一个接驳台只能给一个工位)。无接驳台留空。
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-else label="接驳台编码">
|
||||
<div style="color:#909399;font-size:12px;line-height:1.5">
|
||||
该工位无实体接驳台(「是否有接驳台」由内置数据给定,页面不可更改),无需绑定。
|
||||
</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="dispatch.show" title="工位派工(工位↔工序)" width="680px">
|
||||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||||
title="按生效日+班次定义每个工位执行的工序编号(1~12)。同工序的工位可连续排布(如 3/5/7 同为工序1);已派工工位须沿工位号单调不降、不可穿插(不能在工序1 的 3/5 之间插入工序2 的 4)。工序=0 表示该工位当日不参与生产。" />
|
||||
<el-form inline>
|
||||
<el-form-item label="生效日期">
|
||||
<el-date-picker v-model="dispatch.effectDate" type="date" value-format="YYYY-MM-DD" style="width:170px" @change="loadDispatch" />
|
||||
</el-form-item>
|
||||
<el-form-item label="班次">
|
||||
<el-input v-model="dispatch.shift" placeholder="默认空=单班" style="width:140px" @input="loadDispatch" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="dispatch.rows" border size="small" max-height="360">
|
||||
<el-table-column prop="stationNo" label="工位号" width="80" align="center" />
|
||||
<el-table-column prop="name" label="工位名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column label="工序编号" width="200">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.processCode" clearable placeholder="0=不参与" style="width:170px">
|
||||
<el-option :value="0" label="0 不参与" />
|
||||
<el-option v-for="p in processOptions" :key="p" :value="p" :label="`${p} 工序${p}`" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="dispatch.show=false">取消</el-button>
|
||||
<el-button type="primary" @click="saveDispatch">保存派工</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
<PageHelp :data="helpStation" page="Station" />
|
||||
</template>
|
||||
@@ -87,13 +139,28 @@ import { helpStation } from '../help'
|
||||
const stations = ref([])
|
||||
const flows = ref([])
|
||||
|
||||
// 接驳台编码选项(真源在 WMS dock 表,从 /docks 拉取;拉取失败降级为写死兜底)
|
||||
const dockOptions = ref([...Array.from({ length: 20 }, (_, i) => `DOCK${String(i + 1).padStart(2, '0')}`)])
|
||||
|
||||
async function loadDocks() {
|
||||
try {
|
||||
const list = (await request.get('/docks')) || []
|
||||
const codes = (Array.isArray(list) ? list : []).map((d) => d.dockCode).filter(Boolean)
|
||||
if (codes.length) dockOptions.value = codes
|
||||
} catch {
|
||||
// 降级保留写死兜底
|
||||
}
|
||||
}
|
||||
// 工序编号(产品级 1~12)
|
||||
const processOptions = [...Array.from({ length: 12 }, (_, i) => i + 1)]
|
||||
|
||||
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 }))
|
||||
.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 || '' }))
|
||||
})
|
||||
|
||||
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'LINE', isBuiltin: false })
|
||||
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'LINE', isBuiltin: false, hasDock: false, dockCode: '' })
|
||||
|
||||
async function load() {
|
||||
stations.value = (await request.get('/stations')) || []
|
||||
@@ -103,11 +170,11 @@ 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: 'LINE', isBuiltin: false })
|
||||
Object.assign(dlg, { show: true, isAdd: true, title: '新增工位', id: 0, stationNo: next, name: '', stationType: 'LINE', isBuiltin: false, hasDock: false, dockCode: '' })
|
||||
}
|
||||
|
||||
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 })
|
||||
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, dockCode: row.dockCode || '' })
|
||||
}
|
||||
|
||||
async function save() {
|
||||
@@ -116,7 +183,7 @@ async function save() {
|
||||
return ElMessage.warning(`工位${dlg.stationNo} 已存在,请换一个工位号`)
|
||||
}
|
||||
await request.post('/stations', {
|
||||
id: dlg.id, stationNo: dlg.stationNo, name: dlg.name, stationType: dlg.stationType
|
||||
id: dlg.id, stationNo: dlg.stationNo, name: dlg.name, stationType: dlg.stationType, dockCode: dlg.dockCode || ''
|
||||
})
|
||||
ElMessage.success(dlg.isAdd ? '工位已新增' : '已保存')
|
||||
dlg.show = false
|
||||
@@ -125,7 +192,7 @@ async function save() {
|
||||
|
||||
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 })
|
||||
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', flowId: fid, dockCode: row.dockCode || '' })
|
||||
ElMessage.success(fid ? '已绑定工艺流程' : '已解除绑定')
|
||||
} catch {
|
||||
// 拦截器已提示(如绑定到未启用的流程)
|
||||
@@ -134,6 +201,17 @@ async function bindFlow(row, fid) {
|
||||
}
|
||||
}
|
||||
|
||||
async function bindDock(row, code) {
|
||||
try {
|
||||
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: row.name, stationType: row.stationType || 'LINE', dockCode: code })
|
||||
ElMessage.success(code ? `已绑定 ${code}` : '已解绑接驳台')
|
||||
} catch {
|
||||
// 拦截器已提示
|
||||
} finally {
|
||||
await load()
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认删除工位${row.stationNo}「${row.name}」?`, '删除工位', { type: 'warning' })
|
||||
@@ -150,8 +228,63 @@ async function remove(row) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 工位派工(station_process) ----------
|
||||
const dispatch = reactive({ show: false, effectDate: '', shift: '', rows: [] })
|
||||
|
||||
async function openDispatch() {
|
||||
dispatch.effectDate = new Date().toISOString().slice(0, 10)
|
||||
dispatch.shift = ''
|
||||
await loadDispatch()
|
||||
dispatch.show = true
|
||||
}
|
||||
|
||||
async function loadDispatch() {
|
||||
const sp = (await request.get('/station-process', { params: { effectDate: dispatch.effectDate, shift: dispatch.shift } })) || []
|
||||
const m = {}
|
||||
sp.forEach((r) => { m[r.stationNo] = r.processCode })
|
||||
dispatch.rows = [...stations.value]
|
||||
.sort((a, b) => (a.stationNo || 0) - (b.stationNo || 0))
|
||||
.map((s) => ({ stationNo: s.stationNo, name: s.name, processCode: m[s.stationNo] || 0 }))
|
||||
}
|
||||
|
||||
// 客户端连续性校验:已派工(processCode>0)沿工位号必须单调不降、不可穿插
|
||||
function validateDispatch() {
|
||||
const arr = dispatch.rows.filter((r) => r.processCode > 0).sort((a, b) => a.stationNo - b.stationNo)
|
||||
for (let i = 1; i < arr.length; i++) {
|
||||
if (arr[i].processCode < arr[i - 1].processCode) {
|
||||
return `工位${arr[i - 1].stationNo}为工序${arr[i - 1].processCode}、工位${arr[i].stationNo}为工序${arr[i].processCode}:沿工位号必须单调不降,不能穿插其他工序`
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
async function saveDispatch() {
|
||||
const err = validateDispatch()
|
||||
if (err) return ElMessage.warning(err)
|
||||
let lastErr = ''
|
||||
for (const r of dispatch.rows) {
|
||||
try {
|
||||
await request.post('/station-process/save', {
|
||||
stationNo: r.stationNo,
|
||||
processCode: r.processCode || 0,
|
||||
effectDate: dispatch.effectDate,
|
||||
shift: dispatch.shift
|
||||
})
|
||||
} catch (e) {
|
||||
lastErr = (e && e.message) || '保存失败'
|
||||
}
|
||||
}
|
||||
if (lastErr) {
|
||||
ElMessage.error(lastErr)
|
||||
} else {
|
||||
ElMessage.success('工位派工已保存')
|
||||
dispatch.show = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await load()
|
||||
await loadDocks()
|
||||
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user