- ConsultationList: 批量解析患者/医生名称替代截断 UUID - PointsOrderList: 使用 product_name + 批量解析患者/核销人名称 - AppointmentList: 破坏性状态变更添加 Modal.confirm + 取消原因收集 - CalendarView: 添加 onPanelChange 回调支持月份切换 - DoctorSchedule: 日历视图切换月份自动刷新数据 - PointsRuleList: 移除无效删除按钮,Switch 添加启用/停用文字 - PointsProductList: 删除按钮替换为上架/下架 Switch - PatientSelect: 性别显示中文化 (male→男, female→女) - VitalSignsChart: API 失败时显示 Alert 错误提示 - PointsOrder 类型: 添加 product_name 字段
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import { Select } from 'antd';
|
|
import { useState, useCallback } from 'react';
|
|
import { patientApi } from '../../../api/health/patients';
|
|
|
|
interface Props {
|
|
value?: string;
|
|
onChange?: (value: string, label: string) => void;
|
|
placeholder?: string;
|
|
}
|
|
|
|
export function PatientSelect({ value, onChange, placeholder }: Props) {
|
|
const [options, setOptions] = useState<
|
|
{ value: string; label: string }[]
|
|
>([]);
|
|
const [fetching, setFetching] = useState(false);
|
|
|
|
const genderMap: Record<string, string> = { male: '男', female: '女' };
|
|
|
|
const handleSearch = useCallback(async (search: string) => {
|
|
if (!search || search.length < 1) {
|
|
setOptions([]);
|
|
return;
|
|
}
|
|
setFetching(true);
|
|
try {
|
|
const result = await patientApi.list({
|
|
search,
|
|
page_size: 20,
|
|
});
|
|
setOptions(
|
|
result.data.map((p) => ({
|
|
value: p.id,
|
|
label: `${p.name}${p.gender ? ` (${genderMap[p.gender] || p.gender})` : ''}`,
|
|
})),
|
|
);
|
|
} finally {
|
|
setFetching(false);
|
|
}
|
|
}, []);
|
|
|
|
return (
|
|
<Select
|
|
showSearch
|
|
filterOption={false}
|
|
onSearch={handleSearch}
|
|
onChange={(val) => {
|
|
const opt = options.find((o) => o.value === val);
|
|
onChange?.(val, opt?.label ?? '');
|
|
}}
|
|
loading={fetching}
|
|
options={options}
|
|
value={value}
|
|
placeholder={placeholder ?? '搜索患者'}
|
|
allowClear
|
|
/>
|
|
);
|
|
}
|