Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b1bf8a1d2 | ||
|
|
ef3e015ff9 |
No files matched your search
@@ -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:
|
||||
|
||||
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,6 +469,9 @@ 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()
|
||||
@@ -527,6 +533,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 +593,15 @@ 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 "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,7 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
||||
db = MagicMock()
|
||||
data = {
|
||||
"bizType": "basic_experiment",
|
||||
"researchCategory": "bio_tech_clinical",
|
||||
"projectTitle": "课题A",
|
||||
"customerName": "",
|
||||
"customerContact": "张三",
|
||||
@@ -43,6 +44,25 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
|
||||
)
|
||||
self.assertIn("客户名称", str(ctx.exception))
|
||||
|
||||
def test_create_basic_experiment_requires_research_category(self):
|
||||
db = MagicMock()
|
||||
data = {
|
||||
"bizType": "basic_experiment",
|
||||
"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,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,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
|
||||
}
|
||||
@@ -71,6 +71,21 @@
|
||||
/>
|
||||
</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="projectTitle">
|
||||
<el-input v-model="formData.projectTitle" placeholder="请输入课题名称" />
|
||||
</el-form-item>
|
||||
@@ -1284,9 +1299,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 +1360,8 @@
|
||||
projectTitle: '',
|
||||
customerName: '',
|
||||
customerContact: '',
|
||||
customerPhone: ''
|
||||
customerPhone: '',
|
||||
researchCategory: ''
|
||||
})
|
||||
|
||||
type SaleProductLine = {
|
||||
@@ -1371,6 +1390,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' }],
|
||||
@@ -2798,6 +2818,7 @@
|
||||
formData.customerName = ''
|
||||
formData.customerContact = ''
|
||||
formData.customerPhone = ''
|
||||
formData.researchCategory = ''
|
||||
saleProductLines.value = []
|
||||
saleLineSeq = 0
|
||||
patientForm.customerId = ''
|
||||
@@ -2850,6 +2871,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)
|
||||
@@ -3062,6 +3084,7 @@
|
||||
}
|
||||
|
||||
if (isBasicExperiment.value) {
|
||||
payload.researchCategory = formData.researchCategory || undefined
|
||||
payload.projectTitle = formData.projectTitle || undefined
|
||||
payload.customerName = formData.customerName || undefined
|
||||
payload.customerContact = formData.customerContact || undefined
|
||||
|
||||
@@ -121,6 +121,12 @@
|
||||
<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.projectTitle) }}</div>
|
||||
@@ -888,6 +894,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' })
|
||||
|
||||
|
||||
Reference in new issue
Block a user