Compare commits

..
Author SHA1 Message Date
zlwuandCursor a69dcc5bca fix(oa): 同意/拒绝/打回前自动发送评论草稿
审批动作前冲刷评论区未发送内容,减少先点发送再审批的一步操作。
关联 #118。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 11:55:53 +08:00
cykj 0929164bf5 fix(qc): 去掉入库质检对象两列跨度导致的空白间距 (#124)
Refs #122
2026-11-19 03:27:55 +00:00
zlwuandCursor 5ecde0c80d fix(qc): 去掉入库质检对象两列跨度导致的空白间距
样本接收场景「质检对象」值很短,colSpan:2 会在样本编码前留出空列(#122)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 11:27:25 +08:00
cykj 4024aad174 feat(qc): 质检工单卡片展示协议母血采集时间 (#123)
feat(qc): 质检工单卡片展示协议母血采集时间 (#123)

Refs #122
2026-11-19 03:20:40 +00:00
zlwuandCursor 02811197c6 feat(qc): 质检工单卡片展示协议母血采集时间
入库细胞存储/科研捐赠质检列表从协议采集信息补齐 maternalBloodCollectTime,
卡片 meta 与协议组摘要同步展示,未录入显示 —(#122)。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 11:19:15 +08:00
zlwuandCursor 7b6a0523dd fix(sql): 兼容 UC MSC 回补脚本的 collation 与确定性 ID
跨表比较统一 COLLATE,避免 unicode_ci/general_ci 混用失败;回补 ID 改 MD5 业务键并修正 task_no 序号,避免 UUID 撞主键与浮点序号。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-13 13:27:43 +08:00
cykj 99562ee584 Merge pull request 'chore(sql): 移除旧版实验室样本处理一级菜单相关迁移 (#108)' (#109) from codex/issue-108-remove-old-lab-sql-5302d8a2cc into V2.0
chore(sql): 移除旧版实验室样本处理一级菜单相关迁移 (#108)

Merged from PR #109
2026-11-13 05:21:18 +00:00
14 changed files with 421 additions and 54 deletions

No files matched your search

+33
View File
@@ -49,6 +49,7 @@ from app.models.models import (
BizPilotInfusionSchedule, BizPilotInfusionSchedule,
BizPilotInfusionScheduleProduct, BizPilotInfusionScheduleProduct,
BizPilotPatient, BizPilotPatient,
BizProtocolCollectionInfo,
BizProtocolPartyCustomer, BizProtocolPartyCustomer,
BizProtocolSample, BizProtocolSample,
BizProductionTask, BizProductionTask,
@@ -69,6 +70,7 @@ from app.models.models import (
from app.models.qc_param import BizQcTaskResult from app.models.qc_param import BizQcTaskResult
from app.models.research_donation import ( from app.models.research_donation import (
BizResearchDonation, BizResearchDonation,
BizResearchDonationCollection,
BizResearchDonationParty, BizResearchDonationParty,
BizResearchDonationSample, BizResearchDonationSample,
) )
@@ -808,12 +810,39 @@ def _enrich_work_order_list_items(
party.mother_name or "", party.mother_name or "",
party.newborn_name or "", party.newborn_name or "",
) )
cell_maternal_map: Dict[str, str] = {}
if cell_proto_ids:
for coll in (
db.query(BizProtocolCollectionInfo)
.filter(
BizProtocolCollectionInfo.collection_protocol_id.in_(cell_proto_ids),
BizProtocolCollectionInfo.del_flag == 0,
)
.all()
):
cell_maternal_map[coll.collection_protocol_id] = _fmt_dt(
coll.maternal_blood_collect_time
)
donation_maternal_map: Dict[str, str] = {}
if donation_ids:
for coll in (
db.query(BizResearchDonationCollection)
.filter(
BizResearchDonationCollection.research_donation_id.in_(donation_ids),
BizResearchDonationCollection.del_flag == 0,
)
.all()
):
donation_maternal_map[coll.research_donation_id] = _fmt_dt(
coll.maternal_blood_collect_time
)
for item in items: for item in items:
if item.get("workOrderType") == "temporary": if item.get("workOrderType") == "temporary":
item["receptionSource"] = "" item["receptionSource"] = ""
item["receptionSourceLabel"] = "" item["receptionSourceLabel"] = ""
item["motherName"] = "" item["motherName"] = ""
item["newbornName"] = "" item["newbornName"] = ""
item["maternalBloodCollectTime"] = ""
continue continue
rec = _resolve_reception(item) rec = _resolve_reception(item)
source = _effective_reception_source(item, rec) source = _effective_reception_source(item, rec)
@@ -826,6 +855,7 @@ def _enrich_work_order_list_items(
_mother, _newborn = donation_party_map.get(_did or "", ("", "")) _mother, _newborn = donation_party_map.get(_did or "", ("", ""))
item["motherName"] = _mother item["motherName"] = _mother
item["newbornName"] = _newborn item["newbornName"] = _newborn
item["maternalBloodCollectTime"] = donation_maternal_map.get(_did or "", "") or ""
else: else:
_pid = ( _pid = (
(getattr(rec, "collection_protocol_id", None) if rec else None) or "" (getattr(rec, "collection_protocol_id", None) if rec else None) or ""
@@ -833,6 +863,7 @@ def _enrich_work_order_list_items(
_mother, _newborn = cell_party_map.get(_pid or "", ("", "")) _mother, _newborn = cell_party_map.get(_pid or "", ("", ""))
item["motherName"] = _mother item["motherName"] = _mother
item["newbornName"] = _newborn item["newbornName"] = _newborn
item["maternalBloodCollectTime"] = cell_maternal_map.get(_pid or "", "") or ""
if not rec: if not rec:
item.setdefault("receptionTime", "") item.setdefault("receptionTime", "")
item.setdefault("handlerName", "") item.setdefault("handlerName", "")
@@ -1140,6 +1171,7 @@ def _wo_to_dict(
"receptionTime": "", "receptionTime": "",
"handlerName": "", "handlerName": "",
"sampleTypeName": "", "sampleTypeName": "",
"maternalBloodCollectTime": "",
"workOrderStatus": wo.work_order_status, "workOrderStatus": wo.work_order_status,
"workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get( "workOrderStatusLabel": _WORK_ORDER_STATUS_LABELS.get(
wo.work_order_status or "", wo.work_order_status or "" wo.work_order_status or "", wo.work_order_status or ""
@@ -2601,6 +2633,7 @@ def get_work_order_detail(
"receptionSourceLabel": enriched.get("receptionSourceLabel", ""), "receptionSourceLabel": enriched.get("receptionSourceLabel", ""),
"motherName": enriched.get("motherName", ""), "motherName": enriched.get("motherName", ""),
"newbornName": enriched.get("newbornName", ""), "newbornName": enriched.get("newbornName", ""),
"maternalBloodCollectTime": enriched.get("maternalBloodCollectTime", ""),
"protocolStatus": enriched.get("protocolStatus", ""), "protocolStatus": enriched.get("protocolStatus", ""),
"protocolStatusLabel": enriched.get("protocolStatusLabel", ""), "protocolStatusLabel": enriched.get("protocolStatusLabel", ""),
"cellProductCode": enriched.get("cellProductCode", ""), "cellProductCode": enriched.get("cellProductCode", ""),
@@ -0,0 +1,174 @@
"""入库质检工单列表:从协议/捐赠采集信息补齐母血采集时间。"""
import unittest
from datetime import datetime
from unittest import mock
import app.crud.qc_task # noqa: F401 先加载任务模块,避免与工单模块循环导入
from app.crud import qc_work_order as qc_wo
from app.crud.qc_work_order import _enrich_work_order_list_items
from app.models.models import (
BizCollectionProtocol,
BizProtocolCollectionInfo,
BizProtocolPartyCustomer,
BizSampleReception,
)
from app.models.research_donation import (
BizResearchDonation,
BizResearchDonationCollection,
BizResearchDonationParty,
)
def _item(**kwargs):
data = {
"id": "wo-1",
"workOrderType": "inbound",
"receptionId": "rec-1",
"sampleCode": "S001",
"collectionProtocolId": "proto-1",
"receptionSource": "cell_storage",
"protocolSampleId": "",
"maternalBloodCollectTime": "",
}
data.update(kwargs)
return data
def _query_router(mapping):
def _query(*entities):
q = mock.Mock()
q.filter.return_value = q
q.order_by.return_value = q
model = entities[0]
# db.query(Model.col, ...) → first entity is InstrumentedAttribute
cls = getattr(model, "class_", model)
key = getattr(cls, "__name__", str(cls))
rows = mapping.get(key, [])
q.all.return_value = rows
return q
return _query
class TestEnrichWorkOrderMaternalBlood(unittest.TestCase):
def test_cell_storage_fills_maternal_blood_collect_time(self):
rec = mock.Mock(
id="rec-1",
sample_code="S001",
reception_source="cell_storage",
collection_protocol_id="proto-1",
research_donation_id="",
protocol_sample_id="",
donation_sample_id="",
reception_time=datetime(2026, 11, 8, 13, 30, 41),
handler_name="质检员",
lab_storage_code="",
)
coll = mock.Mock(
collection_protocol_id="proto-1",
maternal_blood_collect_time=datetime(2026, 11, 7, 9, 15, 0),
del_flag=0,
)
db = mock.Mock()
db.query.side_effect = _query_router(
{
BizSampleReception.__name__: [rec],
BizProtocolCollectionInfo.__name__: [coll],
BizProtocolPartyCustomer.__name__: [],
BizCollectionProtocol.__name__: [],
}
)
with mock.patch.object(
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
), mock.patch.object(
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
):
items = _enrich_work_order_list_items(db, [_item()])
self.assertEqual(items[0]["maternalBloodCollectTime"], "2026-11-07 09:15:00")
def test_missing_maternal_blood_stays_empty(self):
rec = mock.Mock(
id="rec-1",
sample_code="S001",
reception_source="cell_storage",
collection_protocol_id="proto-1",
research_donation_id="",
protocol_sample_id="",
donation_sample_id="",
reception_time=datetime(2026, 11, 8, 13, 30, 41),
handler_name="质检员",
lab_storage_code="",
)
db = mock.Mock()
db.query.side_effect = _query_router(
{
BizSampleReception.__name__: [rec],
BizProtocolCollectionInfo.__name__: [],
BizProtocolPartyCustomer.__name__: [],
BizCollectionProtocol.__name__: [],
}
)
with mock.patch.object(
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
), mock.patch.object(
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
):
items = _enrich_work_order_list_items(db, [_item()])
self.assertEqual(items[0]["maternalBloodCollectTime"], "")
def test_research_donation_fills_maternal_blood_collect_time(self):
rec = mock.Mock(
id="rec-2",
sample_code="D001",
reception_source="research_donation",
collection_protocol_id="",
research_donation_id="don-1",
protocol_sample_id="",
donation_sample_id="",
reception_time=datetime(2026, 11, 8, 10, 0, 0),
handler_name="质检员",
lab_storage_code="",
)
coll = mock.Mock(
research_donation_id="don-1",
maternal_blood_collect_time=datetime(2026, 11, 6, 8, 0, 0),
del_flag=0,
)
db = mock.Mock()
db.query.side_effect = _query_router(
{
BizSampleReception.__name__: [rec],
BizResearchDonationCollection.__name__: [coll],
BizResearchDonationParty.__name__: [],
BizResearchDonation.__name__: [],
}
)
with mock.patch.object(
qc_wo, "_enrich_protocol_sibling_samples", side_effect=lambda _db, items: items
), mock.patch.object(
qc_wo, "apply_special_to_item_from_samples", side_effect=lambda item, **_k: item
):
items = _enrich_work_order_list_items(
db,
[
_item(
id="wo-2",
receptionId="rec-2",
sampleCode="D001",
collectionProtocolId="don-1",
receptionSource="research_donation",
)
],
)
self.assertEqual(items[0]["maternalBloodCollectTime"], "2026-11-06 08:00:00")
if __name__ == "__main__":
unittest.main()
@@ -1,7 +1,8 @@
-- UC 入库编码自动派发:脐带MSC原代培养(内置模版)5 步 -- UC 入库编码自动派发:脐带MSC原代培养(内置模版)5 步
-- 步骤:原代培养 → 半换液 → 二次贴壁 → 重铺 → 冻存(不含传代) -- 步骤:原代培养 → 半换液 → 二次贴壁 → 重铺 → 冻存(不含传代)
-- 内容从既有「干细胞培养(内置模版)」/ MSC培养-BUILTIN 按 process_code 拷贝 -- 内容从既有「干细胞培养(内置模版)」/ MSC培养-BUILTIN 按 process_code 拷贝
-- 幂等:已存在同名内置集合则跳过主数据创建-- 生产历史空任务工单回补(二选一,勿重复对同一工单各跑一遍): -- 幂等:已存在同名内置集合则跳过主数据创建-- 兼容:跨表比较统一 COLLATE utf8mb4_unicode_ci,避免 unicode_ci/general_ci 混用失败
-- 生产历史空任务工单回补(二选一,勿重复对同一工单各跑一遍):
-- SQL:docs/sql/migrations/2026-11-13-uc-msc-production-task-backfill.sql -- SQL:docs/sql/migrations/2026-11-13-uc-msc-production-task-backfill.sql
-- 或 Python: -- 或 Python:
-- cd backend && python -m scripts.backfill_uc_msc_production_tasks -- cd backend && python -m scripts.backfill_uc_msc_production_tasks
@@ -46,7 +47,7 @@ WHERE src.del_flag = 0
) )
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM biz_process_route x SELECT 1 FROM biz_process_route x
WHERE x.tenant_no = src.tenant_no WHERE x.tenant_no COLLATE utf8mb4_unicode_ci = src.tenant_no COLLATE utf8mb4_unicode_ci
AND x.route_code = 'MSC原代-UC-BUILTIN' AND x.route_code = 'MSC原代-UC-BUILTIN'
AND x.del_flag = 0 AND x.del_flag = 0
) )
@@ -67,7 +68,9 @@ SELECT
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content, s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
s.tenant_no, 1, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0 s.tenant_no, 1, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
FROM biz_process_route_step s FROM biz_process_route_step s
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0 JOIN biz_process_route r
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0
WHERE s.del_flag = 0 WHERE s.del_flag = 0
AND s.process_code = 'SOP-SC-003-E01-01' AND s.process_code = 'SOP-SC-003-E01-01'
AND ( AND (
@@ -97,7 +100,9 @@ SELECT
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content, s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
s.tenant_no, 2, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0 s.tenant_no, 2, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
FROM biz_process_route_step s FROM biz_process_route_step s
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0 JOIN biz_process_route r
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0
WHERE s.del_flag = 0 WHERE s.del_flag = 0
AND s.process_code = 'SOP-SC-004-E01-01' AND s.process_code = 'SOP-SC-004-E01-01'
AND ( AND (
@@ -127,7 +132,9 @@ SELECT
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content, s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
s.tenant_no, 3, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0 s.tenant_no, 3, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
FROM biz_process_route_step s FROM biz_process_route_step s
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0 JOIN biz_process_route r
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0
WHERE s.del_flag = 0 WHERE s.del_flag = 0
AND s.process_code = 'SOP-SC-006-E01-01' AND s.process_code = 'SOP-SC-006-E01-01'
AND ( AND (
@@ -157,7 +164,9 @@ SELECT
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content, s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
s.tenant_no, 4, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0 s.tenant_no, 4, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
FROM biz_process_route_step s FROM biz_process_route_step s
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0 JOIN biz_process_route r
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0
WHERE s.del_flag = 0 WHERE s.del_flag = 0
AND s.process_code = 'SOP-SC-005-E01-01' AND s.process_code = 'SOP-SC-005-E01-01'
AND ( AND (
@@ -187,7 +196,9 @@ SELECT
s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content, s.description, s.equipment_ids, s.equipment_name, s.estimated_duration, s.sop_ids, s.sop_content,
s.tenant_no, 5, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0 s.tenant_no, 5, s.remark, s.create_by, IFNULL(s.create_dept_id, ''), NOW(), s.update_by, NOW(), 0
FROM biz_process_route_step s FROM biz_process_route_step s
JOIN biz_process_route r ON r.id = s.route_id AND r.del_flag = 0 JOIN biz_process_route r
ON r.id COLLATE utf8mb4_unicode_ci = s.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0
WHERE s.del_flag = 0 WHERE s.del_flag = 0
AND s.process_code = 'SOP-SC-008-E01-01' AND s.process_code = 'SOP-SC-008-E01-01'
AND ( AND (
@@ -228,7 +239,7 @@ WHERE r.id = 'UCMSCROUTEA5CC11F194118AC54085447A'
AND r.del_flag = 0 AND r.del_flag = 0
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM biz_production_task_set x SELECT 1 FROM biz_production_task_set x
WHERE x.tenant_no = r.tenant_no WHERE x.tenant_no COLLATE utf8mb4_unicode_ci = r.tenant_no COLLATE utf8mb4_unicode_ci
AND x.set_name = '脐带MSC原代培养(内置模版)' AND x.set_name = '脐带MSC原代培养(内置模版)'
AND x.is_builtin = '1' AND x.is_builtin = '1'
AND x.del_flag = 0 AND x.del_flag = 0
@@ -261,5 +272,6 @@ WHERE s.set_name = '脐带MSC原代培养(内置模版)'
AND s.del_flag = 0 AND s.del_flag = 0
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM biz_production_task_set_item x SELECT 1 FROM biz_production_task_set_item x
WHERE x.set_id = s.id AND x.del_flag = 0 WHERE x.set_id COLLATE utf8mb4_unicode_ci = s.id COLLATE utf8mb4_unicode_ci
AND x.del_flag = 0
); );
@@ -16,6 +16,10 @@
-- 幂等:已有有效任务的工单不会进入候选;重复执行影响行数应为 0。 -- 幂等:已有有效任务的工单不会进入候选;重复执行影响行数应为 0。
-- 前置:biz_process_route.route_code='MSC原代-UC-BUILTIN'(或固定 id UCMSCROUTE…)及 5 步须已存在。 -- 前置:biz_process_route.route_code='MSC原代-UC-BUILTIN'(或固定 id UCMSCROUTE…)及 5 步须已存在。
-- MySQL 5.7 / utf8mb4。未在生产库执行;执行前请先跑下方「预览」SELECT。 -- MySQL 5.7 / utf8mb4。未在生产库执行;执行前请先跑下方「预览」SELECT。
-- 兼容:
-- 1) 跨表等值统一 COLLATE utf8mb4_general_ci,避免 unicode_ci/general_ci 混用失败
-- 2) 多行 ID 用 MD5(业务键) 生成,避免同语句多行 UUID() 撞主键
-- 3) task_no 序号用 UNSIGNED 整数拼接,避免用户变量浮点变成 RW…2.00
SET NAMES utf8mb4; SET NAMES utf8mb4;
@@ -43,7 +47,7 @@ SET @uc_route_id := (
SET @uc_step_count := ( SET @uc_step_count := (
SELECT COUNT(*) SELECT COUNT(*)
FROM biz_process_route_step s FROM biz_process_route_step s
WHERE s.route_id = @uc_route_id WHERE s.route_id COLLATE utf8mb4_unicode_ci = @uc_route_id COLLATE utf8mb4_unicode_ci
AND s.del_flag = 0 AND s.del_flag = 0
); );
@@ -70,7 +74,7 @@ CREATE TEMPORARY TABLE tmp_uc_wo_backfill (
route_id VARCHAR(64) NULL, route_id VARCHAR(64) NULL,
PRIMARY KEY (seq), PRIMARY KEY (seq),
UNIQUE KEY uk_wo (work_order_id) UNIQUE KEY uk_wo (work_order_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO tmp_uc_wo_backfill ( INSERT INTO tmp_uc_wo_backfill (
work_order_id, reception_id, lab_storage_code, tenant_no, sample_code, route_id work_order_id, reception_id, lab_storage_code, tenant_no, sample_code, route_id
@@ -84,8 +88,8 @@ SELECT
@uc_route_id @uc_route_id
FROM biz_production_work_order wo FROM biz_production_work_order wo
INNER JOIN biz_sample_reception rec INNER JOIN biz_sample_reception rec
ON rec.id = wo.reception_id ON rec.id COLLATE utf8mb4_general_ci = wo.reception_id COLLATE utf8mb4_general_ci
AND rec.tenant_no = wo.tenant_no AND rec.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
AND rec.del_flag = 0 AND rec.del_flag = 0
WHERE @uc_ready = 1 WHERE @uc_ready = 1
AND wo.del_flag = 0 AND wo.del_flag = 0
@@ -101,8 +105,8 @@ WHERE @uc_ready = 1
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 SELECT 1
FROM biz_production_task t FROM biz_production_task t
WHERE t.work_order_id = wo.id WHERE t.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
AND t.tenant_no = wo.tenant_no AND t.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
AND t.del_flag = 0 AND t.del_flag = 0
) )
ORDER BY rec.reception_time ASC, wo.create_time ASC; ORDER BY rec.reception_time ASC, wo.create_time ASC;
@@ -125,12 +129,13 @@ SET @task_day := DATE_FORMAT(NOW(), '%Y%m%d');
SET @task_no_base := ( SET @task_no_base := (
SELECT IFNULL(MAX(CAST(SUBSTRING(t.task_no, 11) AS UNSIGNED)), 0) SELECT IFNULL(MAX(CAST(SUBSTRING(t.task_no, 11) AS UNSIGNED)), 0)
FROM biz_production_task t FROM biz_production_task t
WHERE t.task_no LIKE CONCAT('RW', @task_day, '%') WHERE t.task_no REGEXP CONCAT('^RW', @task_day, '[0-9]{4}$')
); );
SET @task_no_base := CAST(IFNULL(@task_no_base, 0) AS UNSIGNED);
UPDATE tmp_uc_wo_backfill UPDATE tmp_uc_wo_backfill
SET SET
task_id = UPPER(REPLACE(UUID(), '-', '')), task_id = UPPER(MD5(CONCAT('uc-msc-backfill-task:', work_order_id))),
task_no = CONCAT('RW', @task_day, LPAD(@task_no_base + seq, 4, '0')); task_no = CONCAT('RW', @task_day, LPAD(@task_no_base + seq, 4, '0'));
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
@@ -170,14 +175,14 @@ SELECT
0 0
FROM tmp_uc_wo_backfill c FROM tmp_uc_wo_backfill c
INNER JOIN biz_process_route r INNER JOIN biz_process_route r
ON r.id = c.route_id ON r.id COLLATE utf8mb4_unicode_ci = c.route_id COLLATE utf8mb4_unicode_ci
AND r.del_flag = 0 AND r.del_flag = 0
WHERE @uc_ready = 1 WHERE @uc_ready = 1
AND c.task_id IS NOT NULL AND c.task_id IS NOT NULL
AND NOT EXISTS ( AND NOT EXISTS (
SELECT 1 FROM biz_production_task t SELECT 1 FROM biz_production_task t
WHERE t.work_order_id = c.work_order_id WHERE t.work_order_id COLLATE utf8mb4_general_ci = c.work_order_id COLLATE utf8mb4_general_ci
AND t.tenant_no = c.tenant_no AND t.tenant_no COLLATE utf8mb4_general_ci = c.tenant_no COLLATE utf8mb4_general_ci
AND t.del_flag = 0 AND t.del_flag = 0
); );
@@ -195,7 +200,7 @@ CREATE TEMPORARY TABLE tmp_uc_step_map (
PRIMARY KEY (task_id, route_step_id), PRIMARY KEY (task_id, route_step_id),
KEY ix_route_step (route_step_id), KEY ix_route_step (route_step_id),
KEY ix_task_step (task_step_id) KEY ix_task_step (task_step_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO tmp_uc_step_map ( INSERT INTO tmp_uc_step_map (
task_id, work_order_id, tenant_no, route_step_id, task_step_id, step_order task_id, work_order_id, tenant_no, route_step_id, task_step_id, step_order
@@ -205,16 +210,17 @@ SELECT
c.work_order_id, c.work_order_id,
c.tenant_no, c.tenant_no,
rs.id, rs.id,
UPPER(REPLACE(UUID(), '-', '')), UPPER(MD5(CONCAT('uc-msc-backfill-step:', c.work_order_id, ':', rs.id))),
rs.step_order rs.step_order
FROM tmp_uc_wo_backfill c FROM tmp_uc_wo_backfill c
INNER JOIN biz_process_route_step rs INNER JOIN biz_process_route_step rs
ON rs.route_id = c.route_id ON rs.route_id COLLATE utf8mb4_unicode_ci = c.route_id COLLATE utf8mb4_unicode_ci
AND rs.del_flag = 0 AND rs.del_flag = 0
WHERE @uc_ready = 1 WHERE @uc_ready = 1
AND EXISTS ( AND EXISTS (
SELECT 1 FROM biz_production_task t SELECT 1 FROM biz_production_task t
WHERE t.id = c.task_id AND t.del_flag = 0 WHERE t.id COLLATE utf8mb4_general_ci = c.task_id COLLATE utf8mb4_general_ci
AND t.del_flag = 0
); );
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
@@ -257,11 +263,11 @@ SELECT
0 0
FROM tmp_uc_step_map m FROM tmp_uc_step_map m
INNER JOIN biz_process_route_step rs INNER JOIN biz_process_route_step rs
ON rs.id = m.route_step_id ON rs.id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
AND rs.del_flag = 0 AND rs.del_flag = 0
WHERE NOT EXISTS ( WHERE NOT EXISTS (
SELECT 1 FROM biz_production_task_step x SELECT 1 FROM biz_production_task_step x
WHERE x.id = m.task_step_id WHERE x.id COLLATE utf8mb4_general_ci = m.task_step_id COLLATE utf8mb4_general_ci
); );
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
@@ -273,7 +279,7 @@ INSERT INTO biz_production_task_step_reagent (
create_by, create_dept_id, create_time, update_by, update_time, del_flag create_by, create_dept_id, create_time, update_by, update_time, del_flag
) )
SELECT SELECT
UPPER(REPLACE(UUID(), '-', '')), UPPER(MD5(CONCAT('uc-msc-backfill-reag:', m.task_step_id, ':', src.id))),
m.task_step_id, m.task_step_id,
src.reagent_code, src.reagent_code,
src.reagent_name, src.reagent_name,
@@ -292,7 +298,7 @@ SELECT
0 0
FROM tmp_uc_step_map m FROM tmp_uc_step_map m
INNER JOIN biz_process_route_step_reagent src INNER JOIN biz_process_route_step_reagent src
ON src.step_id = m.route_step_id ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
AND src.del_flag = 0; AND src.del_flag = 0;
INSERT INTO biz_production_task_step_consumable ( INSERT INTO biz_production_task_step_consumable (
@@ -301,7 +307,7 @@ INSERT INTO biz_production_task_step_consumable (
create_by, create_dept_id, create_time, update_by, update_time, del_flag create_by, create_dept_id, create_time, update_by, update_time, del_flag
) )
SELECT SELECT
UPPER(REPLACE(UUID(), '-', '')), UPPER(MD5(CONCAT('uc-msc-backfill-cons:', m.task_step_id, ':', src.id))),
m.task_step_id, m.task_step_id,
src.consumable_code, src.consumable_code,
src.consumable_name, src.consumable_name,
@@ -320,7 +326,7 @@ SELECT
0 0
FROM tmp_uc_step_map m FROM tmp_uc_step_map m
INNER JOIN biz_process_route_step_consumable src INNER JOIN biz_process_route_step_consumable src
ON src.step_id = m.route_step_id ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
AND src.del_flag = 0; AND src.del_flag = 0;
INSERT INTO biz_production_task_step_output ( INSERT INTO biz_production_task_step_output (
@@ -329,7 +335,7 @@ INSERT INTO biz_production_task_step_output (
create_by, create_dept_id, create_time, update_by, update_time, del_flag create_by, create_dept_id, create_time, update_by, update_time, del_flag
) )
SELECT SELECT
UPPER(REPLACE(UUID(), '-', '')), UPPER(MD5(CONCAT('uc-msc-backfill-out:', m.task_step_id, ':', src.id))),
m.task_step_id, m.task_step_id,
src.output_type_id, src.output_type_id,
src.output_name, src.output_name,
@@ -345,7 +351,7 @@ SELECT
0 0
FROM tmp_uc_step_map m FROM tmp_uc_step_map m
INNER JOIN biz_process_route_step_output src INNER JOIN biz_process_route_step_output src
ON src.step_id = m.route_step_id ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
AND src.del_flag = 0; AND src.del_flag = 0;
INSERT INTO biz_production_task_step_data_collection ( INSERT INTO biz_production_task_step_data_collection (
@@ -353,7 +359,7 @@ INSERT INTO biz_production_task_step_data_collection (
create_by, create_dept_id, create_time, update_by, update_time, del_flag create_by, create_dept_id, create_time, update_by, update_time, del_flag
) )
SELECT SELECT
UPPER(REPLACE(UUID(), '-', '')), UPPER(MD5(CONCAT('uc-msc-backfill-dc:', m.task_step_id, ':', src.id))),
m.task_step_id, m.task_step_id,
src.collection_name, src.collection_name,
src.unit, src.unit,
@@ -368,14 +374,15 @@ SELECT
0 0
FROM tmp_uc_step_map m FROM tmp_uc_step_map m
INNER JOIN biz_process_route_step_data_collection src INNER JOIN biz_process_route_step_data_collection src
ON src.step_id = m.route_step_id ON src.step_id COLLATE utf8mb4_unicode_ci = m.route_step_id COLLATE utf8mb4_unicode_ci
AND src.del_flag = 0; AND src.del_flag = 0;
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
-- 6. 回写工单状态:有任务则 jxz(不改 ywc) -- 6. 回写工单状态:有任务则 jxz(不改 ywc)
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
UPDATE biz_production_work_order wo UPDATE biz_production_work_order wo
INNER JOIN tmp_uc_wo_backfill c ON c.work_order_id = wo.id INNER JOIN tmp_uc_wo_backfill c
ON c.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
SET SET
wo.work_order_status = 'jxz', wo.work_order_status = 'jxz',
wo.update_time = NOW() wo.update_time = NOW()
@@ -383,8 +390,8 @@ WHERE wo.del_flag = 0
AND wo.work_order_status = 'dpz' AND wo.work_order_status = 'dpz'
AND EXISTS ( AND EXISTS (
SELECT 1 FROM biz_production_task t SELECT 1 FROM biz_production_task t
WHERE t.work_order_id = wo.id WHERE t.work_order_id COLLATE utf8mb4_general_ci = wo.id COLLATE utf8mb4_general_ci
AND t.tenant_no = wo.tenant_no AND t.tenant_no COLLATE utf8mb4_general_ci = wo.tenant_no COLLATE utf8mb4_general_ci
AND t.del_flag = 0 AND t.del_flag = 0
); );
@@ -399,10 +406,18 @@ SELECT
t.id AS task_id, t.id AS task_id,
t.task_no, t.task_no,
t.task_name, t.task_name,
(SELECT COUNT(*) FROM biz_production_task_step s WHERE s.task_id = t.id AND s.del_flag = 0) AS step_count (
SELECT COUNT(*)
FROM biz_production_task_step s
WHERE s.task_id COLLATE utf8mb4_general_ci = t.id COLLATE utf8mb4_general_ci
AND s.del_flag = 0
) AS step_count
FROM tmp_uc_wo_backfill c FROM tmp_uc_wo_backfill c
LEFT JOIN biz_production_work_order wo ON wo.id = c.work_order_id LEFT JOIN biz_production_work_order wo
LEFT JOIN biz_production_task t ON t.id = c.task_id AND t.del_flag = 0 ON wo.id COLLATE utf8mb4_general_ci = c.work_order_id COLLATE utf8mb4_general_ci
LEFT JOIN biz_production_task t
ON t.id COLLATE utf8mb4_general_ci = c.task_id COLLATE utf8mb4_general_ci
AND t.del_flag = 0
ORDER BY c.seq; ORDER BY c.seq;
DROP TEMPORARY TABLE IF EXISTS tmp_uc_step_map; DROP TEMPORARY TABLE IF EXISTS tmp_uc_step_map;
@@ -150,6 +150,7 @@ import {
uploadAttachment uploadAttachment
} from '../../api/oa.js' } from '../../api/oa.js'
import OaCommentFileCards from './OaCommentFileCards.vue' import OaCommentFileCards from './OaCommentFileCards.vue'
import { hasOaCommentDraft } from '../oa-comment-draft.js'
import { attachmentFullUrl } from '../../utils/attachment.js' import { attachmentFullUrl } from '../../utils/attachment.js'
import { isHarmonyWechat } from '../../utils/harmony-file-picker.js' import { isHarmonyWechat } from '../../utils/harmony-file-picker.js'
import HarmonyFileSource from '../../components/HarmonyFileSource.vue' import HarmonyFileSource from '../../components/HarmonyFileSource.vue'
@@ -516,12 +517,25 @@ function confirmMention() {
mentionVisible.value = false mentionVisible.value = false
} }
async function onSend() { function draftPending() {
const content = draft.value.trim() return hasOaCommentDraft({
if (!content && !mentionUsers.value.length && !picked.value.length) { content: draft.value,
showToast('请填写评论、@人员或添加附件') mentionCount: mentionUsers.value.length,
return attachmentCount: picked.value.length
})
}
/**
* 审批动作前冲刷未发送草稿:无草稿直接成功;有草稿则等同点击「发送」。
* @returns {Promise<boolean>} false 表示发送失败或忙碌,调用方应中止审批动作
*/
async function flushDraft(opts = {}) {
if (!draftPending()) return true
if (sending.value || uploading.value) {
showToast(uploading.value ? '附件上传中,请稍后再试' : '评论发送中,请稍后再试')
return false
} }
const content = draft.value.trim()
sending.value = true sending.value = true
try { try {
await fetchCreateOaComment(props.instanceId, { await fetchCreateOaComment(props.instanceId, {
@@ -533,15 +547,27 @@ async function onSend() {
picked.value = [] picked.value = []
mentionUsers.value = [] mentionUsers.value = []
closeAtSuggest() closeAtSuggest()
showToast('已发送') if (!opts.quiet) showToast('已发送')
emit('refresh') emit('refresh')
return true
} catch (e) { } catch (e) {
showToast(e?.message || '发送失败') showToast(e?.message || '发送失败')
return false
} finally { } finally {
sending.value = false sending.value = false
} }
} }
async function onSend() {
if (!draftPending()) {
showToast('请填写评论、@人员或添加附件')
return
}
await flushDraft()
}
defineExpose({ flushDraft, draftPending })
onMounted(() => { onMounted(() => {
void ensureUserCache() void ensureUserCache()
}) })
+7
View File
@@ -0,0 +1,7 @@
/** 评论区是否有未发送草稿(文字 / @ / 附件) */
export function hasOaCommentDraft(input = {}) {
const content = String(input.content || '').trim()
const mentionCount = Number(input.mentionCount || 0)
const attachmentCount = Number(input.attachmentCount || 0)
return !!(content || mentionCount > 0 || attachmentCount > 0)
}
@@ -0,0 +1,14 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { hasOaCommentDraft } from './oa-comment-draft.js'
test('empty draft is false', () => {
assert.equal(hasOaCommentDraft({}), false)
assert.equal(hasOaCommentDraft({ content: ' ', mentionCount: 0, attachmentCount: 0 }), false)
})
test('text / mention / attachment counts as draft', () => {
assert.equal(hasOaCommentDraft({ content: '@test' }), true)
assert.equal(hasOaCommentDraft({ mentionCount: 1 }), true)
assert.equal(hasOaCommentDraft({ attachmentCount: 2 }), true)
})
+11 -1
View File
@@ -29,6 +29,7 @@
@refresh="reloadDetail" @refresh="reloadDetail"
/> />
<OaCommentComposer <OaCommentComposer
ref="commentComposerRef"
:instance-id="instanceId" :instance-id="instanceId"
:instance-status="detail?.status || ''" :instance-status="detail?.status || ''"
@refresh="reloadDetail" @refresh="reloadDetail"
@@ -238,6 +239,7 @@ const currentUserId = ref('')
const currentUserName = ref('') const currentUserName = ref('')
const autoPrinted = ref(false) const autoPrinted = ref(false)
const commentComposerRef = ref(null)
const commentVisible = ref(false) const commentVisible = ref(false)
const commentKind = ref('approve') // approve | reject | return const commentKind = ref('approve') // approve | reject | return
const commentText = ref('') const commentText = ref('')
@@ -492,8 +494,16 @@ function goCopyRestart() {
}) })
} }
function openComment(kind) { /** 同意/拒绝/打回前先发送评论区未提交草稿 */
async function flushPendingComment() {
const flush = commentComposerRef.value?.flushDraft
if (!flush) return true
return await flush()
}
async function openComment(kind) {
if (!myPendingTask.value) return if (!myPendingTask.value) return
if (!(await flushPendingComment())) return
commentKind.value = kind commentKind.value = kind
commentText.value = defaultComment(kind) commentText.value = defaultComment(kind)
commentVisible.value = true commentVisible.value = true
+2
View File
@@ -141,6 +141,8 @@ export type QcWorkOrder = {
patientName?: string patientName?: string
/** 入库工单(细胞存储/科研捐赠):母亲姓名 */ /** 入库工单(细胞存储/科研捐赠):母亲姓名 */
motherName?: string motherName?: string
/** 协议单母血采集时间;未录入时为空,前端展示为 — */
maternalBloodCollectTime?: string
/** 入库工单(细胞存储/科研捐赠):新生儿姓名 */ /** 入库工单(细胞存储/科研捐赠):新生儿姓名 */
newbornName?: string newbornName?: string
/** 出库工单:当前为第几次输注计划 */ /** 出库工单:当前为第几次输注计划 */
@@ -192,6 +192,7 @@
} from '@/api/oaApproval' } from '@/api/oaApproval'
import OaCommentFileCards from '@/components/oa-approval/OaCommentFileCards.vue' import OaCommentFileCards from '@/components/oa-approval/OaCommentFileCards.vue'
import { attachmentFullUrl } from '@/composables/useAttachmentActions' import { attachmentFullUrl } from '@/composables/useAttachmentActions'
import { hasOaCommentDraft } from '@/utils/oa-comment-draft'
import { isOaUploadImageFile, isOaUploadVideoFile } from '@/utils/oa-upload-file-type' import { isOaUploadImageFile, isOaUploadVideoFile } from '@/utils/oa-upload-file-type'
defineOptions({ name: 'OaCommentPanel' }) defineOptions({ name: 'OaCommentPanel' })
@@ -546,12 +547,25 @@
} }
} }
async function onSend() { function draftPending() {
const content = draft.value.trim() return hasOaCommentDraft({
if (!content && !mentionUsers.value.length && !picked.value.length) { content: draft.value,
ElMessage.warning('请填写评论、@人员或添加附件') mentionCount: mentionUsers.value.length,
return attachmentCount: picked.value.length
})
}
/**
* 审批动作前冲刷未发送草稿:无草稿直接成功;有草稿则等同点击「发送」。
* @returns false 表示发送失败或忙碌,调用方应中止审批动作
*/
async function flushDraft(opts?: { quiet?: boolean }): Promise<boolean> {
if (!draftPending()) return true
if (sending.value || uploading.value) {
ElMessage.warning(uploading.value ? '附件上传中,请稍后再试' : '评论发送中,请稍后再试')
return false
} }
const content = draft.value.trim()
sending.value = true sending.value = true
try { try {
await fetchCreateOaComment(props.instanceId, { await fetchCreateOaComment(props.instanceId, {
@@ -565,15 +579,27 @@
picked.value = [] picked.value = []
mentionUsers.value = [] mentionUsers.value = []
closeAtSuggest() closeAtSuggest()
ElMessage.success('已发送') if (!opts?.quiet) ElMessage.success('已发送')
emit('refresh') emit('refresh')
return true
} catch (e: any) { } catch (e: any) {
ElMessage.error(e?.message || '发送失败') ElMessage.error(e?.message || '发送失败')
return false
} finally { } finally {
sending.value = false sending.value = false
} }
} }
async function onSend() {
if (!draftPending()) {
ElMessage.warning('请填写评论、@人员或添加附件')
return
}
await flushDraft()
}
defineExpose({ flushDraft, draftPending })
onMounted(() => { onMounted(() => {
void ensureUserCache() void ensureUserCache()
}) })
@@ -0,0 +1,16 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { hasOaCommentDraft } from './oa-comment-draft.ts'
describe('hasOaCommentDraft', () => {
it('treats blank content without mentions/files as empty', () => {
assert.equal(hasOaCommentDraft({}), false)
assert.equal(hasOaCommentDraft({ content: ' ', mentionCount: 0, attachmentCount: 0 }), false)
})
it('detects text, mentions and attachments', () => {
assert.equal(hasOaCommentDraft({ content: '@test' }), true)
assert.equal(hasOaCommentDraft({ mentionCount: 1 }), true)
assert.equal(hasOaCommentDraft({ attachmentCount: 2 }), true)
})
})
+12
View File
@@ -0,0 +1,12 @@
/** 评论区是否有未发送草稿(文字 / @ / 附件) */
export function hasOaCommentDraft(input: {
content?: string | null
mentionCount?: number
attachmentCount?: number
}): boolean {
return !!(
String(input.content || '').trim() ||
(input.mentionCount || 0) > 0 ||
(input.attachmentCount || 0) > 0
)
}
@@ -127,7 +127,7 @@ const inboundGroupedFields: CardMetaField[] = [
{ label: '母亲姓名', getValue: (row) => row.motherName || '—', visible: isInboundUserInfoRow }, { label: '母亲姓名', getValue: (row) => row.motherName || '—', visible: isInboundUserInfoRow },
{ label: '新生儿姓名', getValue: (row) => row.newbornName || '—', visible: isInboundUserInfoRow }, { label: '新生儿姓名', getValue: (row) => row.newbornName || '—', visible: isInboundUserInfoRow },
inboundProtocolStatusField, inboundProtocolStatusField,
{ label: '质检对象', getValue: formatQcTarget, colSpan: 2 }, { label: '质检对象', getValue: formatQcTarget },
{ {
label: '关联生产工单', label: '关联生产工单',
getValue: (row) => row.productionWorkOrderNo || '—', getValue: (row) => row.productionWorkOrderNo || '—',
@@ -139,6 +139,11 @@ const inboundGroupedFields: CardMetaField[] = [
getValue: (row) => row.sampleTypeName || '—', getValue: (row) => row.sampleTypeName || '—',
visible: isInboundUserInfoRow visible: isInboundUserInfoRow
}, },
{
label: '母血采集时间',
getValue: (row) => formatDisplayOrDash(row.maternalBloodCollectTime),
visible: isInboundUserInfoRow
},
...commonTailFields ...commonTailFields
] ]
@@ -197,6 +202,7 @@ function buildCellStorageGroupContext(row: QcWorkOrder): string[] {
if (row.newbornName) parts.push(`新生儿 ${row.newbornName}`) if (row.newbornName) parts.push(`新生儿 ${row.newbornName}`)
if (row.sampleTypeName) parts.push(row.sampleTypeName) if (row.sampleTypeName) parts.push(row.sampleTypeName)
if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`) if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`)
parts.push(`母血采集 ${formatDisplayOrDash(row.maternalBloodCollectTime)}`)
if (row.handlerName) parts.push(row.handlerName) if (row.handlerName) parts.push(row.handlerName)
return parts return parts
} }
@@ -207,6 +213,7 @@ function buildDonationGroupContext(row: QcWorkOrder): string[] {
if (row.newbornName) parts.push(`新生儿 ${row.newbornName}`) if (row.newbornName) parts.push(`新生儿 ${row.newbornName}`)
if (row.sampleTypeName) parts.push(row.sampleTypeName) if (row.sampleTypeName) parts.push(row.sampleTypeName)
if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`) if (row.receptionTime) parts.push(`接收 ${row.receptionTime}`)
parts.push(`母血采集 ${formatDisplayOrDash(row.maternalBloodCollectTime)}`)
if (row.handlerName) parts.push(row.handlerName) if (row.handlerName) parts.push(row.handlerName)
return parts return parts
} }
@@ -99,6 +99,7 @@
/> />
<OaCommentPanel <OaCommentPanel
v-if="detail?.id" v-if="detail?.id"
ref="commentPanelRef"
:instance-id="detail.id" :instance-id="detail.id"
:instance-status="detail.status || ''" :instance-status="detail.status || ''"
@refresh="load" @refresh="load"
@@ -236,6 +237,9 @@
const userStore = useUserStore() const userStore = useUserStore()
const loading = ref(false) const loading = ref(false)
const acting = ref(false) const acting = ref(false)
const commentPanelRef = ref<{ flushDraft?: (opts?: { quiet?: boolean }) => Promise<boolean> } | null>(
null
)
const detail = ref<any>(null) const detail = ref<any>(null)
const viewFormData = ref<Record<string, any>>({}) const viewFormData = ref<Record<string, any>>({})
const viewRule = ref<any[]>([]) const viewRule = ref<any[]>([])
@@ -392,9 +396,17 @@
} }
} }
/** 同意/拒绝/打回前先发送评论区未提交草稿 */
async function flushPendingComment(): Promise<boolean> {
const flush = commentPanelRef.value?.flushDraft
if (!flush) return true
return await flush()
}
async function act(kind: 'approve' | 'reject') { async function act(kind: 'approve' | 'reject') {
const task = myPendingTask.value const task = myPendingTask.value
if (!task) return if (!task) return
if (!(await flushPendingComment())) return
let comment = '' let comment = ''
try { try {
const res = await ElMessageBox.prompt( const res = await ElMessageBox.prompt(
@@ -436,6 +448,7 @@
async function doReturn() { async function doReturn() {
const task = myPendingTask.value const task = myPendingTask.value
if (!task) return if (!task) return
if (!(await flushPendingComment())) return
let comment = '' let comment = ''
try { try {
const res = await ElMessageBox.prompt('请填写打回意见(必填)', '打回', { const res = await ElMessageBox.prompt('请填写打回意见(必填)', '打回', {