更新体检客户列表接口请求参数

This commit is contained in:
xianyi
2025-12-23 11:56:59 +08:00
parent c3ef051de6
commit 2fd1bfb4e8
2 changed files with 46 additions and 83 deletions

View File

@@ -115,17 +115,26 @@ export type RevenueStatisticsResponse = CommonActionResult<OutputRevenueStatisti
* 体检客户列表入参
*/
export interface InputPhysicalExamCustomerList {
/** 客户姓名 */
customer_name?: string | null;
/** 联系电话 */
phone?: string | null;
/** 身份证号 */
id_no?: string | null;
/**
* 筛选类型
* 1-全部 2-上午 3-下午 4-高客 5-普客 6-已登记 7-未登记 8-散客 9-团客
*/
filter_type?: number | null;
/** 查询文本(客户姓名、证件号码、联系电话、卡号) */
query_text?: string | null;
/** 是否全部 1-是 0-否) */
is_all: number;
/** 是否上午 1-是 0-否) */
is_morning: number;
/** 是否下午 1-是 0-否) */
is_afternoon: number;
/** 是否高客 1-是 0-否) */
is_high_customer: number;
/** 是否普客 1-是 0-否) */
is_general_customer: number;
/** 是否已登记 1-是 0-否) */
is_registered: number;
/** 是否未登记 1-是 0-否) */
is_not_registered: number;
/** 是否散客 1-是 0-否) */
is_individual_customer: number;
/** 是否团客 1-是 0-否) */
is_group_customer: number;
}
/**

View File

@@ -15,86 +15,40 @@ export const ExamPage = () => {
const [examFilterTag, setExamFilterTag] = useState<(typeof EXAM_TAGS)[number]>('全部');
const [loading, setLoading] = useState(false);
// 将筛选标签映射为接口 filter_type
const filterType = useMemo(() => {
switch (examFilterTag) {
case '上午':
return 2;
case '下午':
return 3;
case '高客':
return 4;
case '普客':
return 5;
case '已登记':
return 6;
case '未登记':
return 7;
case '散客':
return 8;
case '团客':
return 9;
default:
return 1; // 全部
}
}, [examFilterTag]);
// 智能识别搜索内容类型
const getSearchParams = useMemo(() => {
// 构建接口请求参数
const getRequestPayload = useMemo(() => {
const trimmed = searchValue.trim();
if (!trimmed) {
return {
customer_name: undefined,
phone: undefined,
id_no: undefined,
};
}
const query_text = trimmed || null;
// 判断是否为手机号11位数字以1开头
if (/^1[3-9]\d{9}$/.test(trimmed)) {
return {
customer_name: undefined,
phone: trimmed,
id_no: undefined,
};
}
// 根据筛选标签设置标志位
const is_all = examFilterTag === '全部' ? 1 : 0;
const is_morning = examFilterTag === '上午' ? 1 : 0;
const is_afternoon = examFilterTag === '下午' ? 1 : 0;
const is_high_customer = examFilterTag === '高客' ? 1 : 0;
const is_general_customer = examFilterTag === '普客' ? 1 : 0;
const is_registered = examFilterTag === '已登记' ? 1 : 0;
const is_not_registered = examFilterTag === '未登记' ? 1 : 0;
const is_individual_customer = examFilterTag === '散客' ? 1 : 0;
const is_group_customer = examFilterTag === '团客' ? 1 : 0;
// 判断是否为身份证号15位或18位最后一位可能是X
if (/^(\d{15}|\d{17}[\dXx])$/.test(trimmed)) {
return {
customer_name: undefined,
phone: undefined,
id_no: trimmed,
};
}
// 判断是否为卡号纯数字长度在6-20位之间
if (/^\d{6,20}$/.test(trimmed)) {
// 接口中没有卡号字段,暂时使用 customer_name 搜索
// 如果后续接口支持卡号字段,可以添加 card_no 参数
return {
customer_name: trimmed,
phone: undefined,
id_no: undefined,
};
}
// 默认为姓名
return {
customer_name: trimmed,
phone: undefined,
id_no: undefined,
query_text,
is_all,
is_morning,
is_afternoon,
is_high_customer,
is_general_customer,
is_registered,
is_not_registered,
is_individual_customer,
is_group_customer,
};
}, [searchValue]);
}, [searchValue, examFilterTag]);
// 从接口拉取体检客户列表
useEffect(() => {
const payload = {
...getSearchParams,
filter_type: filterType,
};
setLoading(true);
getPhysicalExamCustomerList(payload)
getPhysicalExamCustomerList(getRequestPayload)
.then((res) => {
const list = res.Data || [];
const mapped: ExamClient[] = list.map((item) => {
@@ -166,7 +120,7 @@ export const ExamPage = () => {
.finally(() => {
setLoading(false);
});
}, [getSearchParams, filterType, examSelectedId]);
}, [getRequestPayload, examSelectedId]);
const selectedExamClient: ExamClient | undefined = useMemo(
() => clients.find((c) => c.id === examSelectedId) || clients[0],