Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9242ed0538 | ||
|
|
2e741b1284 | ||
|
|
6b1bf8a1d2 | ||
|
|
ef3e015ff9 | ||
|
|
a598b17ab9 | ||
|
|
f7890f5560 | ||
|
|
6ea3aed8db | ||
|
|
8349b0ce73 | ||
|
|
85fe63fa9f | ||
|
|
77cdeede15 | ||
|
|
4dc352e4f4 | ||
|
|
c5f26912bd |
No files matched your search
+1
-31
@@ -7,7 +7,7 @@ from app.core.response import success_response
|
||||
router = APIRouter(prefix="/web/menu", tags=["菜单管理"])
|
||||
|
||||
# 与 web-admin/src/router/modules/sqxp.ts 一致:6 个一级菜单分组
|
||||
# 市场二级顺序:存储服务、科研捐赠、市场基础信息、中试服务、临床科研、器械销售
|
||||
# 市场二级顺序:存储服务、科研捐赠、市场基础信息、临床科研、器械销售
|
||||
STATIC_MENU_TREE = [
|
||||
{
|
||||
"id": "TOP00000000000000000000000000006",
|
||||
@@ -298,36 +298,6 @@ STATIC_MENU_TREE = [
|
||||
],
|
||||
},
|
||||
|
||||
# 中试服务
|
||||
{
|
||||
"id": "PIL00000000000000000000000000001",
|
||||
"name": "PilotService",
|
||||
"path": "pilot-service",
|
||||
"component": "",
|
||||
"meta": {
|
||||
"title": "中试服务",
|
||||
"icon": "ri:flask-line",
|
||||
"keepAlive": False,
|
||||
"roles": ["admin"],
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "80000000000000000000000000000010",
|
||||
"name": "PilotApplication",
|
||||
"path": "pilot-application",
|
||||
"component": "/pilot-service/pilot-application/index",
|
||||
"meta": {"title": "中试服务申请单", "keepAlive": True, "menuCode": "pilot-service:pilot-application:list"},
|
||||
},
|
||||
{
|
||||
"id": "PIL00000000000000000000000000004",
|
||||
"name": "PilotOutboundRelease",
|
||||
"path": "outbound-release-review",
|
||||
"component": "/pilot-service/outbound-release-review/index",
|
||||
"meta": {"title": "出库放行审核", "keepAlive": True, "menuCode": "pilot-service:outbound-release-review:list"},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
# 临床科研
|
||||
{
|
||||
"id": "BEX00000000000000000000000000001",
|
||||
|
||||
@@ -53,6 +53,7 @@ class ApplicationCreateBody(BaseModel):
|
||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||
|
||||
|
||||
class ApplicationUpdateBody(BaseModel):
|
||||
@@ -65,6 +66,7 @@ class ApplicationUpdateBody(BaseModel):
|
||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||
|
||||
|
||||
class PatientSaveBody(BaseModel):
|
||||
@@ -206,6 +208,7 @@ class ApplicationSaveBody(BaseModel):
|
||||
customer_name: Optional[str] = Field(None, alias="customerName")
|
||||
customer_contact: Optional[str] = Field(None, alias="customerContact")
|
||||
customer_phone: Optional[str] = Field(None, alias="customerPhone")
|
||||
research_category: Optional[str] = Field(None, alias="researchCategory")
|
||||
remark: Optional[str] = None
|
||||
consent_form_urls: Optional[str] = Field(None, alias="consentFormUrls")
|
||||
consent_attachments: Optional[list] = Field(None, alias="consentAttachments")
|
||||
@@ -287,6 +290,7 @@ async def api_create_application(
|
||||
"customerName": body.customer_name,
|
||||
"customerContact": body.customer_contact,
|
||||
"customerPhone": body.customer_phone,
|
||||
"researchCategory": body.research_category,
|
||||
}
|
||||
result = pilot_application.create_application(
|
||||
db,
|
||||
@@ -322,6 +326,8 @@ async def api_update_application(
|
||||
data["customerContact"] = body.customer_contact
|
||||
if body.customer_phone is not None:
|
||||
data["customerPhone"] = body.customer_phone
|
||||
if body.research_category is not None:
|
||||
data["researchCategory"] = body.research_category
|
||||
result = pilot_application.update_application(
|
||||
db, app_id=body.id, data=data, tenant_no=tenant_no
|
||||
)
|
||||
@@ -364,6 +370,8 @@ async def api_save_application(
|
||||
app_data["customerContact"] = body.customer_contact
|
||||
if body.customer_phone is not None:
|
||||
app_data["customerPhone"] = body.customer_phone
|
||||
if body.research_category is not None:
|
||||
app_data["researchCategory"] = body.research_category
|
||||
if body.consent_attachments is not None:
|
||||
app_data["consentAttachments"] = body.consent_attachments
|
||||
elif body.consent_form_urls is not None:
|
||||
@@ -380,7 +388,11 @@ async def api_save_application(
|
||||
):
|
||||
return error_response(400, "请选择渠道服务订单")
|
||||
|
||||
if not is_edit and biz_type == "clinical_application" and not app_data["channelId"]:
|
||||
if (
|
||||
not is_edit
|
||||
and biz_type in ("clinical_application", "basic_experiment")
|
||||
and not app_data["channelId"]
|
||||
):
|
||||
return error_response(400, "请选择渠道")
|
||||
|
||||
if is_edit:
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,27 @@
|
||||
"""临床科研申请单 · 业务子类型(research_category)"""
|
||||
from typing import Optional
|
||||
|
||||
RESEARCH_CATEGORY_LABELS = {
|
||||
"bio_tech_clinical": "生物新技术临床科研",
|
||||
"joint_topic_declare": "临床课题联合申报",
|
||||
"bio_pharma_rd": "生物制药研发",
|
||||
}
|
||||
|
||||
RESEARCH_CATEGORY_CODES = tuple(RESEARCH_CATEGORY_LABELS.keys())
|
||||
|
||||
|
||||
def research_category_label(code: Optional[str]) -> str:
|
||||
if not code:
|
||||
return ""
|
||||
return RESEARCH_CATEGORY_LABELS.get(code, code)
|
||||
|
||||
|
||||
def validate_research_category(code: Optional[str], required: bool = False) -> str:
|
||||
value = (code or "").strip()
|
||||
if not value:
|
||||
if required:
|
||||
raise ValueError("请选择业务类型")
|
||||
return ""
|
||||
if value not in RESEARCH_CATEGORY_LABELS:
|
||||
raise ValueError("业务类型无效")
|
||||
return value
|
||||
@@ -25,6 +25,7 @@ from app.models.models import (
|
||||
)
|
||||
from app.crud import pilot_checkup
|
||||
from app.crud.collection_protocol import attachments_to_urls, urls_to_attachment_list
|
||||
from app.constants.research_category import validate_research_category
|
||||
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
@@ -125,6 +126,7 @@ def _row_to_dict_application(row, db=None, tenant_no=None) -> Dict[str, Any]:
|
||||
"customerName": row.customer_name or "",
|
||||
"customerContact": row.customer_contact or "",
|
||||
"customerPhone": row.customer_phone or "",
|
||||
"researchCategory": getattr(row, "research_category", None) or "",
|
||||
"applicationStatus": row.application_status or "",
|
||||
"bizType": row.biz_type or "pilot_service",
|
||||
"channelServiceOrderId": row.channel_service_order_id or "",
|
||||
@@ -455,6 +457,7 @@ def create_application(
|
||||
customer_name = ""
|
||||
customer_contact = ""
|
||||
customer_phone = ""
|
||||
research_category = ""
|
||||
consent_form_urls = data.get("consentFormUrls") or None
|
||||
|
||||
if biz_type == "basic_experiment":
|
||||
@@ -466,13 +469,29 @@ def create_application(
|
||||
raise ValueError("请填写客户联系人")
|
||||
if not (data.get("customerPhone") or "").strip():
|
||||
raise ValueError("请填写客户联系方式")
|
||||
research_category = validate_research_category(
|
||||
data.get("researchCategory"), required=True
|
||||
)
|
||||
project_title = (data.get("projectTitle") or "").strip()
|
||||
customer_name = (data.get("customerName") or "").strip()
|
||||
customer_contact = (data.get("customerContact") or "").strip()
|
||||
customer_phone = (data.get("customerPhone") or "").strip()
|
||||
channel_service_order_id = ""
|
||||
channel_id = ""
|
||||
channel_name = ""
|
||||
channel_id = (data.get("channelId") or "").strip()
|
||||
if not channel_id:
|
||||
raise ValueError("请选择渠道")
|
||||
ch = (
|
||||
db.query(BizChannel)
|
||||
.filter(
|
||||
BizChannel.id == channel_id,
|
||||
BizChannel.tenant_no == tenant_no,
|
||||
BizChannel.del_flag == 0,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if not ch:
|
||||
raise ValueError("渠道不存在")
|
||||
channel_name = ch.channel_name or ""
|
||||
consent_form_urls = None
|
||||
elif not channel_service_order_id and biz_type != "clinical_application":
|
||||
raise ValueError("请选择渠道服务订单")
|
||||
@@ -527,6 +546,7 @@ def create_application(
|
||||
customer_name=customer_name or None,
|
||||
customer_contact=customer_contact or None,
|
||||
customer_phone=customer_phone or None,
|
||||
research_category=research_category or None,
|
||||
application_status="dks",
|
||||
channel_service_order_id=channel_service_order_id or "",
|
||||
channel_id=(
|
||||
@@ -586,6 +606,35 @@ def update_application(db: Session, app_id: str, data: dict, tenant_no: str) ->
|
||||
row.customer_contact = (data["customerContact"] or "").strip() or None
|
||||
if "customerPhone" in data and data["customerPhone"] is not None:
|
||||
row.customer_phone = (data["customerPhone"] or "").strip() or None
|
||||
if "researchCategory" in data and data["researchCategory"] is not None:
|
||||
if (row.biz_type or "") == "basic_experiment":
|
||||
row.research_category = validate_research_category(
|
||||
data.get("researchCategory"), required=True
|
||||
) or None
|
||||
else:
|
||||
row.research_category = validate_research_category(
|
||||
data.get("researchCategory"), required=False
|
||||
) or None
|
||||
if "channelId" in data and data["channelId"] is not None:
|
||||
if (row.biz_type or "") in ("basic_experiment", "clinical_application"):
|
||||
new_channel_id = (data.get("channelId") or "").strip()
|
||||
if not new_channel_id:
|
||||
raise ValueError("请选择渠道")
|
||||
ch = (
|
||||
db.query(BizChannel)
|
||||
.filter(
|
||||
BizChannel.id == new_channel_id,
|
||||
BizChannel.tenant_no == tenant_no,
|
||||
BizChannel.del_flag == 0,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if not ch:
|
||||
raise ValueError("渠道不存在")
|
||||
row.channel_id = new_channel_id
|
||||
row.channel_name = ch.channel_name or ""
|
||||
if (row.biz_type or "") == "basic_experiment":
|
||||
row.channel_service_order_id = ""
|
||||
if "consentFormUrls" in data:
|
||||
row.consent_form_urls = data.get("consentFormUrls") or None
|
||||
if "attachmentUrls" in data:
|
||||
|
||||
@@ -4182,6 +4182,11 @@ class BizPilotApplication(Base):
|
||||
customer_name = Column(String(200), nullable=True, comment="客户名称(临床科研)")
|
||||
customer_contact = Column(String(100), nullable=True, comment="客户联系人(临床科研)")
|
||||
customer_phone = Column(String(32), nullable=True, comment="客户联系方式(临床科研)")
|
||||
research_category = Column(
|
||||
String(32),
|
||||
nullable=True,
|
||||
comment="临床科研业务子类型: bio_tech_clinical/joint_topic_declare/bio_pharma_rd",
|
||||
)
|
||||
application_status = Column(String(16), nullable=False, default="dks", comment="dks待开始 jxz进行中 ywc已完成 yzf已作废")
|
||||
channel_service_order_id = Column(String(64), nullable=False, comment="渠道服务购买订单ID")
|
||||
channel_id = Column(String(64), nullable=True, comment="渠道ID(缓存自服务订单)")
|
||||
|
||||
@@ -28,6 +28,8 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
||||
db = MagicMock()
|
||||
data = {
|
||||
"bizType": "basic_experiment",
|
||||
"researchCategory": "bio_tech_clinical",
|
||||
"channelId": "ch-1",
|
||||
"projectTitle": "课题A",
|
||||
"customerName": "",
|
||||
"customerContact": "张三",
|
||||
@@ -43,6 +45,46 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("客户名称", str(ctx.exception))
|
||||
|
||||
def test_create_basic_experiment_requires_research_category(self):
|
||||
db = MagicMock()
|
||||
data = {
|
||||
"bizType": "basic_experiment",
|
||||
"channelId": "ch-1",
|
||||
"projectTitle": "课题A",
|
||||
"customerName": "客户A",
|
||||
"customerContact": "张三",
|
||||
"customerPhone": "13800000000",
|
||||
}
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
crud.create_application(
|
||||
db,
|
||||
data=data,
|
||||
tenant_no="zkxw",
|
||||
user_id="user-1",
|
||||
dept_id="dept-1",
|
||||
)
|
||||
self.assertIn("业务类型", str(ctx.exception))
|
||||
|
||||
def test_create_basic_experiment_requires_channel(self):
|
||||
db = MagicMock()
|
||||
data = {
|
||||
"bizType": "basic_experiment",
|
||||
"researchCategory": "bio_tech_clinical",
|
||||
"projectTitle": "课题A",
|
||||
"customerName": "客户A",
|
||||
"customerContact": "张三",
|
||||
"customerPhone": "13800000000",
|
||||
}
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
crud.create_application(
|
||||
db,
|
||||
data=data,
|
||||
tenant_no="zkxw",
|
||||
user_id="user-1",
|
||||
dept_id="dept-1",
|
||||
)
|
||||
self.assertIn("渠道", str(ctx.exception))
|
||||
|
||||
|
||||
class TestBasicExperimentSaleSchedules(unittest.TestCase):
|
||||
@patch("app.crud.pilot_application.create_schedule")
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
"""市场下「中试服务」已从静态菜单树下线(Issue #158)。"""
|
||||
import ast
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MENU_PY = ROOT / "backend/app/api/menu.py"
|
||||
SQXP_TS = ROOT / "web-admin/src/router/modules/sqxp.ts"
|
||||
HIDE_SQL = ROOT / "docs/sql/migrations/2026-11-20-hide-market-pilot-service-menus.sql"
|
||||
|
||||
|
||||
def _market_children_titles_from_menu_py() -> list[str]:
|
||||
source = MENU_PY.read_text(encoding="utf-8")
|
||||
tree_match = re.search(r"STATIC_MENU_TREE\s*=\s*(\[[\s\S]*?\n\])\s*\n", source)
|
||||
assert tree_match, "STATIC_MENU_TREE not found"
|
||||
tree = ast.literal_eval(tree_match.group(1))
|
||||
market = next(
|
||||
node
|
||||
for node in tree
|
||||
if isinstance(node, dict) and (node.get("meta") or {}).get("menuCode") == "menu:market"
|
||||
)
|
||||
titles = []
|
||||
for child in market.get("children") or []:
|
||||
meta = child.get("meta") or {}
|
||||
titles.append(str(meta.get("title") or ""))
|
||||
return titles
|
||||
|
||||
|
||||
def test_backend_static_menu_has_no_market_pilot_service():
|
||||
titles = _market_children_titles_from_menu_py()
|
||||
assert "中试服务" not in titles
|
||||
assert "中试服务申请单" not in titles
|
||||
|
||||
|
||||
def test_frontend_sqxp_has_no_market_pilot_service_block():
|
||||
text = SQXP_TS.read_text(encoding="utf-8")
|
||||
assert "name: 'PilotService'" not in text
|
||||
assert "id: 'PIL00000000000000000000000000001'" not in text
|
||||
assert "pilot-service:pilot-application:list" not in text
|
||||
# 基础实验 / 临床仍可复用出库放行组件与权限码前缀
|
||||
assert "basic-experiment:outbound-release-review:list" in text
|
||||
assert "clinical-application:outbound-release-review:list" in text
|
||||
|
||||
|
||||
def test_hide_sql_soft_deletes_sys_menu_only_under_market_pilot():
|
||||
sql = HIDE_SQL.read_text(encoding="utf-8")
|
||||
compact = re.sub(r"\s+", " ", re.sub(r"--[^\n]*", "", sql))
|
||||
assert re.search(r"UPDATE\s+sys_menu", compact, re.IGNORECASE)
|
||||
assert re.search(r"SET\s+m\.del_flag\s*=\s*1", compact, re.IGNORECASE)
|
||||
assert "menu:market" in compact
|
||||
assert "中试服务" in compact
|
||||
assert not re.search(r"DELETE\s+FROM\s+sys_menu", compact, re.IGNORECASE)
|
||||
@@ -0,0 +1,62 @@
|
||||
"""Static checks for market/pilot-service role-menu revoke migration (#156)."""
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MIGRATION = (
|
||||
Path(__file__).resolve().parents[2]
|
||||
/ "docs/sql/migrations/2026-11-20-revoke-market-pilot-service-role-menus.sql"
|
||||
)
|
||||
|
||||
|
||||
def _sql() -> str:
|
||||
return MIGRATION.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _compact(sql: str) -> str:
|
||||
return re.sub(r"\s+", " ", sql)
|
||||
|
||||
|
||||
def _without_comments(sql: str) -> str:
|
||||
return re.sub(r"--[^\n]*", "", sql)
|
||||
|
||||
|
||||
def test_migration_file_exists():
|
||||
assert MIGRATION.is_file()
|
||||
|
||||
|
||||
def test_scopes_to_market_pilot_service_tree():
|
||||
compact = _compact(_without_comments(_sql()))
|
||||
assert "menu:market" in compact
|
||||
assert "中试服务" in compact
|
||||
assert re.search(r"pilot\.menu_name\s*=\s*'中试服务'", compact)
|
||||
assert re.search(r"market\.perms\s*=\s*'menu:market'", compact)
|
||||
|
||||
|
||||
def test_revokes_role_menu_by_soft_delete_only():
|
||||
compact = _compact(_without_comments(_sql()))
|
||||
assert re.search(r"UPDATE\s+sys_role_menu", compact, re.IGNORECASE)
|
||||
assert re.search(
|
||||
r"UPDATE\s+sys_role_menu\s+rm\b.*SET\s+rm\.del_flag\s*=\s*1",
|
||||
compact,
|
||||
re.IGNORECASE,
|
||||
)
|
||||
assert not re.search(r"DELETE\s+FROM\s+sys_role_menu", compact, re.IGNORECASE)
|
||||
assert not re.search(r"UPDATE\s+sys_menu\s+SET\s+del_flag\s*=\s*1", compact, re.IGNORECASE)
|
||||
assert not re.search(r"DELETE\s+FROM\s+sys_menu", compact, re.IGNORECASE)
|
||||
|
||||
|
||||
def test_includes_children_and_button_descendants():
|
||||
compact = _compact(_without_comments(_sql()))
|
||||
assert re.search(r"child\.parent_id\s*=\s*pilot\.id", compact)
|
||||
assert re.search(r"btn\.parent_id\s*=\s*child\.id", compact)
|
||||
assert compact.count("UNION") >= 2
|
||||
|
||||
|
||||
def test_update_only_touches_active_bindings():
|
||||
compact = _compact(_without_comments(_sql()))
|
||||
assert re.search(
|
||||
r"SET\s+rm\.del_flag\s*=\s*1[\s\S]*WHERE\s+rm\.del_flag\s*=\s*0",
|
||||
compact,
|
||||
re.IGNORECASE,
|
||||
)
|
||||
@@ -0,0 +1,129 @@
|
||||
-- 软删【市场】下【中试服务】目录及其子菜单(含按钮),与前端静态路由下线对齐。
|
||||
-- Issue #158(承接 #156:仅解绑角色对超管侧栏无效)
|
||||
-- MySQL 5.7,可重复执行;不影响基础实验/临床应用下同名菜单。
|
||||
|
||||
-- 0) 预览目标菜单
|
||||
SELECT
|
||||
m.tenant_no,
|
||||
m.id AS menu_id,
|
||||
m.menu_name,
|
||||
m.menu_type,
|
||||
m.perms,
|
||||
m.parent_id,
|
||||
m.del_flag
|
||||
FROM sys_menu m
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = m.id
|
||||
AND tgt.tenant_no = m.tenant_no
|
||||
WHERE m.del_flag = 0
|
||||
ORDER BY m.tenant_no, m.menu_type, m.order_num, m.menu_name;
|
||||
|
||||
-- 1) 软删目标菜单
|
||||
UPDATE sys_menu m
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = m.id
|
||||
AND tgt.tenant_no = m.tenant_no
|
||||
SET
|
||||
m.del_flag = 1,
|
||||
m.update_by = 'migration',
|
||||
m.update_time = NOW()
|
||||
WHERE m.del_flag = 0;
|
||||
|
||||
-- 2) 核对:市场下不应再有有效「中试服务」目录(期望 0 行)
|
||||
SELECT
|
||||
market.tenant_no,
|
||||
pilot.id,
|
||||
pilot.menu_name,
|
||||
pilot.del_flag
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market';
|
||||
@@ -0,0 +1,20 @@
|
||||
-- 临床科研申请单:业务子类型 research_category
|
||||
-- MySQL 5.7,可重复执行。
|
||||
|
||||
SET @col_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'biz_pilot_application'
|
||||
AND COLUMN_NAME = 'research_category'
|
||||
);
|
||||
|
||||
SET @sql := IF(
|
||||
@col_exists = 0,
|
||||
"ALTER TABLE biz_pilot_application ADD COLUMN research_category VARCHAR(32) NULL COMMENT '临床科研业务子类型: bio_tech_clinical/joint_topic_declare/bio_pharma_rd' AFTER customer_phone",
|
||||
'SELECT 1'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
@@ -0,0 +1,256 @@
|
||||
-- 解除【市场】下【中试服务】目录及其全部子菜单(含按钮)与角色的绑定。
|
||||
-- Issue #156
|
||||
-- 仅软删 sys_role_menu(del_flag=1),不删除/隐藏菜单本身。
|
||||
-- 按树定位:menu:market → menu_name=中试服务 → 直系子菜单 → 孙级按钮;
|
||||
-- 不匹配基础实验/临床应用等其他目录下的同名「出库放行审核」。
|
||||
-- MySQL 5.7,可重复执行(只处理 del_flag=0 的绑定)。
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 0) 预览:将要解绑的目标菜单(目录 + 子菜单 + 按钮)
|
||||
-- ---------------------------------------------------------------------------
|
||||
SELECT
|
||||
m.tenant_no,
|
||||
m.id AS menu_id,
|
||||
m.menu_name,
|
||||
m.menu_type,
|
||||
m.perms,
|
||||
m.parent_id,
|
||||
m.path
|
||||
FROM sys_menu m
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = m.id
|
||||
AND tgt.tenant_no = m.tenant_no
|
||||
WHERE m.del_flag = 0
|
||||
ORDER BY m.tenant_no, m.menu_type, m.order_num, m.menu_name;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 1) 预览:将要软删的角色-菜单绑定
|
||||
-- ---------------------------------------------------------------------------
|
||||
SELECT
|
||||
rm.tenant_no,
|
||||
r.id AS role_id,
|
||||
r.role_name,
|
||||
m.id AS menu_id,
|
||||
m.menu_name,
|
||||
m.menu_type,
|
||||
m.perms,
|
||||
rm.id AS role_menu_id
|
||||
FROM sys_role_menu rm
|
||||
JOIN sys_role r
|
||||
ON r.id = rm.role_id
|
||||
AND r.tenant_no = rm.tenant_no
|
||||
AND r.del_flag = 0
|
||||
JOIN sys_menu m
|
||||
ON m.id = rm.menu_id
|
||||
AND m.tenant_no = rm.tenant_no
|
||||
AND m.del_flag = 0
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = rm.menu_id
|
||||
AND tgt.tenant_no = rm.tenant_no
|
||||
WHERE rm.del_flag = 0
|
||||
ORDER BY rm.tenant_no, r.role_name, m.menu_name;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 2) 软删绑定(可重复执行)
|
||||
-- ---------------------------------------------------------------------------
|
||||
UPDATE sys_role_menu rm
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = rm.menu_id
|
||||
AND tgt.tenant_no = rm.tenant_no
|
||||
SET
|
||||
rm.del_flag = 1,
|
||||
rm.update_by = 'migration',
|
||||
rm.update_time = NOW()
|
||||
WHERE rm.del_flag = 0;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 3) 核对:目标菜单上不应再有有效角色绑定(期望 0 行)
|
||||
-- ---------------------------------------------------------------------------
|
||||
SELECT
|
||||
rm.tenant_no,
|
||||
r.role_name,
|
||||
m.menu_name,
|
||||
m.perms,
|
||||
COUNT(*) AS active_role_menu_rows
|
||||
FROM sys_role_menu rm
|
||||
JOIN sys_role r
|
||||
ON r.id = rm.role_id
|
||||
AND r.tenant_no = rm.tenant_no
|
||||
AND r.del_flag = 0
|
||||
JOIN sys_menu m
|
||||
ON m.id = rm.menu_id
|
||||
AND m.tenant_no = rm.tenant_no
|
||||
AND m.del_flag = 0
|
||||
JOIN (
|
||||
SELECT pilot.id AS menu_id, pilot.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT child.id, child.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
UNION
|
||||
SELECT btn.id, btn.tenant_no
|
||||
FROM sys_menu market
|
||||
JOIN sys_menu pilot
|
||||
ON pilot.parent_id = market.id
|
||||
AND pilot.tenant_no = market.tenant_no
|
||||
AND pilot.del_flag = 0
|
||||
AND pilot.menu_name = '中试服务'
|
||||
JOIN sys_menu child
|
||||
ON child.parent_id = pilot.id
|
||||
AND child.tenant_no = market.tenant_no
|
||||
AND child.del_flag = 0
|
||||
JOIN sys_menu btn
|
||||
ON btn.parent_id = child.id
|
||||
AND btn.tenant_no = market.tenant_no
|
||||
AND btn.del_flag = 0
|
||||
WHERE market.del_flag = 0
|
||||
AND market.perms = 'menu:market'
|
||||
) tgt
|
||||
ON tgt.menu_id = rm.menu_id
|
||||
AND tgt.tenant_no = rm.tenant_no
|
||||
WHERE rm.del_flag = 0
|
||||
GROUP BY rm.tenant_no, r.role_name, m.menu_name, m.perms;
|
||||
@@ -62,7 +62,7 @@ export const PILOT_BIZ_TYPE_CONFIG: Record<PilotBizType, PilotBizTypeConfig> = {
|
||||
basic_experiment: {
|
||||
label: '临床科研',
|
||||
applicationNoPrefix: 'JCSY',
|
||||
showChannel: false,
|
||||
showChannel: true,
|
||||
showPatient: false,
|
||||
showConsent: false,
|
||||
showOtherAttachments: false,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/** 临床科研申请单 · 业务子类型(researchCategory) */
|
||||
export const CLINICAL_RESEARCH_CATEGORY_OPTIONS = [
|
||||
{ value: 'bio_tech_clinical', label: '生物新技术临床科研' },
|
||||
{ value: 'joint_topic_declare', label: '临床课题联合申报' },
|
||||
{ value: 'bio_pharma_rd', label: '生物制药研发' }
|
||||
] as const
|
||||
|
||||
export type ClinicalResearchCategory =
|
||||
(typeof CLINICAL_RESEARCH_CATEGORY_OPTIONS)[number]['value']
|
||||
|
||||
const LABEL_MAP = Object.fromEntries(
|
||||
CLINICAL_RESEARCH_CATEGORY_OPTIONS.map((o) => [o.value, o.label])
|
||||
) as Record<string, string>
|
||||
|
||||
export function clinicalResearchCategoryLabel(code?: string | null): string {
|
||||
if (!code) return ''
|
||||
return LABEL_MAP[code] || code
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
},
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// 1. 市场 (menu:market)
|
||||
// 二级菜单:存储服务、科研捐赠、市场基础信息、中试服务、临床科研、器械销售
|
||||
// 二级菜单:存储服务、科研捐赠、市场基础信息、临床科研、器械销售
|
||||
// (主推存储/捐赠在前;中试/临床科研及关联基础信息后置;器械销售在末位)
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
{
|
||||
@@ -553,72 +553,6 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
]
|
||||
},
|
||||
|
||||
// ── 中试服务 ──────────────────────────────────────────────────────────
|
||||
{
|
||||
id: 'PIL00000000000000000000000000001',
|
||||
name: 'PilotService',
|
||||
path: 'pilot-service',
|
||||
component: '',
|
||||
meta: {
|
||||
title: '中试服务',
|
||||
icon: 'ri:flask-line',
|
||||
keepAlive: false,
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: '80000000000000000000000000000010',
|
||||
name: 'PilotApplication',
|
||||
path: 'pilot-application',
|
||||
component: '/pilot-service/pilot-application/index',
|
||||
meta: {
|
||||
title: '中试服务申请单',
|
||||
keepAlive: true,
|
||||
menuCode: 'pilot-service:pilot-application:list'
|
||||
},
|
||||
props: { bizType: 'pilot_service' }
|
||||
},
|
||||
{
|
||||
id: 'PIL00000000000000000000000000002',
|
||||
name: 'PilotCheckupManagement',
|
||||
path: 'checkup-management',
|
||||
component: '/pilot-service/checkup-management/index',
|
||||
meta: {
|
||||
title: '体检管理',
|
||||
keepAlive: false,
|
||||
isHide: true,
|
||||
menuCode: 'pilot-service:checkup-management:list'
|
||||
},
|
||||
props: { bizType: 'pilot_service' }
|
||||
},
|
||||
{
|
||||
id: 'PIL00000000000000000000000000003',
|
||||
name: 'PilotInfusionSchedule',
|
||||
path: 'infusion-schedule-management',
|
||||
component: '/pilot-service/infusion-schedule-management/index',
|
||||
meta: {
|
||||
title: '输注计划管理',
|
||||
keepAlive: false,
|
||||
isHide: true,
|
||||
menuCode: 'pilot-service:infusion-schedule-management:list'
|
||||
},
|
||||
props: { bizType: 'pilot_service' }
|
||||
},
|
||||
{
|
||||
id: 'PIL00000000000000000000000000004',
|
||||
name: 'PilotOutboundRelease',
|
||||
path: 'outbound-release-review',
|
||||
component: '/pilot-service/outbound-release-review/index',
|
||||
meta: {
|
||||
title: '出库放行审核',
|
||||
keepAlive: true,
|
||||
menuCode: 'pilot-service:outbound-release-review:list'
|
||||
},
|
||||
props: { bizType: 'pilot_service' }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// ── 临床科研 ──────────────────────────────────────────────────────────
|
||||
{
|
||||
id: 'BEX00000000000000000000000000001',
|
||||
|
||||
@@ -6,7 +6,8 @@ import {
|
||||
resolveTabKeyFromWorkOrder,
|
||||
getProductionWorkOrderTab,
|
||||
toWorkOrderListQuery,
|
||||
isAllProductionWorkOrderTab
|
||||
isAllProductionWorkOrderTab,
|
||||
workOrderMatchesTab
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
import { toAllTabListQuery, workOrderMatchesCategory } from '@/utils/production-work-order-category'
|
||||
import { matchesWorkOrderStatusFilter } from '@/utils/status-tag-registry'
|
||||
@@ -231,9 +232,7 @@ export function filterMineEntriesByWorkOrderSearch(
|
||||
const tabKey = filters.tabKey
|
||||
return entries.filter((entry) => {
|
||||
const row = entry.workOrder
|
||||
if (!isAllProductionWorkOrderTab(tabKey) && resolveTabKeyFromWorkOrder(row) !== tabKey) {
|
||||
return false
|
||||
}
|
||||
if (!workOrderMatchesTab(row, tabKey)) return false
|
||||
if (
|
||||
isAllProductionWorkOrderTab(tabKey) &&
|
||||
!workOrderMatchesCategory(row, filters.productionCategory || '')
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
PRODUCTION_WORK_ORDER_VISIBLE_TABS,
|
||||
parseProductionWorkOrderTabKey,
|
||||
workOrderMatchesTab,
|
||||
isPilotServiceOutboundWorkOrder
|
||||
} from './production-work-order-tabs'
|
||||
import { PRODUCTION_WORK_ORDER_CATEGORY_OPTIONS } from './production-work-order-category'
|
||||
|
||||
describe('production work order tabs — hide pilot service', () => {
|
||||
it('visible tabs exclude outbound_pilot_service', () => {
|
||||
assert.ok(!PRODUCTION_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_pilot_service'))
|
||||
assert.ok(!PRODUCTION_WORK_ORDER_CATEGORY_OPTIONS.some((o) => o.key === 'outbound_pilot_service'))
|
||||
})
|
||||
|
||||
it('parse: hidden pilot key and outbound alias fall back safely', () => {
|
||||
assert.equal(parseProductionWorkOrderTabKey('outbound_pilot_service'), 'all')
|
||||
assert.equal(parseProductionWorkOrderTabKey('outbound'), 'outbound_basic_experiment')
|
||||
})
|
||||
|
||||
it('「所有」excludes pilot outbound (incl. default bizType)', () => {
|
||||
const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' }
|
||||
const defaultPilot = { workOrderType: 'outbound' }
|
||||
const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' }
|
||||
assert.equal(isPilotServiceOutboundWorkOrder(pilot), true)
|
||||
assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true)
|
||||
assert.equal(workOrderMatchesTab(pilot as any, 'all'), false)
|
||||
assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false)
|
||||
assert.equal(workOrderMatchesTab(basic as any, 'all'), true)
|
||||
})
|
||||
})
|
||||
@@ -53,7 +53,9 @@ export const PRODUCTION_WORK_ORDER_TABS: ProductionWorkOrderTabConfig[] = [
|
||||
group: 'outbound',
|
||||
workOrderType: 'outbound',
|
||||
bizType: 'pilot_service',
|
||||
listLayout: 'standalone'
|
||||
listLayout: 'standalone',
|
||||
/** 客户已下线中试业务:侧栏不展示,路由 key 保留供历史解析 */
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
key: 'outbound_basic_experiment',
|
||||
@@ -97,7 +99,7 @@ export function parseProductionWorkOrderTabKey(raw?: string | null): ProductionW
|
||||
const tab = getProductionWorkOrderTab(k)
|
||||
if (tab && !tab.hidden) return tab.key
|
||||
if (k === 'inbound') return 'inbound_cell_storage'
|
||||
if (k === 'outbound') return 'outbound_pilot_service'
|
||||
if (k === 'outbound') return 'outbound_basic_experiment'
|
||||
if (k === 'temporary') return 'temporary'
|
||||
return DEFAULT_PRODUCTION_WORK_ORDER_TAB
|
||||
}
|
||||
@@ -145,11 +147,19 @@ export function keywordPlaceholderForTab(tab: ProductionWorkOrderTabConfig): str
|
||||
return '工单号/样本编码/入库编码'
|
||||
}
|
||||
|
||||
/** 出库中试服务(含 bizType 缺省落成中试) */
|
||||
export function isPilotServiceOutboundWorkOrder(row: {
|
||||
workOrderType?: string
|
||||
bizType?: string
|
||||
}): boolean {
|
||||
return resolveTabKeyFromWorkOrder(row) === 'outbound_pilot_service'
|
||||
}
|
||||
|
||||
export function workOrderMatchesTab(
|
||||
row: ProductionWorkOrderItem,
|
||||
tabKey: ProductionWorkOrderTabKey
|
||||
): boolean {
|
||||
if (tabKey === 'all') return true
|
||||
if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row)
|
||||
return resolveTabKeyFromWorkOrder(row) === tabKey
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
import type { BizType, ProjectRecord } from '@/api/project-management'
|
||||
|
||||
/**
|
||||
* 项目新建/编辑弹窗「业务类型」选项。
|
||||
* 中试服务已下线:默认不可选;若旧项目已含 pilot_service 则保留展示。
|
||||
*/
|
||||
export function projectBizTypeSelectLabels(
|
||||
allLabels: Record<string, string>,
|
||||
selectedBizTypes?: string[] | null
|
||||
): Record<string, string> {
|
||||
const selected = new Set((selectedBizTypes || []).filter(Boolean))
|
||||
return Object.fromEntries(
|
||||
Object.entries(allLabels).filter(([key]) => {
|
||||
if (key === 'presign') return false
|
||||
if (key === 'pilot_service') return selected.has('pilot_service')
|
||||
return true
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/** Drill-down uses the last successful statistics query, never unsaved filter edits. */
|
||||
export function buildDrillFilters(
|
||||
applied: ProjectRecord,
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
tabUsesInfusionTimeFilter,
|
||||
getQcWorkOrderTab,
|
||||
toWorkOrderListQuery,
|
||||
isAllQcWorkOrderTab
|
||||
isAllQcWorkOrderTab,
|
||||
workOrderMatchesTab
|
||||
} from '@/utils/qc-work-order-tabs'
|
||||
import {
|
||||
matchesAllTabTriggerSource,
|
||||
@@ -101,9 +102,7 @@ export function filterMineEntriesByWorkOrderSearch(
|
||||
const tab = getQcWorkOrderTab(tabKey)!
|
||||
return entries.filter((entry) => {
|
||||
const row = entry.workOrder
|
||||
if (!isAllQcWorkOrderTab(tabKey) && resolveTabKeyFromWorkOrder(row) !== tabKey) {
|
||||
return false
|
||||
}
|
||||
if (!workOrderMatchesTab(row, tabKey)) return false
|
||||
if (isAllQcWorkOrderTab(tabKey) && !workOrderMatchesCategory(row, filters.qcCategory || '')) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { describe, it } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import {
|
||||
QC_WORK_ORDER_VISIBLE_TABS,
|
||||
parseQcWorkOrderTabKey,
|
||||
workOrderMatchesTab,
|
||||
isPilotServiceOutboundWorkOrder
|
||||
} from './qc-work-order-tabs'
|
||||
import { QC_WORK_ORDER_CATEGORY_OPTIONS } from './qc-work-order-category'
|
||||
|
||||
describe('qc work order tabs — hide pilot service', () => {
|
||||
it('visible tabs exclude outbound_pilot_service', () => {
|
||||
assert.ok(!QC_WORK_ORDER_VISIBLE_TABS.some((t) => t.key === 'outbound_pilot_service'))
|
||||
assert.ok(!QC_WORK_ORDER_CATEGORY_OPTIONS.some((o) => o.key === 'outbound_pilot_service'))
|
||||
})
|
||||
|
||||
it('parse: hidden pilot key and outbound alias fall back safely', () => {
|
||||
// 质检默认 Tab 为细胞存储(「所有」本身也是 hidden)
|
||||
assert.equal(parseQcWorkOrderTabKey('outbound_pilot_service'), 'inbound_cell_storage')
|
||||
assert.equal(parseQcWorkOrderTabKey('outbound'), 'outbound_basic_experiment')
|
||||
})
|
||||
|
||||
it('「所有」excludes pilot outbound (incl. default bizType)', () => {
|
||||
const pilot = { workOrderType: 'outbound', bizType: 'pilot_service' }
|
||||
const defaultPilot = { workOrderType: 'outbound' }
|
||||
const basic = { workOrderType: 'outbound', bizType: 'basic_experiment' }
|
||||
assert.equal(isPilotServiceOutboundWorkOrder(pilot), true)
|
||||
assert.equal(isPilotServiceOutboundWorkOrder(defaultPilot), true)
|
||||
assert.equal(workOrderMatchesTab(pilot as any, 'all'), false)
|
||||
assert.equal(workOrderMatchesTab(defaultPilot as any, 'all'), false)
|
||||
assert.equal(workOrderMatchesTab(basic as any, 'all'), true)
|
||||
})
|
||||
})
|
||||
@@ -53,7 +53,9 @@ export const QC_WORK_ORDER_TABS: QcWorkOrderTabConfig[] = [
|
||||
group: 'outbound',
|
||||
workOrderType: 'outbound',
|
||||
bizType: 'pilot_service',
|
||||
listLayout: 'outbound-grouped'
|
||||
listLayout: 'outbound-grouped',
|
||||
/** 客户已下线中试业务:侧栏不展示,路由 key 保留供历史解析 */
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
key: 'outbound_basic_experiment',
|
||||
@@ -95,7 +97,7 @@ export function parseQcWorkOrderTabKey(raw?: string | null): QcWorkOrderTabKey {
|
||||
const tab = getQcWorkOrderTab(k)
|
||||
if (tab && !tab.hidden) return tab.key
|
||||
if (k === 'inbound') return 'inbound_cell_storage'
|
||||
if (k === 'outbound') return 'outbound_pilot_service'
|
||||
if (k === 'outbound') return 'outbound_basic_experiment'
|
||||
if (k === 'temporary') return 'temporary'
|
||||
return DEFAULT_QC_WORK_ORDER_TAB
|
||||
}
|
||||
@@ -160,8 +162,16 @@ export function filterTimeLabelForTab(tab: QcWorkOrderTabConfig): string {
|
||||
return '创建时间'
|
||||
}
|
||||
|
||||
/** 出库中试服务(含 bizType 缺省落成中试) */
|
||||
export function isPilotServiceOutboundWorkOrder(row: {
|
||||
workOrderType?: string
|
||||
bizType?: string
|
||||
}): boolean {
|
||||
return resolveTabKeyFromWorkOrder(row) === 'outbound_pilot_service'
|
||||
}
|
||||
|
||||
export function workOrderMatchesTab(row: QcWorkOrder, tabKey: QcWorkOrderTabKey): boolean {
|
||||
if (tabKey === 'all') return true
|
||||
if (tabKey === 'all') return !isPilotServiceOutboundWorkOrder(row)
|
||||
return resolveTabKeyFromWorkOrder(row) === tabKey
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,39 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<template v-if="isBasicExperiment">
|
||||
<el-form-item label="业务类型" prop="researchCategory">
|
||||
<el-select
|
||||
v-model="formData.researchCategory"
|
||||
class="w-full"
|
||||
clearable
|
||||
placeholder="请选择业务类型"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in clinicalResearchCategoryOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道" prop="channelId">
|
||||
<el-select
|
||||
v-model="formData.channelId"
|
||||
class="w-full"
|
||||
filterable
|
||||
clearable
|
||||
placeholder="请选择渠道"
|
||||
:loading="channelLoading"
|
||||
@change="onChannelChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="ch in channelOptions"
|
||||
:key="ch.id"
|
||||
:label="ch.channelName"
|
||||
:value="ch.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="课题名称" prop="projectTitle">
|
||||
<el-input v-model="formData.projectTitle" placeholder="请输入课题名称" />
|
||||
</el-form-item>
|
||||
@@ -92,7 +125,11 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item v-if="bizConfig.showChannel" label="渠道" prop="channelId">
|
||||
<el-form-item
|
||||
v-if="bizConfig.showChannel && !isBasicExperiment"
|
||||
label="渠道"
|
||||
prop="channelId"
|
||||
>
|
||||
<el-select
|
||||
v-model="formData.channelId"
|
||||
class="w-full"
|
||||
@@ -1284,9 +1321,12 @@
|
||||
} from '@/utils/status-tag-registry'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { getPilotBizConfig } from '@/config/pilot-biz-type'
|
||||
import { CLINICAL_RESEARCH_CATEGORY_OPTIONS } from '@/constants/clinical-research-category'
|
||||
|
||||
defineOptions({ name: 'ApplicationFormDialog' })
|
||||
|
||||
const clinicalResearchCategoryOptions = CLINICAL_RESEARCH_CATEGORY_OPTIONS
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
editId: string | null
|
||||
@@ -1342,7 +1382,8 @@
|
||||
projectTitle: '',
|
||||
customerName: '',
|
||||
customerContact: '',
|
||||
customerPhone: ''
|
||||
customerPhone: '',
|
||||
researchCategory: ''
|
||||
})
|
||||
|
||||
type SaleProductLine = {
|
||||
@@ -1371,6 +1412,7 @@
|
||||
channelServiceOrderId: [
|
||||
{ required: true, message: '请选择服务订单', trigger: 'change' }
|
||||
],
|
||||
researchCategory: [{ required: true, message: '请选择业务类型', trigger: 'change' }],
|
||||
projectTitle: [{ required: true, message: '请填写课题名称', trigger: 'blur' }],
|
||||
customerName: [{ required: true, message: '请填写客户名称', trigger: 'blur' }],
|
||||
customerContact: [{ required: true, message: '请填写客户联系人', trigger: 'blur' }],
|
||||
@@ -1437,12 +1479,14 @@
|
||||
formData.channelServiceOrderId = ''
|
||||
serviceOrderOptions.value = []
|
||||
|
||||
if (isClinical.value) {
|
||||
// 临床:价格池与渠道无关;切换渠道时勿清空 agreementPriceOptions(否则「添加细胞产品」会失效)
|
||||
clearScheduleCellProducts()
|
||||
if (!channelId) return
|
||||
if (!agreementPriceOptions.value.length) {
|
||||
await loadClinicalCellProductPrices()
|
||||
if (isClinical.value || isBasicExperiment.value) {
|
||||
// 临床/临床科研:不依赖服务订单;临床还需价格池
|
||||
if (isClinical.value) {
|
||||
clearScheduleCellProducts()
|
||||
if (!channelId) return
|
||||
if (!agreementPriceOptions.value.length) {
|
||||
await loadClinicalCellProductPrices()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -2798,6 +2842,7 @@
|
||||
formData.customerName = ''
|
||||
formData.customerContact = ''
|
||||
formData.customerPhone = ''
|
||||
formData.researchCategory = ''
|
||||
saleProductLines.value = []
|
||||
saleLineSeq = 0
|
||||
patientForm.customerId = ''
|
||||
@@ -2850,6 +2895,7 @@
|
||||
formData.customerName = detail.customerName || ''
|
||||
formData.customerContact = detail.customerContact || ''
|
||||
formData.customerPhone = detail.customerPhone || ''
|
||||
formData.researchCategory = detail.researchCategory || ''
|
||||
|
||||
if (detail.consentAttachmentFiles?.length) {
|
||||
consentFileList.value = mapAttachmentFilesFromDetail(detail.consentAttachmentFiles)
|
||||
@@ -2866,8 +2912,8 @@
|
||||
otherFileList.value = []
|
||||
}
|
||||
|
||||
// 加载渠道后加载服务订单
|
||||
if (formData.channelId && !isClinical.value) {
|
||||
// 中试:加载渠道后加载服务订单(临床/临床科研不需要)
|
||||
if (formData.channelId && !isClinical.value && !isBasicExperiment.value) {
|
||||
try {
|
||||
serviceOrderOptions.value = await fetchAllPagedRecords((page, pageSize) =>
|
||||
fetchChannelServiceOrderList({
|
||||
@@ -2963,7 +3009,7 @@
|
||||
}))
|
||||
}))
|
||||
}
|
||||
if (formData.channelId && !isClinical.value) {
|
||||
if (formData.channelId && !isClinical.value && !isBasicExperiment.value) {
|
||||
await loadAgreements(formData.channelId)
|
||||
}
|
||||
if (isBasicExperiment.value && detail.infusionSchedules?.length) {
|
||||
@@ -3062,6 +3108,8 @@
|
||||
}
|
||||
|
||||
if (isBasicExperiment.value) {
|
||||
payload.researchCategory = formData.researchCategory || undefined
|
||||
payload.channelId = formData.channelId || undefined
|
||||
payload.projectTitle = formData.projectTitle || undefined
|
||||
payload.customerName = formData.customerName || undefined
|
||||
payload.customerContact = formData.customerContact || undefined
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<div class="kpi-value">{{ dash(applicationDetail.customerName) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!isBasicExperiment" class="kpi-card">
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-card__icon" aria-hidden="true">
|
||||
<el-icon><User /></el-icon>
|
||||
</div>
|
||||
@@ -121,6 +121,16 @@
|
||||
<div class="data-label">申请单名称</div>
|
||||
<div class="data-value">{{ dash(applicationDetail.applicationName) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">业务类型</div>
|
||||
<div class="data-value">
|
||||
{{ dash(clinicalResearchCategoryLabel(applicationDetail.researchCategory)) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">渠道名称</div>
|
||||
<div class="data-value">{{ dash(applicationDetail.channelName) }}</div>
|
||||
</div>
|
||||
<div class="data-item">
|
||||
<div class="data-label">课题名称</div>
|
||||
<div class="data-value">{{ dash(applicationDetail.projectTitle) }}</div>
|
||||
@@ -888,6 +898,7 @@
|
||||
import { downloadAttachmentFile } from '@/utils/download-attachment'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { getPilotBizConfig } from '@/config/pilot-biz-type'
|
||||
import { clinicalResearchCategoryLabel } from '@/constants/clinical-research-category'
|
||||
import {
|
||||
applicationStatusLabel,
|
||||
applicationStatusTagType,
|
||||
|
||||
@@ -139,6 +139,17 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isBasicExperiment"
|
||||
prop="researchCategory"
|
||||
label="业务类型"
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
{{ clinicalResearchCategoryLabel(row.researchCategory) || '—' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isBasicExperiment"
|
||||
prop="projectTitle"
|
||||
@@ -330,6 +341,7 @@
|
||||
import { applicationStatusLabel, applicationStatusTagType } from '@/utils/status-tag-registry'
|
||||
import { fetchAllPagedRecords } from '@/utils/fetch-paged-list'
|
||||
import { getPilotBizConfig, resolvePilotBizType } from '@/config/pilot-biz-type'
|
||||
import { clinicalResearchCategoryLabel } from '@/constants/clinical-research-category'
|
||||
|
||||
defineOptions({ name: 'PilotApplicationTab' })
|
||||
|
||||
|
||||
+11
-2
@@ -22,6 +22,7 @@ import {
|
||||
isAllProductionWorkOrderTab,
|
||||
tabSupportsInactiveProtocolFilter,
|
||||
resolveTabKeyFromWorkOrder,
|
||||
workOrderMatchesTab,
|
||||
type ProductionWorkOrderTabKey
|
||||
} from '@/utils/production-work-order-tabs'
|
||||
import { toAllTabListQuery } from '@/utils/production-work-order-category'
|
||||
@@ -164,8 +165,16 @@ export function useProductionWorkOrderTabPage(
|
||||
...listQuery,
|
||||
...buildPlannedStartTimeParams()
|
||||
})
|
||||
tableData.value = res.list || []
|
||||
pagination.total = res.total ?? 0
|
||||
const rawList = res.list || []
|
||||
const list = isAllProductionWorkOrderTab(tabKey.value)
|
||||
? rawList.filter((row) => workOrderMatchesTab(row, 'all'))
|
||||
: rawList
|
||||
tableData.value = list
|
||||
// 「所有」前端排除中试时,按本页剔除量修正 total(后端未改)
|
||||
pagination.total = Math.max(
|
||||
0,
|
||||
(res.total ?? 0) - (rawList.length - list.length)
|
||||
)
|
||||
selectedRows.value = selectedRows.value.filter((row) =>
|
||||
tableData.value.some((item) => item.id === row.id)
|
||||
)
|
||||
|
||||
@@ -260,7 +260,11 @@
|
||||
>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { joinChildNames, managementPayload } from '@/utils/project-management'
|
||||
import {
|
||||
joinChildNames,
|
||||
managementPayload,
|
||||
projectBizTypeSelectLabels
|
||||
} from '@/utils/project-management'
|
||||
import { useMenuPerm } from '@/hooks/core/useMenuPerm'
|
||||
import {
|
||||
Plus,
|
||||
@@ -281,9 +285,6 @@
|
||||
fetchProjectReferences,
|
||||
type ProjectRecord
|
||||
} from '@/api/project-management'
|
||||
const projectBizLabels = Object.fromEntries(
|
||||
Object.entries(bizLabels).filter(([key]) => key !== 'presign')
|
||||
)
|
||||
const props = defineProps<{ kind: 'teams' | 'projects' }>()
|
||||
const isTeam = computed(() => props.kind === 'teams')
|
||||
const { hasMenuPerm } = useMenuPerm()
|
||||
@@ -323,6 +324,10 @@
|
||||
memberIds = ref<string[]>([]),
|
||||
regionIds = ref<string[]>([]),
|
||||
hospitalIds = ref<string[]>([])
|
||||
/** 默认不含中试;旧项目已选中试时保留该选项以展示 */
|
||||
const projectBizLabels = computed(() =>
|
||||
projectBizTypeSelectLabels(bizLabels, form.value.bizTypes as string[] | undefined)
|
||||
)
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
|
||||
+7
-2
@@ -20,6 +20,7 @@ import {
|
||||
isAllQcWorkOrderTab,
|
||||
isInboundSampleQcTab,
|
||||
resolveTabKeyFromWorkOrder,
|
||||
workOrderMatchesTab,
|
||||
type QcWorkOrderTabKey
|
||||
} from '@/utils/qc-work-order-tabs'
|
||||
import { toAllTabListQuery } from '@/utils/qc-work-order-category'
|
||||
@@ -210,7 +211,10 @@ export function useQcWorkOrderTabPage(
|
||||
...listQuery,
|
||||
...timeParams
|
||||
})
|
||||
const list = res.list || []
|
||||
const rawList = res.list || []
|
||||
const list = isAllQcWorkOrderTab(tabKey.value)
|
||||
? rawList.filter((row) => workOrderMatchesTab(row, 'all'))
|
||||
: rawList
|
||||
const ids = list.map((row) => row.id).filter(Boolean)
|
||||
const batchMap = ids.length
|
||||
? (await fetchQcInspectionBatchesBatch(ids).catch(() => ({}))) || {}
|
||||
@@ -218,7 +222,8 @@ export function useQcWorkOrderTabPage(
|
||||
// 先写入批次摘要,再渲染卡片,避免子组件在 preset 未就绪时逐条请求 inspection-batches
|
||||
presetBatchesByWorkOrderId.value = batchMap
|
||||
tableData.value = list
|
||||
pagination.total = res.total ?? 0
|
||||
// 「所有」前端排除中试时,按本页剔除量修正 total(后端未改)
|
||||
pagination.total = Math.max(0, (res.total ?? 0) - (rawList.length - list.length))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ import test from 'node:test'
|
||||
import {
|
||||
buildDrillFilters,
|
||||
assignmentSnapshot,
|
||||
joinChildNames
|
||||
joinChildNames,
|
||||
projectBizTypeSelectLabels
|
||||
} from '../src/utils/project-management'
|
||||
|
||||
test('drill preserves applied dates and selected project when a team is opened', () => {
|
||||
@@ -83,3 +84,22 @@ test('filter options use visible historical scope; create and reassignment remai
|
||||
})
|
||||
assert.deepEqual(projectOptionsParams('cell_storage', false), { bizType: 'cell_storage' })
|
||||
})
|
||||
|
||||
test('project biz type select hides pilot by default but keeps it when already selected', () => {
|
||||
const labels = {
|
||||
presign: '预签约',
|
||||
cell_storage: '细胞存储',
|
||||
research_donation: '科研捐赠',
|
||||
pilot_service: '中试服务',
|
||||
basic_experiment: '临床科研'
|
||||
}
|
||||
const fresh = projectBizTypeSelectLabels(labels, [])
|
||||
assert.equal(fresh.pilot_service, undefined)
|
||||
assert.equal(fresh.presign, undefined)
|
||||
assert.equal(fresh.cell_storage, '细胞存储')
|
||||
assert.equal(fresh.basic_experiment, '临床科研')
|
||||
|
||||
const legacy = projectBizTypeSelectLabels(labels, ['cell_storage', 'pilot_service'])
|
||||
assert.equal(legacy.pilot_service, '中试服务')
|
||||
assert.equal(legacy.cell_storage, '细胞存储')
|
||||
})
|
||||
Reference in new issue
Block a user