feat(production-master-data): 新增工艺流程管理完整模块
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

- 添加工艺流程、流程卡工序的全套CRUD及复制接口
- 新增工艺流程列表页与流程卡详情页的路由和页面组件
- 补充产品、工序分类、工序子类的全量查询接口
- 优化弹窗表单组件,支持字段禁用与focus/blur/change事件回调
- 修复工序单元页面的国际化调用和权限配置问题
- 补充中英文多语言国际化文案
- 新增该模块的功能测试文档
This commit is contained in:
sheng
2026-06-04 17:07:15 +08:00
parent b6c362d906
commit 3f546564cc
15 changed files with 2071 additions and 36 deletions

View File

@@ -0,0 +1,580 @@
# 功能测试文档 — 工艺流程 (Process Routing)
> 模块路径:生产配置 → 工艺模型 → **工艺流程**
> 路由:`/production_configuration/technology_model/technology_flow`
> API BASE`production_configuration/technology_model/technology_flow/`
> i18n 前缀:`page.production_master_data.process_model.process_routing`
> 文档版本v1.0
> 适用代码版本:基于 [process-routing/index.vue](file:///d:/code/mes/mes-ui/src/views/production-master-data/process-model/process-routing/index.vue)
> 测试目标:验证工艺流程页面的列表、查询、新增、编辑、删除、流程卡管理入口等核心操作
---
## 0. 文档使用说明
- 测试人员按顺序执行 **T-XX** 编号的测试用例
- 每个用例的 **预期结果** 描述必须与实际界面/接口响应一致才可标记为通过
- 失败的用例在 **问题描述** 列填写具体错误信息、截图编号、操作环境
- 所有"实际结果"必须如实记录,禁止空填或留白
- 整体测试结论位于文末 **测试总结**
---
## 1. 测试环境配置要求
| 项目 | 要求 |
| --- | --- |
| 操作系统 | Windows 10 / 11 64-bit |
| Node.js | **18.16.0**(与项目 `.node-version` / `package.json#engines` 一致) |
| 包管理器 | **pnpm 10.33.0**(与 `package.json#packageManager` 一致) |
| 浏览器 | Chrome 100+ / Edge 100+ |
| 后端服务 | Webman 后端已启动且数据库已初始化 |
| 数据库 | 工艺流程、流程类别、产品、权限等基础数据已存在 |
| 启动命令 | `pnpm install``pnpm dev`,访问 `http://localhost:8080` |
| 测试账号 | 具备「生产配置-工艺模型-工艺流程」读写权限的账号 |
| 浏览器语言 | 中英文均需验证(默认以中文为准) |
---
## 2. 测试前置条件
1. 已使用具备 `production_configuration/technology_model/technology_flow` 下 create / edit / delete 权限的账号登录
2. **流程类别** 至少存在 1 条数据(否则新增时的「流程类别」下拉为空)
3. **产品列表** 至少存在 1 条数据(否则新增时的「关联产品」下拉为空)
4. 浏览器开发者工具 Network 面板可正常观察接口请求
5. 已确认 `src/locales/zh-chs.json``src/locales/en.json` 中存在 `page.production_master_data.process_model.process_routing` 节点
---
## 3. 测试用例
### 3.1 列表与查询
#### T-01页面正常加载
- **操作步骤**
1. 登录系统
2. 进入「生产配置 → 工艺模型 → 工艺流程」
- **预期结果**
- URL 跳转到 `/production_configuration/technology_model/technology_flow`
- 页面顶部展示搜索区(编码、名称、查询、重置)
- 下方展示表格列:序号 / 工艺流程编码 / 工艺流程名称 / 流程类别 / 关联产品 / 版本 / 状态 / 备注 / 操作
- 工具栏右上角显示帮助按钮,鼠标悬停提示「工艺流程用于设置生产工艺流程并管理流程卡…」
- 控制台无报错
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-02默认分页加载列表
- **操作步骤**
1. 访问工艺流程页面
- **预期结果**
- 列表自动加载(无需手动点击查询)
- 加载时表格显示 loading 遮罩
- 加载完成显示数据行(如有数据)
- 分页组件显示「共 X 条」并按 10 条/页 显示
- 发起请求 `GET production_configuration/technology_model/technology_flow/list?method=production_master_data_process_model_process_routing_list&page_no=1&page_size=10&code=&name=`
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-03按编码精确搜索
- **操作步骤**
1. 在「工艺流程编码」输入框输入已存在的完整编码
2. 点击「查询」按钮
- **预期结果**
- 列表仅展示编码完全匹配的数据行
- 列表刷新到第 1 页
- 接口请求参数 `code=<已输入值>`
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-04按名称模糊搜索
- **操作步骤**
1. 在「工艺流程名称」输入框输入名称片段
2. 点击「查询」按钮
- **预期结果**
- 列表仅展示名称包含该片段的数据行
- 接口请求参数 `name=<已输入值>`
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-05按回车键触发查询
- **操作步骤**
1. 在「工艺流程编码」或「工艺流程名称」输入框聚焦
2. 输入关键字后按键盘 `Enter`
- **预期结果**
- 等同于点击「查询」按钮,触发列表刷新
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-06重置搜索条件
- **操作步骤**
1. 在搜索框输入任意条件并点击「查询」
2. 点击「重置」按钮
- **预期结果**
- 两个搜索输入框被清空
- 列表自动以空条件重新加载
- 页码回到第 1 页
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-07分页切换
- **操作步骤**
1. 准备超过 10 条工艺流程数据
2. 在分页器中切换到第 2 页或修改每页条数
- **预期结果**
- 列表按新页码 / 每页条数重新加载
- 接口请求参数 `page_no` / `page_size` 与界面一致
- 分页总数保持正确
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-08空数据展示
- **操作步骤**
1. 在没有任何工艺流程数据时访问页面,或筛选一个不存在的数据
- **预期结果**
- 表格区域显示 Element UI 空数据占位(无红色错误)
- 分页器显示「共 0 条」
- 不会弹出错误提示
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-09i18n 中文切换
- **操作步骤**
1. 在用户设置中切换语言到「简体中文」
2. 访问工艺流程页面
- **预期结果**
- 所有表头、按钮、提示文本为中文("工艺流程编码"、"新增"、"删除"等)
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-10i18n 英文切换
- **操作步骤**
1. 切换语言到「English」
2. 访问工艺流程页面
- **预期结果**
- 所有表头、按钮、提示文本为英文("Routing Code"、"Add"、"Delete" 等)
- 切换瞬间不需要刷新页面即生效
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.2 新增
#### T-11打开新增弹窗
- **操作步骤**
1. 点击工具栏的「新增」按钮
- **预期结果**
- 弹出标题为「新增工艺流程」的对话框(宽 40%
- 表单为空且编码字段可编辑
- 默认值:版本 = `1.0`、状态 = 启用
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-12新增必填校验 — 编码
- **操作步骤**
1. 打开新增弹窗
2. 编码留空,其它字段填写完整
3. 点击「确定」
- **预期结果**
- 编码输入框下方红色提示「请输入工艺流程编码」
- 接口未发起,弹窗保持打开
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-13新增必填校验 — 名称
- **操作步骤**
1. 打开新增弹窗
2. 名称留空,其它字段填写完整
3. 点击「确定」
- **预期结果**
- 名称输入框下方红色提示「请输入工艺流程名称」
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-14新增必填校验 — 流程类别
- **操作步骤**
1. 打开新增弹窗
2. 不选择「流程类别」
3. 点击「确定」
- **预期结果**
- 流程类别下拉框下方红色提示「请选择流程类别」
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-15新增必填校验 — 版本
- **操作步骤**
1. 打开新增弹窗
2. 清空「版本」(默认 `1.0`
3. 点击「确定」
- **预期结果**
- 版本输入框下方红色提示「请输入版本号」
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-16新增字段长度校验
- **操作步骤**
1. 打开新增弹窗
2. 在「编码」输入超过 100 个字符
3. 点击「确定」
- **预期结果**
- 编码输入框下方红色提示「长度在 1 到 100 个字符」
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-17新增成功
- **操作步骤**
1. 打开新增弹窗
2. 填写完整有效数据:编码、名称、流程类别、关联产品、版本、状态、备注
3. 点击「确定」
- **预期结果**
- 接口请求 `POST production_configuration/technology_model/technology_flow/create` 状态码 200`code=0`
- 页面弹出绿色提示「操作成功」
- 弹窗自动关闭
- 列表自动刷新,新数据展示在表格中
- 页码回到第 1 页
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-18新增重复编码
- **操作步骤**
1. 准备一个已存在的编码
2. 在新增弹窗中输入相同编码
3. 点击「确定」
- **预期结果**
- 后端返回业务错误
- 页面弹出红色错误提示(如「编码已存在」)
- 弹窗保持打开,用户可修改后重试
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-19取消新增
- **操作步骤**
1. 打开新增弹窗,填写部分数据
2. 点击「取消」按钮或右上角 X
- **预期结果**
- 弹窗关闭
- 不发起任何接口请求
- 再次打开新增弹窗,表单恢复为空(默认值除外)
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-20新增提交中重复点击防护
- **操作步骤**
1. 打开新增弹窗,填写有效数据
2. 连续快速点击「确定」两次
- **预期结果**
- 第一次点击后按钮进入 loading 状态,禁用重复提交
- 接口仅被调用 1 次
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.3 编辑
#### T-21打开编辑弹窗
- **操作步骤**
1. 在列表中点击某行的「编辑」按钮
- **预期结果**
- 弹出标题为「编辑工艺流程」的对话框
- 表单自动回填该行数据
- 「编码」字段为禁用状态(不可编辑)
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-22编辑必填校验
- **操作步骤**
1. 打开编辑弹窗
2. 清空「名称」
3. 点击「确定」
- **预期结果**
- 名称输入框下方红色提示「请输入工艺流程名称」
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-23编辑成功
- **操作步骤**
1. 打开编辑弹窗
2. 修改名称、流程类别、版本、状态、备注等字段
3. 点击「确定」
- **预期结果**
- 接口请求 `PUT production_configuration/technology_model/technology_flow/edit` 状态码 200`code=0`
- 页面弹出绿色提示「操作成功」
- 弹窗关闭
- 列表自动刷新,目标行显示新值
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-24编辑时编码不可修改
- **操作步骤**
1. 打开编辑弹窗
2. 尝试修改「编码」字段
- **预期结果**
- 编码字段处于禁用状态,无法输入
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-25取消编辑
- **操作步骤**
1. 打开编辑弹窗,修改若干字段
2. 点击「取消」按钮
- **预期结果**
- 弹窗关闭
- 不发起任何接口请求
- 列表数据保持原样
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.4 删除
#### T-26删除二次确认弹窗
- **操作步骤**
1. 点击某行的「删除」按钮
- **预期结果**
- 弹出警告提示「确定要删除该工艺流程吗?」
- 提示框有「确定」与「取消」两个按钮
- 列表中的该行仍存在
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-27删除 — 取消
- **操作步骤**
1. 点击「删除」按钮
2. 在确认弹窗中点击「取消」
- **预期结果**
- 弹窗关闭
- 不发起删除接口
- 数据行保持原样
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-28删除成功
- **操作步骤**
1. 点击「删除」按钮
2. 在确认弹窗中点击「确定」
- **预期结果**
- 接口请求 `DELETE production_configuration/technology_model/technology_flow/delete` 状态码 200`code=0`
- 页面弹出绿色提示「操作成功」
- 列表自动刷新,目标行消失
- 删除当前页最后一行时,自动跳转到合理页码
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-29删除 — 关联数据拒绝
- **操作步骤**
1. 准备一条已被产品、批次或其它模块引用的工艺流程
2. 尝试删除
- **预期结果**
- 后端返回业务错误
- 页面弹出红色错误提示(如「该工艺流程已被引用,不可删除」)
- 列表数据保持原样
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.5 流程卡管理入口
#### T-30流程卡管理按钮存在
- **操作步骤**
1. 在列表中查看任意一行的操作列
- **预期结果**
- 操作列包含「编辑」、「流程卡管理」、「删除」3 个按钮
- 「流程卡管理」按钮为黄色文字 + `el-icon-tickets` 图标
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-31点击流程卡管理
- **操作步骤**
1. 点击某行的「流程卡管理」按钮
- **预期结果**
- 当前阶段:弹出信息提示「流程卡管理: <工艺流程名称>」(占位实现)
- 后续阶段:应打开独立的流程卡管理抽屉 / 弹窗
- 不影响列表状态
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.6 权限控制
#### T-32无「新增」权限
- **操作步骤**
1. 使用无 `/production_configuration/technology_model/technology_flow/create` 权限的账号登录
2. 访问工艺流程页面
- **预期结果**
- 工具栏不显示「新增」按钮
- 列表正常加载
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-33无「编辑」权限
- **操作步骤**
1. 使用无 `…/edit` 权限的账号登录
2. 访问工艺流程页面
- **预期结果**
- 行内「编辑」按钮不显示
- 「新增」与「删除」按钮仍可正常显示(按权限配置)
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-34无「删除」权限
- **操作步骤**
1. 使用无 `…/delete` 权限的账号登录
2. 访问工艺流程页面
- **预期结果**
- 行内「删除」按钮不显示
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-35未登录访问
- **操作步骤**
1. 退出登录后,直接在地址栏访问 `/production_configuration/technology_model/technology_flow`
- **预期结果**
- 自动跳转到登录页
- 不会出现 404 或白屏
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
### 3.7 错误处理
#### T-36网络异常
- **操作步骤**
1. 在浏览器开发者工具 Network 面板中离线Offline
2. 刷新工艺流程页面
- **预期结果**
- 页面顶部红色错误提示(如「请求超时」或「网络异常」)
- loading 状态关闭
- 表格维持之前的数据或显示空数据
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-37后端 500 错误
- **操作步骤**
1. 模拟后端列表接口返回 500
2. 刷新工艺流程页面
- **预期结果**
- 拦截器统一弹出红色错误提示
- 表格显示空数据
- 控制台无未捕获异常
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
#### T-38参数缺失
- **操作步骤**
1. 模拟后端创建接口缺参返回 `code=500`
2. 在新增弹窗点击「确定」
- **预期结果**
- 拦截器弹出后端返回的错误信息
- 弹窗不关闭
- 表单数据保持原样
- **实际结果**__________
- **测试状态**:☐ 通过 ☐ 失败
- **问题描述**__________
---
## 4. 测试总结
| 维度 | 统计 |
| --- | --- |
| 用例总数 | 38 |
| 通过数 | __________ |
| 失败数 | __________ |
| 阻塞数 | __________ |
| 跳过数 | __________ |
| 整体结论 | ☐ 通过 ☐ 有条件通过 ☐ 不通过 |
### 4.1 遗留问题清单
| 编号 | 用例编号 | 严重程度 | 描述 | 负责人 | 计划修复日期 |
| --- | --- | --- | --- | --- | --- |
| 1 | | | | | |
| 2 | | | | | |
| 3 | | | | | |
### 4.2 测试执行信息
- **测试执行人**__________
- **测试起止时间**__________
- **测试环境版本**Node `18.16.0` / pnpm `10.33.0` / 浏览器 `__________`
- **后端版本 / 提交**__________
- **测试账号**__________
---
## 5. 附录
### 5.1 关键文件
| 类型 | 路径 |
| --- | --- |
| 主页面 | [process-routing/index.vue](file:///d:/code/mes/mes-ui/src/views/production-master-data/process-model/process-routing/index.vue) |
| API 文件 | [process-routing.js](file:///d:/code/mes/mes-ui/src/api/production-master-data/process-routing.js) |
| 路由模块 | [production-master-data.js](file:///d:/code/mes/mes-ui/src/router/modules/production-master-data.js) |
| 中文语言包 | [zh-chs.json#process_routing](file:///d:/code/mes/mes-ui/src/locales/zh-chs.json) |
| 英文语言包 | [en.json#process_routing](file:///d:/code/mes/mes-ui/src/locales/en.json) |
### 5.2 关键接口
| 操作 | Method | URL |
| --- | --- | --- |
| 查询列表 | GET | `production_configuration/technology_model/technology_flow/list` |
| 新增 | POST | `production_configuration/technology_model/technology_flow/create` |
| 编辑 | PUT | `production_configuration/technology_model/technology_flow/edit` |
| 删除 | DELETE | `production_configuration/technology_model/technology_flow/delete` |
公共参数:`method=production_master_data_process_model_process_routing_<action>``platform=background`
### 5.3 字段说明
| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| code | string | 是 | 工艺流程编码,唯一,创建后不可修改 |
| name | string | 是 | 工艺流程名称 |
| category_id | int | 是 | 流程类别 ID关联工艺流程类别 |
| product_id | int | 否 | 关联产品 ID关联产品列表 |
| version | string | 是 | 版本号,默认 `1.0` |
| status | int | 是 | 1=启用0=禁用 |
| remark | string | 否 | 备注 |

View File

@@ -18,6 +18,18 @@ export function getProcessCategoryList (data) {
})
}
export function getProcessCategoryAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: {
method: 'production_configuration_technology_model_technology_flow_category_all',
platform: 'background',
...data
}
})
}
export function createProcessCategory (data) {
return request({
url: BASE + 'create',

View File

@@ -0,0 +1,67 @@
import { request } from '@/api/_service'
const BASE = 'production_configuration/technology_model/technology_flow_process/'
function apiParams (method, data = {}) {
return {
method: `production_configuration_technology_model_technology_flow_process_${method}`,
platform: 'background',
...data
}
}
export function getProcessCardAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: apiParams('all', data)
})
}
export function createProcessCard (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
export function editProcessCard (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
export function deleteProcessCard (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
export function setSetting (data) {
return request({
url: BASE + 'set_setting',
method: 'post',
data: apiParams('set_setting', data)
})
}
export function moveUp (data) {
return request({
url: BASE + 'move_up',
method: 'post',
data: apiParams('move_up', data)
})
}
export function moveDown (data) {
return request({
url: BASE + 'move_down',
method: 'post',
data: apiParams('move_down', data)
})
}

View File

@@ -0,0 +1,51 @@
import { request } from '@/api/_service'
const BASE = 'production_configuration/technology_model/technology_flow/'
function apiParams (method, data = {}) {
return {
method: `production_master_data_process_model_process_routing_${method}`,
platform: 'background',
...data
}
}
export function getProcessRoutingList (data) {
return request({
url: BASE + 'list',
method: 'get',
params: apiParams('list', data)
})
}
export function createProcessRouting (data) {
return request({
url: BASE + 'create',
method: 'post',
data: apiParams('create', data)
})
}
export function editProcessRouting (data) {
return request({
url: BASE + 'edit',
method: 'put',
data: apiParams('edit', data)
})
}
export function deleteProcessRouting (data) {
return request({
url: BASE + 'delete',
method: 'delete',
data: apiParams('delete', data)
})
}
export function copyProcessRouting (data) {
return request({
url: BASE + 'copy',
method: 'post',
data: apiParams('copy', data)
})
}

View File

@@ -18,6 +18,18 @@ export function getProcessStepList (data) {
})
}
export function getWorkingsubclassAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: {
method: 'production_configuration_technology_model_technology_flow_workingsubclass_all',
platform: 'background',
...data
}
})
}
export function createProcessStep (data) {
return request({
url: BASE + 'create',

View File

@@ -18,6 +18,18 @@ export function getProductList (data) {
})
}
export function getProductBatteryAll (data) {
return request({
url: BASE + 'all',
method: 'get',
params: {
method: 'production_configuration_product_model_battery_model_all',
platform: 'background',
...data
}
})
}
export function createProduct (data) {
return request({
url: BASE + 'create',

View File

@@ -68,7 +68,10 @@
:type="col.inputType || 'text'"
:autosize="col.autosize"
:clearable="col.clearable !== false"
:disabled="!!col.disabled"
:style="col.style"
@focus="handleFieldEvent(col, 'focus', $event)"
@blur="handleFieldEvent(col, 'blur', $event)"
/>
<!-- ===== 下拉选择类型 ===== -->
<!--
@@ -83,6 +86,9 @@
:clearable="col.clearable !== false"
:style="col.style"
:filterable="col.filterable !== false"
:disabled="!!col.disabled"
@change="handleFieldEvent(col, 'change', $event)"
@focus="handleFieldEvent(col, 'focus', $event)"
>
<el-option
v-for="opt in col.options"
@@ -255,6 +261,14 @@ export default {
}
},
methods: {
handleFieldEvent (col, eventName, value) {
if (!col) return
const handlerKey = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1)
const handler = col[handlerKey]
if (typeof handler === 'function') {
handler(value, col, this.formData)
}
},
/**
* 点击确定按钮
* 1. 调用 el-form 的 validate 方法验证所有字段

View File

@@ -153,6 +153,80 @@
"setting_placeholder": "Preset setting configuration area",
"setting_tip": "Configure preset settings for this process unit here",
"import_tip": "Import function is under development"
},
"process_routing": {
"search": "Search",
"reset": "Reset",
"sort": "No.",
"code": "Routing Code",
"name": "Routing Name",
"category": "Category",
"product": "Product",
"remark": "Remark",
"creator": "Creator",
"create_time": "Created At",
"operation": "Actions",
"add": "Add",
"edit": "Edit",
"delete": "Delete",
"set_process": "Set Process",
"copy": "Copy",
"enter_code": "Please enter routing code",
"enter_name": "Please enter routing name",
"enter_remark": "Please enter remark",
"select_category": "Please select a category",
"select_product": "Please select a product",
"remark_length": "Length must be 1-100 characters",
"add_title": "Add Process Routing",
"edit_title": "Edit Process Routing",
"cancel": "Cancel",
"confirm": "Confirm",
"tip": "Tip",
"confirm_delete": "Are you sure to delete this process routing?",
"confirm_copy": "Are you sure to copy this process routing?",
"operation_success": "Operation succeeded",
"validation_fail": "Validation failed",
"help": "Process routing defines the production flow and manages routing cards by linking multiple process steps in order to form a complete production route.",
"batch_bound_no_delete": "This routing is bound to a batch and cannot be deleted",
"card": {
"flow_info": "Flow Info",
"flow_name": "Flow Name",
"category": "Category",
"product": "Product",
"batch_bound": "Batch Bound",
"yes": "Yes",
"no": "No",
"sort": "No.",
"step_code": "Step Code",
"step_name": "Step Name",
"process_unit": "Process Unit",
"process_unit_name": "Process Unit Name",
"operation": "Actions",
"add_step": "Add",
"edit_step": "Edit Step",
"delete": "Delete",
"setting": "Settings",
"result_param": "Result Params",
"temperature": "Temperature Compensation",
"calculation_script": "Calculation Script",
"view_log": "View Log",
"enter_step_code": "Please enter step code",
"enter_step_name": "Please enter step name",
"select_process_unit": "Please select a process unit",
"pin_check": "Channel Detection",
"enable": "Enable",
"disable": "Disable",
"select_pin_check": "Please select channel detection status",
"confirm": "Confirm",
"cancel": "Cancel",
"tip": "Tip",
"confirm_delete": "Are you sure to delete this step?",
"operation_success": "Operation succeeded",
"length_1_100": "Length must be 1-100 characters",
"batch_bound_no_move": "Batch bound, cannot move",
"select_category": "Please select a category",
"log_operation_step": "Operation step: "
}
}
},
"material_model": {

View File

@@ -153,6 +153,80 @@
"setting_placeholder": "预设设定值配置区域",
"setting_tip": "在此配置工序单元的预设设定值",
"import_tip": "导入功能开发中"
},
"process_routing": {
"search": "查询",
"reset": "重置",
"sort": "序号",
"code": "工艺流程编码",
"name": "工艺流程名称",
"category": "流程类别",
"product": "关联产品",
"remark": "备注",
"creator": "创建人",
"create_time": "创建时间",
"operation": "操作",
"add": "新 增",
"edit": "编 辑",
"delete": "删 除",
"set_process": "设置工序",
"copy": "复 制",
"enter_code": "请输入工艺流程编码",
"enter_name": "请输入工艺流程名称",
"enter_remark": "请输入备注",
"select_category": "请选择流程类别",
"select_product": "请选择关联产品",
"remark_length": "长度在 1 到 100 个字符",
"add_title": "新增工艺流程",
"edit_title": "编辑工艺流程",
"cancel": "取消",
"confirm": "确定",
"tip": "提示",
"confirm_delete": "确定要删除该工艺流程吗?",
"confirm_copy": "确定要复制该工艺流程吗?",
"operation_success": "操作成功",
"validation_fail": "校验失败",
"help": "工艺流程用于设置生产工艺流程并管理流程卡,将多个工序单元有序串联形成完整的生产工艺路线。",
"batch_bound_no_delete": "该工艺流程已绑定批次,不可删除",
"card": {
"flow_info": "工艺信息",
"flow_name": "流程名称",
"category": "流程类别",
"product": "产品型号",
"batch_bound": "绑定批次",
"yes": "是",
"no": "否",
"sort": "序号",
"step_code": "工序编码",
"step_name": "工序名称",
"process_unit": "工序单元",
"process_unit_name": "工序单元名称",
"operation": "操作",
"add_step": "新 增",
"edit_step": "编辑工序",
"delete": "删 除",
"setting": "设定值",
"result_param": "结果参数",
"temperature": "温度补偿",
"calculation_script": "计算脚本",
"view_log": "查看日志",
"enter_step_code": "请输入工序编码",
"enter_step_name": "请输入工序名称",
"select_process_unit": "请选择工序单元",
"pin_check": "通道检测",
"enable": "启用",
"disable": "禁用",
"select_pin_check": "请选择通道检测状态",
"confirm": "确定",
"cancel": "取消",
"tip": "提示",
"confirm_delete": "确定要删除该工序吗?",
"operation_success": "操作成功",
"length_1_100": "长度在 1 到 100 个字符",
"batch_bound_no_move": "已绑定批次,不可移动",
"select_category": "请选择流程类别",
"log_operation_step": "操作工序:"
}
}
},
"material_model": {

View File

@@ -38,6 +38,18 @@ export default {
meta: { ...meta, cache: true, title: '工序单元' },
component: _import('production-master-data/process-model/process-step')
},
{
path: 'technology_model/technology_flow',
name: `${pre}technology_model-technology_flow`,
meta: { ...meta, cache: true, title: '工艺流程' },
component: _import('production-master-data/process-model/process-routing')
},
{
path: 'technology_model/technology_flow/:flow_id/process',
name: `${pre}technology_model-technology_flow-process`,
meta: { ...meta, cache: false, title: '工艺详情' },
component: _import('production-master-data/process-model/process-routing-card')
},
{
path: 'product_model/battery_model',
name: `${pre}product_management-product_list`,

View File

@@ -0,0 +1,592 @@
<template>
<d2-container>
<template #header>
<el-page-header @back="$router.go(-1)" :content="flowName" style="margin: 10px 0" />
</template>
<el-descriptions
v-if="flowInfo"
class="margin-top"
:title="$t(key('flow_info'))"
:column="4"
direction="vertical"
border
>
<template #title>
<span style="color: #409EFF; font-size: 14px;">| {{ $t(key('flow_info')) }}</span>
</template>
<el-descriptions-item :label="$t(key('flow_name'))">{{ flowInfo.name }}</el-descriptions-item>
<el-descriptions-item :label="$t(key('category'))">{{ flowInfo.flow_category_name }}</el-descriptions-item>
<el-descriptions-item :label="$t(key('product'))">{{ flowInfo.product_model_name }}</el-descriptions-item>
<el-descriptions-item :label="$t(key('batch_bound'))">
<el-tag v-if="isBindingBatch" size="small">{{ $t(key('yes')) }}</el-tag>
<el-tag v-else size="small" type="info">{{ $t(key('no')) }}</el-tag>
</el-descriptions-item>
</el-descriptions>
<div class="card-toolbar">
<strong v-for="(btn, index) in toolbarButtons" :key="index">
<el-button
v-if="btn.hasPermission && __judgeToolbarButton(btn.key)"
:type="btn.type"
:size="btn.size || 'mini'"
:icon="btn.icon"
@click="btn.onClick"
:style="btn.cssStyle"
>
{{ $t(btn.label) }}
</el-button>
</strong>
</div>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="[]"
:row-buttons="[]"
:pagination="null"
auto-height
:table-attrs="{ border: true }"
>
<template #col-up="{ row, index }">
<i
v-show="index > 0"
v-if="$permission('/production_configuration/technology_model/technology_flow_process/sort')"
class="el-icon-sort-up"
style="cursor: pointer"
@click="handleMoveUp(row, index)"
/>
</template>
<template #col-down="{ row, index }">
<i
v-show="index < tableData.length - 1"
v-if="$permission('/production_configuration/technology_model/technology_flow_process/sort')"
class="el-icon-sort-down"
style="cursor: pointer"
@click="handleMoveDown(row, index)"
/>
</template>
<template #col-sort="{ row }">
{{ row.sort }}
</template>
<template #col-handle="{ row, index }">
<strong v-for="(btn, btnIdx) in rowOperationButtons" :key="btnIdx">
<i
:class="btn.icon"
:style="btn.cssStyle"
v-if="$permission(btn.auth) && __judgeRowButton(row, btn.key)"
@click="btn.onClick(row, index)"
>
{{ btn.label }}
</i>
</strong>
</template>
</page-table>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="formCols"
:form-data="formData"
:rules="rules"
:label-width="'130px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
<technology-flow-model
:visible.sync="settingVisible"
:title="settingTitle"
:type="settingType"
:code="settingCode"
:width="settingWidth"
:plugin-data="settingPluginData"
@close="settingVisible = false"
@submit="handleSettingSubmit"
/>
<result-param
:visible.sync="resultVisible"
:title="resultTitle"
:workingsubclass-id="resultWorkingsubclassId"
@close="resultVisible = false"
/>
<el-drawer
:title="$t(key('view_log'))"
:visible.sync="drawer"
size="35%"
:with-header="false"
>
<div style="margin: 20px">
<div
v-for="(item, index) in operationLogs"
:key="index"
style="padding-bottom: 20px; margin-bottom: 30px"
>
<div style="margin-bottom: 10px; color: rgba(0,0,0,.36); font-size: 14px">
<i class="el-icon-star-on" style="color: #409EFF" />
<span style="margin-right: 10px; margin-left: 2px">{{ item.nyr_date }}</span>
<span>{{ item.week }}</span>
</div>
<div style="margin-bottom: 10px; display: flex; align-items: center; justify-content: flex-start">
<div style="margin-right: 10px"><el-avatar size="small"> user </el-avatar></div>
<div style="color: #8BCF70">{{ item.username }}</div>
</div>
<div style="margin-left: 40px; margin-bottom: 10px">
<span>{{ item.action_name }}</span>
<span style="color: rgba(0,0,0,.36); font-size: 14px">
<span style="margin-left: 10px; margin-right: 5px">{{ item.yr_date }}</span>
<span>{{ item.ampm }}</span>
<span style="margin-left: 5px">{{ item.time }}</span>
</span>
</div>
<div style="margin-left: 40px; margin-bottom: 10px" v-if="item.process_name">
<span style="color: rgba(0,0,0,.36); font-size: 14px">
{{ $t(key('log_operation_step')) }}{{ item.process_name }}
</span>
</div>
</div>
</div>
</el-drawer>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getProcessCardAll,
createProcessCard,
editProcessCard,
deleteProcessCard,
moveUp,
moveDown,
setSetting
} from '@/api/production-master-data/process-routing-card'
import { getWorkingsubclassAll } from '@/api/production-master-data/process-step'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
import TechnologyFlowModel from '../process-step/components/technology-flow-model.vue'
import ResultParam from '../process-step/components/result-param.vue'
export default {
name: 'production-master-data-process-routing-card',
components: { PageTable, PageDialogForm, TechnologyFlowModel, ResultParam },
mixins: [i18nMixin('page.production_master_data.process_model.process_routing.card'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
flowId: '',
flowName: '',
flowInfo: null,
isBindingBatch: false,
tableData: [],
drawer: false,
operationLogs: [],
workingsubclassOptions: [],
workingsubclassRawData: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
settingVisible: false,
settingTitle: '',
settingType: '',
settingCode: '',
settingWidth: '60%',
settingPluginData: {},
settingRowId: '',
resultVisible: false,
resultTitle: '',
resultWorkingsubclassId: '',
formData: {
workingsubclass_id: '',
code: '',
name: '',
pin_check: '0'
},
rules: {
workingsubclass_id: [
{ required: true, message: this.key('select_process_unit'), trigger: 'change' }
],
code: [
{ required: true, message: this.key('enter_step_code'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_step_name'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('length_1_100'), trigger: 'blur' }
]
},
columns: [],
toolbarButtons: [],
rowOperationButtons: [],
formCols: [
[
{
type: 'select',
prop: 'workingsubclass_id',
label: this.key('process_unit'),
placeholder: this.key('select_process_unit'),
clearable: true,
filterable: true,
style: { width: '90%' },
options: [],
onChange: this.onWorkingsubclassChange
}
],
[
{
type: 'input',
prop: 'code',
label: this.key('step_code'),
placeholder: this.key('enter_step_code'),
clearable: true,
disabled: false,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('step_name'),
placeholder: this.key('enter_step_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'select',
prop: 'pin_check',
label: this.$t(this.key('pin_check')),
placeholder: this.$t(this.key('select_pin_check')),
clearable: false,
style: { width: '90%' },
options: [
{ label: this.$t(this.key('enable')), value: '1' },
{ label: this.$t(this.key('disable')), value: '0' }
]
}
]
]
}
},
created () {
this.flowId = this.$route.params.flow_id || ''
this.flowName = this.$route.query.flow_name || ''
this.columns = useTableColumns([
{ prop: 'up', label: '', slot: 'up', width: 40 },
{ prop: 'down', label: '', slot: 'down', width: 40 },
{ prop: 'sort', label: this.key('sort'), slot: 'sort', width: 80 },
{ prop: 'code', label: this.key('step_code'), minWidth: 120 },
{ prop: 'name', label: this.key('step_name'), minWidth: 140 },
{ prop: 'workingsubclass_name', label: this.key('process_unit_name'), minWidth: 140 },
{ prop: 'handle', label: this.key('operation'), slot: 'handle', width: 500 }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add_step'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/technology_model/technology_flow_process/create',
onClick: this.openAdd
},
{
key: 'viewLog',
label: this.key('view_log'),
icon: 'el-icon-view',
type: 'warning',
auth: '/production_configuration/technology_model/technology_flow_process/view_log',
onClick: this.openLog
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowOperationButtons = [
{
key: 'edit',
label: '编辑',
icon: 'el-icon-edit',
cssStyle: { marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/edit',
onClick: this.openEdit
},
{
key: 'delete',
label: '删除',
icon: 'el-icon-delete',
cssStyle: { color: 'red', marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/delete',
onClick: this.handleDelete
},
{
key: 'setting',
label: '设定值',
icon: 'el-icon-setting',
cssStyle: { color: '#409EFF', marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/setting',
onClick: this.openSettingDrawer
},
{
key: 'resultParam',
label: '结果参数',
icon: 'el-icon-s-promotion',
cssStyle: { color: '#E6A23C', marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/result_params',
onClick: this.openResultParamDrawer
},
{
key: 'temperature',
label: '温度补偿',
icon: 'el-icon-magic-stick',
cssStyle: { color: '#67C23A', marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/temperature',
onClick: this.openTemperatureDrawer
},
{
key: 'calculationScript',
label: '计算脚本',
icon: 'el-icon-monitor',
cssStyle: { color: '#67C23A', marginRight: '10px', cursor: 'pointer' },
auth: '/production_configuration/technology_model/technology_flow_process/calculation_script',
onClick: this.openCalculationScriptDrawer
}
]
if (this.flowId) {
this.fetchData()
}
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getProcessCardAll({ flow_id: this.flowId })
const data = res.data || res || {}
this.tableData = data.process || []
this.flowInfo = data.flow_data || null
this.flowName = this.flowName || (this.flowInfo && this.flowInfo.name) || ''
this.isBindingBatch = data.is_binding_batch === 1
this.operationLogs = data.technology_flow_operate_log || []
} finally {
this.loading = false
}
},
__judgeToolbarButton (key) {
if (key === 'add' && this.isBindingBatch) return false
return true
},
__judgeRowButton (row, key) {
if (key === 'setting' && row.setting_plugin) return true
if (key === 'delete' && !this.isBindingBatch) return true
if (key === 'temperature' &&
['FORMATION', 'YC', 'HC', 'IC', 'FORMATION_SS'].indexOf(row.device_category_code) !== -1) {
return false
}
if (key === 'resultParam') return true
if (key === 'calculationScript') return false
if (key === 'edit') return true
return false
},
async handleMoveUp (row, index) {
if (this.isBindingBatch) {
this.$message.warning(this.$t(this.key('batch_bound_no_move')))
return
}
if (index <= 0) return
try {
await moveUp({
flow_id: this.flowId,
move_id: row.id,
quilt_move_id: this.tableData[index - 1].id,
move_sort: row.sort,
quilt_move_sort: this.tableData[index - 1].sort
})
this.fetchData()
} catch (e) { /* 拦截器已处理 */ }
},
async handleMoveDown (row, index) {
if (this.isBindingBatch) {
this.$message.warning(this.$t(this.key('batch_bound_no_move')))
return
}
if (index >= this.tableData.length - 1) return
try {
await moveDown({
flow_id: this.flowId,
move_id: row.id,
quilt_move_id: this.tableData[index + 1].id,
move_sort: row.sort,
quilt_move_sort: this.tableData[index + 1].sort
})
this.fetchData()
} catch (e) { /* 拦截器已处理 */ }
},
loadWorkingsubclassOptions () {
if (this.workingsubclassOptions.length > 0) return Promise.resolve()
return getWorkingsubclassAll().then(res => {
const list = res.data || res || []
this.workingsubclassRawData = list
this.workingsubclassOptions = list.map(item => ({
label: item.name,
value: item.id
}))
this.formCols[0][0].options = this.workingsubclassOptions
})
},
onWorkingsubclassChange (value) {
if (!value) return
const raw = this.workingsubclassRawData.find(item => item.id === value)
if (!raw) return
const wsCode = raw.code
const wsName = raw.name
const identicalData = this.tableData.filter(
v => v.workingsubclass_code === wsCode
)
if (identicalData.length > 0) {
const firstCode = identicalData[0].code
const firstName = identicalData[0].name
const len = identicalData.length
this.formData.code = firstCode + '_' + len
this.formData.name = firstName + '_' + len
} else {
this.formData.code = this.flowId + '_' + wsCode
this.formData.name = this.flowId + '_' + wsName
}
const autoPinDevices = ['IC', 'HC', 'YC', 'OCV01', 'OCV02', 'OCV03', 'OCV04', 'OCV05', 'OCV06', 'DCIR', 'FORMATION', 'FORMATION_SS']
this.formData.pin_check = autoPinDevices.includes(wsCode) ? '1' : '0'
},
resetForm () {
this.formData = { workingsubclass_id: '', code: '', name: '', pin_check: '0' }
this.editId = ''
this.$nextTick(() => {
this.formCols[0][0].disabled = false
this.formCols[1][0].disabled = false
this.formCols[2][0].disabled = false
})
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_step')
this.loadWorkingsubclassOptions().then(() => {
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_step')
this.editId = row.id
this.formData = {
workingsubclass_id: row.workingsubclass_id || '',
code: row.code,
name: row.name,
pin_check: row.pin_check !== undefined ? String(row.pin_check) : '0'
}
this.loadWorkingsubclassOptions().then(() => {
this.$nextTick(() => {
this.formCols[0][0].disabled = true
this.formCols[1][0].disabled = true
this.formCols[2][0].disabled = true
})
})
this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createProcessCard({ ...this.formData, flow_id: this.flowId })
} else {
await editProcessCard({ ...this.formData, id: this.editId, flow_id: this.flowId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row, index) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteProcessCard({ id: [row.id], flow_id: this.flowId })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.fetchData()
},
openLog () {
this.drawer = true
},
openSettingDrawer (row) {
this.settingRowId = row.id
this.settingTitle = this.key('setting')
this.settingType = row.setting_plugin || row.device_category_code || ''
this.settingCode = row.workingsubclass_code || row.code || ''
this.settingPluginData = row.setting || {}
this.settingVisible = true
},
openResultParamDrawer (row) {
this.resultTitle = this.key('result_param')
this.resultWorkingsubclassId = row.workingsubclass_id || ''
this.resultVisible = true
},
openTemperatureDrawer (row) {
this.$message.warning('当前项目暂未接入温度补偿功能')
},
openCalculationScriptDrawer (row) {
this.$message.warning('当前项目暂未接入计算脚本功能')
},
async handleSettingSubmit (data) {
await setSetting({
id: this.settingRowId,
flow_id: this.flowId,
setting: JSON.stringify(data)
})
this.$message.success(this.$t(this.key('operation_success')))
this.settingVisible = false
this.fetchData()
}
}
}
</script>
<style scoped>
.card-toolbar {
margin-bottom: 15px;
margin-top: -10px;
}
/deep/ .el-page-header__content {
font-weight: bold;
}
</style>

View File

@@ -0,0 +1,467 @@
<template>
<d2-container>
<template #header>
<div class="search-bar">
<el-form :inline="true" size="mini">
<el-form-item :label="$t(key('code'))">
<el-input
v-model="search.code"
:placeholder="$t(key('enter_code'))"
clearable
style="width:180px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('name'))">
<el-input
v-model="search.name"
:placeholder="$t(key('enter_name'))"
clearable
style="width:180px"
@keyup.enter.native="onSearch"
/>
</el-form-item>
<el-form-item :label="$t(key('category'))">
<el-select
v-model="search.flow_category_id"
:placeholder="$t(key('select_category'))"
clearable
filterable
size="mini"
style="width:180px"
@focus="loadSearchCategories"
>
<el-option
v-for="item in searchCategoryOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item :label="$t(key('product'))">
<el-select
v-model="search.product_model_id"
:placeholder="$t(key('select_product'))"
clearable
filterable
size="mini"
style="width:180px"
@focus="loadSearchProducts"
>
<el-option
v-for="item in searchProductOptions"
:key="item.product_model_id"
:label="item.name"
:value="item.product_model_id"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="onSearch">
{{ $t(key('search')) }}
</el-button>
<el-button icon="el-icon-refresh" @click="onReset">
{{ $t(key('reset')) }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>
<page-table
ref="pageTable"
:columns="columns"
:data="tableData"
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
:pagination="pagination"
help-url="/help/process-routing"
:help-text="$t(ckey('help'))"
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
/>
<page-dialog-form
ref="dialogForm"
:visible.sync="dialogVisible"
:title="dialogTitle"
:width="'35%'"
:form-cols="formCols"
:form-data="formData"
:rules="rules"
:label-width="'120px'"
:submitting="submitting"
:confirm-text="key('confirm')"
:cancel-text="key('cancel')"
@submit="onDialogSubmit"
@close="onDialogClose"
/>
</d2-container>
</template>
<script>
import { useTableColumns } from '@/composables/useTableColumns'
import { useTableButtons } from '@/composables/useTableButtons'
import { i18nMixin } from '@/composables/useI18n'
import { confirmMixin } from '@/composables/useConfirmHandle'
import {
getProcessRoutingList,
createProcessRouting,
editProcessRouting,
deleteProcessRouting,
copyProcessRouting
} from '@/api/production-master-data/process-routing'
import { getProcessCategoryAll } from '@/api/production-master-data/process-category'
import { getProductBatteryAll } from '@/api/production-master-data/product-management'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
export default {
name: 'production-master-data-process-routing',
components: { PageTable, PageDialogForm },
mixins: [i18nMixin('page.production_master_data.process_model.process_routing'), confirmMixin],
data () {
return {
loading: false,
submitting: false,
tableData: [],
selectedRows: [],
dialogVisible: false,
dialogTitle: '',
editId: '',
handleType: 'create',
search: { code: '', name: '', flow_category_id: '', product_model_id: '' },
pagination: { current: 1, size: 10, total: 0 },
formData: {
code: '',
name: '',
flow_category_id: '',
product_model_id: '',
remark: ''
},
categoryOptions: [],
productOptions: [],
searchCategoryOptions: [],
searchProductOptions: [],
rules: {
code: [
{ required: true, message: this.key('enter_code'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
],
name: [
{ required: true, message: this.key('enter_name'), trigger: 'blur' },
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
],
flow_category_id: [
{ required: true, message: this.key('select_category'), trigger: 'change' }
],
product_model_id: [
{ required: true, message: this.key('select_product'), trigger: 'change' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
formCols: [
[
{
type: 'input',
prop: 'code',
label: this.key('code'),
placeholder: this.key('enter_code'),
clearable: true,
disabled: false,
style: { width: '90%' }
}
],
[
{
type: 'input',
prop: 'name',
label: this.key('name'),
placeholder: this.key('enter_name'),
clearable: true,
style: { width: '90%' }
}
],
[
{
type: 'select',
prop: 'flow_category_id',
label: this.key('category'),
placeholder: this.key('select_category'),
clearable: true,
filterable: true,
style: { width: '90%' },
options: []
}
],
[
{
type: 'select',
prop: 'product_model_id',
label: this.key('product'),
placeholder: this.key('select_product'),
clearable: true,
filterable: true,
style: { width: '90%' },
options: []
}
],
[
{
type: 'input',
prop: 'remark',
inputType: 'textarea',
autosize: { minRows: 2, maxRows: 6 },
label: this.key('remark'),
placeholder: this.key('enter_remark'),
clearable: true,
style: { width: '90%' }
}
]
]
}
},
created () {
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('code'), minWidth: 120 },
{ prop: 'name', label: this.key('name'), minWidth: 140 },
{ prop: 'flow_category_name', label: this.key('category'), minWidth: 120 },
{ prop: 'product_model_code', label: this.key('product'), minWidth: 140 },
{ prop: 'remark', label: this.key('remark'), minWidth: 120 },
{ prop: 'username', label: this.key('creator'), minWidth: 100 },
{ prop: 'create_time', label: this.key('create_time'), width: 160 },
{ prop: '_actions', label: this.key('operation'), width: 240, fixed: 'right' }
])
const btns = useTableButtons({
toolbar: [
{
key: 'add',
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
auth: '/production_configuration/technology_model/technology_flow/create',
onClick: this.openAdd
}
],
row: [
{
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/technology_model/technology_flow/edit',
onClick: this.openEdit
},
{
key: 'setProcess',
label: this.key('set_process'),
icon: 'el-icon-s-operation',
color: 'primary',
auth: '/production_configuration/technology_model/technology_flow/set_process',
onClick: this.openProcessCard
},
{
key: 'copy',
label: this.key('copy'),
icon: 'el-icon-document-copy',
color: 'warning',
auth: '/production_configuration/technology_model/technology_flow/copy',
onClick: this.handleCopy
},
{
key: 'delete',
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
auth: '/production_configuration/technology_model/technology_flow/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
this.fetchData()
},
methods: {
async fetchData () {
this.loading = true
try {
const res = await getProcessRoutingList({
...this.search,
page_no: this.pagination.current,
page_size: this.pagination.size
})
const list = Array.isArray(res) ? res : (res.data || [])
const total = Array.isArray(res) ? res.length : (res.count || 0)
this.tableData = list
this.pagination.total = total
} finally {
this.loading = false
}
},
onSearch () {
this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '', flow_category_id: '', product_model_id: '' }
this.pagination.current = 1
this.fetchData()
},
onPageChange (page) {
this.pagination.current = page.current
this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
this.selectedRows = rows
},
resetForm () {
this.formData = {
code: '',
name: '',
flow_category_id: '',
product_model_id: '',
remark: ''
}
this.editId = ''
this.$nextTick(() => {
this.formCols[0][0].disabled = false
})
},
loadDialogCategories () {
if (this.categoryOptions.length > 0) return
getProcessCategoryAll().then(res => {
this.categoryOptions = (res.data || res || []).map(item => ({
label: item.name,
value: item.id
}))
this.formCols[2][0].options = this.categoryOptions
})
},
loadDialogProducts () {
if (this.productOptions.length > 0) return
getProductBatteryAll().then(res => {
this.productOptions = (res.data || res || []).map(item => ({
label: item.name,
value: item.product_model_id
}))
this.formCols[3][0].options = this.productOptions
})
},
loadSearchCategories () {
if (this.searchCategoryOptions.length > 0) return
getProcessCategoryAll().then(res => {
this.searchCategoryOptions = res.data || res || []
})
},
loadSearchProducts () {
if (this.searchProductOptions.length > 0) return
getProductBatteryAll().then(res => {
this.searchProductOptions = res.data || res || []
})
},
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_title')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.loadDialogCategories()
this.loadDialogProducts()
this.dialogVisible = true
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = row.id
this.formData = {
code: row.code,
name: row.name,
flow_category_id: row.flow_category_id || '',
product_model_id: row.product_model_id || '',
remark: row.remark || ''
}
this.loadDialogCategories()
this.loadDialogProducts()
this.$nextTick(() => {
this.formCols[0][0].disabled = true
})
this.dialogVisible = true
},
openProcessCard (row) {
this.$router.push({
name: 'production_configuration-technology_model-technology_flow-process',
params: { flow_id: row.id },
query: { flow_name: row.name }
})
},
async onDialogSubmit () {
this.submitting = true
try {
if (this.handleType === 'create') {
await createProcessRouting(this.formData)
} else {
await editProcessRouting({ ...this.formData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
this.fetchData()
} finally {
this.submitting = false
}
},
onDialogClose () {
this.resetForm()
},
async handleDelete (row) {
if (row.is_binding_batch === 1) {
this.$message.warning(this.$t(this.key('batch_bound_no_delete')))
return
}
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_delete'),
title: this.key('tip')
},
() => deleteProcessRouting({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = Math.min(
this.pagination.current,
Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1
)
this.fetchData()
},
async handleCopy (row) {
const cancelled = await this.$confirmAction(
{
message: this.key('confirm_copy'),
title: this.key('tip')
},
() => copyProcessRouting({ id: [row.id] })
)
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.pagination.current = 1
this.fetchData()
}
}
}
</script>
<style scoped>
.search-bar {
padding: 10px 0;
}
/deep/ .el-form-item--mini.el-form-item {
margin-bottom: 4px;
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<el-dialog
:title="title"
:title="$t(title)"
:visible.sync="visible"
:append-to-body="true"
:close-on-click-modal="false"
@@ -86,7 +86,7 @@
</div>
<el-dialog
:title="dialogTitle"
:title="$t(dialogTitle)"
:visible.sync="innerVisible"
append-to-body
width="600px"
@@ -258,13 +258,13 @@ export default {
this.innerVisible = true
},
handleDelete (row) {
this.$confirm(this.key('confirm_delete_data'), this.key('tips'), {
confirmButtonText: this.key('confirm'),
cancelButtonText: this.key('cancel'),
this.$confirm(this.$t(this.key('confirm_delete_data')), this.$t(this.key('tips')), {
confirmButtonText: this.$t(this.key('confirm')),
cancelButtonText: this.$t(this.key('cancel')),
type: 'warning'
}).then(() => {
deleteOptionalParams({ workingsubclass_id: this.workingsubclass_id, id: row.id }).then(() => {
this.$message.success(this.key('operation_success'))
this.$message.success(this.$t(this.key('operation_success')))
this.fetchData()
})
}).catch(() => {})
@@ -274,11 +274,8 @@ export default {
if (!valid) return
const action = this.formData.id ? editOptionalParams : createOptionalParams
const data = { workingsubclass_id: this.workingsubclass_id, ...this.formData }
if (this.formData.id) {
delete data.id
}
action(data).then(() => {
this.$message.success(this.key('operation_success'))
this.$message.success(this.$t(this.key('operation_success')))
this.innerVisible = false
this.$refs.form.resetFields()
this.fetchData()
@@ -286,7 +283,7 @@ export default {
})
},
handleImport () {
this.$message.info(this.key('import_tip'))
this.$message.info(this.$t(this.key('import_tip')))
}
}
}

View File

@@ -1,6 +1,6 @@
<template>
<el-dialog
:title="title"
:title="$t(title)"
:visible.sync="visible"
:append-to-body="true"
:close-on-click-modal="false"
@@ -14,10 +14,17 @@
:closable="false"
show-icon
/>
<div class="setting-placeholder">
<p>{{ $t(key('setting_placeholder')) }}</p>
<el-tag type="warning">{{ type }}</el-tag>
<div class="setting-meta">
<el-tag v-if="type" type="warning" size="mini">{{ type }}</el-tag>
<el-tag v-if="code" type="info" size="mini">{{ code }}</el-tag>
</div>
<el-input
v-model="jsonText"
type="textarea"
:rows="16"
resize="vertical"
:placeholder="jsonPlaceholder"
/>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="handleClose">{{ $t(key('cancel')) }}</el-button>
@@ -57,18 +64,65 @@ export default {
default: ''
}
},
data () {
return {
jsonText: ''
}
},
computed: {
settingTip () {
return this.$t(this.key('setting_tip'))
},
jsonPlaceholder () {
return '{\n "key": "value"\n}'
}
},
watch: {
visible: {
handler (val) {
if (val) {
this.resetJsonText()
}
},
immediate: true
},
pluginData: {
handler () {
if (this.visible) {
this.resetJsonText()
}
},
deep: true
}
},
methods: {
resetJsonText () {
const data = this.pluginData
if (data === undefined || data === null || data === '') {
this.jsonText = '{}'
return
}
if (typeof data === 'string') {
this.jsonText = data.trim() ? data : '{}'
return
}
this.jsonText = JSON.stringify(data, null, 2)
},
handleClose () {
this.$emit('close')
},
handleSubmit () {
this.$message.success(this.key('operation_success'))
this.$emit('close')
const raw = (this.jsonText || '').trim()
if (!raw) {
this.$emit('submit', {})
return
}
try {
const parsed = JSON.parse(raw)
this.$emit('submit', parsed)
} catch (error) {
this.$message.error('JSON 格式不正确')
}
}
}
}
@@ -78,14 +132,9 @@ export default {
.setting-content {
padding: 10px 0;
}
.setting-placeholder {
margin-top: 20px;
text-align: center;
padding: 40px 0;
color: #909399;
}
.setting-placeholder p {
margin-bottom: 15px;
font-size: 14px;
.setting-meta {
margin: 16px 0 12px;
display: flex;
gap: 8px;
}
</style>

View File

@@ -93,8 +93,10 @@ import {
getProcessStepList,
createProcessStep,
editProcessStep,
deleteProcessStep
deleteProcessStep,
settingSubmit
} from '@/api/production-master-data/process-step'
import { getDeviceCategoryAll } from '@/api/production-master-data/device-category'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
import TechnologyFlowModel from './components/technology-flow-model.vue'
@@ -193,7 +195,7 @@ export default {
},
created () {
this.columns = useTableColumns([
{ prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'sort ', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('process_unit_code'), minWidth: 120 },
{ prop: 'name', label: this.key('process_unit_name'), minWidth: 120 },
{ prop: 'device_category_name', label: this.key('device_category'), minWidth: 120 },
@@ -216,7 +218,7 @@ export default {
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
auth: '/production_configuration/technology_model/technology_flow_workingsubclass/edit',
auth: '/production_configuration/technology_model/technology_flow_process/edit',
onClick: this.openEdit
},
{
@@ -250,6 +252,16 @@ export default {
this.fetchData()
},
methods: {
loadDeviceCategoryOptions () {
if (this.formCols[2][0].options.length > 0) return Promise.resolve()
return getDeviceCategoryAll().then(res => {
const list = res.data || res || []
this.formCols[2][0].options = list.map(item => ({
label: item.name,
value: item.id
}))
})
},
async fetchData () {
this.loading = true
try {
@@ -293,10 +305,12 @@ export default {
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_process_unit')
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
this.loadDeviceCategoryOptions().then(() => {
this.$nextTick(() => {
this.$refs.dialogForm && this.$refs.dialogForm.reset()
this.resetForm()
this.dialogVisible = true
})
})
},
openEdit (row) {
@@ -312,7 +326,9 @@ export default {
this.$nextTick(() => {
this.formCols[0][0].disabled = true
})
this.dialogVisible = true
this.loadDeviceCategoryOptions().then(() => {
this.dialogVisible = true
})
},
async onDialogSubmit () {
this.submitting = true
@@ -351,14 +367,20 @@ export default {
openSetting (row) {
this.currentRowId = row.id
this.settingTitle = this.key('preset_setting')
this.settingType = row.device_category_id || ''
this.settingType = row.device_category_code || row.device_category_name || ''
this.settingCode = row.code
this.settingWidth = '60%'
this.settingPluginData = row.setting || {}
this.settingVisible = true
},
handleSettingSubmit (data) {
async handleSettingSubmit (data) {
await settingSubmit({
id: this.currentRowId,
setting: JSON.stringify(data)
})
this.$message.success(this.$t(this.key('operation_success')))
this.settingVisible = false
this.fetchData()
},
openResult (row) {
this.currentRowId = row.id