326 lines
16 KiB
Plaintext
326 lines
16 KiB
Plaintext
╔══════════════════════════════════════════════════════════════════════════════╗
|
||
║ 配置类型选择功能 - 流程图 ║
|
||
╚══════════════════════════════════════════════════════════════════════════════╝
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 场景1:配置设置 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
用户点击"配置"按钮
|
||
│
|
||
▼
|
||
┌─────────────────────┐
|
||
│ 选择配置类型对话框 │
|
||
│ │
|
||
│ ○ 600泵 ✓ │
|
||
│ ● 1000泵 ✓ │
|
||
│ │
|
||
│ [确定] [取消] │
|
||
└─────────────────────┘
|
||
│
|
||
▼
|
||
用户选择"1000泵"
|
||
│
|
||
▼
|
||
┌─────────────────────┐
|
||
│ 配置设置 - 1000泵 │
|
||
│ │
|
||
│ [InfluxDB配置] │
|
||
│ [占位符配置] │
|
||
│ [设备配置] │
|
||
│ ... │
|
||
│ │
|
||
│ [保存] [取消] │
|
||
└─────────────────────┘
|
||
│
|
||
▼
|
||
保存到 configs/1000泵/default.json
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 场景2:开始工单 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
用户点击"开始工单"按钮
|
||
│
|
||
▼
|
||
┌─────────────────────┐
|
||
│ 选择配置类型对话框 │
|
||
│ │
|
||
│ ● 600泵 ✓ │
|
||
│ ○ 1000泵 ✓ │
|
||
│ │
|
||
│ [确定] [取消] │
|
||
└─────────────────────┘
|
||
│
|
||
▼
|
||
用户选择"600泵"
|
||
│
|
||
▼
|
||
加载 configs/600泵/default.json
|
||
加载 configs/600泵/template.docx
|
||
│
|
||
▼
|
||
┌─────────────────────┐
|
||
│ 开始工单 - 600泵 │
|
||
│ │
|
||
│ 工单号: _______ │
|
||
│ 操作员: _______ │
|
||
│ 备注: _______ │
|
||
│ │
|
||
│ [开始] [取消] │
|
||
└─────────────────────┘
|
||
│
|
||
▼
|
||
开始工单
|
||
├─ 使用 600泵 的配置
|
||
└─ 使用 600泵 的模板
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 对话框详细界面 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
┌──────────────────────────────────────────────────┐
|
||
│ 选择配置类型 [_][□][X] │
|
||
├──────────────────────────────────────────────────┤
|
||
│ │
|
||
│ 请选择要使用的配置类型: │
|
||
│ │
|
||
│ ┌────────────────────────────────────────┐ │
|
||
│ │ 📁 600泵 ✓ │◄─── 配置完整
|
||
│ │ 📁 1000泵 ✓ │ 可以选择
|
||
│ │ 📁 新设备 ⚠ (缺少模板) │◄─── 缺少模板
|
||
│ │ 📁 测试 ✗ (配置缺失) │◄─── 配置缺失
|
||
│ │ │ 不可选择
|
||
│ └────────────────────────────────────────┘
|
||
│ │
|
||
│ ┌────────────────────────────────────────┐ │
|
||
│ │ 📋 类型名称: 600泵 │◄─── 详细信息
|
||
│ │ │
|
||
│ │ ✓ 配置文件: default.json │
|
||
│ │ ✓ 模板文件: template-001.docx │
|
||
│ │ │
|
||
│ │ 📂 路径: F:\...\configs\600泵 │
|
||
│ └────────────────────────────────────────┘
|
||
│ │
|
||
│ [确定] [取消] │
|
||
└──────────────────────────────────────────────────┘
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 数据流向 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
ConfigCategoryManager
|
||
│
|
||
├─► scan_categories()
|
||
│ │
|
||
│ └─► 扫描 configs/ 目录
|
||
│ │
|
||
│ ├─► 发现 600泵/
|
||
│ │ ├─ default.json ✓
|
||
│ │ └─ template.docx ✓
|
||
│ │
|
||
│ └─► 发现 1000泵/
|
||
│ ├─ default.json ✓
|
||
│ └─ template.docx ✓
|
||
│
|
||
└─► 返回: [ConfigCategory, ConfigCategory]
|
||
|
||
|
||
ConfigTypeSelectorDialog
|
||
│
|
||
├─► 显示配置类型列表
|
||
│ ├─ 600泵 ✓
|
||
│ └─ 1000泵 ✓
|
||
│
|
||
├─► 用户选择 "600泵"
|
||
│
|
||
└─► 返回: ConfigCategory(name="600泵", ...)
|
||
|
||
|
||
MainWindow
|
||
│
|
||
├─► 接收选择结果
|
||
│
|
||
├─► 加载配置
|
||
│ └─ AppConfig.load(configs/600泵/default.json)
|
||
│
|
||
├─► 加载模板
|
||
│ └─ template_path = configs/600泵/template.docx
|
||
│
|
||
└─► 继续后续操作
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 代码调用流程 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
# 场景1:配置设置
|
||
─────────────────────
|
||
def open_config_dialog(self):
|
||
# 1. 显示类型选择对话框
|
||
category = select_config_for_settings(self)
|
||
|
||
if category is None:
|
||
return # 用户取消
|
||
|
||
# 2. 加载配置
|
||
self.config = AppConfig.load(category.config_path)
|
||
self._autosave_path = category.config_path
|
||
|
||
# 3. 打开配置对话框
|
||
dlg = QDialog(self)
|
||
dlg.setWindowTitle(f"配置设置 - {category.name}")
|
||
# ...
|
||
|
||
|
||
# 场景2:开始工单
|
||
─────────────────────
|
||
def _start_work_order(self):
|
||
# 1. 显示类型选择对话框
|
||
category = select_config_for_work_order(self)
|
||
|
||
if category is None:
|
||
return # 用户取消
|
||
|
||
# 2. 加载配置和模板
|
||
self.config = AppConfig.load(category.config_path)
|
||
self.template_path = category.template_path
|
||
|
||
# 3. 显示工单信息输入对话框
|
||
dlg = QDialog(self)
|
||
dlg.setWindowTitle(f"开始工单 - {category.name}")
|
||
# ...
|
||
|
||
# 4. 开始工单
|
||
# 使用当前配置和模板
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 配置类型状态 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
状态1: 完整配置 ✓
|
||
─────────────────
|
||
configs/600泵/
|
||
├── default.json ✓ 存在
|
||
└── template.docx ✓ 存在
|
||
|
||
→ 可以选择
|
||
→ 显示绿色 ✓
|
||
|
||
|
||
状态2: 缺少模板 ⚠
|
||
─────────────────
|
||
configs/新设备/
|
||
├── default.json ✓ 存在
|
||
└── template.docx ✗ 不存在
|
||
|
||
→ 可以选择(但有警告)
|
||
→ 显示橙色 ⚠
|
||
|
||
|
||
状态3: 配置缺失 ✗
|
||
─────────────────
|
||
configs/测试/
|
||
├── default.json ✗ 不存在
|
||
└── template.docx ? 不检查
|
||
|
||
→ 不可选择
|
||
→ 显示红色 ✗
|
||
→ 项目被禁用
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 用户体验对比 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
之前的流程:
|
||
───────────
|
||
点击"配置" → 打开配置对话框
|
||
↓
|
||
编辑哪个配置?
|
||
保存到哪里?
|
||
不清楚!❌
|
||
|
||
|
||
现在的流程:
|
||
───────────
|
||
点击"配置" → 选择配置类型 → 打开该类型的配置对话框
|
||
(600泵/1000泵) ↓
|
||
清楚明了!✓
|
||
|
||
|
||
之前的流程:
|
||
───────────
|
||
点击"开始工单" → 使用哪个配置?
|
||
使用哪个模板?
|
||
不清楚!❌
|
||
|
||
|
||
现在的流程:
|
||
───────────
|
||
点击"开始工单" → 选择配置类型 → 使用该类型的配置和模板
|
||
(600泵/1000泵) ↓
|
||
清楚明了!✓
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 集成步骤 │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
步骤1: 导入模块
|
||
─────────────────
|
||
from config_type_selector import (
|
||
select_config_for_work_order,
|
||
select_config_for_settings
|
||
)
|
||
|
||
|
||
步骤2: 修改"配置"按钮
|
||
─────────────────────
|
||
def open_config_dialog(self):
|
||
category = select_config_for_settings(self)
|
||
if category:
|
||
# 加载配置
|
||
# 打开配置对话框
|
||
|
||
|
||
步骤3: 修改"开始工单"按钮
|
||
─────────────────────────
|
||
def _start_work_order(self):
|
||
category = select_config_for_work_order(self)
|
||
if category:
|
||
# 加载配置和模板
|
||
# 显示工单信息输入
|
||
# 开始工单
|
||
|
||
|
||
步骤4: 测试
|
||
─────────────
|
||
✓ 点击"配置",验证类型选择
|
||
✓ 点击"开始工单",验证类型选择
|
||
✓ 验证配置保存到正确位置
|
||
|
||
|
||
┌─────────────────────────────────────────────────────────────────────────────┐
|
||
│ 完成! │
|
||
└─────────────────────────────────────────────────────────────────────────────┘
|
||
|
||
✅ 配置类型选择对话框已开发
|
||
✅ 演示程序已创建
|
||
✅ 集成代码已编写
|
||
✅ 文档已完成
|
||
|
||
📝 下一步:
|
||
1. 运行 python demo_type_selector.py 查看效果
|
||
2. 参考 集成类型选择对话框.py 集成到主程序
|
||
3. 测试功能
|
||
|
||
╔══════════════════════════════════════════════════════════════════════════════╗
|
||
║ 完成! ║
|
||
╚══════════════════════════════════════════════════════════════════════════════╝
|