refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -59,8 +59,12 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="300" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="can('produce.workorder:dailyplan') && !['DONE','CANCELLED'].includes(row.status)"
|
||||
size="small" type="success" plain @click="openAutoSchedule(row)">自动排产</el-button>
|
||||
<el-tooltip v-if="can('produce.workorder:dailyplan') && !['DONE','CANCELLED'].includes(row.status)"
|
||||
:disabled="hasCombination(row)" content="请先选择工艺组合" placement="top">
|
||||
<span style="margin-right:12px">
|
||||
<el-button size="small" type="success" plain :disabled="!hasCombination(row)" @click="openAutoSchedule(row)">自动排产</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-dropdown
|
||||
v-if="can('produce.workorder:edit') && statusActions(row.status).length"
|
||||
trigger="click" @command="(cmd) => changeStatus(row, cmd)">
|
||||
@@ -88,7 +92,7 @@
|
||||
</el-card>
|
||||
|
||||
<!-- 新建/编辑工单 -->
|
||||
<el-dialog v-model="dialog.show" :title="dialog.id ? '编辑工单' : '新建工单'" width="560px">
|
||||
<el-dialog v-model="dialog.show" :title="dialog.id ? '编辑工单' : '新建工单'" width="640px">
|
||||
<el-form :model="dialog" label-width="90px">
|
||||
<el-form-item label="工单号" required><el-input v-model="dialog.workOrderNo" /></el-form-item>
|
||||
<el-form-item label="产品型号" required>
|
||||
@@ -114,6 +118,25 @@
|
||||
<el-date-picker v-model="dialog.planStart" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="计划开始日期(选填)" style="width:100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="工艺组合" required>
|
||||
<div style="width:100%">
|
||||
<el-checkbox-group v-model="selStations" class="combo-group">
|
||||
<template v-for="g in flowGroups" :key="g.key">
|
||||
<div class="combo-group-title" :class="{ 'combo-empty': g.flowId === 0 }">
|
||||
{{ g.title }}({{ g.stations.length }} 个工位)
|
||||
</div>
|
||||
<el-checkbox v-for="st in g.stations" :key="st.stationNo" :label="st.stationNo" :disabled="g.flowId === 0">
|
||||
工位{{ st.stationNo }}<span v-if="st.name" class="combo-station-name">{{ st.name }}</span>
|
||||
</el-checkbox>
|
||||
</template>
|
||||
</el-checkbox-group>
|
||||
<div v-if="routeText" class="combo-route">
|
||||
执行路线:{{ routeText }}
|
||||
<span class="combo-route-tip">(执行顺序=工位号升序,可跳过未选工位)</span>
|
||||
</div>
|
||||
<div class="combo-tip">默认每个已绑定工艺的工位全选;至少选一道工艺;全不选某工艺则该工艺不进入组合。</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="dialog.show=false">取消</el-button>
|
||||
@@ -208,6 +231,59 @@ const query = reactive({ orderNo: '', productCode: '', productName: '', contract
|
||||
const list = ref([])
|
||||
const productTypes = ref([])
|
||||
|
||||
// 工艺组合:数据源=工位(含 flowId/flowName)+ 工艺列表;按工艺分组勾选工位
|
||||
const stations = ref([])
|
||||
const flows = ref([])
|
||||
const selStations = ref([])
|
||||
|
||||
const flowGroups = computed(() => {
|
||||
const map = new Map()
|
||||
stations.value.forEach((s) => {
|
||||
const fid = s.flowId || 0
|
||||
if (!map.has(fid)) map.set(fid, { flowId: fid, flowName: s.flowName || '', stations: [] })
|
||||
map.get(fid).stations.push(s)
|
||||
})
|
||||
flows.value.forEach((f) => {
|
||||
if (map.has(f.id) && f.name) map.get(f.id).flowName = f.name
|
||||
})
|
||||
const arr = Array.from(map.values())
|
||||
arr.sort((a, b) => {
|
||||
if (a.flowId === 0) return 1
|
||||
if (b.flowId === 0) return -1
|
||||
return (a.flowName || '').localeCompare(b.flowName || '', 'zh')
|
||||
})
|
||||
return arr.map((g) => ({
|
||||
key: g.flowId,
|
||||
flowId: g.flowId,
|
||||
title: g.flowId ? (g.flowName || `工艺${g.flowId}`) : '未绑定工艺',
|
||||
stations: [...g.stations].sort((a, b) => (a.stationNo || 0) - (b.stationNo || 0))
|
||||
}))
|
||||
})
|
||||
|
||||
// 组合结果 [{flowId,stationNo}]:勾选工位映射其绑定工艺;按工位号升序即执行路线
|
||||
const flowCombination = computed(() =>
|
||||
stations.value
|
||||
.filter((s) => s.flowId > 0 && selStations.value.includes(s.stationNo))
|
||||
.map((s) => ({ flowId: s.flowId, stationNo: s.stationNo }))
|
||||
.sort((a, b) => a.stationNo - b.stationNo)
|
||||
)
|
||||
const routeText = computed(() => flowCombination.value.map((c) => c.stationNo).join('→'))
|
||||
|
||||
const hasCombination = (row) => Array.isArray(row.flowCombination) && row.flowCombination.length > 0
|
||||
|
||||
function defaultSelStations() {
|
||||
return stations.value.filter((s) => s.flowId > 0).map((s) => s.stationNo).sort((a, b) => a - b)
|
||||
}
|
||||
|
||||
async function loadComboData() {
|
||||
try {
|
||||
stations.value = (await request.get('/stations')) || []
|
||||
} catch { stations.value = [] }
|
||||
try {
|
||||
flows.value = (await request.get('/process-flows', { params: { page: 1, pageSize: 1000 } }))?.list || []
|
||||
} catch { flows.value = [] }
|
||||
}
|
||||
|
||||
const dialog = reactive({ show: false, id: 0, workOrderNo: '', productTypeId: 0, productCode: '', productName: '', contractNo: '', projectNo: '', productSerial: '', quantity: 1, dueDate: '', planStart: '', status: 'CREATED' })
|
||||
|
||||
async function load() {
|
||||
@@ -221,7 +297,7 @@ async function load() {
|
||||
list.value = data || []
|
||||
}
|
||||
async function loadProducts() {
|
||||
productTypes.value = (await request.get('/product-types')) || []
|
||||
productTypes.value = (await request.get('/product-types', { params: { isActive: 'true' } })) || []
|
||||
}
|
||||
function genOrderNo() {
|
||||
const d = new Date()
|
||||
@@ -241,13 +317,18 @@ function onProductTypeChange(id) {
|
||||
}
|
||||
function openCreate() {
|
||||
Object.assign(dialog, { show: true, id: 0, workOrderNo: genOrderNo(), productTypeId: 0, productCode: '', productName: '', contractNo: '', projectNo: '', productSerial: '', quantity: 1, dueDate: '', planStart: '', status: 'CREATED' })
|
||||
selStations.value = defaultSelStations()
|
||||
}
|
||||
function openEdit(row) {
|
||||
Object.assign(dialog, { show: true, id: row.id, workOrderNo: row.workOrderNo, productTypeId: row.productTypeId, productCode: row.productCode, productName: row.productName, contractNo: row.contractNo || '', projectNo: row.projectNo || '', productSerial: row.productSerial || '', quantity: row.quantity, dueDate: row.dueDate ? String(row.dueDate).slice(0, 10) : '', planStart: row.planStart ? String(row.planStart).slice(0, 10) : '', status: row.status })
|
||||
selStations.value = hasCombination(row)
|
||||
? [...new Set(row.flowCombination.map((c) => c.stationNo))].sort((a, b) => a - b)
|
||||
: defaultSelStations()
|
||||
}
|
||||
async function save() {
|
||||
if (!dialog.dueDate) return ElMessage.warning('请选择完成日期(必填)')
|
||||
const body = { id: dialog.id, workOrderNo: dialog.workOrderNo, productTypeId: dialog.productTypeId, productCode: dialog.productCode, productName: dialog.productName, contractNo: dialog.contractNo, projectNo: dialog.projectNo, productSerial: dialog.productSerial, quantity: dialog.quantity, dueDate: dialog.dueDate, planStart: dialog.planStart }
|
||||
if (!flowCombination.value.length) return ElMessage.warning('请至少勾选一个工位形成工艺组合')
|
||||
const body = { id: dialog.id, workOrderNo: dialog.workOrderNo, productTypeId: dialog.productTypeId, productCode: dialog.productCode, productName: dialog.productName, contractNo: dialog.contractNo, projectNo: dialog.projectNo, productSerial: dialog.productSerial, quantity: dialog.quantity, dueDate: dialog.dueDate, planStart: dialog.planStart, flowCombination: flowCombination.value }
|
||||
if (dialog.id) await request.put('/work-orders', body)
|
||||
else await request.post('/work-orders', body)
|
||||
ElMessage.success('保存成功')
|
||||
@@ -338,10 +419,17 @@ async function submitAutoSchedule() {
|
||||
sched.show = false
|
||||
}
|
||||
|
||||
onMounted(async () => { load(); loadProducts() })
|
||||
onMounted(async () => { load(); loadProducts(); loadComboData() })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sched-tip { font-size: 12px; color: #909399; margin-top: 4px; }
|
||||
.sched-preview { font-size: 13px; color: #606266; line-height: 1.7; background: #f5f7fa; padding: 8px 12px; border-radius: 4px; width: 100%; }
|
||||
.combo-group { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; width: 100%; }
|
||||
.combo-group-title { width: 100%; font-size: 12px; font-weight: 600; color: #303133; background: #f5f7fa; padding: 4px 8px; border-radius: 4px; margin-top: 4px; }
|
||||
.combo-group-title.combo-empty { color: #909399; font-weight: 500; }
|
||||
.combo-station-name { margin-left: 6px; font-size: 12px; color: #909399; }
|
||||
.combo-route { margin-top: 8px; font-size: 13px; color: #1668dc; background: #ecf3fe; padding: 6px 10px; border-radius: 4px; width: 100%; }
|
||||
.combo-route-tip { color: #909399; font-size: 12px; }
|
||||
.combo-tip { font-size: 12px; color: #909399; margin-top: 6px; line-height: 1.5; width: 100%; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user