完善B1 面板

This commit is contained in:
xianyi
2025-12-17 14:10:15 +08:00
parent 1c15d4b892
commit 1adb79ca0e
3 changed files with 117 additions and 36 deletions

View File

@@ -40,6 +40,8 @@ import type {
VerificationCodePhoneResponse,
InputUserOwnedMenus,
UserOwnedMenusResponse,
InputB1ServiceBoard,
B1ServiceBoardResponse,
} from './types';
/**
@@ -332,3 +334,15 @@ export const getUserOwnedMenus = (
).then(res => res.data);
};
/**
* B1服务看板
*/
export const getB1ServiceBoard = (
data: InputB1ServiceBoard = {}
): Promise<B1ServiceBoardResponse> => {
return request.post<B1ServiceBoardResponse>(
`${MEDICAL_EXAM_BASE_PATH}/b1-service-board`,
data
).then(res => res.data);
};

View File

@@ -708,3 +708,39 @@ export interface OutputUserOwnedMenus {
*/
export type UserOwnedMenusResponse = CommonActionResult<OutputUserOwnedMenus>;
/**
* B1服务点信息
*/
export interface B1ServiceInfo {
/** 科室名称 */
dept_name?: string | null;
/** 医生名称 */
doctor_name?: string | null;
/** 已检部位数 */
exam_part_count?: number | null;
/** 总时长(分钟) */
total_duration_minutes?: number | null;
/** 平均时长(分钟) */
average_duration_minutes?: number | null;
}
/**
* B1服务看板入参
*/
export interface InputB1ServiceBoard {
// 空对象,无需参数
}
/**
* B1服务看板出参
*/
export interface OutputB1ServiceBoard {
/** B1服务点信息列表 */
b1_service_info_list: B1ServiceInfo[];
}
/**
* B1服务看板响应
*/
export type B1ServiceBoardResponse = CommonActionResult<OutputB1ServiceBoard>;

View File

@@ -1,6 +1,7 @@
import { useEffect, useMemo, useState } from 'react';
import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus } from '../../api';
import { B1_ROWS, B1_SUMMARY, NORTH3_ROWS, NORTH3_SUMMARY } from '../../data/mockData';
import { getRevenueStatistics, getTodayExamStatistics, getUserOwnedMenus, getB1ServiceBoard } from '../../api';
import type { B1ServiceInfo } from '../../api/types';
import { NORTH3_ROWS, NORTH3_SUMMARY } from '../../data/mockData';
import { Card, CardContent, CardHeader, InfoCard } from '../ui';
const APP_ID = 'b2b49e91d21446aeb14579930f732985';
@@ -25,6 +26,8 @@ export const HomeSection = () => {
{ label: '当日缺口', value: '¥ 0' },
]);
const [showRevenueStats, setShowRevenueStats] = useState(false);
const [b1ServiceList, setB1ServiceList] = useState<B1ServiceInfo[]>([]);
const [b1Loading, setB1Loading] = useState(false);
const currencyFormatter = useMemo(() => new Intl.NumberFormat('zh-CN', {
style: 'currency',
@@ -98,6 +101,32 @@ export const HomeSection = () => {
});
}, []);
useEffect(() => {
setB1Loading(true);
getB1ServiceBoard({})
.then((res) => {
if (res.Status === 200 && res.Data) {
setB1ServiceList(res.Data.b1_service_info_list || []);
}
})
.catch((err) => {
console.error('获取B1服务看板失败', err);
setB1ServiceList([]);
})
.finally(() => {
setB1Loading(false);
});
}, []);
// 计算B1汇总信息
const b1Summary = useMemo(() => {
const totalClients = b1ServiceList.length;
// 由于接口没有返回"在检"和"待检"数据这里暂时使用0
const waiting = 0;
const inExam = 0;
return { totalClients, waiting, inExam };
}, [b1ServiceList]);
return (
<div className='space-y-6'>
<Card>
@@ -129,42 +158,44 @@ export const HomeSection = () => {
<CardHeader>B1 </CardHeader>
<CardContent>
<div className='grid grid-cols-3 gap-3 mb-3'>
<InfoCard label='客户总数' value={B1_SUMMARY.totalClients} />
<InfoCard label='待检人数' value={B1_SUMMARY.waiting} />
<InfoCard label='已检人数' value={B1_SUMMARY.inExam} />
<InfoCard label='客户总数' value={b1Summary.totalClients} />
<InfoCard label='待检人数' value={b1Summary.waiting} />
<InfoCard label='已检人数' value={b1Summary.inExam} />
</div>
<table className='w-full text-xs'>
<thead>
<tr className='text-gray-500 border-b'>
<th className='py-2 text-left'></th>
<th className='py-2 text-left'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
</tr>
</thead>
<tbody>
{B1_ROWS.map(([dept, doctor, done, inExam, waiting, avg]) => {
const parts = done * 3;
const totalTime = done * avg;
return (
<tr key={dept} className='border-b last:border-b-0'>
<td className='py-2'>{dept}</td>
<td className='py-2'>{doctor}</td>
<td className='py-2 text-right'>{done}</td>
<td className='py-2 text-right'>{parts}</td>
<td className='py-2 text-right'>{totalTime}</td>
<td className='py-2 text-right'>{avg}</td>
<td className='py-2 text-right'>{inExam}</td>
<td className='py-2 text-right'>{waiting}</td>
{b1Loading ? (
<div className='text-center text-gray-500 py-4'>...</div>
) : b1ServiceList.length === 0 ? (
<div className='text-center text-gray-500 py-4'></div>
) : (
<table className='w-full text-xs'>
<thead>
<tr className='text-gray-500 border-b'>
<th className='py-2 text-left'></th>
<th className='py-2 text-left'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
<th className='py-2 text-right'></th>
</tr>
</thead>
<tbody>
{b1ServiceList.map((item, index) => (
<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.doctor_name || '-'}</td>
<td className='py-2 text-right'>-</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.average_duration_minutes ?? '-'}</td>
<td className='py-2 text-right'>-</td>
<td className='py-2 text-right'>-</td>
</tr>
);
})}
</tbody>
</table>
))}
</tbody>
</table>
)}
</CardContent>
</Card>