feat: 完成产线MES系统全流程功能迭代与优化
本提交完成了多个核心模块的功能完善与业务对齐: 1. 工位终端:固定工位配置、移除自选工位逻辑、适配配置化工位号 2. MES核心:重构工位组合逻辑、新增工单/流程状态管理、补全报工/追溯逻辑 3. WMS客户端:新增修改密码功能、优化帮助弹窗逻辑 4. 文档与权限:补充完整操作手册、统一菜单名称与权限描述 5. 修复多业务校验:排产数量校验、工单状态校验、工位绑定规则
This commit is contained in:
@@ -1,103 +1,79 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<el-tabs v-model="tab" @tab-change="onTabChange">
|
||||
<!-- ============ Tab1:工艺流程管理 ============ -->
|
||||
<el-tab-pane label="工艺流程管理" name="flows">
|
||||
<el-form inline>
|
||||
<el-form-item label="工序号">
|
||||
<el-select v-model="query.processCode" placeholder="全部" clearable style="width:140px" @change="loadFlows">
|
||||
<el-option v-for="i in 12" :key="i" :label="`工序${i}`" :value="i" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="loadFlows">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button v-if="can('produce.processflow:add')" type="success" @click="openFlow()">新增流程</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form inline>
|
||||
<el-form-item label="工位号">
|
||||
<el-select v-model="query.stationNo" placeholder="全部" clearable style="width:140px" @change="loadFlows">
|
||||
<el-option v-for="i in 12" :key="i" :label="`工位${i}`" :value="i" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="loadFlows">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button v-if="can('produce.processflow:add')" type="success" @click="openFlow()">新增流程</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="flows" border size="small">
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column prop="name" label="流程名" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="processCode" label="工序编号" width="90" align="center" />
|
||||
<el-table-column label="PDF" width="130" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.pdfFile" link type="primary" @click="previewPdf(row.pdfFile)">预览</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'ACTIVE' ? 'success' : 'info'">{{ row.status }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="绑定工位" min-width="110">
|
||||
<template #default="{ row }">{{ (row.stations || []).join(', ') || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="步骤" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip
|
||||
v-if="row.steps && row.steps.length"
|
||||
:content="row.steps.map(s => `${s.seq}.${s.name}`).join(' ')">
|
||||
<span>{{ row.steps.length }} 步</span>
|
||||
</el-tooltip>
|
||||
<span v-else>0 步</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="创建时间" width="150">
|
||||
<template #default="{ row }">{{ fmt(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="can('produce.processflow:add') || can('produce.processflow:edit')"
|
||||
size="small" @click="openFlow(row)">编辑</el-button>
|
||||
<el-button v-if="can('produce.processflow:delete')" size="small" type="danger" @click="delFlow(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- ============ Tab2:工位管理 ============ -->
|
||||
<el-tab-pane label="工位管理" name="stations">
|
||||
<div style="margin-bottom:10px">
|
||||
<el-button v-if="can('produce.station:edit')" type="success" @click="openStation()">新增工位</el-button>
|
||||
</div>
|
||||
<el-table :data="stations" border size="small">
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column prop="stationNo" label="工位号" width="90" align="center" />
|
||||
<el-table-column prop="name" label="工位名称" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="flowName" label="绑定流程" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="processCode" label="工序编号" width="90" align="center" />
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'ACTIVE' ? 'success' : 'info'">{{ row.status }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="can('produce.station:edit')" size="small" @click="openStation(row)">编辑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<el-table :data="flows" border size="small">
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column prop="name" label="流程名" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="stationNo" label="工位号" width="90" align="center" />
|
||||
<el-table-column label="PDF" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.pdfFile" link type="primary" @click="previewPdf(row.pdfFile)">预览</el-button>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'ACTIVE' ? 'success' : 'info'">{{ statusText(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="绑定工位" min-width="120">
|
||||
<template #default="{ row }">{{ (row.stations || []).map(s => `工位${s}`).join('、') || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="步骤" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tooltip
|
||||
v-if="row.steps && row.steps.length"
|
||||
:content="row.steps.map(s => `${s.seq}.${s.name}`).join(' ')">
|
||||
<span>{{ row.steps.length }} 步</span>
|
||||
</el-tooltip>
|
||||
<span v-else>0 步</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="创建时间" width="150">
|
||||
<template #default="{ row }">{{ fmt(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="can('produce.processflow:add') || can('produce.processflow:edit')"
|
||||
size="small" @click="openFlow(row)">编辑</el-button>
|
||||
<el-button
|
||||
v-if="can('produce.processflow:edit')"
|
||||
size="small" :type="row.status === 'ACTIVE' ? 'danger' : 'success'" @click="toggleStatus(row)">
|
||||
{{ row.status === 'ACTIVE' ? '停用' : '启用' }}
|
||||
</el-button>
|
||||
<el-button v-if="can('produce.processflow:delete')" size="small" type="danger" @click="delFlow(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- ============ 工艺流程 新增/编辑 ============ -->
|
||||
<el-dialog v-model="flowDlg.show" :title="flowDlg.id ? '编辑工艺流程' : '新增工艺流程'" width="920px" top="6vh">
|
||||
<el-dialog v-model="flowDlg.show" :title="flowDlg.id ? '编辑工艺流程' : '新增工艺流程'" width="940px" top="6vh">
|
||||
<el-form :model="flowDlg" label-width="90px">
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="流程名" required>
|
||||
<el-input v-model="flowDlg.name" placeholder="如 一号线总装流程" />
|
||||
<el-input v-model="flowDlg.name" placeholder="如 3号工位装配流程" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="工序编号" required>
|
||||
<el-select v-model="flowDlg.processCode" style="width:100%">
|
||||
<el-option v-for="i in 12" :key="i" :label="`工序${i}`" :value="i" />
|
||||
<el-form-item label="工位号" required>
|
||||
<el-select v-model="flowDlg.stationNo" placeholder="请选择工位号(固定12个)" style="width:100%">
|
||||
<el-option v-for="i in 12" :key="i" :label="`工位${i}`" :value="i" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -105,14 +81,14 @@
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="flowDlg.status" style="width:100%">
|
||||
<el-select v-model="flowDlg.status" placeholder="请选择状态" style="width:100%">
|
||||
<el-option label="启用" value="ACTIVE" />
|
||||
<el-option label="停用" value="INACTIVE" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="工序PDF">
|
||||
<el-form-item label="作业指导PDF">
|
||||
<el-button
|
||||
v-if="can('produce.processflow:upload')"
|
||||
type="primary" plain :loading="flowDlg.uploading" @click="pickPdf">
|
||||
@@ -130,8 +106,8 @@
|
||||
<el-input v-model="flowDlg.remark" placeholder="备注(可空)" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 步骤模板子表 -->
|
||||
<el-form-item label="步骤模板">
|
||||
<!-- 工序步骤子表 -->
|
||||
<el-form-item label="工序步骤">
|
||||
<div style="width:100%">
|
||||
<el-table :data="flowDlg.steps" border size="small">
|
||||
<el-table-column label="步骤" width="80" align="center">
|
||||
@@ -142,7 +118,7 @@
|
||||
<el-table-column label="步骤名称" min-width="140">
|
||||
<template #default="{ row }"><el-input v-model="row.name" placeholder="如 拧紧扭矩" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="采集方式" width="130">
|
||||
<el-table-column label="采集方式" width="140">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.collectType" placeholder="请选择">
|
||||
<el-option value="AUTO" label="拧紧枪自动" />
|
||||
@@ -157,64 +133,19 @@
|
||||
<el-table-column label="备注" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.remark" placeholder="备注(可空)" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" align="center">
|
||||
<el-table-column label="考核标准" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="row._showCrit = !row._showCrit">
|
||||
{{ row._showCrit ? '收起标准' : '考核标准' }}
|
||||
<el-button link type="primary" size="small" @click="openCriteria(row)">
|
||||
{{ (row.criteria || []).length }} 条
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="70" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" size="small" @click="removeStep(row)">删</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 考核标准编辑 -->
|
||||
<template v-for="row in flowDlg.steps" :key="row._key">
|
||||
<div v-if="row._showCrit" class="crit-box">
|
||||
<b>考核标准:{{ row.name || '(未命名步骤)' }}</b>
|
||||
<el-table :data="row.criteria" border size="small" style="margin-top:8px">
|
||||
<el-table-column label="指标名" min-width="110">
|
||||
<template #default="{ row: c }"><el-input v-model="c.name" placeholder="如 扭矩" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" width="80">
|
||||
<template #default="{ row: c }"><el-input v-model="c.unit" placeholder="N·m" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="逻辑" width="120">
|
||||
<template #default="{ row: c }">
|
||||
<el-select v-model="c.logic" placeholder="请选择">
|
||||
<el-option value="GE" label="≥" />
|
||||
<el-option value="LE" label="≤" />
|
||||
<el-option value="GT" label=">" />
|
||||
<el-option value="LT" label="<" />
|
||||
<el-option value="RANGE" label="区间" />
|
||||
<el-option value="EQUAL" label="=" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="cLogicNeedsTarget(row)" label="目标值" width="110">
|
||||
<template #default="{ row: c }">
|
||||
<el-input-number v-model="c.target" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="editingRanges(row)" label="下限" width="110">
|
||||
<template #default="{ row: c }">
|
||||
<el-input-number v-model="c.min" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="editingRanges(row)" label="上限" width="110">
|
||||
<template #default="{ row: c }">
|
||||
<el-input-number v-model="c.max" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="70" align="center">
|
||||
<template #default="{ row: c }">
|
||||
<el-button link type="danger" size="small" @click="removeCriterion(row, c)">删</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-button size="small" style="margin-top:8px" @click="addCriterion(row)">新增标准行</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-button size="small" style="margin-top:10px" @click="addStep">新增步骤</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@@ -227,26 +158,54 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- ============ 工位 新增/编辑 ============ -->
|
||||
<el-dialog v-model="stationDlg.show" :title="stationDlg.id ? '编辑工位' : '新增工位'" width="460px">
|
||||
<el-form :model="stationDlg" label-width="90px">
|
||||
<el-form-item label="工位号" required>
|
||||
<el-select v-model="stationDlg.stationNo" style="width:100%">
|
||||
<el-option v-for="i in 12" :key="i" :label="`工位${i}`" :value="i" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="工位名称" required>
|
||||
<el-input v-model="stationDlg.name" placeholder="如 一号工位" />
|
||||
</el-form-item>
|
||||
<el-form-item label="绑定流程" required>
|
||||
<el-select v-model="stationDlg.flowId" filterable placeholder="请选择工艺流程" style="width:100%">
|
||||
<el-option v-for="f in flowOptions" :key="f.id" :label="f.name" :value="f.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- ============ 考核标准编辑(每步骤独立弹窗,单独保存) ============ -->
|
||||
<el-dialog v-model="critDlg.show" :title="`考核标准 - ${critDlg.stepName || ''}`" width="720px" top="10vh" append-to-body>
|
||||
<el-alert type="info" :closable="false" style="margin-bottom:12px"
|
||||
title="为「步骤」设置合格判定标准:报工时按此标准自动判定合格/不合格;未设标准则该步骤仅记录、不判定。" />
|
||||
<el-table :data="critDlg.criteria" border size="small">
|
||||
<el-table-column label="指标名" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.name" placeholder="如 扭矩" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" width="80">
|
||||
<template #default="{ row }"><el-input v-model="row.unit" placeholder="N·m" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="逻辑" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.logic" placeholder="请选择">
|
||||
<el-option value="GE" label="≥ 大于等于" />
|
||||
<el-option value="LE" label="≤ 小于等于" />
|
||||
<el-option value="GT" label="> 大于" />
|
||||
<el-option value="LT" label="< 小于" />
|
||||
<el-option value="RANGE" label="区间" />
|
||||
<el-option value="EQUAL" label="= 等于" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="needsTarget" label="目标值" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.target" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="needsRange" label="下限" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.min" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="needsRange" label="上限" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.max" :step="1" controls-position="right" style="width:100%" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="70" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" size="small" @click="removeCriterion(row)">删</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-button size="small" style="margin-top:10px" @click="addCriterion">新增标准行</el-button>
|
||||
<template #footer>
|
||||
<el-button @click="stationDlg.show = false">取消</el-button>
|
||||
<el-button v-if="can('produce.station:edit')" type="primary" @click="saveStation">保存</el-button>
|
||||
<el-button @click="critDlg.show = false">取消</el-button>
|
||||
<el-button type="primary" @click="saveCriteria">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
@@ -254,18 +213,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import PageHelp from '../components/PageHelp.vue'
|
||||
import { helpProcessFlow } from '../help'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import request from '../utils/request'
|
||||
|
||||
const tab = ref('flows')
|
||||
const flows = ref([])
|
||||
const stations = ref([])
|
||||
const flowOptions = ref([])
|
||||
const query = reactive({ processCode: undefined })
|
||||
|
||||
const query = reactive({ stationNo: undefined })
|
||||
const pdfInput = ref(null)
|
||||
|
||||
/* ---------- 权限 ---------- */
|
||||
@@ -280,6 +235,10 @@ function can(code) {
|
||||
}
|
||||
}
|
||||
|
||||
function statusText(s) {
|
||||
return s === 'ACTIVE' ? '启用' : '停用'
|
||||
}
|
||||
|
||||
/* ---------- 工艺流程 ---------- */
|
||||
function blankStep(seq) {
|
||||
return {
|
||||
@@ -289,14 +248,13 @@ function blankStep(seq) {
|
||||
collectType: 'MANUAL',
|
||||
isTorque: false,
|
||||
remark: '',
|
||||
criteria: [],
|
||||
_showCrit: false
|
||||
criteria: []
|
||||
}
|
||||
}
|
||||
|
||||
async function loadFlows() {
|
||||
const params = {}
|
||||
if (query.processCode) params.processCode = query.processCode
|
||||
if (query.stationNo) params.stationNo = query.stationNo
|
||||
flows.value = (await request.get('/process-flows', { params })) || []
|
||||
}
|
||||
|
||||
@@ -334,7 +292,7 @@ async function onPdfChange(e) {
|
||||
}
|
||||
|
||||
const flowDlg = reactive({
|
||||
show: false, id: 0, name: '', processCode: 1, pdfFile: '', status: 'ACTIVE',
|
||||
show: false, id: 0, name: '', stationNo: 1, pdfFile: '', status: 'ACTIVE',
|
||||
remark: '', uploading: false, steps: []
|
||||
})
|
||||
|
||||
@@ -342,7 +300,7 @@ function openFlow(row) {
|
||||
if (row) {
|
||||
flowDlg.id = row.id
|
||||
flowDlg.name = row.name || ''
|
||||
flowDlg.processCode = row.processCode
|
||||
flowDlg.stationNo = row.stationNo || 1
|
||||
flowDlg.pdfFile = row.pdfFile || ''
|
||||
flowDlg.status = row.status || 'ACTIVE'
|
||||
flowDlg.remark = row.remark || ''
|
||||
@@ -353,12 +311,11 @@ function openFlow(row) {
|
||||
collectType: s.collectType || 'MANUAL',
|
||||
isTorque: !!s.isTorque,
|
||||
remark: s.remark || '',
|
||||
criteria: (s.criteria || []).map((c) => ({ ...c })),
|
||||
_showCrit: false
|
||||
criteria: (s.criteria || []).map((c) => ({ ...c }))
|
||||
}))
|
||||
} else {
|
||||
Object.assign(flowDlg, {
|
||||
id: 0, name: '', processCode: 1, pdfFile: '', status: 'ACTIVE', remark: '', steps: []
|
||||
id: 0, name: '', stationNo: 1, pdfFile: '', status: 'ACTIVE', remark: '', steps: []
|
||||
})
|
||||
}
|
||||
if (!flowDlg.steps.length) flowDlg.steps.push(blankStep(1))
|
||||
@@ -373,31 +330,46 @@ function removeStep(row) {
|
||||
const i = flowDlg.steps.indexOf(row)
|
||||
if (i >= 0) flowDlg.steps.splice(i, 1)
|
||||
}
|
||||
function addCriterion(row) {
|
||||
row.criteria.push({ name: '', unit: '', logic: 'GE', target: null, min: null, max: null })
|
||||
|
||||
/* ---------- 考核标准(独立弹窗) ---------- */
|
||||
const critDlg = reactive({ show: false, stepName: '', criteria: [], _step: null })
|
||||
|
||||
const needsTarget = computed(() => critDlg.criteria.some((c) => c.logic && c.logic !== 'RANGE'))
|
||||
const needsRange = computed(() => critDlg.criteria.some((c) => c.logic === 'RANGE'))
|
||||
|
||||
function openCriteria(step) {
|
||||
critDlg._step = step
|
||||
critDlg.stepName = step.name || '(未命名步骤)'
|
||||
critDlg.criteria = (step.criteria || []).map((c) => ({ ...c }))
|
||||
critDlg.show = true
|
||||
}
|
||||
function removeCriterion(row, c) {
|
||||
const i = row.criteria.indexOf(c)
|
||||
if (i >= 0) row.criteria.splice(i, 1)
|
||||
function addCriterion() {
|
||||
critDlg.criteria.push({ name: '', unit: '', logic: 'GE', target: null, min: null, max: null })
|
||||
}
|
||||
function cLogicNeedsTarget(row) {
|
||||
return row.criteria.some((c) => c.logic && c.logic !== 'RANGE')
|
||||
function removeCriterion(c) {
|
||||
const i = critDlg.criteria.indexOf(c)
|
||||
if (i >= 0) critDlg.criteria.splice(i, 1)
|
||||
}
|
||||
function editingRanges(row) {
|
||||
return row.criteria.some((c) => c.logic === 'RANGE')
|
||||
function saveCriteria() {
|
||||
if (critDlg._step) {
|
||||
critDlg._step.criteria = critDlg.criteria
|
||||
.filter((c) => c.name)
|
||||
.map((c) => ({ ...c }))
|
||||
}
|
||||
critDlg.show = false
|
||||
}
|
||||
|
||||
async function saveFlow() {
|
||||
if (!flowDlg.name) return ElMessage.warning('请填写流程名')
|
||||
if (!flowDlg.processCode) return ElMessage.warning('请选择工序编号')
|
||||
if (!flowDlg.stationNo) return ElMessage.warning('请选择工位号(1~12)')
|
||||
const body = {
|
||||
id: flowDlg.id || undefined,
|
||||
name: flowDlg.name,
|
||||
processCode: flowDlg.processCode,
|
||||
stationNo: flowDlg.stationNo,
|
||||
pdfFile: flowDlg.pdfFile,
|
||||
status: flowDlg.status,
|
||||
remark: flowDlg.remark,
|
||||
steps: flowDlg.steps.map(({ _key, _showCrit, ...st }) => ({
|
||||
steps: flowDlg.steps.map(({ _key, ...st }) => ({
|
||||
seq: st.seq,
|
||||
name: st.name,
|
||||
collectType: st.collectType,
|
||||
@@ -419,61 +391,26 @@ async function delFlow(row) {
|
||||
loadFlows()
|
||||
}
|
||||
|
||||
/* ---------- 工位管理 ---------- */
|
||||
async function loadStations() {
|
||||
stations.value = (await request.get('/stations')) || []
|
||||
}
|
||||
async function loadFlowOptions() {
|
||||
const list = (await request.get('/process-flows', { params: {} })) || []
|
||||
flowOptions.value = list.map((f) => ({ id: f.id, name: f.name }))
|
||||
}
|
||||
|
||||
const stationDlg = reactive({ show: false, id: 0, stationNo: 1, name: '', flowId: null })
|
||||
|
||||
function openStation(row) {
|
||||
if (row) {
|
||||
Object.assign(stationDlg, {
|
||||
show: true, id: row.id, stationNo: row.stationNo, name: row.name || '', flowId: row.flowId || null
|
||||
})
|
||||
async function toggleStatus(row) {
|
||||
const toStatus = row.status === 'ACTIVE' ? 'INACTIVE' : 'ACTIVE'
|
||||
const action = toStatus === 'INACTIVE' ? '停用' : '启用'
|
||||
if (toStatus === 'INACTIVE') {
|
||||
await ElMessageBox.confirm(
|
||||
`确认停用「${row.name}」?停用后将自动解除工位${row.stationNo || ''}的绑定,且该流程不可再被工位使用。`,
|
||||
'提示', { type: 'warning' })
|
||||
} else {
|
||||
Object.assign(stationDlg, { show: true, id: 0, stationNo: 1, name: '', flowId: null })
|
||||
await ElMessageBox.confirm(
|
||||
`确认启用「${row.name}」?启用后将自动绑定到工位${row.stationNo || ''}(该工位若有其他启用流程需先停用)。`,
|
||||
'提示', { type: 'warning' })
|
||||
}
|
||||
}
|
||||
|
||||
async function saveStation() {
|
||||
if (!stationDlg.stationNo) return ElMessage.warning('请选择工位号')
|
||||
if (!stationDlg.name) return ElMessage.warning('请填写工位名称')
|
||||
if (!stationDlg.flowId) return ElMessage.warning('请选择绑定流程')
|
||||
const body = {
|
||||
id: stationDlg.id || undefined,
|
||||
stationNo: stationDlg.stationNo,
|
||||
name: stationDlg.name,
|
||||
flowId: stationDlg.flowId
|
||||
}
|
||||
await request.post('/stations', body)
|
||||
ElMessage.success('保存成功')
|
||||
stationDlg.show = false
|
||||
loadStations()
|
||||
}
|
||||
|
||||
function onTabChange(name) {
|
||||
if (name === 'stations') {
|
||||
loadStations()
|
||||
loadFlowOptions()
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
await request.post('/process-flows/status', { id: row.id, status: toStatus })
|
||||
ElMessage.success(`已${action}`)
|
||||
loadFlows()
|
||||
loadStations()
|
||||
loadFlowOptions()
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(loadFlows)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pdf-name { margin-left: 10px; color: #606266; font-size: 13px; }
|
||||
.crit-box {
|
||||
border: 1px solid #ebeef5; border-radius: 6px; padding: 10px; margin: 8px 0;
|
||||
background: #fafbfc;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user