完善B1看板数据

This commit is contained in:
xianyi
2025-12-26 09:59:18 +08:00
parent 97eec39398
commit c46df45495
2 changed files with 22 additions and 19 deletions

View File

@@ -823,10 +823,14 @@ export type UserOwnedMenusResponse = CommonActionResult<OutputUserOwnedMenus>;
* B1服务点信息 * B1服务点信息
*/ */
export interface B1ServiceInfo { export interface B1ServiceInfo {
/** 科室代码 */
dept_code?: string | null;
/** 科室名称 */ /** 科室名称 */
dept_name?: string | null; dept_name?: string | null;
/** 医生名称 */ /** 医生名称 */
doctor_name?: string | null; doctor_name?: string | null;
/** 已完成客户数 */
completed_customer_count?: number | null;
/** 已检部位数 */ /** 已检部位数 */
exam_part_count?: number | null; exam_part_count?: number | null;
/** 总时长(分钟) */ /** 总时长(分钟) */
@@ -846,8 +850,14 @@ export interface InputB1ServiceBoard {
* B1服务看板出参 * B1服务看板出参
*/ */
export interface OutputB1ServiceBoard { export interface OutputB1ServiceBoard {
/** 总客户数 */
total_customer_count?: number | null;
/** 等待体检客户数 */
waiting_exam_count?: number | null;
/** 体检中客户数 */
in_exam_count?: number | null;
/** B1服务点信息列表 */ /** B1服务点信息列表 */
b1_service_info_list: B1ServiceInfo[]; b1_service_info_list?: B1ServiceInfo[] | null;
} }
/** /**

View File

@@ -1,6 +1,6 @@
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus, getB1ServiceBoard, getNorth3ServiceBoard } from '../../api'; 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 { Card, CardContent, CardHeader, InfoCard } from '../ui';
import { cleanLocalStorageIfNeeded } from '../../utils/clean'; import { cleanLocalStorageIfNeeded } from '../../utils/clean';
@@ -26,7 +26,7 @@ export const HomeSection = () => {
{ label: '当日缺口', value: '¥ 0' }, { label: '当日缺口', value: '¥ 0' },
]); ]);
const [showRevenueStats, setShowRevenueStats] = useState(false); const [showRevenueStats, setShowRevenueStats] = useState(false);
const [b1ServiceList, setB1ServiceList] = useState<B1ServiceInfo[]>([]); const [b1Data, setB1Data] = useState<OutputB1ServiceBoard | null>(null);
const [b1Loading, setB1Loading] = useState(false); const [b1Loading, setB1Loading] = useState(false);
const [north3Data, setNorth3Data] = useState<OutputNorth3ServiceBoard | null>(null); const [north3Data, setNorth3Data] = useState<OutputNorth3ServiceBoard | null>(null);
const [north3Loading, setNorth3Loading] = useState(false); const [north3Loading, setNorth3Loading] = useState(false);
@@ -112,26 +112,19 @@ export const HomeSection = () => {
getB1ServiceBoard({}) getB1ServiceBoard({})
.then((res) => { .then((res) => {
if (res.Status === 200 && res.Data) { if (res.Status === 200 && res.Data) {
setB1ServiceList(res.Data.b1_service_info_list || []); setB1Data(res.Data);
} }
}) })
.catch((err) => { .catch((err) => {
console.error('获取B1服务看板失败', err); console.error('获取B1服务看板失败', err);
setB1ServiceList([]); setB1Data(null);
}) })
.finally(() => { .finally(() => {
setB1Loading(false); setB1Loading(false);
}); });
}, []); }, []);
// 计算B1汇总信息 const b1ServiceList = b1Data?.b1_service_info_list || [];
const b1Summary = useMemo(() => {
const totalClients = b1ServiceList.length;
// 由于接口没有返回"在检"和"待检"数据这里暂时使用0
const waiting = 0;
const inExam = 0;
return { totalClients, waiting, inExam };
}, [b1ServiceList]);
useEffect(() => { useEffect(() => {
setNorth3Loading(true); setNorth3Loading(true);
@@ -181,9 +174,9 @@ export const HomeSection = () => {
<CardHeader>B1 </CardHeader> <CardHeader>B1 </CardHeader>
<CardContent> <CardContent>
<div className='grid grid-cols-3 gap-3 mb-3'> <div className='grid grid-cols-3 gap-3 mb-3'>
<InfoCard label='客户总数' value={b1Summary.totalClients} /> <InfoCard label='客户总数' value={b1Data?.total_customer_count ?? 0} />
<InfoCard label='待检人数' value={b1Summary.waiting} /> <InfoCard label='待检人数' value={b1Data?.waiting_exam_count ?? 0} />
<InfoCard label='检人数' value={b1Summary.inExam} /> <InfoCard label='检人数' value={b1Data?.in_exam_count ?? 0} />
</div> </div>
{b1Loading ? ( {b1Loading ? (
<div className='text-center text-gray-500 py-4'>...</div> <div className='text-center text-gray-500 py-4'>...</div>
@@ -208,10 +201,10 @@ export const HomeSection = () => {
<tr key={`${item.dept_name}-${item.doctor_name}-${index}`} className='border-b last:border-b-0'> <tr key={`${item.dept_name}-${item.doctor_name}-${index}`} className='border-b last:border-b-0'>
<td className='py-2'>{item.dept_name || '-'}</td> <td className='py-2'>{item.dept_name || '-'}</td>
<td className='py-2'>{item.doctor_name || '-'}</td> <td className='py-2'>{item.doctor_name || '-'}</td>
<td className='py-2 text-right'>-</td> <td className='py-2 text-right'>{item.completed_customer_count ?? '-'}</td>
<td className='py-2 text-right'>{item.exam_part_count ?? '-'}</td> <td className='py-2 text-right'>{item.exam_part_count ?? '-'}</td>
<td className='py-2 text-right'>{item.total_duration_minutes ?? '-'}</td> <td className='py-2 text-right'>{item.total_duration_minutes !== null && item.total_duration_minutes !== undefined ? `${item.total_duration_minutes}分钟` : '-'}</td>
<td className='py-2 text-right'>{item.average_duration_minutes ?? '-'}</td> <td className='py-2 text-right'>{item.average_duration_minutes !== null && item.average_duration_minutes !== undefined ? `${item.average_duration_minutes}分钟` : '-'}</td>
<td className='py-2 text-right'>-</td> <td className='py-2 text-right'>-</td>
<td className='py-2 text-right'>-</td> <td className='py-2 text-right'>-</td>
</tr> </tr>