diff --git a/src/api/his.ts b/src/api/his.ts index 26b75f5..af41106 100644 --- a/src/api/his.ts +++ b/src/api/his.ts @@ -42,6 +42,8 @@ import type { UserOwnedMenusResponse, InputB1ServiceBoard, B1ServiceBoardResponse, + InputNorth3ServiceBoard, + North3ServiceBoardResponse, } from './types'; /** @@ -346,3 +348,15 @@ export const getB1ServiceBoard = ( ).then(res => res.data); }; +/** + * 北3服务看板 + */ +export const getNorth3ServiceBoard = ( + data: InputNorth3ServiceBoard = {} +): Promise => { + return request.post( + `${MEDICAL_EXAM_BASE_PATH}/north3-service-board`, + data + ).then(res => res.data); +}; + diff --git a/src/api/types.ts b/src/api/types.ts index 7dfe68d..fc6ec85 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -744,3 +744,43 @@ export interface OutputB1ServiceBoard { */ export type B1ServiceBoardResponse = CommonActionResult; +/** + * 北3服务点信息 + */ +export interface North3ServiceInfo { + /** 家医名称 */ + family_doctor_name?: string | null; + /** 面诊率 */ + face_to_face_rate: number; + /** 分配客户数 */ + assigned_customer_count: number; + /** 面诊数 */ + face_to_face_count: number; +} + +/** + * 北3服务看板入参 + */ +export interface InputNorth3ServiceBoard { + // 空对象,无需参数 +} + +/** + * 北3服务看板出参 + */ +export interface OutputNorth3ServiceBoard { + /** 今日家医数 */ + today_family_doctor_count: number; + /** 分配客户数 */ + assigned_customer_count: number; + /** 面诊数 */ + face_to_face_count: number; + /** 北3服务点信息列表 */ + north3_service_list: North3ServiceInfo[]; +} + +/** + * 北3服务看板响应 + */ +export type North3ServiceBoardResponse = CommonActionResult; + diff --git a/src/components/home/HomeSection.tsx b/src/components/home/HomeSection.tsx index 6c6099d..8297819 100644 --- a/src/components/home/HomeSection.tsx +++ b/src/components/home/HomeSection.tsx @@ -1,7 +1,6 @@ import { useEffect, useMemo, useState } from 'react'; -import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus, getB1ServiceBoard } from '../../api'; -import type { B1ServiceInfo } from '../../api/types'; -import { NORTH3_ROWS, NORTH3_SUMMARY } from '../../data/mockData'; +import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus, getB1ServiceBoard, getNorth3ServiceBoard } from '../../api'; +import type { B1ServiceInfo, OutputNorth3ServiceBoard } from '../../api/types'; import { Card, CardContent, CardHeader, InfoCard } from '../ui'; const APP_ID = 'b2b49e91d21446aeb14579930f732985'; @@ -28,6 +27,8 @@ export const HomeSection = () => { const [showRevenueStats, setShowRevenueStats] = useState(false); const [b1ServiceList, setB1ServiceList] = useState([]); const [b1Loading, setB1Loading] = useState(false); + const [north3Data, setNorth3Data] = useState(null); + const [north3Loading, setNorth3Loading] = useState(false); const currencyFormatter = useMemo(() => new Intl.NumberFormat('zh-CN', { style: 'currency', @@ -127,6 +128,23 @@ export const HomeSection = () => { return { totalClients, waiting, inExam }; }, [b1ServiceList]); + useEffect(() => { + setNorth3Loading(true); + getNorth3ServiceBoard({}) + .then((res) => { + if (res.Status === 200 && res.Data) { + setNorth3Data(res.Data); + } + }) + .catch((err) => { + console.error('获取北3服务看板失败', err); + setNorth3Data(null); + }) + .finally(() => { + setNorth3Loading(false); + }); + }, []); + return (
@@ -203,30 +221,43 @@ export const HomeSection = () => { 北3服务看板
- - - + + +
- - - - - - - - - - - {NORTH3_ROWS.map(([name, total, consult]) => ( - - - - - + {north3Loading ? ( +
加载中...
+ ) : !north3Data || north3Data.north3_service_list.length === 0 ? ( +
暂无数据
+ ) : ( +
家医分配客户数面诊数面诊率
{name}{total}{consult}{((Number(consult) / Number(total)) * 100).toFixed(2)}%
+ + + + + + - ))} - -
家医分配客户数面诊数面诊率
+ + + {north3Data.north3_service_list.map((item, index) => ( + + {item.family_doctor_name || '-'} + {item.assigned_customer_count ?? '-'} + {item.face_to_face_count ?? '-'} + + {item.face_to_face_rate !== undefined + ? `${(item.face_to_face_rate * 100).toFixed(2)}%` + : item.assigned_customer_count && item.assigned_customer_count > 0 + ? `${((item.face_to_face_count ?? 0) / item.assigned_customer_count * 100).toFixed(2)}%` + : '-' + } + + + ))} + + + )}