From b552ff4963414809ec1f86783099d11f7afa5876 Mon Sep 17 00:00:00 2001 From: xianyi Date: Thu, 25 Dec 2025 16:07:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8A=A0=E9=A1=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=85=A5=E5=8F=82=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/types.ts | 44 +++++++++++++++++++++++--- src/components/exam/ExamAddonPanel.tsx | 24 +++++++++++--- src/components/exam/ExamModal.tsx | 2 +- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 982cb38..065e120 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -399,14 +399,34 @@ export type CustomerDetailEditResponse = CommonActionResult; +export type PhysicalExamAddItemListResponse = CommonActionResult; /** * 体检加项支付记录入参(生成扫码支付二维码) diff --git a/src/components/exam/ExamAddonPanel.tsx b/src/components/exam/ExamAddonPanel.tsx index 964f9ca..58dffe2 100644 --- a/src/components/exam/ExamAddonPanel.tsx +++ b/src/components/exam/ExamAddonPanel.tsx @@ -1,5 +1,6 @@ import { useEffect, useMemo, useState } from 'react'; +import type { ExamClient } from '../../data/mockData'; import { searchPhysicalExamAddItem } from '../../api'; import { Button, Input } from '../ui'; @@ -17,7 +18,11 @@ interface AddonItem { currentPrice?: string; } -export const ExamAddonPanel = () => { +interface ExamAddonPanelProps { + client: ExamClient; +} + +export const ExamAddonPanel = ({ client }: ExamAddonPanelProps) => { const [addonList, setAddonList] = useState([]); const [addonSearch, setAddonSearch] = useState(''); const [addonLoading, setAddonLoading] = useState(false); @@ -25,13 +30,22 @@ export const ExamAddonPanel = () => { // 拉取加项列表 useEffect(() => { + const physical_exam_id = Number(client.id); + if (!physical_exam_id) { + setAddonError('缺少体检ID'); + return; + } + const fetchList = async () => { setAddonLoading(true); setAddonError(null); try { - const res = await searchPhysicalExamAddItem({ item_name: addonSearch.trim() }); - if (res.Status === 200 && Array.isArray(res.Data)) { - const list: AddonItem[] = res.Data.map((item) => ({ + const res = await searchPhysicalExamAddItem({ + physical_exam_id, + item_name: addonSearch.trim() || null, + }); + if (res.Status === 200 && res.Data?.addItemList) { + const list: AddonItem[] = res.Data.addItemList.map((item) => ({ id: item.item_id ? String(item.item_id) : `addon_${item.item_name}`, name: item.item_name || '', originalPrice: item.original_price !== undefined ? Number(item.original_price).toFixed(2) : '0.00', @@ -55,7 +69,7 @@ export const ExamAddonPanel = () => { } }; fetchList(); - }, [addonSearch]); + }, [addonSearch, client.id]); const allAddons = useMemo(() => addonList, [addonList]); diff --git a/src/components/exam/ExamModal.tsx b/src/components/exam/ExamModal.tsx index cc7d871..f8b17ac 100644 --- a/src/components/exam/ExamModal.tsx +++ b/src/components/exam/ExamModal.tsx @@ -161,7 +161,7 @@ export const ExamModal = ({ client, tab, onTabChange, onClose }: ExamModalProps) /> )} {tab === 'sign' && } - {tab === 'addon' && } + {tab === 'addon' && } {tab === 'print' && } {tab === 'delivery' && }