85 lines
3.0 KiB
Vue
85 lines
3.0 KiB
Vue
<template>
|
||||
|
|
<el-card>
|
|||
|
|
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
|||
|
|
title="产线固定 12 个工位,本页为工位总览(不增删工位)。每个工位的工艺流程在「工艺流程」页维护:工艺流程选工位号并启用后,即自动绑定到该工位;一个工位只能有一个启用的工艺流程。" />
|
|||
|
|
|
|||
|
|
<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="绑定工艺流程" min-width="220" show-overflow-tooltip>
|
|||
|
|
<template #default="{ row }">
|
|||
|
|
<span v-if="row.flowName">{{ row.flowName }}</span>
|
|||
|
|
<span v-else style="color:#909399">未绑定(请在「工艺流程」页为该工位启用流程)</span>
|
|||
|
|
</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>
|
|||
|
|
<PageHelp :data="helpStation" />
|
|||
|
|
</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([])
|
|||
|
|
|
|||
|
|
const rows = computed(() => {
|
|||
|
|
const map = {}
|
|||
|
|
stations.value.forEach((s) => { map[s.stationNo] = s })
|
|||
|
|
const out = []
|
|||
|
|
for (let i = 1; i <= 12; i++) {
|
|||
|
|
const s = map[i]
|
|||
|
|
out.push({
|
|||
|
|
stationNo: i,
|
|||
|
|
name: s ? s.name : `工位${i}`,
|
|||
|
|
flowName: s ? s.flowName : '',
|
|||
|
|
flowId: s ? s.flowId : 0
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
return out
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
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()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
onMounted(load)
|
|||
|
|
</script>
|