2026-08-31 12:58:28 +08:00
|
|
|
<template>
|
|
|
|
|
<el-card>
|
|
|
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
2026-09-10 16:59:15 +08:00
|
|
|
title="工位数以数据库为准(仅改名称,不增删工位)。本页为工位总览,每个工位的工艺流程在「关联工位」页维护:在下拉选择启用的工艺流程即绑定到该工位;一个工位只能有一个启用的工艺流程。" />
|
2026-08-31 12:58:28 +08:00
|
|
|
|
|
|
|
|
<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 />
|
2026-09-10 16:59:15 +08:00
|
|
|
<el-table-column label="绑定工艺流程" min-width="240">
|
2026-08-31 12:58:28 +08:00
|
|
|
<template #default="{ row }">
|
2026-09-10 16:59:15 +08:00
|
|
|
<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>
|
2026-08-31 12:58:28 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="操作" width="120" align="center" fixed="right">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-button v-if="can('produce.station:edit')" size="small" @click="openName(row)">改名</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
<el-dialog v-model="dlg.show" :title="`工位${dlg.stationNo} - 修改名称`" width="420px">
|
|
|
|
|
<el-form :model="dlg" label-width="90px">
|
|
|
|
|
<el-form-item label="工位名称" required>
|
|
|
|
|
<el-input v-model="dlg.name" placeholder="如 一号装配工位" />
|
|
|
|
|
</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-card>
|
2026-09-07 11:58:19 +08:00
|
|
|
<PageHelp :data="helpStation" page="Station" />
|
2026-08-31 12:58:28 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { reactive, ref, computed, onMounted } from 'vue'
|
|
|
|
|
import { ElMessage } 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([])
|
2026-09-10 16:59:15 +08:00
|
|
|
const flows = ref([])
|
2026-08-31 12:58:28 +08:00
|
|
|
|
|
|
|
|
const rows = computed(() => {
|
2026-09-10 16:59:15 +08:00
|
|
|
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 }))
|
2026-08-31 12:58:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const dlg = reactive({ show: false, id: 0, stationNo: 1, name: '' })
|
|
|
|
|
|
|
|
|
|
async function load() {
|
|
|
|
|
stations.value = (await request.get('/stations')) || []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openName(row) {
|
|
|
|
|
Object.assign(dlg, { show: true, id: row.id, stationNo: row.stationNo, name: row.name })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function save() {
|
|
|
|
|
if (!dlg.name) return ElMessage.warning('请输入工位名称')
|
|
|
|
|
await request.post('/stations', {
|
|
|
|
|
id: dlg.id, stationNo: dlg.stationNo, name: dlg.name
|
|
|
|
|
})
|
|
|
|
|
ElMessage.success('已保存')
|
|
|
|
|
dlg.show = false
|
|
|
|
|
load()
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-10 16:59:15 +08:00
|
|
|
async function bindFlow(row, fid) {
|
|
|
|
|
try {
|
|
|
|
|
await request.post('/stations', { id: row.id, stationNo: row.stationNo, name: row.name, flowId: fid })
|
|
|
|
|
ElMessage.success(fid ? '已绑定工艺流程' : '已解除绑定')
|
|
|
|
|
} catch {
|
|
|
|
|
// 拦截器已提示(如绑定到未启用的流程)
|
|
|
|
|
} finally {
|
|
|
|
|
await load()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await load()
|
|
|
|
|
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
|
|
|
|
|
})
|
2026-08-31 12:58:28 +08:00
|
|
|
</script>
|