feat:多项功能优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||||
title="工位数量以数据库为准。本页可新增工位(工位号自定义,可扩展到 14、15…)与改名;每个工位的工艺流程在「关联工位」页维护:在下拉选择启用的工艺流程即绑定到该工位;一个工位只能有一个启用的工艺流程。" />
|
||||
title="工位数量以数据库为准。本页可新增工位(工位号自定义,可扩展到 14、15…)与改名;每个工位的工艺流程在「关联工位」页维护:在下拉选择启用的工艺流程即绑定到该工位;一个工位只能有一个启用的工艺流程。内置工位由种子/初始化数据产生,需与 PLC 通讯、必须按工位号顺序流转,不允许修改工位类型、不允许删除;「是否有接驳台」对应实体位置,由内置数据给定,不可手动更改。页面点击「新增工位」创建的是非内置工位,可改类型、可删除。" />
|
||||
|
||||
<div style="margin-bottom:12px">
|
||||
<el-button v-if="can('produce.station:add')" type="primary" @click="openAdd">新增工位</el-button>
|
||||
@@ -18,6 +18,18 @@
|
||||
</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="90" 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="240">
|
||||
<template #default="{ row }">
|
||||
<el-select :model-value="row.flowId" size="small" placeholder="未绑定" @change="(v) => bindFlow(row, v)" style="width:100%">
|
||||
@@ -26,9 +38,10 @@
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="170" 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:delete') && !row.isBuiltin" size="small" type="danger" @click="remove(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -45,10 +58,13 @@
|
||||
<el-input v-model="dlg.name" placeholder="如 一号装配工位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工位类型">
|
||||
<el-radio-group v-model="dlg.stationType">
|
||||
<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>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -62,7 +78,7 @@
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref, computed, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
import { can } from '../utils/perm'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
@@ -74,10 +90,10 @@ const flows = ref([])
|
||||
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 }))
|
||||
.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 }))
|
||||
})
|
||||
|
||||
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'LINE' })
|
||||
const dlg = reactive({ show: false, isAdd: false, title: '', id: 0, stationNo: 1, name: '', stationType: 'LINE', isBuiltin: false })
|
||||
|
||||
async function load() {
|
||||
stations.value = (await request.get('/stations')) || []
|
||||
@@ -87,11 +103,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' })
|
||||
Object.assign(dlg, { show: true, isAdd: true, title: '新增工位', id: 0, stationNo: next, name: '', stationType: 'LINE', isBuiltin: 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' })
|
||||
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 })
|
||||
}
|
||||
|
||||
async function save() {
|
||||
@@ -118,6 +134,22 @@ async function bindFlow(row, fid) {
|
||||
}
|
||||
}
|
||||
|
||||
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 load()
|
||||
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
||||
|
||||
Reference in New Issue
Block a user