feat(pilot): 临床科研申请单增加必填渠道

开通 showChannel,保存校验并回写 channel_id/name;表单/列表/详情展示渠道,不绑定服务订单。用户确认免除 Figma。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-11-20 16:05:05 +08:00
1 parent 2e741b1284
commit 9242ed0538
6 files changed
+103 -15

No files matched your search

+5 -1
View File
@@ -388,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:
+35 -2
View File
@@ -477,8 +477,21 @@ def create_application(
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("请选择渠道服务订单")
@@ -602,6 +615,26 @@ def update_application(db: Session, app_id: str, data: dict, tenant_no: str) ->
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:
@@ -29,6 +29,7 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
data = {
"bizType": "basic_experiment",
"researchCategory": "bio_tech_clinical",
"channelId": "ch-1",
"projectTitle": "课题A",
"customerName": "",
"customerContact": "张三",
@@ -48,6 +49,7 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
db = MagicMock()
data = {
"bizType": "basic_experiment",
"channelId": "ch-1",
"projectTitle": "课题A",
"customerName": "客户A",
"customerContact": "张三",
@@ -63,6 +65,26 @@ class TestBasicExperimentCreateValidation(unittest.TestCase):
)
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")
+1 -1
View File
@@ -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,
@@ -86,6 +86,24 @@
/>
</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>
@@ -107,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"
@@ -1457,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
}
@@ -2888,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({
@@ -2985,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) {
@@ -3085,6 +3109,7 @@
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>
@@ -127,6 +127,10 @@
{{ 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>