提交
This commit is contained in:
1 parent
4a00f21bfb
commit
edf88dc016
1503 files changed
+329728
-41987
No files matched your search
@@ -1,8 +0,0 @@
|
||||
-- 2026-05-26: biz_pilot_checkup 新增 pilot_patient_id 字段
|
||||
-- 用于体检管理页面按患者维度管理体检记录
|
||||
|
||||
ALTER TABLE biz_pilot_checkup
|
||||
ADD COLUMN pilot_patient_id VARCHAR(64) DEFAULT NULL COMMENT '中试患者ID'
|
||||
AFTER pilot_application_id;
|
||||
|
||||
CREATE INDEX idx_pilot_checkup_patient_id ON biz_pilot_checkup(pilot_patient_id);
|
||||
@@ -1,9 +0,0 @@
|
||||
-- 出库生产工单:新增 biz_type 字段 + 更新 comment
|
||||
ALTER TABLE biz_production_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_type VARCHAR(20) NOT NULL DEFAULT 'inbound' COMMENT '工单类型: inbound=入库, temporary=临时, outbound=出库';
|
||||
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_status VARCHAR(16) NOT NULL DEFAULT 'dpz' COMMENT '工单状态 dpz待配置 jxz进行中 ywc已完成 yzf已作废';
|
||||
@@ -1,37 +0,0 @@
|
||||
-- 中试服务申请单:支持新增弹窗一揽子保存(申请单名称、输注方案扩展、输注计划明细、细胞产品)
|
||||
|
||||
ALTER TABLE `biz_pilot_application`
|
||||
ADD COLUMN `application_name` varchar(200) DEFAULT NULL COMMENT '申请单名称' AFTER `application_no`;
|
||||
|
||||
ALTER TABLE `biz_pilot_infusion_plan`
|
||||
ADD COLUMN `channel_agreement_id` varchar(64) DEFAULT NULL COMMENT '渠道协议ID' AFTER `infusion_start_date`;
|
||||
|
||||
ALTER TABLE `biz_pilot_infusion_schedule`
|
||||
ADD COLUMN `infusion_location` varchar(200) DEFAULT NULL COMMENT '输注地点' AFTER `infusion_time`,
|
||||
ADD COLUMN `infusion_method` varchar(32) DEFAULT NULL COMMENT '输注方式(字典 szfs)' AFTER `infusion_location`;
|
||||
|
||||
DROP TABLE IF EXISTS `biz_pilot_infusion_schedule_product`;
|
||||
CREATE TABLE `biz_pilot_infusion_schedule_product` (
|
||||
`id` varchar(64) NOT NULL COMMENT '主键ID',
|
||||
`infusion_schedule_id` varchar(64) NOT NULL COMMENT '输注计划ID',
|
||||
`price_id` varchar(64) DEFAULT NULL COMMENT '协议价格/订单产品引用ID',
|
||||
`project_code` varchar(64) DEFAULT NULL COMMENT '项目编码',
|
||||
`project_name` varchar(200) DEFAULT NULL COMMENT '项目名称',
|
||||
`cell_type_name` varchar(200) DEFAULT NULL COMMENT '细胞类型',
|
||||
`spec_text` varchar(200) DEFAULT NULL COMMENT '规格',
|
||||
`agreement_price` decimal(18,2) DEFAULT NULL COMMENT '协议单价(元)',
|
||||
`actual_price` decimal(18,2) DEFAULT NULL COMMENT '实际单价(元)',
|
||||
`quantity` int(11) DEFAULT '1' COMMENT '份数',
|
||||
`product_status` varchar(32) DEFAULT NULL COMMENT '产品状态(如待输注)',
|
||||
`tenant_no` varchar(64) NOT NULL DEFAULT 'zkxw' COMMENT '租户编号',
|
||||
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
|
||||
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
|
||||
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人id',
|
||||
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人id',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`del_flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除标记:0-正常 1-已删除',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_pisp_schedule` (`infusion_schedule_id`,`del_flag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='中试申请单-输注计划细胞产品';
|
||||
@@ -1,85 +0,0 @@
|
||||
-- 中试服务申请单 — 输注方式字典(dict_type: szfs)
|
||||
-- 在「系统管理 > 字典管理」中维护;前端通过 fetchDictDataOptions('szfs') 加载
|
||||
|
||||
INSERT INTO `sys_dict_type` (
|
||||
`id`, `dict_name`, `dict_type`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
) VALUES (
|
||||
'TDP000000000000000000000000000090',
|
||||
'输注方式',
|
||||
'szfs',
|
||||
'zkxw',
|
||||
10,
|
||||
'中试服务申请单-输注计划输注方式',
|
||||
'd3000000000000000000000000000001',
|
||||
'b13c2be2-4e71-11f1-9f47-00163e3bdd96',
|
||||
NOW(),
|
||||
'd3000000000000000000000000000001',
|
||||
NOW(),
|
||||
0
|
||||
);
|
||||
|
||||
INSERT INTO `sys_dict_data` (
|
||||
`id`, `dict_label`, `dict_value`, `dict_type`, `tenant_no`, `order_num`, `remark`,
|
||||
`create_by`, `create_dept_id`, `create_time`, `update_by`, `update_time`, `del_flag`
|
||||
) VALUES
|
||||
(
|
||||
'TDP000000000000000000000000000091',
|
||||
'静脉输注',
|
||||
'jmsz',
|
||||
'szfs',
|
||||
'zkxw',
|
||||
1,
|
||||
'',
|
||||
'd3000000000000000000000000000001',
|
||||
'b13c2be2-4e71-11f1-9f47-00163e3bdd96',
|
||||
NOW(),
|
||||
'd3000000000000000000000000000001',
|
||||
NOW(),
|
||||
0
|
||||
),
|
||||
(
|
||||
'TDP000000000000000000000000000092',
|
||||
'皮下注射',
|
||||
'pxzs',
|
||||
'szfs',
|
||||
'zkxw',
|
||||
2,
|
||||
'',
|
||||
'd3000000000000000000000000000001',
|
||||
'b13c2be2-4e71-11f1-9f47-00163e3bdd96',
|
||||
NOW(),
|
||||
'd3000000000000000000000000000001',
|
||||
NOW(),
|
||||
0
|
||||
),
|
||||
(
|
||||
'TDP000000000000000000000000000093',
|
||||
'局部注射',
|
||||
'jbzs',
|
||||
'szfs',
|
||||
'zkxw',
|
||||
3,
|
||||
'',
|
||||
'd3000000000000000000000000000001',
|
||||
'b13c2be2-4e71-11f1-9f47-00163e3bdd96',
|
||||
NOW(),
|
||||
'd3000000000000000000000000000001',
|
||||
NOW(),
|
||||
0
|
||||
),
|
||||
(
|
||||
'TDP000000000000000000000000000094',
|
||||
'其他',
|
||||
'qt',
|
||||
'szfs',
|
||||
'zkxw',
|
||||
4,
|
||||
'',
|
||||
'd3000000000000000000000000000001',
|
||||
'b13c2be2-4e71-11f1-9f47-00163e3bdd96',
|
||||
NOW(),
|
||||
'd3000000000000000000000000000001',
|
||||
NOW(),
|
||||
0
|
||||
);
|
||||
@@ -1,3 +0,0 @@
|
||||
-- 出库质检工单:新增 biz_type 字段
|
||||
ALTER TABLE biz_qc_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
+1235
-62
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,483 @@
|
||||
# 输注计划管理页面实施计划
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 新建独立的输注计划管理页面,管理所有输注计划的状态流转(待输注→已用户确认→已完成/已取消),支持编辑、取消原因录入、完成时自动扣减渠道服务订单余额或产品份数。
|
||||
|
||||
**Architecture:** 新增 `infusion_status` 字段到 `biz_pilot_infusion_schedule` 表(与现有 `schedule_status` 生产状态独立),新增后端 CRUD/API 和前端完整页面(模式 P02 列表多状态),遵循 openspec UI 规范。
|
||||
|
||||
**Tech Stack:** FastAPI + SQLAlchemy + Pydantic v2 (后端) · Vue 3 + Element Plus + Tailwind CSS 4 (前端) · MySQL 5.7
|
||||
|
||||
**UI 模式选型:** **P02**(列表多状态,操作按钮随状态变化),参考页 `/#/demo/order`,业务参考 `pilot-service/checkup-management`。
|
||||
|
||||
---
|
||||
|
||||
## 文件结构
|
||||
|
||||
| 操作 | 文件路径 | 职责 |
|
||||
|------|----------|------|
|
||||
| 新建 | `docs/sql/20260526_infusion_schedule_add_fields.sql` | 数据库迁移 SQL |
|
||||
| 修改 | `backend/app/models/models.py` (BizPilotInfusionSchedule) | 添加 infusion_status、cancel_reason 字段 |
|
||||
| 新建 | `backend/app/crud/pilot_infusion_schedule_mgmt.py` | 输注计划管理 CRUD(列表 JOIN 查询、状态变更、扣减) |
|
||||
| 新建 | `backend/app/api/pilot_infusion_schedule_mgmt.py` | 输注计划管理 API 路由 |
|
||||
| 修改 | `backend/app/api/__init__.py` | 注册新路由 |
|
||||
| 修改 | `backend/app/api/pilot_application.py` | Bug Fix:创建时默认 infusion_status='dtz' |
|
||||
| 修改 | `web-admin/src/api/admin.ts` | 添加输注计划管理 API 函数 |
|
||||
| 修改 | `web-admin/src/utils/status-tag-registry.ts` | 添加 infusionStatusLabel/TagType |
|
||||
| 新建 | `web-admin/src/views/pilot-service/infusion-schedule-management/index.vue` | 主列表页 |
|
||||
| 新建 | `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue` | 编辑弹窗 |
|
||||
| 新建 | `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue` | 查看弹窗 |
|
||||
| 新建 | `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleCancelDialog.vue` | 取消弹窗(输入原因) |
|
||||
| 修改 | `web-admin/src/router/modules/sqxp.ts` | 添加路由 |
|
||||
| 修改 | `web-admin/src/App.vue` | panelTitleBarTextRules 添加标题 |
|
||||
| 修改 | `docs/web-admin-ui-pattern-index.md` | 补充页面→模式映射 |
|
||||
|
||||
---
|
||||
|
||||
## 状态码定义
|
||||
|
||||
### infusion_status(新增字段 — 输注状态)
|
||||
|
||||
| Code | 含义 | TagType | 说明 |
|
||||
|------|------|---------|------|
|
||||
| `dtz` | 待输注 | `info` | 默认值,创建时自动设置 |
|
||||
| `yrqr` | 已用户确认 | `warning` | 点击"用户已确认"按钮 |
|
||||
| `yqx` | 已取消 | `danger` | 点击"取消"按钮,需输入取消原因 |
|
||||
| `ywc` | 已完成 | `success` | 点击"完成"按钮,触发费用扣减 |
|
||||
|
||||
### product_status(扩展 — 细胞产品状态,跟随 infusion_status 变化)
|
||||
|
||||
| Code | 含义 | TagType |
|
||||
|------|------|---------|
|
||||
| `dtz` | 待输注 | `info` |
|
||||
| `yrqr` | 已用户确认 | `warning` |
|
||||
| `yqx` | 已取消 | `danger` |
|
||||
| `ywc` | 已完成 | `success` |
|
||||
|
||||
> **注意**:当前 `product_status` 使用中文文本"待输注",需改为 code `dtz`。迁移 SQL 中需 UPDATE 现有数据。
|
||||
|
||||
### 状态流转规则
|
||||
|
||||
```
|
||||
待输注(dtz) ──→ 已用户确认(yrqr) ──→ 已完成(ywc)
|
||||
│ │
|
||||
└──→ 已取消(yqx) │
|
||||
└──→ 已取消(yqx) ←────────────────────┘
|
||||
```
|
||||
|
||||
- `dtz` → `yrqr`:点击"用户已确认"
|
||||
- `dtz` → `yqx`:点击"取消"
|
||||
- `yrqr` → `ywc`:点击"完成",触发扣减
|
||||
- `yrqr` → `yqx`:点击"取消"
|
||||
- `ywc`/`yqx` 为终态,不可变更
|
||||
|
||||
---
|
||||
|
||||
## Task 1: 数据库变更
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/sql/20260526_infusion_schedule_add_fields.sql`
|
||||
|
||||
- [ ] **Step 1: 编写迁移 SQL**
|
||||
|
||||
```sql
|
||||
-- 20260526: 输注计划管理 — 添加输注状态字段
|
||||
-- 1. biz_pilot_infusion_schedule 新增 infusion_status 和 cancel_reason
|
||||
ALTER TABLE `biz_pilot_infusion_schedule`
|
||||
ADD COLUMN `infusion_status` varchar(16) NOT NULL DEFAULT 'dtz' COMMENT 'dtz待输注 yrqr已用户确认 yqx已取消 ywc已完成' AFTER `schedule_status`,
|
||||
ADD COLUMN `cancel_reason` varchar(512) DEFAULT NULL COMMENT '取消原因' AFTER `infusion_status`;
|
||||
|
||||
-- 2. biz_pilot_infusion_schedule_product 的 product_status 从中文文本改为 code
|
||||
-- 先更新现有数据
|
||||
UPDATE `biz_pilot_infusion_schedule_product` SET `product_status` = 'dtz' WHERE `product_status` = '待输注' OR `product_status` IS NULL;
|
||||
ALTER TABLE `biz_pilot_infusion_schedule_product`
|
||||
MODIFY COLUMN `product_status` varchar(32) DEFAULT 'dtz' COMMENT 'dtz待输注 yrqr已用户确认 yqx已取消 ywc已完成';
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 在数据库执行 SQL**
|
||||
|
||||
连接开发库执行上述 SQL,确认无报错。
|
||||
|
||||
- [ ] **Step 3: 更新 zkxw.sql 全量备份(手动确认后)**
|
||||
|
||||
记录变更到 `docs/sql/` 目录。
|
||||
|
||||
---
|
||||
|
||||
## Task 2: 后端 Model 更新
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/models/models.py` (BizPilotInfusionSchedule 类,约 line 2892)
|
||||
|
||||
- [ ] **Step 1: 在 BizPilotInfusionSchedule 模型中添加新字段**
|
||||
|
||||
在 `schedule_status` 列定义之后添加:
|
||||
|
||||
```python
|
||||
# BizPilotInfusionSchedule 类中,schedule_status 字段之后添加:
|
||||
infusion_status = Column('infusion_status', String(16), nullable=False, default='dtz', comment='dtz待输注 yrqr已用户确认 yqx已取消 ywc已完成')
|
||||
cancel_reason = Column('cancel_reason', String(512), nullable=True, default=None, comment='取消原因')
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 验证无 import 错误**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.models.models import BizPilotInfusionSchedule; print('OK')"`
|
||||
Expected: `OK`
|
||||
|
||||
---
|
||||
|
||||
## Task 3: 后端 CRUD
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/crud/pilot_infusion_schedule_mgmt.py`
|
||||
|
||||
这个文件实现输注计划管理的核心业务逻辑。
|
||||
|
||||
- [ ] **Step 1: 创建 CRUD 文件,实现列表查询(多表 JOIN)**
|
||||
|
||||
关键:列表需要 JOIN 患者信息、渠道信息、申请单信息、方案信息。
|
||||
|
||||
```python
|
||||
"""输注计划管理 CRUD(独立管理页面用)"""
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from sqlalchemy import and_, func, or_
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.models.models import (
|
||||
BizChannelServiceOrder,
|
||||
BizChannelServiceOrderProduct,
|
||||
BizChannelAccount,
|
||||
BizChannelAgreementProductPrice,
|
||||
BizChannelProductQuota,
|
||||
BizPilotApplication,
|
||||
BizPilotInfusionPlan,
|
||||
BizPilotInfusionSchedule,
|
||||
BizPilotInfusionScheduleProduct,
|
||||
BizPilotPatient,
|
||||
)
|
||||
from app.crud.pilot_service import (
|
||||
_get_or_create_channel_account,
|
||||
_reduce_channel_product_quota,
|
||||
)
|
||||
```
|
||||
|
||||
需要实现的核心函数:
|
||||
|
||||
1. **`list_infusion_schedules_mgmt`** — 多表 JOIN 分页查询
|
||||
- 查询 `biz_pilot_infusion_schedule` 为主表
|
||||
- LEFT JOIN `biz_pilot_infusion_plan` → `biz_pilot_application` → `biz_pilot_patient`
|
||||
- 筛选条件:keyword(申请单号/患者姓名/渠道名称)、infusion_status、infusion_time 范围(默认最近 30 天)
|
||||
- 返回字段包括:schedule 自身字段 + patientName/sex/age + channelName/applicationNo + plan 信息 + products 列表
|
||||
|
||||
2. **`update_infusion_status`** — 状态变更
|
||||
- 校验状态流转合法性
|
||||
- 更新 schedule 的 `infusion_status`
|
||||
- 同步更新所有关联 product 的 `product_status`
|
||||
- 如果变为 `yqx`,保存 `cancel_reason`
|
||||
- 如果变为 `ywc`,调用 `_deduct_fee_on_complete`
|
||||
|
||||
3. **`_deduct_fee_on_complete`** — 完成时费用扣减
|
||||
- 复用 `pilot_delivery.py` 中 `_deduct_fee_on_delivery` 的逻辑
|
||||
- schedule → plan → application → service_order
|
||||
- 预付款型(yfk):扣渠道账户余额 + 更新订单余额
|
||||
- 购买型(gmcp):扣产品份数 + 更新订单产品持仓
|
||||
- 余额/份数不足时抛出 ValueError
|
||||
|
||||
4. **`get_infusion_schedule_detail`** — 获取详情(含 products)
|
||||
5. **`update_infusion_schedule_mgmt`** — 编辑 schedule 和 products 信息
|
||||
|
||||
- [ ] **Step 2: 实现所有 CRUD 函数**
|
||||
|
||||
具体实现需参考:
|
||||
- `pilot_delivery.py` 的 `_deduct_fee_on_delivery` (line 174-327) — 扣减逻辑
|
||||
- `pilot_checkup.py` 的 `list_pilot_checkup` — 多表 JOIN 列表查询模式
|
||||
- `pilot_application.py` 的 `_row_to_dict_schedule` — schedule 序列化模式
|
||||
|
||||
- [ ] **Step 3: 验证 import**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "import app.crud.pilot_infusion_schedule_mgmt; print('OK')"`
|
||||
Expected: `OK`
|
||||
|
||||
---
|
||||
|
||||
## Task 4: 后端 API
|
||||
|
||||
**Files:**
|
||||
- Create: `backend/app/api/pilot_infusion_schedule_mgmt.py`
|
||||
- Modify: `backend/app/api/__init__.py` — 注册新路由
|
||||
|
||||
- [ ] **Step 1: 创建 API 路由文件**
|
||||
|
||||
端点列表(前缀 `/web/admin/pilot-infusion-schedule-mgmt`):
|
||||
|
||||
```python
|
||||
# 1. 列表(分页 + 多表 JOIN)
|
||||
@router.get("/list")
|
||||
|
||||
# 2. 详情
|
||||
@router.get("/detail")
|
||||
|
||||
# 3. 更新状态(确认/取消/完成)
|
||||
@router.put("/update-status")
|
||||
# Body: { scheduleId, infusionStatus, cancelReason? }
|
||||
|
||||
# 4. 编辑(schedule 信息 + products)
|
||||
@router.put("/update")
|
||||
# Body: { id, cellType?, specText?, infusionTime?, infusionLocation?, infusionMethod?, products: [...] }
|
||||
```
|
||||
|
||||
Pydantic schemas 内联在 API 文件中(与现有模式一致),使用 `populate_by_name=True` + alias 驼峰命名。
|
||||
|
||||
- [ ] **Step 2: 注册路由到 __init__.py**
|
||||
|
||||
在 `backend/app/api/__init__.py` 中,pilot 相关路由组内添加:
|
||||
```python
|
||||
from app.api.pilot_infusion_schedule_mgmt import router as pilot_infusion_schedule_mgmt_router
|
||||
# ...
|
||||
api_router.include_router(pilot_infusion_schedule_mgmt_router, prefix="/web/admin", tags=["中试-输注计划管理"])
|
||||
```
|
||||
|
||||
同时检查 `app/main.py` 是否需要额外注册。
|
||||
|
||||
- [ ] **Step 3: 验证 API 注册**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.main import app; routes = [r.path for r in app.routes]; print(any('pilot-infusion-schedule-mgmt' in str(r) for r in routes))"`
|
||||
Expected: `True`
|
||||
|
||||
---
|
||||
|
||||
## Task 5: 前端 API 函数
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/api/admin.ts`
|
||||
|
||||
- [ ] **Step 1: 在 admin.ts 末尾添加输注计划管理 API 函数**
|
||||
|
||||
参考现有函数风格(如 `fetchPilotCheckupList`),添加:
|
||||
|
||||
```typescript
|
||||
// ═══════════════════════════════════════════
|
||||
// 输注计划管理
|
||||
// ═══════════════════════════════════════════
|
||||
|
||||
/** 输注计划管理 - 列表 */
|
||||
export function fetchInfusionScheduleMgmtList(params: any) {
|
||||
return request({ url: '/web/admin/pilot-infusion-schedule-mgmt/list', method: 'get', params })
|
||||
}
|
||||
|
||||
/** 输注计划管理 - 详情 */
|
||||
export function fetchInfusionScheduleMgmtDetail(params: any) {
|
||||
return request({ url: '/web/admin/pilot-infusion-schedule-mgmt/detail', method: 'get', params })
|
||||
}
|
||||
|
||||
/** 输注计划管理 - 更新状态 */
|
||||
export function updateInfusionScheduleStatus(data: any) {
|
||||
return request({ url: '/web/admin/pilot-infusion-schedule-mgmt/update-status', method: 'put', data })
|
||||
}
|
||||
|
||||
/** 输注计划管理 - 编辑 */
|
||||
export function updateInfusionScheduleMgmt(data: any) {
|
||||
return request({ url: '/web/admin/pilot-infusion-schedule-mgmt/update', method: 'put', data })
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 6: 前端状态注册
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/utils/status-tag-registry.ts`
|
||||
|
||||
- [ ] **Step 1: 添加输注状态标签函数**
|
||||
|
||||
在文件末尾(`scheduleStatusTagType` 之后)添加:
|
||||
|
||||
```typescript
|
||||
// ========== 中试服务 - 输注状态(infusion_status) ==========
|
||||
export function infusionStatusLabel(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
dtz: '待输注',
|
||||
yrqr: '已用户确认',
|
||||
yqx: '已取消',
|
||||
ywc: '已完成',
|
||||
}
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
export function infusionStatusTagType(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
dtz: 'info',
|
||||
yrqr: 'warning',
|
||||
yqx: 'danger',
|
||||
ywc: 'success',
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 更新 scheduleStatusLabel — 移除 yjf**
|
||||
|
||||
修改现有 `scheduleStatusLabel` 函数,移除 `yjf: '已交付'`:
|
||||
```typescript
|
||||
export function scheduleStatusLabel(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
dsc: '待生产',
|
||||
ysc: '已生产',
|
||||
yqx: '已取消',
|
||||
}
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
export function scheduleStatusTagType(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
dsc: 'info',
|
||||
ysc: '',
|
||||
yqx: 'danger',
|
||||
}
|
||||
return map[status] || 'info'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 7: 前端页面
|
||||
|
||||
**Files:**
|
||||
- Create: `web-admin/src/views/pilot-service/infusion-schedule-management/index.vue`
|
||||
- Create: `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleEditDialog.vue`
|
||||
- Create: `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleViewDialog.vue`
|
||||
- Create: `web-admin/src/views/pilot-service/infusion-schedule-management/ScheduleCancelDialog.vue`
|
||||
|
||||
**UI 模式**: P02(列表多状态),参考 `checkup-management/index.vue`
|
||||
|
||||
- [ ] **Step 1: 创建目录**
|
||||
|
||||
```bash
|
||||
mkdir -p web-admin/src/views/pilot-service/infusion-schedule-management
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 创建主列表页 index.vue**
|
||||
|
||||
遵循 openspec UI 规范,页面结构:
|
||||
- `page-container` > `page-head` > `h1` 标题"输注计划管理"
|
||||
- `panel` > `panel-top` > `h2` 标题"输注计划"
|
||||
- `filter-block`:关键词、输注状态(下拉)、输注时间范围(`el-date-picker` type="daterange",默认最近 30 天)
|
||||
- `list-toolbar`:已选 N 项
|
||||
- `el-table` 列:
|
||||
- 序号、申请单号、患者姓名、性别、年龄、渠道名称、细胞类型、规格、输注时间、输注地点、输注方式
|
||||
- **生产状态**(`schedule_status`)— el-tag
|
||||
- **输注状态**(`infusion_status`)— el-tag
|
||||
- **操作列** `fixed="right" min-width="400"`:
|
||||
- 编辑(dtz/yrqr 可编辑)
|
||||
- 用户已确认(dtz→yrqr)
|
||||
- 完成(yrqr→ywc)
|
||||
- 取消(dtz/yrqr→yqx)
|
||||
- 查看
|
||||
|
||||
弹窗组件:
|
||||
- `ScheduleEditDialog.vue` — 编辑输注计划和细胞产品信息,`label-position="top"`,`dialog-form-layout`
|
||||
- `ScheduleViewDialog.vue` — 只读查看详情,展示关联信息和产品列表
|
||||
- `ScheduleCancelDialog.vue` — 取消原因输入(简单弹窗,textarea + 确认/取消)
|
||||
|
||||
- [ ] **Step 3: 创建 ScheduleEditDialog.vue**
|
||||
|
||||
- `el-dialog` width="800px" :close-on-click-modal="false"
|
||||
- 表单字段:细胞类型、规格、输注时间、输注地点、输注方式
|
||||
- 内嵌可编辑产品表格:项目名称、细胞类型、规格、协议单价、实际单价、份数
|
||||
- 使用 `.dialog-form-layout` + `.form-grid-2` 布局
|
||||
- `label-position="top"`
|
||||
|
||||
- [ ] **Step 4: 创建 ScheduleViewDialog.vue**
|
||||
|
||||
- 展示完整信息:申请单信息、患者信息、输注方案信息、输注计划信息、产品列表
|
||||
- 状态使用 el-tag
|
||||
- 参考 `SystemViewDialog` 模式
|
||||
|
||||
- [ ] **Step 5: 创建 ScheduleCancelDialog.vue**
|
||||
|
||||
- 简单弹窗 width="500px"
|
||||
- `el-input` type="textarea" placeholder="请输入取消原因" maxlength="500" show-word-limit
|
||||
- 确认/取消按钮
|
||||
|
||||
---
|
||||
|
||||
## Task 8: 前端路由
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/router/modules/sqxp.ts`
|
||||
- Modify: `web-admin/src/App.vue` (panelTitleBarTextRules)
|
||||
|
||||
- [ ] **Step 1: 添加路由**
|
||||
|
||||
在 `sqxp.ts` 的 PilotService children 中,`checkup-management` 路由之后添加:
|
||||
|
||||
```typescript
|
||||
{
|
||||
id: '80000000000000000000000000000012',
|
||||
name: 'InfusionScheduleManagement',
|
||||
path: 'infusion-schedule-management',
|
||||
component: '/pilot-service/infusion-schedule-management/index',
|
||||
meta: {
|
||||
title: '输注计划管理',
|
||||
keepAlive: true,
|
||||
menuCode: 'pilot-service:infusion-schedule-management:list'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 更新 App.vue panelTitleBarTextRules**
|
||||
|
||||
在 `App.vue` 的 `panelTitleBarTextRules` 正则中追加 `输注计划` 标题文案。
|
||||
|
||||
---
|
||||
|
||||
## Task 9: Bug Fix — 新增时默认状态
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/pilot_application.py` — 查找创建 schedule 和 product 的位置
|
||||
- Modify: `backend/app/api/pilot_application.py` — 如需在 API 层默认设置
|
||||
|
||||
- [ ] **Step 1: 定位创建 infusion schedule 的代码**
|
||||
|
||||
在 `pilot_application.py` CRUD 中查找创建 `BizPilotInfusionSchedule` 和 `BizPilotInfusionScheduleProduct` 的位置,确认:
|
||||
1. 创建 schedule 时 `infusion_status` 默认为 `'dtz'`(Model 默认值已处理)
|
||||
2. 创建 product 时 `product_status` 默认为 `'dtz'`(需确认代码是否显式设置)
|
||||
|
||||
如果代码中显式设置了 `product_status='待输注'`,需改为 `'dtz'`。
|
||||
|
||||
- [ ] **Step 2: 验证创建流程**
|
||||
|
||||
通过 API 创建新的中试申请单,检查生成的 schedule 的 `infusion_status` 和 product 的 `product_status` 是否为 `'dtz'`。
|
||||
|
||||
---
|
||||
|
||||
## Task 10: 更新文档
|
||||
|
||||
**Files:**
|
||||
- Modify: `docs/web-admin-ui-pattern-index.md`
|
||||
|
||||
- [ ] **Step 1: 补充页面→模式映射**
|
||||
|
||||
在文档 §四中添加:
|
||||
```
|
||||
| 输注计划管理 | pilot-service/infusion-schedule-management | P02 | /#/pilot-service/infusion-schedule-management |
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 验证清单
|
||||
|
||||
- [ ] 数据库:新字段已添加,现有数据已迁移
|
||||
- [ ] 后端:新 API 可通过 Swagger (/docs) 访问
|
||||
- [ ] 后端:扣减逻辑在余额/份数不足时正确报错
|
||||
- [ ] 前端:页面正常加载,列表展示多表 JOIN 数据
|
||||
- [ ] 前端:状态流转按钮根据 infusion_status 动态显示/隐藏
|
||||
- [ ] 前端:取消弹窗要求输入原因
|
||||
- [ ] 前端:完成操作触发扣减,错误时前端提示
|
||||
- [ ] Bug Fix:新创建的申请单中 schedule 和 product 默认状态为 dtz
|
||||
- [ ] openspec:页面标题竖条装饰正常显示
|
||||
- [ ] openspec:所有状态字段使用 el-tag 展示
|
||||
- [ ] openspec:操作列 fixed="right",按钮带 el-icon
|
||||
@@ -0,0 +1,846 @@
|
||||
# 出库生产工单 Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 在生产工单页面新增出库生产工单 tab,输注计划创建时自动创建出库工单,删除时自动作废,详情展示关联业务信息。
|
||||
|
||||
**Architecture:** 在现有生产工单 index.vue 中扩展第 4 个 tab(outbound),复用通用列表/详情 API。后端通过 `work_order_type="outbound"` 过滤,通过 `infusion_schedule_id` 反查关联链。自动创建/作废通过在 `pilot_application.py` 的 CRUD 函数中挂载钩子实现。
|
||||
|
||||
**Tech Stack:** Python 3.9 / FastAPI / SQLAlchemy / MySQL / Vue 3 / Element Plus / TypeScript
|
||||
|
||||
**Design Spec:** `docs/superpowers/specs/2026-05-26-outbound-production-work-order-design.md`
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
| 操作 | 文件 | 职责 |
|
||||
|------|------|------|
|
||||
| 新增 | `docs/sql/2026-05-26-outbound-work-order.sql` | ALTER TABLE DDL |
|
||||
| 修改 | `backend/app/models/models.py` (BizProductionWorkOrder 类) | 新增 biz_type 字段 |
|
||||
| 修改 | `backend/app/crud/production_work_order.py` | 状态映射、_wo_to_dict、create_outbound 函数签名、列表增强、详情增强 |
|
||||
| 修改 | `backend/app/crud/pilot_application.py` | create_schedule 自动创建钩子、soft_delete_schedule 作废钩子 |
|
||||
| 修改 | `web-admin/src/views/production/production-work-order/index.vue` | 新 tab、列配置、操作按钮、详情弹窗、状态映射 |
|
||||
|
||||
---
|
||||
|
||||
### Task 1: 数据库 DDL 脚本
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/sql/2026-05-26-outbound-work-order.sql`
|
||||
|
||||
- [ ] **Step 1: 创建 SQL 迁移脚本**
|
||||
|
||||
```sql
|
||||
-- 出库生产工单:新增 biz_type 字段 + 更新 comment
|
||||
ALTER TABLE biz_production_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_type VARCHAR(20) NOT NULL DEFAULT 'inbound' COMMENT '工单类型: inbound=入库, temporary=临时, outbound=出库';
|
||||
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_status VARCHAR(16) NOT NULL DEFAULT 'dpz' COMMENT '工单状态 dpz待配置 jxz进行中 ywc已完成 yzf已作废';
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 在数据库中执行此脚本**
|
||||
|
||||
Run: `source venv/bin/activate && python -c "from app.core.database import engine; from sqlalchemy import text; conn = engine.connect(); [conn.execute(text(s)) for s in open('docs/sql/2026-05-26-outbound-work-order.sql').read().split(';') if s.strip() and not s.strip().startswith('--')]; conn.commit(); print('OK')"`
|
||||
|
||||
或手动在 MySQL 客户端中执行。Expected: `OK`
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add docs/sql/2026-05-26-outbound-work-order.sql
|
||||
git commit -m "feat(production): add biz_type column and yzf status for outbound work orders"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: 后端模型层 — BizProductionWorkOrder 新增 biz_type
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/models/models.py` (BizProductionWorkOrder 类, 约 line 2430)
|
||||
|
||||
- [ ] **Step 1: 在 BizProductionWorkOrder 类中新增 biz_type 字段**
|
||||
|
||||
在 `infusion_schedule_id` 字段之后新增:
|
||||
|
||||
```python
|
||||
biz_type = Column(String(20), nullable=True, comment="业务类型: pilot_service=中试服务, clinical_application=临床应用")
|
||||
```
|
||||
|
||||
同时更新 `work_order_type` 字段的 comment:
|
||||
```python
|
||||
work_order_type = Column(String(20), nullable=False, default="inbound", comment="工单类型: inbound=入库, temporary=临时, outbound=出库")
|
||||
```
|
||||
|
||||
更新 `work_order_status` 字段的 comment:
|
||||
```python
|
||||
work_order_status = Column(String(16), nullable=False, default="dpz", comment="工单状态 dpz待配置 jxz进行中 ywc已完成 yzf已作废")
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 验证模型无语法错误**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.models.models import BizProductionWorkOrder; print('OK')"`
|
||||
|
||||
Expected: `OK`
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/models/models.py
|
||||
git commit -m "feat(production): add biz_type field to BizProductionWorkOrder model"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: 后端 CRUD 层 — production_work_order.py
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/production_work_order.py`
|
||||
|
||||
- [ ] **Step 1: 扩展状态映射和来源标签**
|
||||
|
||||
文件顶部 `_WORK_ORDER_STATUS_LABELS` (约 line 32-36) 修改为:
|
||||
|
||||
```python
|
||||
_WORK_ORDER_STATUS_LABELS = {
|
||||
"dpz": "待配置",
|
||||
"jxz": "进行中",
|
||||
"ywc": "已完成",
|
||||
"yzf": "已作废",
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 2: _wo_to_dict 增加 bizType 字段**
|
||||
|
||||
在 `_wo_to_dict()` 函数 (约 line 87-111) 中,`"infusionScheduleId"` 之后新增:
|
||||
|
||||
```python
|
||||
"bizType": getattr(wo, "biz_type", None) or None,
|
||||
"bizTypeLabel": {"pilot_service": "中试服务", "clinical_application": "临床应用"}.get(getattr(wo, "biz_type", None) or "", ""),
|
||||
```
|
||||
|
||||
- [ ] **Step 3: create_outbound_production_work_order 增加 biz_type 参数**
|
||||
|
||||
函数签名 (约 line 638-646) 修改为:
|
||||
|
||||
```python
|
||||
def create_outbound_production_work_order(
|
||||
db: Session,
|
||||
*,
|
||||
schedule_id: str,
|
||||
tenant_no: str,
|
||||
user_id: Optional[str] = None,
|
||||
create_dept_id: str = "",
|
||||
remark: str = "",
|
||||
biz_type: str = "pilot_service",
|
||||
) -> BizProductionWorkOrder:
|
||||
```
|
||||
|
||||
在创建 `BizProductionWorkOrder` 对象时 (约 line 658-674) 新增字段:
|
||||
|
||||
```python
|
||||
wo = BizProductionWorkOrder(
|
||||
id=generate_uuid(),
|
||||
work_order_no=_generate_outbound_work_order_no(db, tenant_no),
|
||||
work_order_type="outbound",
|
||||
reception_id=None,
|
||||
protocol_sample_id=None,
|
||||
collection_protocol_id=None,
|
||||
protocol_no=None,
|
||||
sample_code=None,
|
||||
reception_source="outbound",
|
||||
infusion_schedule_id=schedule_id,
|
||||
biz_type=biz_type,
|
||||
work_order_status="dpz",
|
||||
tenant_no=tenant_no,
|
||||
remark=remark,
|
||||
create_by=user_id,
|
||||
create_dept_id=create_dept_id,
|
||||
)
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 列表增强 — outbound 工单附加业务数据**
|
||||
|
||||
在 `_enrich_wo_items()` 函数之后新增辅助函数:
|
||||
|
||||
```python
|
||||
_BIZ_TYPE_LABELS = {"pilot_service": "中试服务", "clinical_application": "临床应用"}
|
||||
|
||||
|
||||
def _enrich_outbound_items(db: Session, items: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""为 outbound 类型工单附加申请单号、细胞类型、规格、输注时间等关联数据。"""
|
||||
from app.models.models import (
|
||||
BizPilotApplication,
|
||||
BizPilotInfusionPlan,
|
||||
BizPilotInfusionSchedule,
|
||||
)
|
||||
|
||||
outbound_ids = [
|
||||
it["infusionScheduleId"]
|
||||
for it in items
|
||||
if it.get("workOrderType") == "outbound" and it.get("infusionScheduleId")
|
||||
]
|
||||
if not outbound_ids:
|
||||
return items
|
||||
|
||||
schedules = (
|
||||
db.query(BizPilotInfusionSchedule)
|
||||
.filter(
|
||||
BizPilotInfusionSchedule.id.in_(outbound_ids),
|
||||
BizPilotInfusionSchedule.del_flag == 0,
|
||||
)
|
||||
.all()
|
||||
)
|
||||
sched_map = {s.id: s for s in schedules}
|
||||
|
||||
plan_ids = list({s.infusion_plan_id for s in schedules if s.infusion_plan_id})
|
||||
plan_map = {}
|
||||
if plan_ids:
|
||||
plans = db.query(BizPilotInfusionPlan).filter(BizPilotInfusionPlan.id.in_(plan_ids)).all()
|
||||
plan_map = {p.id: p for p in plans}
|
||||
|
||||
app_ids = list({p.pilot_application_id for p in plan_map.values() if p.pilot_application_id})
|
||||
app_map = {}
|
||||
if app_ids:
|
||||
apps = db.query(BizPilotApplication).filter(BizPilotApplication.id.in_(app_ids)).all()
|
||||
app_map = {a.id: a for a in apps}
|
||||
|
||||
for it in items:
|
||||
if it.get("workOrderType") != "outbound" or not it.get("infusionScheduleId"):
|
||||
continue
|
||||
sched = sched_map.get(it["infusionScheduleId"])
|
||||
if not sched:
|
||||
continue
|
||||
plan = plan_map.get(sched.infusion_plan_id) if sched.infusion_plan_id else None
|
||||
app = app_map.get(plan.pilot_application_id) if plan and plan.pilot_application_id else None
|
||||
|
||||
it["applicationNo"] = app.application_no if app else ""
|
||||
it["cellType"] = sched.cell_type or ""
|
||||
it["specText"] = sched.spec_text or ""
|
||||
it["infusionTime"] = _fmt_dt(sched.infusion_time) if sched.infusion_time else ""
|
||||
it["infusionLocation"] = sched.infusion_location or ""
|
||||
|
||||
return items
|
||||
```
|
||||
|
||||
然后在 `list_production_work_orders()` (约 line 343) 的 return 之前调用:
|
||||
|
||||
将:
|
||||
```python
|
||||
items = _enrich_wo_items(db, [_wo_to_dict(x) for x in rows])
|
||||
return {"items": items, "total": int(total)}
|
||||
```
|
||||
|
||||
改为:
|
||||
```python
|
||||
items = _enrich_wo_items(db, [_wo_to_dict(x) for x in rows])
|
||||
items = _enrich_outbound_items(db, items)
|
||||
return {"items": items, "total": int(total)}
|
||||
```
|
||||
|
||||
- [ ] **Step 5: 详情增强 — outbound 工单详情返回关联链**
|
||||
|
||||
在 `_wo_to_response_dict()` 函数 (约 line 160-164) 中,对 outbound 类型附加关联信息:
|
||||
|
||||
将:
|
||||
```python
|
||||
def _wo_to_response_dict(db: Session, wo: BizProductionWorkOrder) -> Dict[str, Any]:
|
||||
"""工单响应(含接收记录关联的样本类型、接收人、接收时间及 reception 详情)。"""
|
||||
out = _enrich_wo_items(db, [_wo_to_dict(wo)])[0]
|
||||
_attach_reception_detail(db, wo, out, wo.tenant_no or "")
|
||||
return out
|
||||
```
|
||||
|
||||
改为:
|
||||
```python
|
||||
def _wo_to_response_dict(db: Session, wo: BizProductionWorkOrder) -> Dict[str, Any]:
|
||||
"""工单响应(含接收记录关联的样本类型、接收人、接收时间及 reception 详情)。"""
|
||||
out = _enrich_wo_items(db, [_wo_to_dict(wo)])[0]
|
||||
if wo.work_order_type == "outbound" and wo.infusion_schedule_id:
|
||||
_attach_outbound_detail(db, wo, out)
|
||||
else:
|
||||
_attach_reception_detail(db, wo, out, wo.tenant_no or "")
|
||||
return out
|
||||
```
|
||||
|
||||
新增 `_attach_outbound_detail` 函数:
|
||||
|
||||
```python
|
||||
def _attach_outbound_detail(
|
||||
db: Session, wo: BizProductionWorkOrder, out: Dict[str, Any]
|
||||
) -> None:
|
||||
"""outbound 工单详情附加申请单 + 输注计划信息。"""
|
||||
from app.models.models import (
|
||||
BizPilotApplication,
|
||||
BizPilotInfusionPlan,
|
||||
BizPilotInfusionSchedule,
|
||||
)
|
||||
|
||||
_APP_STATUS_LABELS = {"dks": "待开始", "jxz": "进行中", "ywc": "已完成", "yzf": "已作废"}
|
||||
|
||||
sched = (
|
||||
db.query(BizPilotInfusionSchedule)
|
||||
.filter(BizPilotInfusionSchedule.id == wo.infusion_schedule_id, BizPilotInfusionSchedule.del_flag == 0)
|
||||
.first()
|
||||
)
|
||||
plan = None
|
||||
app = None
|
||||
if sched and sched.infusion_plan_id:
|
||||
plan = db.query(BizPilotInfusionPlan).filter(BizPilotInfusionPlan.id == sched.infusion_plan_id).first()
|
||||
if plan and plan.pilot_application_id:
|
||||
app = db.query(BizPilotApplication).filter(BizPilotApplication.id == plan.pilot_application_id).first()
|
||||
|
||||
out["reception"] = {}
|
||||
out["pilotApplication"] = {
|
||||
"applicationNo": app.application_no if app else "",
|
||||
"applicationName": app.application_name if app else "",
|
||||
"applicationStatus": app.application_status if app else "",
|
||||
"applicationStatusLabel": _APP_STATUS_LABELS.get(app.application_status, "") if app else "",
|
||||
} if app else {}
|
||||
out["infusionSchedule"] = {
|
||||
"cellType": sched.cell_type if sched else "",
|
||||
"specText": sched.spec_text if sched else "",
|
||||
"infusionTime": _fmt_dt(sched.infusion_time) if sched and sched.infusion_time else "",
|
||||
"infusionLocation": sched.infusion_location if sched else "",
|
||||
"infusionMethod": sched.infusion_method if sched else "",
|
||||
"scheduleStatus": sched.schedule_status if sched else "",
|
||||
} if sched else {}
|
||||
```
|
||||
|
||||
- [ ] **Step 6: 验证无语法错误**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.crud.production_work_order import list_production_work_orders, _wo_to_response_dict, create_outbound_production_work_order; print('OK')"`
|
||||
|
||||
Expected: `OK`
|
||||
|
||||
- [ ] **Step 7: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/crud/production_work_order.py
|
||||
git commit -m "feat(production): extend CRUD for outbound work orders — biz_type, yzf status, list/detail enrichment"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 后端钩子 — 自动创建出库工单
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/pilot_application.py` (create_schedule 函数, 约 line 926)
|
||||
|
||||
- [ ] **Step 1: 在 create_schedule 中增加自动创建出库工单**
|
||||
|
||||
在 `create_schedule()` 函数 (约 line 966) 的 `if commit:` 之前插入:
|
||||
|
||||
```python
|
||||
# 自动创建出库生产工单
|
||||
from app.crud import production_work_order as pwo_svc
|
||||
pwo_svc.create_outbound_production_work_order(
|
||||
db,
|
||||
schedule_id=schedule_id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user_id,
|
||||
create_dept_id=dept_id,
|
||||
biz_type="pilot_service",
|
||||
)
|
||||
```
|
||||
|
||||
注意位置:应在 `_create_schedule_products` 之后、`if commit:` 之前,确保 schedule_id 和 products 已写入但还未 commit(在同一事务内)。
|
||||
|
||||
- [ ] **Step 2: 验证无语法错误**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.crud.pilot_application import create_schedule; print('OK')"`
|
||||
|
||||
Expected: `OK`
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/crud/pilot_application.py
|
||||
git commit -m "feat(pilot): auto-create outbound production work order on schedule creation"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: 后端钩子 — 自动作废出库工单
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/pilot_application.py` (soft_delete_schedule 函数, 约 line 1064)
|
||||
|
||||
- [ ] **Step 1: 在 soft_delete_schedule 中增加作废逻辑**
|
||||
|
||||
在 `soft_delete_schedule()` 函数中,`row.del_flag = 1` (约 line 1077) 之前插入:
|
||||
|
||||
```python
|
||||
# 关联的出库生产工单标记为已作废
|
||||
from app.models.models import BizProductionWorkOrder
|
||||
outbound_wo = (
|
||||
db.query(BizProductionWorkOrder)
|
||||
.filter(
|
||||
BizProductionWorkOrder.infusion_schedule_id == schedule_id,
|
||||
BizProductionWorkOrder.tenant_no == tenant_no,
|
||||
BizProductionWorkOrder.del_flag == 0,
|
||||
BizProductionWorkOrder.work_order_type == "outbound",
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if outbound_wo:
|
||||
outbound_wo.work_order_status = "yzf"
|
||||
outbound_wo.update_time = datetime.now()
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 验证无语法错误**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.crud.pilot_application import soft_delete_schedule; print('OK')"`
|
||||
|
||||
Expected: `OK`
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/crud/pilot_application.py
|
||||
git commit -m "feat(pilot): auto-void outbound production work order on schedule deletion"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: 前端 — 生产工单页面扩展 outbound tab
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/production/production-work-order/index.vue`
|
||||
|
||||
- [ ] **Step 1: 扩展 WorkOrderTypeTab 类型**
|
||||
|
||||
约 line 432,修改为:
|
||||
|
||||
```typescript
|
||||
type WorkOrderTypeTab = 'inbound' | 'temporary' | 'outbound' | 'all'
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 新增 outbound tab 面板**
|
||||
|
||||
约 line 15-19,在 `全部生产工单` 之前插入 outbound tab:
|
||||
|
||||
```html
|
||||
<el-tabs v-model="activeTypeTab" class="work-order-type-tabs" @tab-change="handleTypeTabChange">
|
||||
<el-tab-pane label="入库生产工单" name="inbound" />
|
||||
<el-tab-pane label="临时生产工单" name="temporary" />
|
||||
<el-tab-pane label="出库生产工单" name="outbound" />
|
||||
<el-tab-pane label="全部生产工单" name="all" />
|
||||
</el-tabs>
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 更新搜索框 placeholder**
|
||||
|
||||
约 line 27,修改 placeholder 为 computed:
|
||||
|
||||
将:
|
||||
```html
|
||||
:placeholder="activeTypeTab === 'temporary' ? '工单号' : '工单号/协议号/样本编码'"
|
||||
```
|
||||
|
||||
改为:
|
||||
```html
|
||||
:placeholder="searchPlaceholder"
|
||||
```
|
||||
|
||||
在 script setup 区域新增 computed:
|
||||
|
||||
```typescript
|
||||
const searchPlaceholder = computed(() => {
|
||||
if (activeTypeTab.value === 'temporary') return '工单号'
|
||||
if (activeTypeTab.value === 'outbound') return '工单号/申请单号'
|
||||
return '工单号/协议号/样本编码'
|
||||
})
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 更新工具栏 — outbound 和 all tab 不显示新增按钮**
|
||||
|
||||
约 line 69,修改:
|
||||
|
||||
将:
|
||||
```html
|
||||
<div v-if="activeTypeTab !== 'all'" class="list-toolbar">
|
||||
```
|
||||
|
||||
改为:
|
||||
```html
|
||||
<div v-if="activeTypeTab !== 'all' && activeTypeTab !== 'outbound'" class="list-toolbar">
|
||||
```
|
||||
|
||||
- [ ] **Step 5: 更新全部 tab 的工单类型 tag 映射**
|
||||
|
||||
约 line 94-100,修改类型 tag:
|
||||
|
||||
将:
|
||||
```html
|
||||
<el-table-column v-if="activeTypeTab === 'all'" prop="workOrderType" label="工单类型" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.workOrderType === 'temporary' ? 'warning' : 'success'" size="small">
|
||||
{{ row.workOrderType === 'temporary' ? '临时' : '入库' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
```
|
||||
|
||||
改为:
|
||||
```html
|
||||
<el-table-column v-if="activeTypeTab === 'all'" prop="workOrderType" label="工单类型" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="woTypeTag(row.workOrderType).type" size="small">
|
||||
{{ woTypeTag(row.workOrderType).label }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
```
|
||||
|
||||
在 script 中 `sourceTag` 函数之后新增:
|
||||
|
||||
```typescript
|
||||
const woTypeTag = (type: string) => {
|
||||
const map: Record<string, { label: string; type: string }> = {
|
||||
inbound: { label: '入库', type: 'success' },
|
||||
temporary: { label: '临时', type: 'warning' },
|
||||
outbound: { label: '出库', type: 'primary' },
|
||||
}
|
||||
return map[type] || { label: type, type: 'info' }
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 6: 新增 outbound 专属列**
|
||||
|
||||
在 `全部工单类型` 列之后、`协议号` 列之前(约 line 100-101 之间),插入 outbound 专属列:
|
||||
|
||||
```html
|
||||
<!-- 出库工单专属列 -->
|
||||
<el-table-column v-if="activeTypeTab === 'outbound'" prop="bizTypeLabel" label="业务类型" min-width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.bizType === 'pilot_service' ? 'primary' : 'success'" size="small">
|
||||
{{ row.bizTypeLabel || '—' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTypeTab === 'outbound'" prop="applicationNo" label="申请单号" min-width="150" align="center">
|
||||
<template #default="{ row }">{{ row.applicationNo || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTypeTab === 'outbound'" prop="cellType" label="细胞类型" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.cellType || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTypeTab === 'outbound'" prop="specText" label="规格" min-width="110" align="center">
|
||||
<template #default="{ row }">{{ row.specText || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="activeTypeTab === 'outbound'" prop="infusionTime" label="输注时间" min-width="170" align="center">
|
||||
<template #default="{ row }">{{ row.infusionTime || '—' }}</template>
|
||||
</el-table-column>
|
||||
```
|
||||
|
||||
- [ ] **Step 7: 更新 showReceptionCols 逻辑**
|
||||
|
||||
约 line 434,修改:
|
||||
|
||||
将:
|
||||
```typescript
|
||||
const showReceptionCols = computed(() => activeTypeTab.value !== 'temporary')
|
||||
```
|
||||
|
||||
改为:
|
||||
```typescript
|
||||
const showReceptionCols = computed(() => activeTypeTab.value !== 'temporary' && activeTypeTab.value !== 'outbound')
|
||||
```
|
||||
|
||||
- [ ] **Step 8: 全部 tab 隐藏操作列**
|
||||
|
||||
约 line 145-178 的操作列 `<el-table-column>` 添加 `v-if`:
|
||||
|
||||
将:
|
||||
```html
|
||||
<el-table-column
|
||||
label="操作"
|
||||
min-width="600"
|
||||
fixed="right"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
```
|
||||
|
||||
改为:
|
||||
```html
|
||||
<el-table-column
|
||||
v-if="activeTypeTab !== 'all'"
|
||||
label="操作"
|
||||
min-width="600"
|
||||
fixed="right"
|
||||
align="center"
|
||||
header-align="center"
|
||||
>
|
||||
```
|
||||
|
||||
- [ ] **Step 9: 更新工单状态 Tag 映射**
|
||||
|
||||
约 line 510-517,修改 `woStatusTag`:
|
||||
|
||||
将:
|
||||
```typescript
|
||||
const woStatusTag = (status: string) => {
|
||||
const map: Record<string, { label: string; type: string }> = {
|
||||
dpz: { label: '待配置', type: 'info' },
|
||||
jxz: { label: '进行中', type: 'warning' },
|
||||
ywc: { label: '已完成', type: 'success' }
|
||||
}
|
||||
return map[status] || { label: status, type: 'info' }
|
||||
}
|
||||
```
|
||||
|
||||
改为:
|
||||
```typescript
|
||||
const woStatusTag = (status: string) => {
|
||||
const map: Record<string, { label: string; type: string }> = {
|
||||
dpz: { label: '待配置', type: 'info' },
|
||||
jxz: { label: '进行中', type: 'warning' },
|
||||
ywc: { label: '已完成', type: 'success' },
|
||||
yzf: { label: '已作废', type: 'danger' }
|
||||
}
|
||||
return map[status] || { label: status, type: 'info' }
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 10: 状态筛选下拉增加已作废选项**
|
||||
|
||||
约 line 38-41,增加选项:
|
||||
|
||||
将:
|
||||
```html
|
||||
<el-option label="待配置" value="dpz" />
|
||||
<el-option label="进行中" value="jxz" />
|
||||
<el-option label="已完成" value="ywc" />
|
||||
```
|
||||
|
||||
改为:
|
||||
```html
|
||||
<el-option label="待配置" value="dpz" />
|
||||
<el-option label="进行中" value="jxz" />
|
||||
<el-option label="已完成" value="ywc" />
|
||||
<el-option label="已作废" value="yzf" />
|
||||
```
|
||||
|
||||
- [ ] **Step 11: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/views/production/production-work-order/index.vue
|
||||
git commit -m "feat(production): add outbound work order tab with columns, filters, and status mapping"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 7: 前端 — 详情弹窗增强
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/production/production-work-order/index.vue` (viewSections computed, 约 line 640)
|
||||
|
||||
- [ ] **Step 1: 更新 viewSections computed,增加 outbound 分支**
|
||||
|
||||
约 line 640-733,替换整个 `viewSections` computed。
|
||||
|
||||
核心逻辑:
|
||||
- `isOutbound = d.workOrderType === 'outbound'`
|
||||
- outbound 基本信息:工单号、工单类型(出库/primary)、业务类型、工单状态、备注、创建时间
|
||||
- outbound 不显示协议号/协议状态/样本编码/来源类型/样本类型
|
||||
- outbound 新增"中试申请信息"section:申请单号、申请名称、申请状态
|
||||
- outbound 新增"输注计划信息"section:细胞类型、规格、输注时间、输注地点、输注方式
|
||||
- outbound 不显示运输信息、样本接收 section
|
||||
|
||||
```typescript
|
||||
const viewSections = computed<ViewSection[]>(() => {
|
||||
if (!detail.value) return []
|
||||
const d = detail.value
|
||||
const isTemp = d.workOrderType === 'temporary'
|
||||
const isOutbound = d.workOrderType === 'outbound'
|
||||
const r = d.reception || {}
|
||||
|
||||
// ── 基本信息 fields ──
|
||||
const baseFields: ViewSection['fields'] = [
|
||||
{ label: '工单号', value: d.workOrderNo },
|
||||
{
|
||||
label: '工单类型',
|
||||
value: isTemp ? '临时' : isOutbound ? '出库' : '入库',
|
||||
tagType: isTemp ? 'warning' : isOutbound ? 'primary' : 'success'
|
||||
},
|
||||
]
|
||||
|
||||
// outbound 显示业务类型
|
||||
if (isOutbound) {
|
||||
baseFields.push({
|
||||
label: '业务类型',
|
||||
value: d.bizTypeLabel || (d.bizType === 'pilot_service' ? '中试服务' : d.bizType === 'clinical_application' ? '临床应用' : '—'),
|
||||
tagType: 'primary' as const
|
||||
})
|
||||
}
|
||||
|
||||
// inbound 显示协议/样本字段
|
||||
if (!isTemp && !isOutbound) {
|
||||
baseFields.push(
|
||||
{ label: '协议号', value: d.protocolNo },
|
||||
{
|
||||
label: '协议状态',
|
||||
value: protocolStatusLabelBySource(String(d.protocolStatus || ''), d.receptionSource || 'cell_storage'),
|
||||
tagType: protocolStatusTagTypeBySource(String(d.protocolStatus || ''), d.receptionSource || 'cell_storage')
|
||||
},
|
||||
{ label: '样本编码', value: d.sampleCode },
|
||||
{
|
||||
label: '来源类型',
|
||||
value:
|
||||
r.sourceTypeLabel ||
|
||||
d.receptionSourceLabel ||
|
||||
receptionSourceLabel(d.receptionSource || ''),
|
||||
tagType: 'primary' as const
|
||||
},
|
||||
{ label: '样本类型', value: r.sampleTypeName || d.sampleTypeName || '—' }
|
||||
)
|
||||
}
|
||||
|
||||
baseFields.push(
|
||||
{
|
||||
label: '工单状态',
|
||||
value: woStatusTag(d.workOrderStatus).label,
|
||||
tagType: woStatusTag(d.workOrderStatus).type as any
|
||||
},
|
||||
{ label: '备注', value: d.remark || '—', span: true },
|
||||
{ label: '创建时间', value: d.createTime || '—' }
|
||||
)
|
||||
|
||||
const sections: ViewSection[] = [
|
||||
{ title: '基本信息', fields: baseFields }
|
||||
]
|
||||
|
||||
// outbound: 申请单 + 输注计划
|
||||
if (isOutbound) {
|
||||
const pa = d.pilotApplication || {}
|
||||
const sched = d.infusionSchedule || {}
|
||||
const appStatusLabel = (s: string) => {
|
||||
const m: Record<string, string> = { dks: '待开始', jxz: '进行中', ywc: '已完成', yzf: '已作废' }
|
||||
return m[s] || s || '—'
|
||||
}
|
||||
const appStatusTagType = (s: string) => {
|
||||
const m: Record<string, string> = { dks: 'info', jxz: 'warning', ywc: 'success', yzf: 'danger' }
|
||||
return m[s] || 'info'
|
||||
}
|
||||
sections.push({
|
||||
title: '中试申请信息',
|
||||
fields: [
|
||||
{ label: '申请单号', value: pa.applicationNo || '—' },
|
||||
{ label: '申请名称', value: pa.applicationName || '—' },
|
||||
{
|
||||
label: '申请状态',
|
||||
value: appStatusLabel(pa.applicationStatus),
|
||||
tagType: appStatusTagType(pa.applicationStatus) as any
|
||||
},
|
||||
]
|
||||
})
|
||||
sections.push({
|
||||
title: '输注计划信息',
|
||||
fields: [
|
||||
{ label: '细胞类型', value: sched.cellType || '—' },
|
||||
{ label: '规格', value: sched.specText || '—' },
|
||||
{ label: '输注时间', value: sched.infusionTime || '—' },
|
||||
{ label: '输注地点', value: sched.infusionLocation || '—' },
|
||||
{ label: '输注方式', value: sched.infusionMethod || '—' },
|
||||
]
|
||||
})
|
||||
return sections
|
||||
}
|
||||
|
||||
// inbound: 运输 + 样本接收
|
||||
const transportFields: ViewSection['fields'] = [
|
||||
{ label: '运输方式', value: transportTypeLabel(String(r.transportType || '')) }
|
||||
]
|
||||
if (r.transportType === 'kdys') {
|
||||
transportFields.push(
|
||||
{ label: '快递公司', value: r.expressCompanyName || '—' },
|
||||
{ label: '快递单号', value: r.waybillNo || '—' }
|
||||
)
|
||||
} else if (r.transportType === 'ryxd') {
|
||||
transportFields.push(
|
||||
{ label: '携带人', value: r.carrierName || '—' },
|
||||
{ label: '携带人电话', value: r.carrierPhone || '—' }
|
||||
)
|
||||
}
|
||||
if (r.etaTime) transportFields.push({ label: '预计到达', value: r.etaTime })
|
||||
const transportSection = transportFields.length > 1 || r.transportType ? [{ title: '运输信息', fields: transportFields }] : []
|
||||
|
||||
return [
|
||||
{ title: '基本信息', fields: baseFields },
|
||||
...transportSection,
|
||||
...(!isTemp ? [{
|
||||
title: '样本接收',
|
||||
slot: 'reception-extra',
|
||||
fields: [
|
||||
{ label: '接收时间', value: r.receptionTime || d.receptionTime || '—' },
|
||||
{ label: '接收经手人', value: r.handlerName || d.handlerName || '—' },
|
||||
{ label: '接收温度(℃)', value: r.receiveTemperature ? `${r.receiveTemperature}℃` : '—' },
|
||||
{ label: '体积(ml)', value: formatMetric(r.volumeMl) },
|
||||
{ label: '净重(g)', value: formatMetric(r.netWeightG) },
|
||||
{
|
||||
label: '结论',
|
||||
value: r.acceptConclusionLabel || acceptConclusionLabel(String(r.acceptConclusion || '')),
|
||||
tagType: r.acceptConclusion === 'js' ? 'success' : r.acceptConclusion === 'jj' ? 'danger' : 'info'
|
||||
},
|
||||
{ label: '检查项', value: formatCheckResults(r.checkResults), span: true },
|
||||
{ label: '备注', value: r.remark || '—', span: true }
|
||||
]
|
||||
}] : [])
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 验证前端无编译错误**
|
||||
|
||||
Run: `cd web-admin && pnpm build 2>&1 | tail -5`
|
||||
|
||||
Expected: Build 成功(可能有无关的 type warning,但不应有 error)
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/views/production/production-work-order/index.vue
|
||||
git commit -m "feat(production): add outbound work order detail dialog with pilot application and infusion schedule sections"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 8: 端到端验证
|
||||
|
||||
**Files:** 无文件修改
|
||||
|
||||
- [ ] **Step 1: 启动后端,确认无报错**
|
||||
|
||||
Run: `cd backend && source venv/bin/activate && python -c "from app.main import app; print('App OK')"`
|
||||
|
||||
Expected: `App OK`
|
||||
|
||||
- [ ] **Step 2: 启动前端,确认无编译错误**
|
||||
|
||||
Run: `cd web-admin && pnpm build 2>&1 | tail -5`
|
||||
|
||||
Expected: Build 成功
|
||||
|
||||
- [ ] **Step 3: 功能验证清单(手动)**
|
||||
|
||||
1. 打开生产工单页面,确认 4 个 tab 都显示
|
||||
2. 点击「出库生产工单」tab,确认列表加载(无数据或已有数据)
|
||||
3. 确认出库 tab 不显示新增按钮
|
||||
4. 确认出库 tab 显示专属列(业务类型、申请单号、细胞类型、规格、输注时间)
|
||||
5. 点击「全部生产工单」tab,确认操作列已隐藏
|
||||
6. 创建一条输注计划,切换到出库 tab 确认自动生成了工单
|
||||
7. 删除该输注计划,确认出库工单状态变为「已作废」
|
||||
8. 点击出库工单的查看详情,确认显示申请单信息和输注计划信息
|
||||
9. 确认编辑任务、派发任务、完成工单按钮可正常使用
|
||||
|
||||
- [ ] **Step 4: Final Commit (如有遗漏修复)**
|
||||
|
||||
```bash
|
||||
git add -A
|
||||
git commit -m "fix(production): final adjustments for outbound work order feature"
|
||||
```
|
||||
@@ -0,0 +1,881 @@
|
||||
# 出库质检工单功能实施计划
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 在现有质检工单页面新增"出库质检工单"Tab,展示由中试服务申请单/输注计划触发的出库质检工单,支持查看(含完整申请单+输注计划信息)、编辑备注、配置检测。
|
||||
|
||||
**Architecture:** 前端在 `qc-work-order/index.vue` 中新增第 4 个 Tab `outbound`,复用列表骨架、配置检测、编辑备注逻辑,新建独立查看对话框组件 `OutboundQcViewDialog.vue`。后端新增聚合查询 API,扩展现有列表 API 返回字段,并在输注计划取消时自动作废关联质检工单。
|
||||
|
||||
**Tech Stack:** Vue 3 + Element Plus (前端) / FastAPI + SQLAlchemy + Pydantic v2 (后端) / MySQL 5.7
|
||||
|
||||
**设计文档:** `docs/superpowers/specs/2026-05-26-outbound-qc-work-order-design.md`
|
||||
|
||||
---
|
||||
|
||||
## Task 1: 数据库 — 新增 biz_type 字段
|
||||
|
||||
**Files:**
|
||||
- Create: `docs/sql/2026-05-26-qc-work-order-add-biz-type.sql`
|
||||
- Modify: `backend/app/models/models.py:1239` (在 `infusion_schedule_id` 后新增字段)
|
||||
|
||||
- [ ] **Step 1: 创建 SQL 迁移文件**
|
||||
|
||||
```sql
|
||||
-- 出库质检工单:新增 biz_type 字段
|
||||
ALTER TABLE biz_qc_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 在 SQLAlchemy 模型中新增 biz_type 字段**
|
||||
|
||||
在 `backend/app/models/models.py` 的 `BizQcWorkOrder` 类中,在 `infusion_schedule_id` 字段之后添加:
|
||||
|
||||
```python
|
||||
biz_type = Column(String(20), nullable=True, comment="业务类型: pilot_service=中试服务, clinical_application=临床应用")
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 在数据库执行 SQL**
|
||||
|
||||
在 MySQL 客户端中执行迁移 SQL。
|
||||
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
```bash
|
||||
git add docs/sql/2026-05-26-qc-work-order-add-biz-type.sql backend/app/models/models.py
|
||||
git commit -m "feat(qc): add biz_type column to qc_work_order table for outbound business type"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 2: 后端 — 扩展列表 API 和 _row_to_dict
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/qc_work_order.py` (扩展列表查询和 `_row_to_dict`)
|
||||
- Modify: `backend/app/schemas/qc_work_order.py` (无改动,schema 跟随 _row_to_dict)
|
||||
|
||||
**参考文件(只读):**
|
||||
- `backend/app/crud/qc_work_order.py` — 搜索 `_row_to_dict` 函数和 `list_work_orders` 函数
|
||||
- `backend/app/models/models.py` — 搜索 `BizPilotInfusionSchedule`、`BizPilotInfusionPlan`、`BizPilotApplication` 模型
|
||||
|
||||
- [ ] **Step 1: 修改 `list_work_orders()` 函数,支持 outbound 类型的 JOIN 查询和 bizType 筛选参数**
|
||||
|
||||
在 `backend/app/crud/qc_work_order.py` 中:
|
||||
|
||||
1. 找到 `list_work_orders()` 函数(查询质检工单列表)
|
||||
2. 新增可选参数 `biz_type: Optional[str] = None`
|
||||
3. 当 `work_order_type == 'outbound'` 时,LEFT JOIN 以下链路获取关联数据:
|
||||
- `biz_qc_work_order.infusion_schedule_id` → `biz_pilot_infusion_schedule`
|
||||
- `biz_pilot_infusion_schedule.infusion_plan_id` → `biz_pilot_infusion_plan`
|
||||
- `biz_pilot_infusion_plan.pilot_application_id` → `biz_pilot_application`
|
||||
4. 添加 WHERE 条件 `biz_type` 筛选(当参数非空时)
|
||||
|
||||
- [ ] **Step 2: 扩展 `_row_to_dict()` 函数,为 outbound 类型返回额外字段**
|
||||
|
||||
在 `_row_to_dict()` 函数中,当工单的 `work_order_type == 'outbound'` 时,额外返回:
|
||||
|
||||
```python
|
||||
# outbound 工单额外字段
|
||||
'bizType': row.biz_type, # 业务类型
|
||||
'bizTypeLabel': '中试服务' if row.biz_type == 'pilot_service' else ('临床应用' if row.biz_type == 'clinical_application' else ''),
|
||||
'applicationNo': application_no if outbound else None, # 申请单号
|
||||
'applicationName': application_name if outbound else None, # 申请单名称
|
||||
'channelName': channel_name if outbound else None, # 渠道名称
|
||||
'infusionTime': infusion_time if outbound else None, # 输注时间
|
||||
```
|
||||
|
||||
这些字段从 JOIN 查询结果中获取。
|
||||
|
||||
- [ ] **Step 3: 修改列表 API 路由,接收 bizType 查询参数**
|
||||
|
||||
在 `backend/app/api/qc.py` 的工单列表端点中,从 `request.args` 或 Pydantic 查询模型中接收 `bizType` 参数,传递给 `list_work_orders()`。
|
||||
|
||||
- [ ] **Step 4: 修改 `create_outbound_qc_work_order()` 写入 biz_type**
|
||||
|
||||
在 `create_outbound_qc_work_order()` 函数中,创建工单时设置 `biz_type = 'pilot_service'`(当前场景均为中试服务)。
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/crud/qc_work_order.py backend/app/api/qc.py
|
||||
git commit -m "feat(qc): extend outbound work order list API with application/infusion fields and bizType filter"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 3: 后端 — 新增出库质检查看聚合 API
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/api/qc.py` (新增路由)
|
||||
- Modify: `backend/app/crud/qc_work_order.py` (新增查询函数)
|
||||
- Modify: `backend/app/schemas/qc_work_order.py` (新增返回 Schema)
|
||||
|
||||
**参考文件(只读):**
|
||||
- `backend/app/crud/qc_work_order.py` — 搜索 `get_work_order_detail` 了解现有详情查询模式
|
||||
- `backend/app/crud/pilot_application.py` — 搜索申请单/方案/计划的查询模式
|
||||
- `backend/app/models/models.py` — 搜索 `BizPilotPatient`、`BizPilotInfusionScheduleProduct` 模型
|
||||
|
||||
- [ ] **Step 1: 在 `schemas/qc_work_order.py` 中新增出库详情返回 Schema**
|
||||
|
||||
```python
|
||||
class OutboundQcDetailApplication(BaseModel):
|
||||
"""出库质检查看 - 申请单信息"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
application_no: Optional[str] = Field(None, alias="applicationNo")
|
||||
application_name: Optional[str] = Field(None, alias="applicationName")
|
||||
application_status: Optional[str] = Field(None, alias="applicationStatus")
|
||||
channel_name: Optional[str] = Field(None, alias="channelName")
|
||||
|
||||
|
||||
class OutboundQcDetailPatient(BaseModel):
|
||||
"""出库质检查看 - 患者信息"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
patient_name: Optional[str] = Field(None, alias="patientName")
|
||||
sex: Optional[str] = Field(None)
|
||||
age: Optional[str] = Field(None)
|
||||
phone_no: Optional[str] = Field(None, alias="phoneNo")
|
||||
id_card_no: Optional[str] = Field(None, alias="idCardNo")
|
||||
emergency_contact: Optional[str] = Field(None, alias="emergencyContact")
|
||||
emergency_phone: Optional[str] = Field(None, alias="emergencyPhone")
|
||||
clinical_diagnosis: Optional[str] = Field(None, alias="clinicalDiagnosis")
|
||||
diagnosis_attachments: Optional[str] = Field(None, alias="diagnosisAttachments")
|
||||
|
||||
|
||||
class OutboundQcDetailInfusionPlan(BaseModel):
|
||||
"""出库质检查看 - 输注方案信息"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
cell_type: Optional[str] = Field(None, alias="cellType")
|
||||
spec_text: Optional[str] = Field(None, alias="specText")
|
||||
total_course_count: Optional[int] = Field(None, alias="totalCourseCount")
|
||||
course_interval: Optional[str] = Field(None, alias="courseInterval")
|
||||
infusion_route: Optional[str] = Field(None, alias="infusionRoute")
|
||||
infusion_start_date: Optional[str] = Field(None, alias="infusionStartDate")
|
||||
|
||||
|
||||
class OutboundQcDetailInfusionSchedule(BaseModel):
|
||||
"""出库质检查看 - 输注计划信息"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
infusion_time: Optional[str] = Field(None, alias="infusionTime")
|
||||
infusion_location: Optional[str] = Field(None, alias="infusionLocation")
|
||||
infusion_method: Optional[str] = Field(None, alias="infusionMethod")
|
||||
schedule_status: Optional[str] = Field(None, alias="scheduleStatus")
|
||||
infusion_status: Optional[str] = Field(None, alias="infusionStatus")
|
||||
qc_status: Optional[str] = Field(None, alias="qcStatus")
|
||||
cancel_reason: Optional[str] = Field(None, alias="cancelReason")
|
||||
|
||||
|
||||
class OutboundQcDetailProduct(BaseModel):
|
||||
"""出库质检查看 - 产品明细"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
project_code: Optional[str] = Field(None, alias="projectCode")
|
||||
project_name: Optional[str] = Field(None, alias="projectName")
|
||||
cell_type_name: Optional[str] = Field(None, alias="cellTypeName")
|
||||
spec_text: Optional[str] = Field(None, alias="specText")
|
||||
agreement_price: Optional[float] = Field(None, alias="agreementPrice")
|
||||
actual_price: Optional[float] = Field(None, alias="actualPrice")
|
||||
quantity: Optional[int] = Field(None)
|
||||
product_status: Optional[str] = Field(None, alias="productStatus")
|
||||
|
||||
|
||||
class OutboundQcDetailResponse(BaseModel):
|
||||
"""出库质检聚合详情"""
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
work_order: Optional[dict] = Field(None, alias="workOrder")
|
||||
application: Optional[OutboundQcDetailApplication] = Field(None, alias="application")
|
||||
patient: Optional[OutboundQcDetailPatient] = Field(None, alias="patient")
|
||||
infusion_plan: Optional[OutboundQcDetailInfusionPlan] = Field(None, alias="infusionPlan")
|
||||
infusion_schedule: Optional[OutboundQcDetailInfusionSchedule] = Field(None, alias="infusionSchedule")
|
||||
products: Optional[list[OutboundQcDetailProduct]] = Field(None, alias="products")
|
||||
tasks: Optional[list[dict]] = Field(None, alias="tasks")
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 在 `crud/qc_work_order.py` 中新增 `get_outbound_qc_detail()` 函数**
|
||||
|
||||
```python
|
||||
def get_outbound_qc_detail(db: Session, work_order_id: str, tenant_no: str) -> dict:
|
||||
"""获取出库质检工单聚合详情(含申请单、患者、方案、计划、产品、任务)"""
|
||||
# 1. 获取工单基本信息(复用现有 get_work_order_detail 或直接查询)
|
||||
# 2. 通过 infusion_schedule_id JOIN 链路获取:
|
||||
# - biz_pilot_infusion_schedule
|
||||
# - biz_pilot_infusion_plan → biz_pilot_application → biz_pilot_patient
|
||||
# - biz_pilot_infusion_schedule_product
|
||||
# 3. 获取关联的质检任务(复用现有任务查询逻辑)
|
||||
# 4. 组装返回 dict
|
||||
```
|
||||
|
||||
实现时参考现有 `get_work_order_detail()` 的模式,通过 SQLAlchemy session 查询并组装字典返回。
|
||||
|
||||
- [ ] **Step 3: 在 `api/qc.py` 中新增路由**
|
||||
|
||||
```python
|
||||
@router.get("/qc-work-orders/{work_order_id}/outbound-detail")
|
||||
def api_get_outbound_qc_detail(work_order_id: str, db: Session = Depends(get_db), current_user=Depends(require_auth)):
|
||||
"""获取出库质检工单聚合详情"""
|
||||
tenant_no = current_user["tenant_no"]
|
||||
result = get_outbound_qc_detail(db, work_order_id, tenant_no)
|
||||
return success(result)
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 验证 API 可用**
|
||||
|
||||
启动后端服务,访问 `/docs` 确认新端点出现在 Swagger 文档中。
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/schemas/qc_work_order.py backend/app/crud/qc_work_order.py backend/app/api/qc.py
|
||||
git commit -m "feat(qc): add outbound QC work order aggregated detail API endpoint"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 4: 后端 — 输注计划取消时自动作废关联质检工单
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/crud/pilot_infusion_schedule_mgmt.py`
|
||||
|
||||
**参考文件(只读):**
|
||||
- `backend/app/crud/pilot_infusion_schedule_mgmt.py` — 搜索状态更新逻辑、`update_status`、取消相关代码
|
||||
- `backend/app/models/models.py` — 搜索 `BizQcWorkOrder` 模型
|
||||
|
||||
- [ ] **Step 1: 找到输注计划取消/删除的状态更新入口**
|
||||
|
||||
在 `pilot_infusion_schedule_mgmt.py` 中搜索输注计划状态变更为 `yqx` 的逻辑入口(通常在 `update_status` 或 `cancel_schedule` 函数中)。
|
||||
|
||||
- [ ] **Step 2: 在取消逻辑中新增自动作废关联质检工单的代码**
|
||||
|
||||
在状态变更为 `yqx` 的逻辑之后,新增:
|
||||
|
||||
```python
|
||||
from app.models.models import BizQcWorkOrder
|
||||
|
||||
# 当输注计划被取消时,自动作废关联的未完成出库质检工单
|
||||
pending_qc_orders = db.query(BizQcWorkOrder).filter(
|
||||
BizQcWorkOrder.infusion_schedule_id == schedule_id,
|
||||
BizQcWorkOrder.work_order_status.notin_(['ywc', 'yzf']),
|
||||
BizQcWorkOrder.del_flag == 0
|
||||
).all()
|
||||
for order in pending_qc_orders:
|
||||
order.work_order_status = 'yzf'
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add backend/app/crud/pilot_infusion_schedule_mgmt.py
|
||||
git commit -m "feat(infusion): auto-void outbound QC work orders when infusion schedule is cancelled"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 5: 前端 — 新增 API 函数和类型
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/api/qc-work-order.ts` (新增类型和 API 函数)
|
||||
|
||||
- [ ] **Step 1: 在 `QcWorkOrder` 类型中新增 outbound 相关字段**
|
||||
|
||||
在 `QcWorkOrder` 类型定义中新增:
|
||||
|
||||
```typescript
|
||||
bizType?: string
|
||||
bizTypeLabel?: string
|
||||
applicationNo?: string
|
||||
applicationName?: string
|
||||
channelName?: string
|
||||
infusionTime?: string
|
||||
```
|
||||
|
||||
同时,`fetchQcWorkOrderList` 的参数类型新增 `bizType?: string`:
|
||||
|
||||
```typescript
|
||||
export function fetchQcWorkOrderList(params?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
keyword?: string
|
||||
workOrderStatus?: string
|
||||
workOrderType?: string
|
||||
bizType?: string
|
||||
createTimeStart?: string
|
||||
createTimeEnd?: string
|
||||
}) {
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 新增出库质检查看聚合 API 类型定义和调用函数**
|
||||
|
||||
```typescript
|
||||
export type OutboundQcDetailApplication = {
|
||||
applicationNo?: string
|
||||
applicationName?: string
|
||||
applicationStatus?: string
|
||||
channelName?: string
|
||||
}
|
||||
|
||||
export type OutboundQcDetailPatient = {
|
||||
patientName?: string
|
||||
sex?: string
|
||||
age?: string
|
||||
phoneNo?: string
|
||||
idCardNo?: string
|
||||
emergencyContact?: string
|
||||
emergencyPhone?: string
|
||||
clinicalDiagnosis?: string
|
||||
diagnosisAttachments?: string
|
||||
}
|
||||
|
||||
export type OutboundQcDetailInfusionPlan = {
|
||||
cellType?: string
|
||||
specText?: string
|
||||
totalCourseCount?: number
|
||||
courseInterval?: string
|
||||
infusionRoute?: string
|
||||
infusionStartDate?: string
|
||||
}
|
||||
|
||||
export type OutboundQcDetailInfusionSchedule = {
|
||||
infusionTime?: string
|
||||
infusionLocation?: string
|
||||
infusionMethod?: string
|
||||
scheduleStatus?: string
|
||||
infusionStatus?: string
|
||||
qcStatus?: string
|
||||
cancelReason?: string
|
||||
}
|
||||
|
||||
export type OutboundQcDetailProduct = {
|
||||
projectCode?: string
|
||||
projectName?: string
|
||||
cellTypeName?: string
|
||||
specText?: string
|
||||
agreementPrice?: number
|
||||
actualPrice?: number
|
||||
quantity?: number
|
||||
productStatus?: string
|
||||
}
|
||||
|
||||
export type OutboundQcDetail = {
|
||||
workOrder: QcWorkOrderDetail
|
||||
application?: OutboundQcDetailApplication
|
||||
patient?: OutboundQcDetailPatient
|
||||
infusionPlan?: OutboundQcDetailInfusionPlan
|
||||
infusionSchedule?: OutboundQcDetailInfusionSchedule
|
||||
products?: OutboundQcDetailProduct[]
|
||||
tasks?: QcWorkOrderDetail['tasks']
|
||||
}
|
||||
|
||||
export function fetchOutboundQcDetail(id: string) {
|
||||
return request.get<OutboundQcDetail>({
|
||||
url: `/web/admin/qc-work-orders/${id}/outbound-detail`
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/api/qc-work-order.ts
|
||||
git commit -m "feat(qc): add outbound QC detail API types and fetch function"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 6: 前端 — 新增出库质检 Tab 和列表
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/quality-inspection/qc-work-order/index.vue`
|
||||
|
||||
- [ ] **Step 1: 扩展 Tab 类型定义和 el-tabs**
|
||||
|
||||
在 `<script setup>` 中修改 `WorkOrderTypeTab` 类型:
|
||||
|
||||
```typescript
|
||||
type WorkOrderTypeTab = 'inbound' | 'temporary' | 'outbound' | 'all'
|
||||
```
|
||||
|
||||
在模板的 `<el-tabs>` 中,在"临时质检工单"和"全部质检工单"之间新增:
|
||||
|
||||
```html
|
||||
<el-tab-pane label="出库质检工单" name="outbound" />
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 新增出库列的 computed 控制**
|
||||
|
||||
在 `<script setup>` 中新增:
|
||||
|
||||
```typescript
|
||||
const showOutboundCols = computed(() => activeTypeTab.value === 'outbound')
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 修改筛选区域 — 出库 Tab 显示业务类型筛选**
|
||||
|
||||
在筛选区域的 `<div class="filter-grid">` 中,关键词输入框的 placeholder 需要根据 Tab 调整:
|
||||
|
||||
```html
|
||||
<el-input
|
||||
v-model="searchForm.keyword"
|
||||
:placeholder="
|
||||
activeTypeTab === 'temporary'
|
||||
? '工单号'
|
||||
: activeTypeTab === 'outbound'
|
||||
? '工单号/申请单号/申请单名称'
|
||||
: '工单号/协议号/样本编码'
|
||||
"
|
||||
clearable
|
||||
/>
|
||||
```
|
||||
|
||||
在工单状态 `el-select` 之后,新增业务类型筛选(仅 outbound Tab 显示):
|
||||
|
||||
```html
|
||||
<el-form-item v-if="activeTypeTab === 'outbound'" label="业务类型">
|
||||
<el-select
|
||||
v-model="searchForm.bizType"
|
||||
placeholder="全部"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="中试服务" value="pilot_service" />
|
||||
<el-option label="临床应用" value="clinical_application" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
```
|
||||
|
||||
同时在 `searchForm` reactive 中新增 `bizType: ''`。
|
||||
|
||||
- [ ] **Step 4: 修改工具栏 — 出库 Tab 不显示新增按钮**
|
||||
|
||||
在 `<div v-if="activeTypeTab !== 'all'" class="list-toolbar">` 中,新增 outbound 的排除:
|
||||
|
||||
```html
|
||||
<div v-if="activeTypeTab !== 'all' && activeTypeTab !== 'outbound'" class="list-toolbar">
|
||||
```
|
||||
|
||||
- [ ] **Step 5: 新增出库质检专属表格列**
|
||||
|
||||
在表格中,在"工单号"列之后、"业务类型"列之前(或复用业务类型列位置),新增出库专属列。在 `<el-table-column prop="workOrderNo"...>` 后面添加:
|
||||
|
||||
```html
|
||||
<!-- 出库质检专属列 -->
|
||||
<el-table-column
|
||||
v-if="showOutboundCols"
|
||||
prop="bizTypeLabel"
|
||||
label="业务类型"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
:type="row.bizType === 'pilot_service' ? 'primary' : 'warning'"
|
||||
size="small"
|
||||
>
|
||||
{{ row.bizTypeLabel || (row.bizType === 'pilot_service' ? '中试服务' : '临床应用') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="showOutboundCols"
|
||||
prop="applicationNo"
|
||||
label="申请单号"
|
||||
min-width="160"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="showOutboundCols"
|
||||
prop="applicationName"
|
||||
label="申请单名称"
|
||||
min-width="200"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="showOutboundCols"
|
||||
prop="channelName"
|
||||
label="渠道名称"
|
||||
min-width="140"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
v-if="showOutboundCols"
|
||||
prop="infusionTime"
|
||||
label="输注时间"
|
||||
min-width="160"
|
||||
align="center"
|
||||
/>
|
||||
```
|
||||
|
||||
- [ ] **Step 6: 修改状态列支持 yzf(已作废)**
|
||||
|
||||
在状态列的 `el-tag` 中,`tagType` 计算需新增 yzf 分支:
|
||||
|
||||
```html
|
||||
<el-tag
|
||||
:type="
|
||||
row.workOrderStatus === 'ywc'
|
||||
? 'success'
|
||||
: row.workOrderStatus === 'ypz'
|
||||
? 'warning'
|
||||
: row.workOrderStatus === 'yzf'
|
||||
? 'danger'
|
||||
: 'info'
|
||||
"
|
||||
size="small"
|
||||
>
|
||||
```
|
||||
|
||||
在 `workOrderStatusLabel` 映射函数中确认已支持 `yzf` → `已作废`(需检查 `utils/qc-labels.ts` 或 `utils/status-tag-registry.ts`,如缺失则新增)。
|
||||
|
||||
- [ ] **Step 7: 修改操作列 — 出库 Tab 按钮逻辑**
|
||||
|
||||
在操作列的 `<template #default="{ row }">` 中:
|
||||
|
||||
**查看按钮** — 所有 Tab 都显示(保持不变)
|
||||
|
||||
**编辑按钮** — 出库 Tab 显示"编辑备注"按钮(与入库的编辑备注行为一致):
|
||||
|
||||
```html
|
||||
<!-- 出库质检编辑备注 -->
|
||||
<el-button
|
||||
v-if="activeTypeTab === 'outbound' && row.workOrderStatus !== 'ywc' && row.workOrderStatus !== 'yzf'"
|
||||
class="btn-op-item"
|
||||
@click="handleEditRemark(row)"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>编辑
|
||||
</el-button>
|
||||
```
|
||||
|
||||
**配置检测按钮** — 保持现有逻辑(`dpz`/`ypz` 时显示),对 outbound 同样适用
|
||||
|
||||
**删除按钮** — outbound Tab 不显示。将删除按钮的条件修改为:
|
||||
|
||||
```html
|
||||
<el-button
|
||||
v-if="activeTypeTab !== 'outbound' && activeTypeTab !== 'all' && row.workOrderStatus !== 'ywc'"
|
||||
class="btn-op-item"
|
||||
@click="handleDelete(row)"
|
||||
>删除</el-button>
|
||||
```
|
||||
|
||||
- [ ] **Step 8: 修改 `loadData()` 传递 bizType 参数**
|
||||
|
||||
在 `loadData()` 函数中,调用 `fetchQcWorkOrderList` 时新增 `bizType` 参数:
|
||||
|
||||
```typescript
|
||||
const res = await fetchQcWorkOrderList({
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
keyword: searchForm.keyword || undefined,
|
||||
workOrderStatus: searchForm.workOrderStatus || undefined,
|
||||
workOrderType: activeTypeTab.value === 'all' ? undefined : activeTypeTab.value,
|
||||
bizType: searchForm.bizType || undefined,
|
||||
createTimeStart: createTimeRange.value?.[0] || undefined,
|
||||
createTimeEnd: createTimeRange.value?.[1] || undefined
|
||||
})
|
||||
```
|
||||
|
||||
- [ ] **Step 9: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/views/quality-inspection/qc-work-order/index.vue
|
||||
git commit -m "feat(qc): add outbound QC work order tab with list, filters and action buttons"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 7: 前端 — 新建 OutboundQcViewDialog.vue 查看对话框
|
||||
|
||||
**Files:**
|
||||
- Create: `web-admin/src/views/quality-inspection/qc-work-order/OutboundQcViewDialog.vue`
|
||||
- Modify: `web-admin/src/views/quality-inspection/qc-work-order/index.vue` (引入并使用新组件)
|
||||
|
||||
**参考文件(只读,必须先读取理解模式):**
|
||||
- `web-admin/src/components/business/system-view-dialog/index.vue` — `SystemViewDialog` 组件接口
|
||||
- `web-admin/src/views/quality-inspection/qc-work-order/index.vue:425-460` — 现有查看对话框的使用方式
|
||||
- `web-admin/src/views/quality-inspection/qc-work-order/index.vue:964-1020` — `buildTaskTypeSections()` 函数
|
||||
- `web-admin/src/components/business/protocol-attachment/ProtocolAttachmentReadonly.vue` — 附件预览组件
|
||||
- `web-admin/src/utils/status-tag-registry.ts` — 状态标签映射函数
|
||||
|
||||
- [ ] **Step 1: 创建 `OutboundQcViewDialog.vue` 基础骨架**
|
||||
|
||||
```vue
|
||||
<!-- 出库质检工单查看对话框 -->
|
||||
<template>
|
||||
<SystemViewDialog
|
||||
v-model:visible="dialogVisible"
|
||||
title="出库质检工单详情"
|
||||
width="1200px"
|
||||
:grid-columns="4"
|
||||
compact
|
||||
:loading="loading"
|
||||
:icon="Document"
|
||||
:meta="detail?.workOrder?.workOrderNo || ''"
|
||||
:sections="sections"
|
||||
>
|
||||
<!-- 诊断附件 slot -->
|
||||
<template #diagnosis-attachments>
|
||||
<ProtocolAttachmentReadonly
|
||||
:files="diagnosisAttachmentFiles"
|
||||
@preview="handlePreview"
|
||||
@download="handleDownload"
|
||||
/>
|
||||
</template>
|
||||
<!-- 任务附件 slots -->
|
||||
<template v-for="task in tasksWithAttachments" #[taskAttachmentSlotName(task.id)]>
|
||||
<div :key="task.id" class="outbound-qc-task-attachments">
|
||||
<ProtocolAttachmentReadonly
|
||||
:files="task.attachmentFiles || []"
|
||||
@preview="handleTaskPreview"
|
||||
@download="handleTaskDownload"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</SystemViewDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { Document } from '@element-plus/icons-vue'
|
||||
import { fetchOutboundQcDetail, type OutboundQcDetail } from '@/api/qc-work-order'
|
||||
import { fetchQcTaskResults, type QcTaskResultItem } from '@/api/qc-task-result'
|
||||
import {
|
||||
workOrderStatusLabel,
|
||||
taskStatusLabel,
|
||||
qcTaskConclusionLabel
|
||||
} from '@/utils/qc-labels'
|
||||
import {
|
||||
scheduleStatusLabel,
|
||||
scheduleStatusTagType,
|
||||
infusionStatusLabel,
|
||||
infusionStatusTagType,
|
||||
qcStatusLabel,
|
||||
qcStatusTagType,
|
||||
applicationStatusLabel,
|
||||
applicationStatusTagType,
|
||||
bizTypeLabel,
|
||||
bizTypeTagType
|
||||
} from '@/utils/status-tag-registry'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import type { ViewField, ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import ProtocolAttachmentReadonly from '@/views/cell-storage/protocol/ProtocolAttachmentReadonly.vue'
|
||||
import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
workOrderId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', v: boolean): void
|
||||
}>()
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (v) => emit('update:visible', v)
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const detail = ref<OutboundQcDetail | null>(null)
|
||||
type TaskWithResults = { id: string; taskNo: string; taskType: string; itemCode?: string; itemName?: string; taskStatus: string; conclusion?: string; conclusionLabel?: string; remark?: string; completedTime?: string; attachmentFiles?: Array<{ id?: string; fileUrl?: string; fileName?: string }>; results?: QcTaskResultItem[]; companyName?: string; feeAmount?: number }
|
||||
const tasksWithResults = ref<TaskWithResults[]>([])
|
||||
|
||||
// ... 后续步骤中补充 sections 计算逻辑和附件处理
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 实现 sections computed 属性**
|
||||
|
||||
在 `<script setup>` 中实现完整的 `sections` computed,包含 7 个 Section 组:
|
||||
|
||||
1. **工单基本信息** — 工单号、工单类型(出库)、业务类型(el-tag)、状态(el-tag)、检测方式、配置时间、配置人、备注、创建时间
|
||||
2. **中试服务申请单信息** — 申请单号、名称、状态(el-tag)、渠道名称
|
||||
3. **患者信息** — 姓名、性别、年龄、电话、证件号、紧急联系人、紧急电话、临床诊断(span)、诊断附件(slot)
|
||||
4. **输注方案信息** — 细胞类型、规格、总疗程数、疗程间隔、输注途径、输注开始日期
|
||||
5. **本次输注计划信息** — 输注时间、地点、方式、生产状态(el-tag)、输注状态(el-tag)、质检状态(el-tag)、取消原因(仅已取消)
|
||||
6. **产品明细** — 内嵌表格展示 `products` 数组(项目编码、名称、细胞类型、规格、协议单价、实际单价、份数、产品状态)
|
||||
7. **检测结果** — 动态 Section,复用 `buildTaskTypeSections` 的逻辑生成实验室和第三方项目的详情
|
||||
|
||||
> 注意:状态标签映射函数需确认 `status-tag-registry.ts` 中是否存在。如 `scheduleStatusLabel`、`infusionStatusLabel`、`qcStatusLabel`、`applicationStatusLabel`、`bizTypeLabel` 等不存在,需在该文件中新增。
|
||||
|
||||
- [ ] **Step 3: 实现 handleView 数据加载**
|
||||
|
||||
```typescript
|
||||
watch(() => props.visible, async (v) => {
|
||||
if (!v || !props.workOrderId) return
|
||||
loading.value = true
|
||||
tasksWithResults.value = []
|
||||
try {
|
||||
const d = await fetchOutboundQcDetail(props.workOrderId)
|
||||
detail.value = d
|
||||
// 加载任务结果
|
||||
const rawTasks = (d.workOrder?.tasks || []) as TaskWithResults[]
|
||||
const enriched = await Promise.all(
|
||||
rawTasks.map(async (task) => {
|
||||
if (task.taskType !== 'sysz' || task.taskStatus !== 'ywc') {
|
||||
return { ...task, results: [] as QcTaskResultItem[] }
|
||||
}
|
||||
try {
|
||||
const results = await fetchQcTaskResults(task.id)
|
||||
return { ...task, results: results || [] }
|
||||
} catch {
|
||||
return { ...task, results: [] as QcTaskResultItem[] }
|
||||
}
|
||||
})
|
||||
)
|
||||
tasksWithResults.value = enriched
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 补充附件处理逻辑**
|
||||
|
||||
实现 `diagnosisAttachmentFiles` computed(解析 `patient.diagnosisAttachments` 为文件数组)、`handlePreview`、`handleDownload`、`handleTaskPreview`、`handleTaskDownload`、`taskAttachmentSlotName` 等函数。参照现有 `index.vue` 中同名函数的模式。
|
||||
|
||||
- [ ] **Step 5: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/views/quality-inspection/qc-work-order/OutboundQcViewDialog.vue
|
||||
git commit -m "feat(qc): create OutboundQcViewDialog component with full detail sections"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 8: 前端 — 在 index.vue 中集成 OutboundQcViewDialog
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/views/quality-inspection/qc-work-order/index.vue`
|
||||
|
||||
- [ ] **Step 1: 导入 OutboundQcViewDialog 组件**
|
||||
|
||||
在 `<script setup>` 的 import 区域添加:
|
||||
|
||||
```typescript
|
||||
import OutboundQcViewDialog from './OutboundQcViewDialog.vue'
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 新增出库查看对话框的状态变量**
|
||||
|
||||
```typescript
|
||||
const outboundViewVisible = ref(false)
|
||||
const outboundViewId = ref('')
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 新增出库查看处理函数**
|
||||
|
||||
```typescript
|
||||
function handleOutboundView(row: QcWorkOrder) {
|
||||
outboundViewId.value = row.id
|
||||
outboundViewVisible.value = true
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 修改 handleView 函数区分出库类型**
|
||||
|
||||
修改现有的 `handleView` 函数,当 `activeTypeTab === 'outbound'` 时调用 `handleOutboundView`:
|
||||
|
||||
```typescript
|
||||
async function handleView(row: QcWorkOrder) {
|
||||
if (activeTypeTab.value === 'outbound') {
|
||||
handleOutboundView(row)
|
||||
return
|
||||
}
|
||||
// ... 原有逻辑不变
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 5: 在模板中放置 OutboundQcViewDialog**
|
||||
|
||||
在 `</section>` 结束标签之前(与 `WorkOrderRemarkDialog` 同级)添加:
|
||||
|
||||
```html
|
||||
<OutboundQcViewDialog
|
||||
v-model:visible="outboundViewVisible"
|
||||
:work-order-id="outboundViewId"
|
||||
/>
|
||||
```
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/views/quality-inspection/qc-work-order/index.vue
|
||||
git commit -m "feat(qc): integrate OutboundQcViewDialog into QC work order page"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 9: 前端 — 补充状态标签映射
|
||||
|
||||
**Files:**
|
||||
- Modify: `web-admin/src/utils/status-tag-registry.ts` (如需新增标签函数)
|
||||
|
||||
- [ ] **Step 1: 检查 status-tag-registry.ts 中是否已有以下映射函数**
|
||||
|
||||
需要确认的函数:
|
||||
- `scheduleStatusLabel` / `scheduleStatusTagType` — 输注计划生产状态 (dsc/ysc/yjf/yqx)
|
||||
- `infusionStatusLabel` / `infusionStatusTagType` — 输注状态 (dtz/yrqr/yqx/ywc)
|
||||
- `qcStatusLabel` / `qcStatusTagType` — 质检状态 (dzc/yzj/yqx)
|
||||
- `applicationStatusLabel` / `applicationStatusTagType` — 申请单状态 (dks/jxz/ywc/yzf)
|
||||
- `bizTypeLabel` / `bizTypeTagType` — 业务类型 (pilot_service/clinical_application)
|
||||
- `productStatusLabel` / `productStatusTagType` — 产品状态 (dtz/yrqr/yqx/ywc)
|
||||
|
||||
如果已存在,跳过此 Task。如果不存在,新增对应的映射函数。
|
||||
|
||||
- [ ] **Step 2: 新增缺失的标签映射函数**
|
||||
|
||||
遵循文件中已有的映射函数模式(label 函数返回中文名,tagType 函数返回 `TagType`),为每个缺失的状态类型新增。
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add web-admin/src/utils/status-tag-registry.ts
|
||||
git commit -m "feat(qc): add missing status label/tag mappings for outbound QC view dialog"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Task 10: 验证与修复
|
||||
|
||||
- [ ] **Step 1: 运行前端 lint 检查**
|
||||
|
||||
```bash
|
||||
cd web-admin && pnpm lint
|
||||
```
|
||||
|
||||
修复所有 lint 错误。
|
||||
|
||||
- [ ] **Step 2: 运行前端 Prettier 格式化**
|
||||
|
||||
```bash
|
||||
cd web-admin && pnpm lint:prettier
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 运行前端类型检查**
|
||||
|
||||
```bash
|
||||
cd web-admin && pnpm build:typecheck
|
||||
```
|
||||
|
||||
确保无类型错误。
|
||||
|
||||
- [ ] **Step 4: 前端构建验证**
|
||||
|
||||
```bash
|
||||
cd web-admin && pnpm build
|
||||
```
|
||||
|
||||
确保构建成功。
|
||||
|
||||
- [ ] **Step 5: 后端 LSP 诊断**
|
||||
|
||||
对修改过的后端文件运行 `lsp_diagnostics` 确认无错误。
|
||||
|
||||
- [ ] **Step 6: 端到端手动验证**
|
||||
|
||||
1. 访问质检工单页面,确认 4 个 Tab 正常切换
|
||||
2. 在出库质检 Tab 确认列表加载、筛选、分页正常
|
||||
3. 确认查看对话框显示完整的申请单+输注计划+患者+产品信息
|
||||
4. 确认编辑备注功能正常
|
||||
5. 确认配置检测功能正常
|
||||
6. 确认删除按钮不显示、新增按钮不显示
|
||||
7. 在输注计划页面取消一个计划,返回出库质检 Tab 确认关联工单状态变为"已作废"
|
||||
@@ -0,0 +1,315 @@
|
||||
# 出库生产工单设计文档
|
||||
|
||||
> 日期: 2026-05-26
|
||||
> 状态: 待实施
|
||||
> 方案: A(在现有生产工单页面扩展 tab)
|
||||
|
||||
## 1. 背景与目标
|
||||
|
||||
### 现状
|
||||
- 生产工单界面有 3 个 tab:入库生产工单、临时生产工单、全部生产工单
|
||||
- 后端 CRUD 层已存在 `create_outbound_production_work_order()` 函数,通用列表 API 已支持 `workOrderType=outbound` 过滤
|
||||
- 出库工单目前只能通过输注计划管理页面的"生成出库工单"按钮手动触发创建
|
||||
- 中试服务申请单、体检管理、输注计划管理三个界面已调通
|
||||
|
||||
### 目标
|
||||
- 在生产工单页面新增「出库生产工单」tab
|
||||
- 输注计划创建时自动创建出库生产工单
|
||||
- 输注计划删除时关联出库工单状态变为已作废
|
||||
- 出库工单详情展示关联的中试申请单信息和输注计划信息
|
||||
- 全部生产工单 tab 隐藏操作列
|
||||
|
||||
## 2. 需求确认
|
||||
|
||||
| # | 需求项 | 确认结果 |
|
||||
|---|--------|----------|
|
||||
| 1 | 出库工单生成时机 | 输注计划创建时立即自动创建 |
|
||||
| 2 | 输注计划删除时出库工单行为 | 保留工单,状态变为已作废(yzf) |
|
||||
| 3 | 业务类型字段 | 新增 biz_type 字段区分中试服务(pilot_service)/临床应用(clinical_application) |
|
||||
| 4 | 详情弹窗 | 复用现有 SystemViewDialog,增加申请单信息和输注计划信息区块 |
|
||||
| 5 | 操作按钮 | 查看详情、编辑(仅备注)、删除、编辑任务、派发任务、完成工单 |
|
||||
| 6 | 列表列 | 工单号、业务类型、申请单号、细胞类型、规格、输注时间、备注、工单状态、创建时间 |
|
||||
| 7 | 全部 tab 操作列 | 隐藏 |
|
||||
|
||||
## 3. 数据库变更
|
||||
|
||||
### 3.1 biz_production_work_order 表新增字段
|
||||
|
||||
```sql
|
||||
ALTER TABLE biz_production_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
```
|
||||
|
||||
### 3.2 工单状态枚举扩展
|
||||
|
||||
现有:`dpz`(待配置), `jxz`(进行中), `ywc`(已完成)
|
||||
新增:`yzf`(已作废)
|
||||
|
||||
无需 ALTER TABLE,VARCHAR(16) 已足够容纳。仅需更新模型 comment:
|
||||
```sql
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_status VARCHAR(16) NOT NULL DEFAULT 'dpz' COMMENT '工单状态 dpz待配置 jxz进行中 ywc已完成 yzf已作废';
|
||||
```
|
||||
|
||||
### 3.3 模型 comment 更新
|
||||
|
||||
```sql
|
||||
ALTER TABLE biz_production_work_order
|
||||
MODIFY COLUMN work_order_type VARCHAR(20) NOT NULL DEFAULT 'inbound' COMMENT '工单类型: inbound=入库, temporary=临时, outbound=出库';
|
||||
```
|
||||
|
||||
## 4. 后端变更
|
||||
|
||||
### 4.1 模型层 — `backend/app/models/models.py`
|
||||
|
||||
`BizProductionWorkOrder` 新增:
|
||||
```python
|
||||
biz_type = Column(String(20), nullable=True, comment="业务类型: pilot_service=中试服务, clinical_application=临床应用")
|
||||
```
|
||||
|
||||
更新 `work_order_type` 和 `work_order_status` 字段 comment。
|
||||
|
||||
### 4.2 CRUD 层 — `backend/app/crud/production_work_order.py`
|
||||
|
||||
#### 4.2.1 状态映射扩展
|
||||
```python
|
||||
_WORK_ORDER_STATUS_LABELS = {
|
||||
"dpz": "待配置",
|
||||
"jxz": "进行中",
|
||||
"ywc": "已完成",
|
||||
"yzf": "已作废", # 新增
|
||||
}
|
||||
```
|
||||
|
||||
#### 4.2.2 `_wo_to_dict()` 增加字段
|
||||
返回值新增:
|
||||
```python
|
||||
"bizType": getattr(wo, "biz_type", None) or None,
|
||||
"bizTypeLabel": {"pilot_service": "中试服务", "clinical_application": "临床应用"}.get(getattr(wo, "biz_type", None), ""),
|
||||
```
|
||||
|
||||
#### 4.2.3 `create_outbound_production_work_order()` 增加 biz_type 参数
|
||||
函数签名新增 `biz_type: str = "pilot_service"` 参数,创建时写入 `biz_type` 字段。
|
||||
|
||||
#### 4.2.4 列表增强 — outbound 类型工单附加业务数据
|
||||
在 `_enrich_wo_items()` 或列表返回后,对 `workOrderType == "outbound"` 的记录:
|
||||
- 通过 `infusion_schedule_id` 关联 `BizPilotInfusionSchedule`
|
||||
- 通过 `infusion_plan_id` 关联 `BizPilotInfusionPlan`
|
||||
- 通过 `pilot_application_id` 关联 `BizPilotApplication`
|
||||
- 附加字段:`applicationNo`, `applicationName`, `cellType`, `specText`, `infusionTime`, `infusionLocation`
|
||||
|
||||
#### 4.2.5 详情增强 — outbound 类型工单详情
|
||||
在 `_wo_to_response_dict()` 中对 outbound 类型,增加返回:
|
||||
```python
|
||||
"pilotApplication": {
|
||||
"applicationNo": "...",
|
||||
"applicationName": "...",
|
||||
"applicationStatus": "...",
|
||||
},
|
||||
"infusionSchedule": {
|
||||
"cellType": "...",
|
||||
"specText": "...",
|
||||
"infusionTime": "...",
|
||||
"infusionLocation": "...",
|
||||
"infusionMethod": "...",
|
||||
"scheduleStatus": "...",
|
||||
}
|
||||
```
|
||||
|
||||
### 4.3 自动创建钩子 — `backend/app/crud/pilot_application.py`
|
||||
|
||||
在 `create_schedule()` 函数末尾(`db.commit()` 之前),增加:
|
||||
```python
|
||||
# 自动创建出库生产工单
|
||||
from app.crud import production_work_order as pwo_svc
|
||||
pwo_svc.create_outbound_production_work_order(
|
||||
db,
|
||||
schedule_id=schedule_id,
|
||||
tenant_no=tenant_no,
|
||||
user_id=user_id,
|
||||
create_dept_id=dept_id,
|
||||
biz_type="pilot_service",
|
||||
)
|
||||
```
|
||||
|
||||
注意:`create_outbound_production_work_order` 内部已有幂等检查(通过 `infusion_schedule_id` 查重),重复调用不会产生重复工单。
|
||||
|
||||
### 4.4 自动作废钩子 — `backend/app/crud/pilot_application.py`
|
||||
|
||||
在 `soft_delete_schedule()` 函数中,`row.del_flag = 1` 之前,增加:
|
||||
```python
|
||||
# 关联的出库生产工单标记为已作废
|
||||
outbound_wo = (
|
||||
db.query(BizProductionWorkOrder)
|
||||
.filter(
|
||||
BizProductionWorkOrder.infusion_schedule_id == schedule_id,
|
||||
BizProductionWorkOrder.tenant_no == tenant_no,
|
||||
BizProductionWorkOrder.del_flag == 0,
|
||||
BizProductionWorkOrder.work_order_type == "outbound",
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if outbound_wo:
|
||||
outbound_wo.work_order_status = "yzf"
|
||||
outbound_wo.update_time = datetime.now()
|
||||
```
|
||||
|
||||
需在文件头部导入 `BizProductionWorkOrder`。
|
||||
|
||||
### 4.5 Schema 层 — `backend/app/schemas/production_work_order.py`
|
||||
|
||||
`ProductionWorkOrderListQuery` 如需支持按 `biz_type` 筛选,新增可选字段。当前需求未要求筛选,暂不增加。
|
||||
|
||||
## 5. 前端变更
|
||||
|
||||
### 5.1 Tab 结构 — `web-admin/src/views/production/production-work-order/index.vue`
|
||||
|
||||
#### 类型定义扩展
|
||||
```typescript
|
||||
type WorkOrderTypeTab = 'inbound' | 'temporary' | 'outbound' | 'all'
|
||||
```
|
||||
|
||||
#### Tab 面板
|
||||
```html
|
||||
<el-tabs v-model="activeTypeTab" class="work-order-type-tabs" @tab-change="handleTypeTabChange">
|
||||
<el-tab-pane label="入库生产工单" name="inbound" />
|
||||
<el-tab-pane label="临时生产工单" name="temporary" />
|
||||
<el-tab-pane label="出库生产工单" name="outbound" />
|
||||
<el-tab-pane label="全部生产工单" name="all" />
|
||||
</el-tabs>
|
||||
```
|
||||
|
||||
### 5.2 列表列配置
|
||||
|
||||
#### 工具栏
|
||||
- outbound tab 不显示新增按钮
|
||||
- 条件:`v-if="activeTypeTab !== 'all' && activeTypeTab !== 'outbound'"`
|
||||
|
||||
#### 关键词搜索框 placeholder
|
||||
```typescript
|
||||
const searchPlaceholder = computed(() => {
|
||||
if (activeTypeTab.value === 'temporary') return '工单号'
|
||||
if (activeTypeTab.value === 'outbound') return '工单号/申请单号'
|
||||
return '工单号/协议号/样本编码'
|
||||
})
|
||||
```
|
||||
|
||||
#### 表格列
|
||||
新增出库工单专属列(仅在 outbound tab 显示):
|
||||
- 业务类型(tag):`v-if="activeTypeTab === 'outbound'"`
|
||||
- 申请单号:`v-if="activeTypeTab === 'outbound'"`
|
||||
- 细胞类型:`v-if="activeTypeTab === 'outbound'"`
|
||||
- 规格:`v-if="activeTypeTab === 'outbound'"`
|
||||
- 输注时间:`v-if="activeTypeTab === 'outbound'"`
|
||||
|
||||
#### 全部 tab 的工单类型 Tag
|
||||
更新 tag 映射:
|
||||
```typescript
|
||||
// 工单类型 tag(全部 tab 显示)
|
||||
const woTypeTag = (type: string) => {
|
||||
const map: Record<string, { label: string; type: string }> = {
|
||||
inbound: { label: '入库', type: 'success' },
|
||||
temporary: { label: '临时', type: 'warning' },
|
||||
outbound: { label: '出库', type: 'primary' },
|
||||
}
|
||||
return map[type] || { label: type, type: 'info' }
|
||||
}
|
||||
```
|
||||
|
||||
#### 全部 tab 隐藏操作列
|
||||
操作列 `<el-table-column>` 添加条件:
|
||||
```html
|
||||
<el-table-column
|
||||
v-if="activeTypeTab !== 'all'"
|
||||
label="操作"
|
||||
...
|
||||
>
|
||||
```
|
||||
|
||||
#### 工单状态 Tag
|
||||
```typescript
|
||||
const woStatusTag = (status: string) => {
|
||||
const map: Record<string, { label: string; type: string }> = {
|
||||
dpz: { label: '待配置', type: 'info' },
|
||||
jxz: { label: '进行中', type: 'warning' },
|
||||
ywc: { label: '已完成', type: 'success' },
|
||||
yzf: { label: '已作废', type: 'danger' }, // 新增
|
||||
}
|
||||
return map[status] || { label: status, type: 'info' }
|
||||
}
|
||||
```
|
||||
|
||||
#### 状态筛选下拉
|
||||
增加已作废选项:
|
||||
```html
|
||||
<el-option label="已作废" value="yzf" />
|
||||
```
|
||||
|
||||
### 5.3 详情弹窗 — viewSections computed
|
||||
|
||||
对 outbound 类型(`isOutbound = d.workOrderType === 'outbound'`):
|
||||
|
||||
**基本信息 section**:
|
||||
- 工单号、工单类型(出库 tag=primary)、业务类型(中试服务 tag=primary)、工单状态、备注、创建时间
|
||||
- 不显示:协议号、协议状态、样本编码、来源类型、样本类型
|
||||
|
||||
**中试申请信息 section**(新增,仅 outbound):
|
||||
```typescript
|
||||
{
|
||||
title: '中试申请信息',
|
||||
fields: [
|
||||
{ label: '申请单号', value: d.pilotApplication?.applicationNo || '—' },
|
||||
{ label: '申请名称', value: d.pilotApplication?.applicationName || '—' },
|
||||
{ label: '申请状态', value: applicationStatusLabel(d.pilotApplication?.applicationStatus), tagType: ... },
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**输注计划信息 section**(新增,仅 outbound):
|
||||
```typescript
|
||||
{
|
||||
title: '输注计划信息',
|
||||
fields: [
|
||||
{ label: '细胞类型', value: d.infusionSchedule?.cellType || '—' },
|
||||
{ label: '规格', value: d.infusionSchedule?.specText || '—' },
|
||||
{ label: '输注时间', value: d.infusionSchedule?.infusionTime || '—' },
|
||||
{ label: '输注地点', value: d.infusionSchedule?.infusionLocation || '—' },
|
||||
{ label: '输注方式', value: d.infusionSchedule?.infusionMethod || '—' },
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**不显示**:运输信息 section、样本接收 section(这些是入库工单特有的)
|
||||
|
||||
### 5.4 操作按钮逻辑
|
||||
|
||||
outbound tab 的操作按钮与 inbound/temporary 基本一致:
|
||||
- 查看详情:始终显示
|
||||
- 编辑:始终显示(仅改备注)
|
||||
- 编辑任务:始终显示
|
||||
- 派发任务:状态为 dpz/jxz 时显示
|
||||
- 完成工单:状态为 dpz/jxz 时显示
|
||||
- 删除:非 ywc 状态时显示(yzf 状态也可删除)
|
||||
|
||||
### 5.5 showReceptionCols 逻辑
|
||||
|
||||
```typescript
|
||||
const showReceptionCols = computed(() => activeTypeTab.value !== 'temporary' && activeTypeTab.value !== 'outbound')
|
||||
```
|
||||
|
||||
## 6. 影响文件清单
|
||||
|
||||
| 文件 | 改动类型 | 说明 |
|
||||
|------|----------|------|
|
||||
| `docs/sql/2026-05-26-outbound-work-order.sql` | 新增 | ALTER TABLE SQL 脚本 |
|
||||
| `backend/app/models/models.py` | 修改 | BizProductionWorkOrder 新增 biz_type 字段,更新 comment |
|
||||
| `backend/app/crud/production_work_order.py` | 修改 | 状态映射、biz_type 字段、出库工单创建参数、列表增强、详情增强 |
|
||||
| `backend/app/crud/pilot_application.py` | 修改 | create_schedule 自动创建钩子、soft_delete_schedule 作废钩子 |
|
||||
| `web-admin/src/views/production/production-work-order/index.vue` | 修改 | 新增 tab、列配置、操作按钮逻辑、详情弹窗、状态映射 |
|
||||
|
||||
## 7. 不涉及的改动
|
||||
|
||||
- 不新增路由或菜单项(复用现有生产工单页面)
|
||||
- 不新增 API 端点(复用现有通用列表/详情 API)
|
||||
- 不修改输注计划管理页面的"生成出库工单"按钮(保持兼容,该按钮仍可手动触发,幂等逻辑保证不重复创建)
|
||||
- 不修改生产任务相关的弹窗组件(派发、执行、完成等逻辑通用,无需改动)
|
||||
@@ -0,0 +1,321 @@
|
||||
# 出库质检工单功能设计
|
||||
|
||||
> 日期:2026-05-26
|
||||
> 状态:待实现
|
||||
> 方案:A — 在现有质检工单页面内新增出库 Tab
|
||||
|
||||
## 1. 需求概述
|
||||
|
||||
在现有质检工单页面 (`quality-inspection/qc-work-order`) 中新增"出库质检工单"Tab,展示由中试服务申请单/输注计划触发的出库质检工单。支持查看(含完整申请单+输注计划信息)、编辑备注、配置检测。不支持新建和删除。输注计划取消/删除时,关联的出库质检工单自动作废。
|
||||
|
||||
### 1.1 关键约束
|
||||
|
||||
- 出库质检工单仅由外部触发创建(输注计划页面),出库 Tab 不提供新建入口
|
||||
- 编辑仅限备注字段
|
||||
- 不支持删除操作
|
||||
- 配置检测功能与现有入库/临时质检完全一致
|
||||
- 输注计划取消时后端自动作废关联质检工单
|
||||
- 工单类型 `biz_type`:`pilot_service`=中试服务、`clinical_application`=临床应用
|
||||
|
||||
### 1.2 已有基础设施
|
||||
|
||||
| 组件 | 状态 | 说明 |
|
||||
|------|------|------|
|
||||
| `biz_qc_work_order.work_order_type='outbound'` | 已有 | 数据库字段已支持 |
|
||||
| `biz_qc_work_order.qc_biz_type='outbound'` | 已有 | 数据库字段已支持 |
|
||||
| `biz_qc_work_order.infusion_schedule_id` | 已有 | 关联输注计划 |
|
||||
| `create_outbound_qc_work_order()` | 已有 | 后端创建逻辑已实现 |
|
||||
| `POST /web/admin/pilot-infusion-schedule/create-qc-work-order` | 已有 | API 端点已存在 |
|
||||
|
||||
### 1.3 需新增的数据库字段
|
||||
|
||||
> **重要发现**:`biz_qc_work_order` 表当前没有 `biz_type` 字段来区分"中试服务/临床应用"。`biz_production_work_order` 已有此字段(通过 `2026-05-26-outbound-work-order.sql` 新增),但质检工单表没有。
|
||||
|
||||
需新增 SQL:
|
||||
```sql
|
||||
ALTER TABLE biz_qc_work_order
|
||||
ADD COLUMN biz_type VARCHAR(20) NULL COMMENT '业务类型: pilot_service=中试服务, clinical_application=临床应用' AFTER infusion_schedule_id;
|
||||
```
|
||||
|
||||
同时更新 `create_outbound_qc_work_order()` 函数,创建出库质检工单时写入 `biz_type='pilot_service'`(来自中试服务申请单触发的场景)。
|
||||
|
||||
## 2. 前端设计
|
||||
|
||||
### 2.1 Tab 结构
|
||||
|
||||
在 `web-admin/src/views/quality-inspection/qc-work-order/index.vue` 的 `el-tabs` 中新增第 4 个 Tab:
|
||||
|
||||
```
|
||||
┌──────────┬──────────┬──────────┬──────────┐
|
||||
│ 入库质检 │ 临时质检 │ 出库质检 │ 全部工单 │
|
||||
│ inbound │ temporary│ outbound │ all │
|
||||
└──────────┴──────────┴──────────┴──────────┘
|
||||
```
|
||||
|
||||
- `activeTypeTab` 类型扩展为 `'inbound' | 'temporary' | 'outbound' | 'all'`
|
||||
- Tab 切换时重置分页并重新加载数据
|
||||
- API 调用复用 `fetchQcWorkOrderList`,传入 `workOrderType='outbound'`
|
||||
|
||||
### 2.2 列表筛选条件
|
||||
|
||||
| 筛选项 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| 工单状态 | `el-select` | 待配置(dpz) / 已配置(ypz) / 已完成(ywc) / 已作废(yzf) |
|
||||
| 业务类型 | `el-select` | 中试服务(pilot_service) / 临床应用(clinical_application) |
|
||||
| 创建时间 | `el-date-picker` | 日期范围选择 |
|
||||
| 关键词 | `el-input` | 搜索工单号、申请单号、申请单名称 |
|
||||
|
||||
### 2.3 表格列
|
||||
|
||||
| 列名 | 字段 | 宽度 | 说明 |
|
||||
|------|------|------|------|
|
||||
| 序号 | — | — | 分页计算 |
|
||||
| 工单号 | `workOrderNo` | min-width:160 | CKZJ 前缀 |
|
||||
| 业务类型 | `bizType` | min-width:100 | `el-tag`: pilot_service=primary, clinical_application=warning |
|
||||
| 申请单号 | `applicationNo` | min-width:160 | 从关联申请单带入 |
|
||||
| 申请单名称 | `applicationName` | min-width:200 | 从关联申请单带入 |
|
||||
| 渠道名称 | `channelName` | min-width:140 | 从关联申请单带入 |
|
||||
| 输注时间 | `infusionTime` | min-width:160 | 从输注计划带入 |
|
||||
| 检测方式 | 计算字段 | min-width:140 | 格式化 "实验室 \ 第三方" |
|
||||
| 备注 | `remark` | min-width:160 | — |
|
||||
| 状态 | `workOrderStatus` | min-width:100 | `el-tag`: dpz=info, ypz=warning, ywc=success, yzf=danger |
|
||||
| 创建时间 | `createTime` | min-width:160 | — |
|
||||
| 操作 | — | min-width:260, fixed="right" | 查看/编辑/配置检测 |
|
||||
|
||||
**操作列按钮可见性**:
|
||||
|
||||
| 按钮 | 显示条件 |
|
||||
|------|---------|
|
||||
| 查看 | 所有状态 |
|
||||
| 编辑(备注) | 非已完成、非已作废 |
|
||||
| 配置检测 | 待配置、已配置 |
|
||||
| 删除 | 不显示 |
|
||||
| 新增 | 不显示 |
|
||||
|
||||
### 2.4 查看对话框 — OutboundQcViewDialog.vue
|
||||
|
||||
新建组件:`web-admin/src/views/quality-inspection/qc-work-order/OutboundQcViewDialog.vue`
|
||||
|
||||
使用 `SystemViewDialog` 组件,宽度 1200px,4列网格,compact 模式。
|
||||
|
||||
#### Section 结构
|
||||
|
||||
**Section 1: 工单基本信息**
|
||||
|
||||
| 字段 | 来源 |
|
||||
|------|------|
|
||||
| 工单号 | `workOrderNo` |
|
||||
| 工单类型 | `workOrderType` → `el-tag` |
|
||||
| 业务类型 | `bizType` → `el-tag` |
|
||||
| 工单状态 | `workOrderStatus` → `el-tag` |
|
||||
| 检测方式 | 计算字段(实验室/第三方) |
|
||||
| 配置时间 | `configuredTime` |
|
||||
| 配置人 | `configuredBy` |
|
||||
| 备注 | `remark` |
|
||||
|
||||
**Section 2: 中试服务申请单信息**
|
||||
|
||||
| 字段 | 来源 |
|
||||
|------|------|
|
||||
| 申请单号 | `application.applicationNo` |
|
||||
| 申请单名称 | `application.applicationName` |
|
||||
| 申请单状态 | `application.applicationStatus` → `el-tag` |
|
||||
| 渠道名称 | `application.channelName` |
|
||||
|
||||
**Section 3: 患者信息**
|
||||
|
||||
| 字段 | 来源 |
|
||||
|------|------|
|
||||
| 患者姓名 | `patient.patientName` |
|
||||
| 性别 | `patient.sex` |
|
||||
| 年龄 | `patient.age` |
|
||||
| 联系电话 | `patient.phoneNo` |
|
||||
| 证件号码 | `patient.idCardNo` |
|
||||
| 紧急联系人 | `patient.emergencyContact` |
|
||||
| 紧急联系电话 | `patient.emergencyPhone` |
|
||||
| 临床诊断 | `patient.clinicalDiagnosis`(跨列) |
|
||||
| 诊断附件 | `patient.diagnosisAttachments`(跨列,附件预览组件) |
|
||||
|
||||
**Section 4: 输注方案信息**
|
||||
|
||||
| 字段 | 来源 |
|
||||
|------|------|
|
||||
| 细胞类型 | `infusionPlan.cellType` |
|
||||
| 规格 | `infusionPlan.specText` |
|
||||
| 总疗程数 | `infusionPlan.totalCourseCount` |
|
||||
| 疗程间隔 | `infusionPlan.courseInterval` |
|
||||
| 输注途径 | `infusionPlan.infusionRoute` |
|
||||
| 输注开始日期 | `infusionPlan.infusionStartDate` |
|
||||
|
||||
**Section 5: 本次输注计划信息**
|
||||
|
||||
| 字段 | 来源 |
|
||||
|------|------|
|
||||
| 输注时间 | `infusionSchedule.infusionTime` |
|
||||
| 输注地点 | `infusionSchedule.infusionLocation` |
|
||||
| 输注方式 | `infusionSchedule.infusionMethod` |
|
||||
| 生产状态 | `infusionSchedule.scheduleStatus` → `el-tag` |
|
||||
| 输注状态 | `infusionSchedule.infusionStatus` → `el-tag` |
|
||||
| 质检状态 | `infusionSchedule.qcStatus` → `el-tag` |
|
||||
| 取消原因 | `infusionSchedule.cancelReason`(仅已取消时显示) |
|
||||
|
||||
**Section 6: 产品明细(表格)**
|
||||
|
||||
| 列 | 字段 |
|
||||
|----|------|
|
||||
| 项目编码 | `projectCode` |
|
||||
| 项目名称 | `projectName` |
|
||||
| 细胞类型 | `cellTypeName` |
|
||||
| 规格 | `specText` |
|
||||
| 协议单价 | `agreementPrice` |
|
||||
| 实际单价 | `actualPrice` |
|
||||
| 份数 | `quantity` |
|
||||
| 产品状态 | `productStatus` → `el-tag` |
|
||||
|
||||
**Section 7+: 检测结果(动态,每个任务一个 Section)**
|
||||
|
||||
复用现有的任务结果展示逻辑(实验室参数表 + 第三方附件),与入库质检查看对话框的检测结果 Section 一致。
|
||||
|
||||
#### 数据加载
|
||||
|
||||
1. 调用新聚合 API `GET /web/admin/qc-work-orders/{id}/outbound-detail`
|
||||
2. 一次性获取工单 + 申请单 + 患者 + 方案 + 计划 + 产品 + 任务结果的全部数据
|
||||
3. 无需前端多次请求
|
||||
|
||||
#### 状态标签映射
|
||||
|
||||
所有状态/类型字段使用 `el-tag` 渲染,复用 `status-tag-registry.ts` 中的映射函数:
|
||||
- `workOrderStatus`: dpz=info, ypz=warning, ywc=success, yzf=danger
|
||||
- `applicationStatus`: dks=info, jxz=warning, ywc=success, yzf=danger
|
||||
- `scheduleStatus`: dsc=info, ysc=primary, yjf=success, yqx=danger
|
||||
- `infusionStatus`: dtz=info, yrqr=warning, yqx=danger, ywc=success
|
||||
- `qcStatus`: dzc=info, yzj=success, yqx=danger
|
||||
- `productStatus`: dtz=info, yrqr=warning, yqx=danger, ywc=success
|
||||
|
||||
## 3. 后端设计
|
||||
|
||||
### 3.1 列表 API 扩展返回字段
|
||||
|
||||
**修改文件**:`backend/app/crud/qc_work_order.py`
|
||||
|
||||
当 `work_order_type='outbound'` 时,在列表 SQL 中 LEFT JOIN 以下链路:
|
||||
|
||||
```
|
||||
biz_qc_work_order
|
||||
→ biz_pilot_infusion_schedule (ON infusion_schedule_id)
|
||||
→ biz_pilot_infusion_plan (ON infusion_plan_id)
|
||||
→ biz_pilot_application (ON pilot_application_id)
|
||||
```
|
||||
|
||||
在 `_row_to_dict()` 中为 outbound 类型额外返回:
|
||||
|
||||
| 字段 | SQL 来源 |
|
||||
|------|---------|
|
||||
| `bizType` | `biz_qc_work_order.biz_type`(**新增字段**,pilot_service/clinical_application) |
|
||||
| `applicationNo` | `biz_pilot_application.application_no` |
|
||||
| `applicationName` | `biz_pilot_application.application_name` |
|
||||
| `channelName` | `biz_pilot_application.channel_name` |
|
||||
| `infusionTime` | `biz_pilot_infusion_schedule.infusion_time` |
|
||||
|
||||
**新增列表查询参数**:`bizType`(可选),用于前端按业务类型筛选。
|
||||
|
||||
### 3.2 新增出库质检查看聚合 API
|
||||
|
||||
**新增端点**:`GET /web/admin/qc-work-orders/{id}/outbound-detail`
|
||||
|
||||
**修改文件**:
|
||||
- `backend/app/api/qc.py` — 新增路由
|
||||
- `backend/app/crud/qc_work_order.py` — 新增 `get_outbound_qc_detail()` 函数
|
||||
|
||||
**返回数据结构**:
|
||||
|
||||
```json
|
||||
{
|
||||
"workOrder": {
|
||||
"id", "workOrderNo", "workOrderType", "workOrderStatus",
|
||||
"bizType", "hasLab", "hasThirdParty", "remark",
|
||||
"configuredTime", "configuredBy", "createTime"
|
||||
},
|
||||
"application": {
|
||||
"applicationNo", "applicationName", "applicationStatus", "channelName"
|
||||
},
|
||||
"patient": {
|
||||
"patientName", "sex", "age", "phoneNo", "idCardNo",
|
||||
"emergencyContact", "emergencyPhone",
|
||||
"clinicalDiagnosis", "diagnosisAttachments"
|
||||
},
|
||||
"infusionPlan": {
|
||||
"cellType", "specText", "totalCourseCount",
|
||||
"courseInterval", "infusionRoute", "infusionStartDate"
|
||||
},
|
||||
"infusionSchedule": {
|
||||
"infusionTime", "infusionLocation", "infusionMethod",
|
||||
"scheduleStatus", "infusionStatus", "qcStatus", "cancelReason"
|
||||
},
|
||||
"products": [
|
||||
{
|
||||
"projectCode", "projectName", "cellTypeName", "specText",
|
||||
"agreementPrice", "actualPrice", "quantity", "productStatus"
|
||||
}
|
||||
],
|
||||
"tasks": [
|
||||
{
|
||||
"taskNo", "taskType", "taskStatus", "conclusion",
|
||||
"results": [...],
|
||||
"thirdPartyAttachments": "...",
|
||||
"materialUsages": [...]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**实现**:通过工单的 `infusion_schedule_id` JOIN 链路一次性获取,tasks 复用现有的任务查询逻辑。
|
||||
|
||||
### 3.3 输注计划取消时自动作废质检工单
|
||||
|
||||
**修改文件**:`backend/app/crud/pilot_infusion_schedule_mgmt.py`
|
||||
|
||||
在输注计划取消/删除的状态更新逻辑中,新增:
|
||||
|
||||
```python
|
||||
# 当输注计划状态变更为取消时
|
||||
if new_status in ('yqx',):
|
||||
# 查找关联的未完成出库质检工单
|
||||
pending_orders = session.query(BizQcWorkOrder).filter(
|
||||
BizQcWorkOrder.infusion_schedule_id == schedule_id,
|
||||
BizQcWorkOrder.work_order_status.notin_(['ywc', 'yzf']),
|
||||
BizQcWorkOrder.del_flag == '0'
|
||||
).all()
|
||||
for order in pending_orders:
|
||||
order.work_order_status = 'yzf'
|
||||
```
|
||||
|
||||
### 3.4 不需要改动的部分
|
||||
|
||||
| 功能 | 原因 |
|
||||
|------|------|
|
||||
| 配置检测 | 完全复用 `configure_work_order()` |
|
||||
| 质检任务执行 | 复用现有任务开始/完成/填写结果流程 |
|
||||
| 工单创建 | 复用 `create_outbound_qc_work_order()` |
|
||||
| 编辑备注 | 复用现有 PUT 端点 |
|
||||
|
||||
## 4. 涉及文件清单
|
||||
|
||||
### 新增文件
|
||||
|
||||
| 文件 | 说明 |
|
||||
|------|------|
|
||||
| `web-admin/src/views/quality-inspection/qc-work-order/OutboundQcViewDialog.vue` | 出库质检查看对话框组件 |
|
||||
| `docs/sql/2026-05-26-qc-work-order-add-biz-type.sql` | 质检工单表新增 biz_type 字段 |
|
||||
|
||||
### 修改文件
|
||||
|
||||
| 文件 | 改动 |
|
||||
|------|------|
|
||||
| `web-admin/src/views/quality-inspection/qc-work-order/index.vue` | 新增 outbound Tab、列表列、筛选条件、操作按钮 |
|
||||
| `web-admin/src/api/qc-work-order.ts` | 新增 `fetchOutboundQcDetail` API 函数 |
|
||||
| `web-admin/src/utils/status-tag-registry.ts` | 确保 outbound 相关状态标签映射完整 |
|
||||
| `backend/app/api/qc.py` | 新增 `GET /qc-work-orders/{id}/outbound-detail` 路由 |
|
||||
| `backend/app/crud/qc_work_order.py` | 扩展 `_row_to_dict()` outbound 字段 + 新增聚合查询函数 + 列表查询支持 bizType 筛选 |
|
||||
| `backend/app/crud/pilot_infusion_schedule_mgmt.py` | 输注计划取消时自动作废关联质检工单 |
|
||||
| `backend/app/schemas/qc_work_order.py` | 新增出库详情返回 Schema |
|
||||
@@ -423,7 +423,7 @@ const viewSections = computed(() => [{
|
||||
| 页面 | 模式 |
|
||||
|------|------|
|
||||
| demo/unit, tenant, site, post, express, customer, cell-sample-type, consumable, reagent, process-category, output-type, qc-material, lab-test-item, third-party-company, material, clean-room, storage-facility, pilot-service/*-type/spec | P01 |
|
||||
| demo/order, protocol-audit, donation/audit, production-work-order, qc-work-order, production-task, leave, exhibition-appointment | P02 |
|
||||
| demo/order, protocol-audit, donation/audit, production-work-order, qc-work-order, production-task, leave, exhibition-appointment, infusion-schedule-management | P02 |
|
||||
| demo/category, dept, menu | P03 |
|
||||
| demo/user, user | P04 |
|
||||
| dict | P05 |
|
||||
|
||||
Reference in new issue
Block a user