添加接口:今日体检进度信息

This commit is contained in:
xianyi
2025-12-10 15:28:45 +08:00
parent 9c8b679689
commit f4d5c085ee
4 changed files with 186 additions and 121 deletions

View File

@@ -4,6 +4,8 @@ import type {
TodayExamStatisticsResponse, TodayExamStatisticsResponse,
InputRevenueStatisticsInfo, InputRevenueStatisticsInfo,
RevenueStatisticsResponse, RevenueStatisticsResponse,
InputTodayExamProgress,
TodayExamProgressResponse,
} from './types'; } from './types';
/** /**
@@ -46,3 +48,17 @@ export const getRevenueStatistics = (
).then(res => res.data); ).then(res => res.data);
}; };
/**
* 今日体检进度信息
* @param data 请求参数(空对象)
* @returns 今日体检进度信息
*/
export const getTodayExamProgress = (
data: InputTodayExamProgress = {}
): Promise<TodayExamProgressResponse> => {
return request.post<TodayExamProgressResponse>(
`${MEDICAL_EXAM_BASE_PATH}/today-exam-progress`,
data
).then(res => res.data);
};

View File

@@ -55,6 +55,32 @@ export interface OutputTodayExamStatisticsInfo {
*/ */
export type TodayExamStatisticsResponse = CommonActionResult<OutputTodayExamStatisticsInfo>; export type TodayExamStatisticsResponse = CommonActionResult<OutputTodayExamStatisticsInfo>;
/**
* 今日体检进度入参
*/
export interface InputTodayExamProgress {
// 空对象,无需参数
}
/**
* 今日体检进度出参
*/
export interface OutputTodayExamProgress {
/** 今日预约人数 */
today_appointment_count?: number | null;
/** 今日已签到人数 */
today_signin_count?: number | null;
/** 今日体检中人数 */
today_in_exam_count?: number | null;
/** 今日用餐人数 */
today_meal_count?: number | null;
}
/**
* 今日体检进度接口返回
*/
export type TodayExamProgressResponse = CommonActionResult<OutputTodayExamProgress>;
/** /**
* 营收数据统计入参 * 营收数据统计入参
*/ */

View File

@@ -1,5 +1,7 @@
import { useEffect, useState } from 'react';
import type { ExamClient, ExamModalTab } from '../../data/mockData'; import type { ExamClient, ExamModalTab } from '../../data/mockData';
import { EXAM_STATS, EXAM_TAGS } from '../../data/mockData'; import { EXAM_TAGS } from '../../data/mockData';
import { getTodayExamProgress } from '../../api';
import { Badge, Card, CardContent, CardHeader, InfoCard } from '../ui'; import { Badge, Card, CardContent, CardHeader, InfoCard } from '../ui';
import { cls } from '../../utils/cls'; import { cls } from '../../utils/cls';
@@ -17,13 +19,37 @@ export const ExamSection = ({
examFilterTag, examFilterTag,
onFilterChange, onFilterChange,
onOpenModal, onOpenModal,
}: ExamSectionProps) => ( }: ExamSectionProps) => {
const [progressStats, setProgressStats] = useState([
{ label: '预约人数', value: 0 },
{ label: '已签到', value: 0 },
{ label: '体检中', value: 0 },
{ label: '用餐', value: 0 },
]);
useEffect(() => {
getTodayExamProgress({})
.then((res) => {
const d = res.Data;
setProgressStats([
{ label: '预约人数', value: Number(d?.today_appointment_count ?? 0) },
{ label: '已签到', value: Number(d?.today_signin_count ?? 0) },
{ label: '体检中', value: Number(d?.today_in_exam_count ?? 0) },
{ label: '用餐', value: Number(d?.today_meal_count ?? 0) },
]);
})
.catch((err) => {
console.error('获取今日体检进度失败', err);
});
}, []);
return (
<div className='space-y-4'> <div className='space-y-4'>
<Card> <Card>
<CardHeader></CardHeader> <CardHeader></CardHeader>
<CardContent> <CardContent>
<div className='grid grid-cols-4 gap-3'> <div className='grid grid-cols-4 gap-3'>
{EXAM_STATS.map(([label, value]) => ( {progressStats.map(({ label, value }) => (
<InfoCard key={label} label={label} value={value} /> <InfoCard key={label} label={label} value={value} />
))} ))}
</div> </div>
@@ -57,11 +83,13 @@ export const ExamSection = ({
const openModal = (tab: ExamModalTab) => onOpenModal(client.id, tab); const openModal = (tab: ExamModalTab) => onOpenModal(client.id, tab);
return ( return (
<button <div
key={client.id} key={client.id}
role='button'
tabIndex={0}
onClick={() => openModal('detail')} onClick={() => openModal('detail')}
className={cls( className={cls(
'text-left p-3 rounded-2xl border bg-white hover:bg-gray-50 flex flex-col gap-1', 'text-left p-3 rounded-2xl border bg-white hover:bg-gray-50 flex flex-col gap-1 cursor-pointer',
selectedExamClient.id === client.id && 'border-gray-900 bg-gray-50', selectedExamClient.id === client.id && 'border-gray-900 bg-gray-50',
)} )}
> >
@@ -130,7 +158,7 @@ export const ExamSection = ({
</button> </button>
</div> </div>
</button> </div>
); );
})} })}
</div> </div>
@@ -138,5 +166,6 @@ export const ExamSection = ({
</Card> </Card>
</div> </div>
); );
};

View File

@@ -226,12 +226,6 @@ export const EXAM_CLIENTS: ExamClient[] = [
}, },
]; ];
export const EXAM_STATS: [string, number][] = [
['预约人数', EXAM_CLIENTS.length],
['已签到', EXAM_CLIENTS.filter((c) => c.status === '已签到').length],
['体检中', EXAM_CLIENTS.filter((c) => c.status === '体检中').length],
['用餐', EXAM_CLIENTS.filter((c) => c.status === '用餐').length],
];
export const EXAM_TAGS = ['全部', '上午', '下午', '高客', '普客', '已登记', '未登记', '散客', '团客'] as const; export const EXAM_TAGS = ['全部', '上午', '下午', '高客', '普客', '已登记', '未登记', '散客', '团客'] as const;