Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2124ce9208 | ||
|
|
e7b3876db6 | ||
|
|
c0aba421da | ||
|
|
2aecb69cc4 | ||
|
|
2878c6889d | ||
|
|
4aee2b1fe5 | ||
|
|
5698a9dfc4 | ||
|
|
77d45d0bc5 | ||
|
|
dc0f8541c4 | ||
|
|
4fd6ef4be5 | ||
|
|
b3c191ee99 | ||
|
|
bbef46b645 |
No files matched your search
@@ -6,7 +6,7 @@ from pydantic import BaseModel, ConfigDict, Field
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.core.database import get_db
|
from app.core.database import get_db
|
||||||
from app.core.menu_guard import require_menu_code
|
from app.core.menu_guard import require_any_menu_code
|
||||||
from app.core.response import error_response, success_response
|
from app.core.response import error_response, success_response
|
||||||
from app.crud import lab_sample_process as svc
|
from app.crud import lab_sample_process as svc
|
||||||
from app.models.models import SysUser
|
from app.models.models import SysUser
|
||||||
@@ -14,8 +14,17 @@ from app.services import lab_sample_process as ledger
|
|||||||
|
|
||||||
router = APIRouter(prefix="/web/admin", tags=["质检管理"])
|
router = APIRouter(prefix="/web/admin", tags=["质检管理"])
|
||||||
|
|
||||||
LIST_MENU = "biz:labSampleProcess:list"
|
# 市场/生产/质检三处菜单权限码不同,接口按并集鉴权
|
||||||
SUPPLEMENT_MENU = "biz:labSampleProcess:supplement"
|
LIST_MENU_CODES = (
|
||||||
|
"biz:labSampleProcess:list",
|
||||||
|
"production:labSampleProcess:list",
|
||||||
|
"cellStorage:labSampleProcess:list",
|
||||||
|
)
|
||||||
|
SUPPLEMENT_MENU_CODES = (
|
||||||
|
"biz:labSampleProcess:supplement",
|
||||||
|
"production:labSampleProcess:supplement",
|
||||||
|
"cellStorage:labSampleProcess:supplement",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _tenant_no(db: Session, user: dict) -> str:
|
def _tenant_no(db: Session, user: dict) -> str:
|
||||||
@@ -59,7 +68,7 @@ def list_lab_sample_process(
|
|||||||
createTimeStart: Optional[str] = Query(None),
|
createTimeStart: Optional[str] = Query(None),
|
||||||
createTimeEnd: Optional[str] = Query(None),
|
createTimeEnd: Optional[str] = Query(None),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user=Depends(require_menu_code(LIST_MENU)),
|
user=Depends(require_any_menu_code(*LIST_MENU_CODES)),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
tenant_no = _tenant_no(db, user)
|
tenant_no = _tenant_no(db, user)
|
||||||
@@ -98,7 +107,7 @@ def list_lab_sample_process(
|
|||||||
def get_supplement(
|
def get_supplement(
|
||||||
labStorageCode: str = Query(...),
|
labStorageCode: str = Query(...),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user=Depends(require_menu_code(LIST_MENU)),
|
user=Depends(require_any_menu_code(*LIST_MENU_CODES)),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
tenant_no = _tenant_no(db, user)
|
tenant_no = _tenant_no(db, user)
|
||||||
@@ -114,7 +123,7 @@ def get_supplement(
|
|||||||
def save_supplement(
|
def save_supplement(
|
||||||
body: SupplementBody,
|
body: SupplementBody,
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
user=Depends(require_menu_code(SUPPLEMENT_MENU)),
|
user=Depends(require_any_menu_code(*SUPPLEMENT_MENU_CODES)),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
tenant_no = _tenant_no(db, user)
|
tenant_no = _tenant_no(db, user)
|
||||||
|
|||||||
@@ -179,6 +179,17 @@ def upsert_supplement(
|
|||||||
del_flag=0,
|
del_flag=0,
|
||||||
)
|
)
|
||||||
db.add(row)
|
db.add(row)
|
||||||
|
# 同步到新模块补充表/生产接收,保证实验室样本处理数据联动
|
||||||
|
from app.services.lab_sample_processing import sync_legacy_supplement_to_processing
|
||||||
|
|
||||||
|
sync_legacy_supplement_to_processing(
|
||||||
|
db,
|
||||||
|
tenant_no=tenant_no,
|
||||||
|
lab_storage_code=code,
|
||||||
|
sample_type_name=type_name,
|
||||||
|
payload=clean_payload,
|
||||||
|
operator_id=user_id,
|
||||||
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(row)
|
db.refresh(row)
|
||||||
return get_supplement(db, tenant_no=tenant_no, lab_storage_code=code) or {}
|
return get_supplement(db, tenant_no=tenant_no, lab_storage_code=code) or {}
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,30 @@
|
|||||||
|
"""恢复被误软删的 Excel 补充字段(真菌/内毒素/CD34 等)并同步旧台账。
|
||||||
|
|
||||||
|
用法:
|
||||||
|
ENV_FILE=.../backend/.env python backend/scripts/restore_lab_sample_processing_excel_extras.py
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
|
BACKEND = ROOT / "backend"
|
||||||
|
if str(BACKEND) not in sys.path:
|
||||||
|
sys.path.insert(0, str(BACKEND))
|
||||||
|
|
||||||
|
from app.core.database import SessionLocal # noqa: E402
|
||||||
|
from app.services.lab_sample_processing import restore_retired_excel_extras # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
db = SessionLocal()
|
||||||
|
try:
|
||||||
|
result = restore_retired_excel_extras(db, tenant_no="zkxw")
|
||||||
|
print(result)
|
||||||
|
finally:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -48,6 +48,183 @@ class LabSampleProcessingFieldsTest(unittest.TestCase):
|
|||||||
self.assertEqual(fmap["cd34Count"].dept, DEPT_QC)
|
self.assertEqual(fmap["cd34Count"].dept, DEPT_QC)
|
||||||
self.assertEqual(fmap["originalBloodWeightG"].dept, DEPT_PRODUCTION)
|
self.assertEqual(fmap["originalBloodWeightG"].dept, DEPT_PRODUCTION)
|
||||||
|
|
||||||
|
def test_source_fields_not_overridden_by_extra(self):
|
||||||
|
from datetime import datetime
|
||||||
|
from app.services.lab_sample_processing import _build_row
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
sample = SimpleNamespace(id="S1", sample_code="ZKZX34000865", collection_protocol_id="P1")
|
||||||
|
party = SimpleNamespace(mother_name="真实妈妈")
|
||||||
|
coll = SimpleNamespace(
|
||||||
|
sample_collect_time=None,
|
||||||
|
maternal_blood_collect_time=datetime(2026, 11, 4, 5, 20),
|
||||||
|
)
|
||||||
|
hospital = SimpleNamespace(hospital_name="真实医院")
|
||||||
|
protocol = SimpleNamespace(
|
||||||
|
consent_form_urls="protocol-consent/a",
|
||||||
|
health_survey_form_urls="",
|
||||||
|
)
|
||||||
|
reception = SimpleNamespace(
|
||||||
|
id="R1",
|
||||||
|
reception_time=None,
|
||||||
|
receive_temperature=None,
|
||||||
|
handler_name="接收人",
|
||||||
|
remark=None,
|
||||||
|
lab_storage_code="B0000103",
|
||||||
|
)
|
||||||
|
production = SimpleNamespace(
|
||||||
|
id="PR1",
|
||||||
|
original_blood_weight_g=72.08,
|
||||||
|
hes_volume_ml=None,
|
||||||
|
blood_type="B",
|
||||||
|
infectious_four_test_result="zc",
|
||||||
|
enriched_blood_weight_g=None,
|
||||||
|
cryopreservation_volume_ml=None,
|
||||||
|
handler_name="操作人",
|
||||||
|
remark=None,
|
||||||
|
original_blood_volume_ml=None,
|
||||||
|
nucleated_cell_count_1e8=None,
|
||||||
|
inoculation_amount=None,
|
||||||
|
cryopreservation_time=None,
|
||||||
|
storage_total_tubes=None,
|
||||||
|
available_cell_count_1e7=None,
|
||||||
|
)
|
||||||
|
row = _build_row(
|
||||||
|
dataset=DATASET_HSC,
|
||||||
|
sample=sample,
|
||||||
|
type_name="围产期造血干细胞",
|
||||||
|
party=party,
|
||||||
|
coll=coll,
|
||||||
|
hospital=hospital,
|
||||||
|
reception=reception,
|
||||||
|
production=production,
|
||||||
|
extra={
|
||||||
|
"motherName": "Excel妈妈",
|
||||||
|
"originalBloodWeightG": 1,
|
||||||
|
"cd34Count": "11.4",
|
||||||
|
},
|
||||||
|
protocol=protocol,
|
||||||
|
check_flags={
|
||||||
|
"健康调查表": True,
|
||||||
|
"样本信息正确,标识清晰": True,
|
||||||
|
"针路密闭": True,
|
||||||
|
"容器无破损": True,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.assertEqual(row["sampleCode"], "B0000103")
|
||||||
|
self.assertEqual(row["protocolSampleCode"], "ZKZX34000865")
|
||||||
|
self.assertEqual(row["motherName"], "真实妈妈")
|
||||||
|
self.assertEqual(row["originalBloodWeightG"], 72.08)
|
||||||
|
self.assertEqual(row["bloodType"], "B")
|
||||||
|
self.assertEqual(row["cd34Count"], "11.4")
|
||||||
|
self.assertEqual(row["hasMaternalBlood"], "是")
|
||||||
|
self.assertEqual(row["hasConsent"], "是")
|
||||||
|
self.assertEqual(row["hasHealthSurvey"], "是")
|
||||||
|
self.assertEqual(row["labelClear"], "是")
|
||||||
|
self.assertEqual(row["infectiousFourCard"], "正常")
|
||||||
|
self.assertIn("针路密闭", row["receiveCheck"] or "")
|
||||||
|
self.assertFalse(row["fromExtraOnly"])
|
||||||
|
|
||||||
|
def test_infectious_code_roundtrip(self):
|
||||||
|
from app.services.lab_sample_processing import _infectious_code, _infectious_label
|
||||||
|
|
||||||
|
self.assertEqual(_infectious_label("zc"), "正常")
|
||||||
|
self.assertEqual(_infectious_label("bzc"), "不正常")
|
||||||
|
self.assertEqual(_infectious_code("正常"), "zc")
|
||||||
|
self.assertEqual(_infectious_code("不正常"), "bzc")
|
||||||
|
|
||||||
|
def test_extra_field_keys_include_fungus(self):
|
||||||
|
from app.services.lab_sample_processing import _extra_field_keys
|
||||||
|
|
||||||
|
keys = _extra_field_keys(DATASET_MSC)
|
||||||
|
self.assertIn("fungusTest", keys)
|
||||||
|
self.assertIn("endotoxinTest", keys)
|
||||||
|
self.assertIn("bacteriaTest", keys)
|
||||||
|
self.assertIn("mycoplasmaTest", keys)
|
||||||
|
|
||||||
|
def test_msc_donation_collect_and_transport_fallback(self):
|
||||||
|
from datetime import datetime
|
||||||
|
from app.services.lab_sample_processing import _build_row
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
sample = SimpleNamespace(id="D1", sample_code="KYJZ1", collection_protocol_id=None)
|
||||||
|
party = SimpleNamespace(mother_name="孙玲")
|
||||||
|
coll = SimpleNamespace(
|
||||||
|
sample_collect_time=datetime(2026, 10, 10, 10, 5),
|
||||||
|
maternal_blood_collect_time=None,
|
||||||
|
)
|
||||||
|
reception = SimpleNamespace(
|
||||||
|
id="R1",
|
||||||
|
reception_time=datetime(2026, 10, 10, 15, 40, 57),
|
||||||
|
receive_temperature="23.1",
|
||||||
|
handler_name="侯以婷",
|
||||||
|
remark=None,
|
||||||
|
lab_storage_code="UC2026006",
|
||||||
|
)
|
||||||
|
row = _build_row(
|
||||||
|
dataset=DATASET_MSC,
|
||||||
|
sample=sample,
|
||||||
|
type_name="脐带间充质干细胞",
|
||||||
|
party=party,
|
||||||
|
coll=coll,
|
||||||
|
hospital=None,
|
||||||
|
reception=reception,
|
||||||
|
production=None,
|
||||||
|
extra={},
|
||||||
|
)
|
||||||
|
self.assertEqual(row["sampleCode"], "UC2026006")
|
||||||
|
self.assertEqual(row["collectTime"], "2026-10-10 10:05:00")
|
||||||
|
self.assertEqual(row["transportTempC"], "23.1")
|
||||||
|
self.assertNotIn("导出自存", row["motherName"] or "")
|
||||||
|
|
||||||
|
def test_legacy_supplement_fills_empty_source_fields(self):
|
||||||
|
from app.services.lab_sample_processing import _build_row, _merge_extra_with_legacy
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
extra = _merge_extra_with_legacy(
|
||||||
|
{},
|
||||||
|
{"infectiousFourTestLabel": "正常", "labMaterialCode": "202611006"},
|
||||||
|
)
|
||||||
|
sample = SimpleNamespace(id="S1", sample_code="UBMC202611006", collection_protocol_id=None)
|
||||||
|
reception = SimpleNamespace(
|
||||||
|
id="R1",
|
||||||
|
reception_time=None,
|
||||||
|
receive_temperature=None,
|
||||||
|
handler_name=None,
|
||||||
|
remark=None,
|
||||||
|
lab_storage_code="UBMC202611006",
|
||||||
|
)
|
||||||
|
production = SimpleNamespace(
|
||||||
|
id="PR1",
|
||||||
|
original_blood_weight_g=None,
|
||||||
|
hes_volume_ml=None,
|
||||||
|
blood_type=None,
|
||||||
|
infectious_four_test_result=None,
|
||||||
|
enriched_blood_weight_g=None,
|
||||||
|
cryopreservation_volume_ml=None,
|
||||||
|
handler_name=None,
|
||||||
|
remark=None,
|
||||||
|
original_blood_volume_ml=None,
|
||||||
|
nucleated_cell_count_1e8=None,
|
||||||
|
inoculation_amount=None,
|
||||||
|
cryopreservation_time=None,
|
||||||
|
storage_total_tubes=None,
|
||||||
|
available_cell_count_1e7=None,
|
||||||
|
)
|
||||||
|
row = _build_row(
|
||||||
|
dataset=DATASET_UBMC,
|
||||||
|
sample=sample,
|
||||||
|
type_name="脐血单个核细胞",
|
||||||
|
party=None,
|
||||||
|
coll=None,
|
||||||
|
hospital=None,
|
||||||
|
reception=reception,
|
||||||
|
production=production,
|
||||||
|
extra=extra,
|
||||||
|
)
|
||||||
|
self.assertEqual(row["infectiousFourCard"], "正常")
|
||||||
|
self.assertEqual(row["labMaterialCode"], "202611006")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
-- 实验室样本处理 ACL 归一化(可重复执行)
|
||||||
|
-- 1) 撤销所有 lab:sample-processing* / menu:lab-sample-processing 角色菜单
|
||||||
|
-- 2) 仅按下列角色重授:
|
||||||
|
-- 市场编辑:市场专员/临床销售/销售助理/客服/采集专员
|
||||||
|
-- 生产编辑:生产专员/实验专员/细胞实验员/研发专员
|
||||||
|
-- 质检编辑:质检专员/质量安全员
|
||||||
|
-- 主管:生产主管/质量主管/采集主管/采集经理/研发主管/研发总监/总经理/副总经理/董事长/超级管理员
|
||||||
|
-- 只读:采集接受人
|
||||||
|
-- 说明:正式执行请用 Agent 脚本 tmp_normalize_lab_acl.py(含幂等 undelete/insert)。
|
||||||
|
-- 本文件作为规则记录;勿在未核对角色名时直接全量套用到其他环境。
|
||||||
|
|
||||||
|
UPDATE sys_role_menu rm
|
||||||
|
JOIN sys_menu m ON m.id = rm.menu_id
|
||||||
|
SET rm.del_flag = 1,
|
||||||
|
rm.update_by = 'normalize-acl',
|
||||||
|
rm.update_time = NOW()
|
||||||
|
WHERE rm.del_flag = 0
|
||||||
|
AND (
|
||||||
|
m.perms LIKE 'lab:sample-processing%'
|
||||||
|
OR m.perms = 'menu:lab-sample-processing'
|
||||||
|
);
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# 恢复 Excel 补充字段(真菌等)
|
||||||
|
|
||||||
|
## 原因
|
||||||
|
|
||||||
|
`20261112_lab_sample_processing_retire_excel_demo.sql` 按「补充表 sample_code = 协议样本号」软删演示行。
|
||||||
|
会议 Excel 实际多用实验室入库编码(`B000*` / `BC*` / `UBMC*`),与协议号不一致,导致真实样本的真菌/内毒素/CD34 等补充字段被误删。
|
||||||
|
|
||||||
|
## 处理
|
||||||
|
|
||||||
|
运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ENV_FILE=backend/.env python backend/scripts/restore_lab_sample_processing_excel_extras.py
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本会:
|
||||||
|
|
||||||
|
1. 找出 `update_by=retire-excel-demo` 且 `del_flag=1` 的补充行
|
||||||
|
2. 仅恢复仍能关联到当前有效协议/接收编码的行
|
||||||
|
3. 只写回 `SOURCE_EXTRA` 字段到有效补充表
|
||||||
|
4. 同步旧台账 `biz_lab_sample_process_supplement`
|
||||||
|
|
||||||
|
列表侧同时会从质检完成任务填空(内毒素/真菌/支原体/细菌及母血相关)。
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
-- 软删除实验室样本处理 Excel 演示补充行:
|
||||||
|
-- 仅删除在协议样本表中不存在对应 sample_code 的补充记录。
|
||||||
|
-- Excel 列结构仍由代码字段目录维护;真实列表只聚合协议/接收/生产源数据。
|
||||||
|
|
||||||
|
UPDATE biz_lab_sample_processing_extra e
|
||||||
|
LEFT JOIN biz_protocol_sample s
|
||||||
|
ON s.sample_code = e.sample_code
|
||||||
|
AND s.tenant_no = e.tenant_no
|
||||||
|
AND s.del_flag = 0
|
||||||
|
SET e.del_flag = 1,
|
||||||
|
e.update_by = 'retire-excel-demo',
|
||||||
|
e.update_time = NOW()
|
||||||
|
WHERE e.del_flag = 0
|
||||||
|
AND s.id IS NULL;
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
-- Issue #102:实验室样本处理数据挂到市场/生产/质检,权限码分端
|
||||||
|
-- 1) 质检管理:调到「入库放行审核」下方
|
||||||
|
-- 2) 存储服务:挂到「缴费财务确认」下方(cellStorage:labSampleProcess:*)
|
||||||
|
-- 3) 生产管理:挂到「废弃物管理」下方(production:labSampleProcess:*;若废弃物菜单缺失则先补齐)
|
||||||
|
-- 4) 拥有 menu:market / menu:production / menu:quality 的角色,授予对应大菜单下入口
|
||||||
|
-- MySQL 5.7,可重复执行
|
||||||
|
|
||||||
|
-- ── 0) 生产管理补齐「废弃物管理」(仅当缺失时,便于排序锚定)────────────────
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('prod-waste-output:', p.tenant_no, ':', p.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
'废弃物管理', p.id, 'C', 'waste-output',
|
||||||
|
'/production/waste-output/index', 'production:waste-output:list',
|
||||||
|
1, '1', '1', p.tenant_no,
|
||||||
|
COALESCE((SELECT MAX(c.order_num) FROM sys_menu c WHERE c.parent_id = p.id AND c.del_flag = 0), 0) + 1,
|
||||||
|
'issue#102 补齐生产废弃物管理以便台账排序',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu p
|
||||||
|
WHERE p.del_flag = 0 AND p.status = '1' AND p.menu_name = '生产管理'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e
|
||||||
|
WHERE e.tenant_no = p.tenant_no AND e.parent_id = p.id
|
||||||
|
AND e.perms = 'production:waste-output:list' AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ── 1) 质检:调到入库放行审核下方(可重复;不连带改动其他菜单 order)────────
|
||||||
|
UPDATE sys_menu lab
|
||||||
|
JOIN sys_menu release_m
|
||||||
|
ON release_m.parent_id = lab.parent_id
|
||||||
|
AND release_m.del_flag = 0
|
||||||
|
AND release_m.menu_name = '入库放行审核'
|
||||||
|
AND release_m.perms = 'quality:storageReleaseReview:list'
|
||||||
|
SET lab.order_num = release_m.order_num + 1,
|
||||||
|
lab.update_by = 'migration',
|
||||||
|
lab.update_time = NOW()
|
||||||
|
WHERE lab.del_flag = 0
|
||||||
|
AND lab.perms = 'biz:labSampleProcess:list'
|
||||||
|
AND lab.path = 'lab-sample-process'
|
||||||
|
AND (lab.order_num IS NULL OR lab.order_num <> release_m.order_num + 1);
|
||||||
|
|
||||||
|
-- ── 2) 存储服务:缴费财务确认下方 ───────────────────────────────────────────
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('cell-lab-sample-process:', anchor.tenant_no, ':', anchor.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
'实验室样本处理数据', anchor.parent_id, 'C', 'lab-sample-process',
|
||||||
|
'quality-inspection/lab-sample-process/index', 'cellStorage:labSampleProcess:list',
|
||||||
|
1, '1', '1', anchor.tenant_no, anchor.order_num + 1,
|
||||||
|
'市场-存储服务-实验室样本处理数据',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu anchor
|
||||||
|
WHERE anchor.del_flag = 0 AND anchor.status = '1'
|
||||||
|
AND anchor.perms = 'biz:cellStoragePaymentConfirm:list'
|
||||||
|
AND anchor.menu_name = '缴费财务确认'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e
|
||||||
|
WHERE e.tenant_no = anchor.tenant_no
|
||||||
|
AND e.parent_id = anchor.parent_id
|
||||||
|
AND e.perms = 'cellStorage:labSampleProcess:list'
|
||||||
|
AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ── 3) 生产管理:废弃物管理下方 ─────────────────────────────────────────────
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('prod-lab-sample-process:', anchor.tenant_no, ':', anchor.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
'实验室样本处理数据', anchor.parent_id, 'C', 'lab-sample-process',
|
||||||
|
'quality-inspection/lab-sample-process/index', 'production:labSampleProcess:list',
|
||||||
|
1, '1', '1', anchor.tenant_no, anchor.order_num + 1,
|
||||||
|
'生产-生产管理-实验室样本处理数据',
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu anchor
|
||||||
|
WHERE anchor.del_flag = 0 AND anchor.status = '1'
|
||||||
|
AND anchor.perms = 'production:waste-output:list'
|
||||||
|
AND anchor.menu_name = '废弃物管理'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e
|
||||||
|
WHERE e.tenant_no = anchor.tenant_no
|
||||||
|
AND e.parent_id = anchor.parent_id
|
||||||
|
AND e.perms = 'production:labSampleProcess:list'
|
||||||
|
AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ── 4) 补录 / 导出按钮(三处列表菜单各挂一套)──────────────────────────────
|
||||||
|
INSERT INTO sys_menu (
|
||||||
|
id, menu_name, parent_id, menu_type, path, component, perms,
|
||||||
|
is_frame, visible, status, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('lab-sp-btn:', m.tenant_no, ':', m.id, ':', btn.perms)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
btn.menu_name, m.id, 'F', '', NULL, btn.perms,
|
||||||
|
1, '1', '1', m.tenant_no, btn.order_num, btn.remark,
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM sys_menu m
|
||||||
|
JOIN (
|
||||||
|
SELECT '补录' AS menu_name, 'cellStorage:labSampleProcess:supplement' AS perms, 10 AS order_num,
|
||||||
|
'存储服务-实验室样本处理数据-补录' AS remark, 'cellStorage:labSampleProcess:list' AS parent_perms
|
||||||
|
UNION ALL
|
||||||
|
SELECT '导出', 'cellStorage:labSampleProcess:export', 20,
|
||||||
|
'存储服务-实验室样本处理数据-导出', 'cellStorage:labSampleProcess:list'
|
||||||
|
UNION ALL
|
||||||
|
SELECT '补录', 'production:labSampleProcess:supplement', 10,
|
||||||
|
'生产-实验室样本处理数据-补录', 'production:labSampleProcess:list'
|
||||||
|
UNION ALL
|
||||||
|
SELECT '导出', 'production:labSampleProcess:export', 20,
|
||||||
|
'生产-实验室样本处理数据-导出', 'production:labSampleProcess:list'
|
||||||
|
) btn ON btn.parent_perms = m.perms
|
||||||
|
WHERE m.del_flag = 0 AND m.status = '1'
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_menu e
|
||||||
|
WHERE e.tenant_no = m.tenant_no AND e.parent_id = m.id
|
||||||
|
AND e.perms = btn.perms AND e.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- ── 5) 按顶级大菜单授权对应入口(含列表/补录/导出)─────────────────────────
|
||||||
|
INSERT INTO sys_role_menu (
|
||||||
|
id, role_id, menu_id, tenant_no, order_num, remark,
|
||||||
|
create_by, create_dept_id, create_time, update_by, update_time, del_flag
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
INSERT(INSERT(MD5(CONCAT('lab-sp-rm:', r.tenant_no, ':', r.id, ':', m.id)), 13, 1, '3'), 17, 1, '8'),
|
||||||
|
r.id, m.id, r.tenant_no, NULL,
|
||||||
|
CONCAT('issue#102 grant from ', map.top_perms),
|
||||||
|
'migration', '', NOW(), 'migration', NOW(), 0
|
||||||
|
FROM (
|
||||||
|
SELECT 'menu:market' AS top_perms, 'cellStorage:labSampleProcess:list' AS list_perms
|
||||||
|
UNION ALL SELECT 'menu:market', 'cellStorage:labSampleProcess:supplement'
|
||||||
|
UNION ALL SELECT 'menu:market', 'cellStorage:labSampleProcess:export'
|
||||||
|
UNION ALL SELECT 'menu:production', 'production:labSampleProcess:list'
|
||||||
|
UNION ALL SELECT 'menu:production', 'production:labSampleProcess:supplement'
|
||||||
|
UNION ALL SELECT 'menu:production', 'production:labSampleProcess:export'
|
||||||
|
UNION ALL SELECT 'menu:quality', 'biz:labSampleProcess:list'
|
||||||
|
UNION ALL SELECT 'menu:quality', 'biz:labSampleProcess:supplement'
|
||||||
|
UNION ALL SELECT 'menu:quality', 'biz:labSampleProcess:export'
|
||||||
|
) map
|
||||||
|
JOIN sys_role r ON r.del_flag = 0
|
||||||
|
JOIN sys_role_menu src
|
||||||
|
ON src.role_id = r.id AND src.tenant_no = r.tenant_no AND src.del_flag = 0
|
||||||
|
JOIN sys_menu top
|
||||||
|
ON top.id = src.menu_id AND top.tenant_no = src.tenant_no AND top.del_flag = 0
|
||||||
|
AND top.perms = map.top_perms
|
||||||
|
JOIN sys_menu m
|
||||||
|
ON m.tenant_no = r.tenant_no AND m.del_flag = 0 AND m.status = '1'
|
||||||
|
AND m.perms = map.list_perms
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_role_menu existing
|
||||||
|
WHERE existing.role_id = r.id
|
||||||
|
AND existing.menu_id = m.id
|
||||||
|
AND existing.tenant_no = r.tenant_no
|
||||||
|
AND existing.del_flag = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 核对
|
||||||
|
SELECT p.menu_name AS parent_name, c.menu_name, c.path, c.perms, c.order_num
|
||||||
|
FROM sys_menu c
|
||||||
|
JOIN sys_menu p ON p.id = c.parent_id
|
||||||
|
WHERE c.del_flag = 0
|
||||||
|
AND (
|
||||||
|
c.perms LIKE '%labSampleProcess%'
|
||||||
|
OR (c.menu_name IN ('缴费财务确认', '废弃物管理', '入库放行审核')
|
||||||
|
AND p.menu_name IN ('存储服务', '生产管理', '质检管理'))
|
||||||
|
)
|
||||||
|
ORDER BY p.menu_name, c.order_num, c.menu_name;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
-- Issue #100:移除多余一级菜单「实验室样本处理数据」及其子菜单/按钮
|
||||||
|
-- 软删除 sys_menu 与对应 sys_role_menu;不影响质检管理下 lab-sample-process 台账
|
||||||
|
-- MySQL 5.7,可重复执行
|
||||||
|
|
||||||
|
-- 1) 角色菜单授权
|
||||||
|
UPDATE sys_role_menu rm
|
||||||
|
JOIN sys_menu m ON m.id = rm.menu_id
|
||||||
|
SET rm.del_flag = 1,
|
||||||
|
rm.update_by = 'migration',
|
||||||
|
rm.update_time = NOW()
|
||||||
|
WHERE rm.del_flag = 0
|
||||||
|
AND (
|
||||||
|
m.perms IN (
|
||||||
|
'menu:lab-sample-processing',
|
||||||
|
'lab:sample-processing:list',
|
||||||
|
'lab:sample-processing:market:edit',
|
||||||
|
'lab:sample-processing:production:edit',
|
||||||
|
'lab:sample-processing:qc:edit',
|
||||||
|
'lab:sample-processing:manager'
|
||||||
|
)
|
||||||
|
OR m.path IN (
|
||||||
|
'/lab-sample-processing',
|
||||||
|
'lab-sample-processing/hsc',
|
||||||
|
'lab-sample-processing/ubmc',
|
||||||
|
'lab-sample-processing/msc'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 2) 按钮 / 子菜单 / 一级菜单(先叶子后父级,同批软删即可)
|
||||||
|
UPDATE sys_menu
|
||||||
|
SET del_flag = 1,
|
||||||
|
update_by = 'migration',
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE del_flag = 0
|
||||||
|
AND (
|
||||||
|
perms IN (
|
||||||
|
'menu:lab-sample-processing',
|
||||||
|
'lab:sample-processing:list',
|
||||||
|
'lab:sample-processing:market:edit',
|
||||||
|
'lab:sample-processing:production:edit',
|
||||||
|
'lab:sample-processing:qc:edit',
|
||||||
|
'lab:sample-processing:manager'
|
||||||
|
)
|
||||||
|
OR path IN (
|
||||||
|
'/lab-sample-processing',
|
||||||
|
'lab-sample-processing/hsc',
|
||||||
|
'lab-sample-processing/ubmc',
|
||||||
|
'lab-sample-processing/msc'
|
||||||
|
)
|
||||||
|
);
|
||||||
@@ -190,6 +190,17 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
menuCode: 'biz:cellStoragePaymentConfirm:list'
|
menuCode: 'biz:cellStoragePaymentConfirm:list'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'CEL0000000000000000000000000LSP1',
|
||||||
|
name: 'CellStorageLabSampleProcess',
|
||||||
|
path: 'lab-sample-process',
|
||||||
|
component: '/quality-inspection/lab-sample-process/index',
|
||||||
|
meta: {
|
||||||
|
title: '实验室样本处理数据',
|
||||||
|
keepAlive: true,
|
||||||
|
menuCode: 'cellStorage:labSampleProcess:list'
|
||||||
|
}
|
||||||
|
},
|
||||||
// 市场侧入库放行审核(总览)暂下线:改由生产/质检入口审核
|
// 市场侧入库放行审核(总览)暂下线:改由生产/质检入口审核
|
||||||
// {
|
// {
|
||||||
// id: '70000000000000000000000000000011',
|
// id: '70000000000000000000000000000011',
|
||||||
@@ -922,6 +933,17 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
menuCode: 'production:waste-output:list'
|
menuCode: 'production:waste-output:list'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'PRM0000000000000000000000000LSP1',
|
||||||
|
name: 'ProductionLabSampleProcess',
|
||||||
|
path: 'lab-sample-process',
|
||||||
|
component: '/quality-inspection/lab-sample-process/index',
|
||||||
|
meta: {
|
||||||
|
title: '实验室样本处理数据',
|
||||||
|
keepAlive: true,
|
||||||
|
menuCode: 'production:labSampleProcess:list'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -1123,17 +1145,6 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
menuCode: 'biz:sampleReception:list'
|
menuCode: 'biz:sampleReception:list'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: '70000000000000000000000000000015',
|
|
||||||
name: 'QualityInspectionLabSampleProcess',
|
|
||||||
path: 'lab-sample-process',
|
|
||||||
component: '/quality-inspection/lab-sample-process/index',
|
|
||||||
meta: {
|
|
||||||
title: '实验室样本处理数据',
|
|
||||||
keepAlive: true,
|
|
||||||
menuCode: 'biz:labSampleProcess:list'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: '70000000000000000000000000000007',
|
id: '70000000000000000000000000000007',
|
||||||
name: 'QualityInspectionQcWorkOrder',
|
name: 'QualityInspectionQcWorkOrder',
|
||||||
@@ -1201,6 +1212,17 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
|||||||
menuCode: 'quality:storageReleaseReview:list'
|
menuCode: 'quality:storageReleaseReview:list'
|
||||||
},
|
},
|
||||||
props: { reviewRole: 'qc' }
|
props: { reviewRole: 'qc' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '70000000000000000000000000000015',
|
||||||
|
name: 'QualityInspectionLabSampleProcess',
|
||||||
|
path: 'lab-sample-process',
|
||||||
|
component: '/quality-inspection/lab-sample-process/index',
|
||||||
|
meta: {
|
||||||
|
title: '实验室样本处理数据',
|
||||||
|
keepAlive: true,
|
||||||
|
menuCode: 'biz:labSampleProcess:list'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -275,15 +275,28 @@
|
|||||||
async function handleExport() {
|
async function handleExport() {
|
||||||
exporting.value = true
|
exporting.value = true
|
||||||
try {
|
try {
|
||||||
|
// 列表接口 pageSize 上限为 200,导出需分页拉全量后再生成 xlsx
|
||||||
|
const pageSize = 200
|
||||||
|
let page = 1
|
||||||
|
let total = Number.POSITIVE_INFINITY
|
||||||
|
const rows: Record<string, any>[] = []
|
||||||
|
let cols = fields.value
|
||||||
|
while (rows.length < total) {
|
||||||
const res = await fetchLabSampleList(props.dataset, {
|
const res = await fetchLabSampleList(props.dataset, {
|
||||||
keyword: searchForm.keyword || undefined,
|
keyword: searchForm.keyword || undefined,
|
||||||
dateFrom: dateRange.value?.[0],
|
dateFrom: dateRange.value?.[0],
|
||||||
dateTo: dateRange.value?.[1],
|
dateTo: dateRange.value?.[1],
|
||||||
page: 1,
|
page,
|
||||||
pageSize: 5000
|
pageSize
|
||||||
})
|
})
|
||||||
const cols = res?.fields?.length ? res.fields : fields.value
|
if (res?.fields?.length) cols = res.fields
|
||||||
const rows = res?.list || []
|
total = Number(res?.total ?? 0)
|
||||||
|
const batch = res?.list || []
|
||||||
|
rows.push(...batch)
|
||||||
|
if (!batch.length || batch.length < pageSize) break
|
||||||
|
page += 1
|
||||||
|
if (page > 500) break
|
||||||
|
}
|
||||||
const ExcelJS = (await import('exceljs')).default
|
const ExcelJS = (await import('exceljs')).default
|
||||||
const workbook = new ExcelJS.Workbook()
|
const workbook = new ExcelJS.Workbook()
|
||||||
const sheet = workbook.addWorksheet(props.title || props.dataset)
|
const sheet = workbook.addWorksheet(props.title || props.dataset)
|
||||||
|
|||||||
@@ -3,18 +3,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-top">
|
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||||||
<h2 class="title-bar-heading">实验室样本处理数据</h2>
|
<div class="panel-pill-tabs__track" role="tablist">
|
||||||
</div>
|
<button
|
||||||
|
|
||||||
<el-tabs v-model="activeTab" class="lab-process-tabs" @tab-change="handleTabChange">
|
|
||||||
<el-tab-pane
|
|
||||||
v-for="tab in LAB_PROCESS_TABS"
|
v-for="tab in LAB_PROCESS_TABS"
|
||||||
:key="tab.key"
|
:key="tab.key"
|
||||||
:label="tab.label"
|
type="button"
|
||||||
:name="tab.key"
|
role="tab"
|
||||||
/>
|
class="panel-pill-tabs__btn"
|
||||||
</el-tabs>
|
:class="{ 'is-active': activeTab === tab.key }"
|
||||||
|
:aria-selected="activeTab === tab.key"
|
||||||
|
@click="handleTabChange(tab.key)"
|
||||||
|
>
|
||||||
|
{{ tab.label }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="filter-block">
|
<div class="filter-block">
|
||||||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||||||
@@ -252,7 +256,9 @@
|
|||||||
handleSearch()
|
handleSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTabChange() {
|
function handleTabChange(name: LabSampleProcessTabKey) {
|
||||||
|
if (activeTab.value === name) return
|
||||||
|
activeTab.value = name
|
||||||
pagination.page = 1
|
pagination.page = 1
|
||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
@@ -335,10 +341,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.lab-process-tabs {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-tip {
|
.form-tip {
|
||||||
margin: 0 0 12px;
|
margin: 0 0 12px;
|
||||||
color: var(--mint-text-muted, #6b7280);
|
color: var(--mint-text-muted, #6b7280);
|
||||||
|
|||||||
Reference in new issue
Block a user