diff --git a/src/api/types.ts b/src/api/types.ts index 975c467..e250c29 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -823,10 +823,14 @@ export type UserOwnedMenusResponse = CommonActionResult; * B1服务点信息 */ export interface B1ServiceInfo { + /** 科室代码 */ + dept_code?: string | null; /** 科室名称 */ dept_name?: string | null; /** 医生名称 */ doctor_name?: string | null; + /** 已完成客户数 */ + completed_customer_count?: number | null; /** 已检部位数 */ exam_part_count?: number | null; /** 总时长(分钟) */ @@ -846,8 +850,14 @@ export interface InputB1ServiceBoard { * B1服务看板出参 */ export interface OutputB1ServiceBoard { + /** 总客户数 */ + total_customer_count?: number | null; + /** 等待体检客户数 */ + waiting_exam_count?: number | null; + /** 体检中客户数 */ + in_exam_count?: number | null; /** B1服务点信息列表 */ - b1_service_info_list: B1ServiceInfo[]; + b1_service_info_list?: B1ServiceInfo[] | null; } /** diff --git a/src/components/home/HomeSection.tsx b/src/components/home/HomeSection.tsx index 0a40303..994bcc5 100644 --- a/src/components/home/HomeSection.tsx +++ b/src/components/home/HomeSection.tsx @@ -1,6 +1,6 @@ import { useEffect, useMemo, useState } from 'react'; import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus, getB1ServiceBoard, getNorth3ServiceBoard } from '../../api'; -import type { B1ServiceInfo, OutputNorth3ServiceBoard } from '../../api/types'; +import type { OutputB1ServiceBoard, OutputNorth3ServiceBoard } from '../../api/types'; import { Card, CardContent, CardHeader, InfoCard } from '../ui'; import { cleanLocalStorageIfNeeded } from '../../utils/clean'; @@ -26,7 +26,7 @@ export const HomeSection = () => { { label: '当日缺口', value: '¥ 0' }, ]); const [showRevenueStats, setShowRevenueStats] = useState(false); - const [b1ServiceList, setB1ServiceList] = useState([]); + const [b1Data, setB1Data] = useState(null); const [b1Loading, setB1Loading] = useState(false); const [north3Data, setNorth3Data] = useState(null); const [north3Loading, setNorth3Loading] = useState(false); @@ -112,26 +112,19 @@ export const HomeSection = () => { getB1ServiceBoard({}) .then((res) => { if (res.Status === 200 && res.Data) { - setB1ServiceList(res.Data.b1_service_info_list || []); + setB1Data(res.Data); } }) .catch((err) => { console.error('获取B1服务看板失败', err); - setB1ServiceList([]); + setB1Data(null); }) .finally(() => { setB1Loading(false); }); }, []); - // 计算B1汇总信息 - const b1Summary = useMemo(() => { - const totalClients = b1ServiceList.length; - // 由于接口没有返回"在检"和"待检"数据,这里暂时使用0 - const waiting = 0; - const inExam = 0; - return { totalClients, waiting, inExam }; - }, [b1ServiceList]); + const b1ServiceList = b1Data?.b1_service_info_list || []; useEffect(() => { setNorth3Loading(true); @@ -181,9 +174,9 @@ export const HomeSection = () => { B1 服务看板
- - - + + +
{b1Loading ? (
加载中...
@@ -208,10 +201,10 @@ export const HomeSection = () => { {item.dept_name || '-'} {item.doctor_name || '-'} - - + {item.completed_customer_count ?? '-'} {item.exam_part_count ?? '-'} - {item.total_duration_minutes ?? '-'} - {item.average_duration_minutes ?? '-'} + {item.total_duration_minutes !== null && item.total_duration_minutes !== undefined ? `${item.total_duration_minutes}分钟` : '-'} + {item.average_duration_minutes !== null && item.average_duration_minutes !== undefined ? `${item.average_duration_minutes}分钟` : '-'} - -