更新体检客户列表接口请求参数
This commit is contained in:
@@ -115,17 +115,26 @@ export type RevenueStatisticsResponse = CommonActionResult<OutputRevenueStatisti
|
|||||||
* 体检客户列表入参
|
* 体检客户列表入参
|
||||||
*/
|
*/
|
||||||
export interface InputPhysicalExamCustomerList {
|
export interface InputPhysicalExamCustomerList {
|
||||||
/** 客户姓名 */
|
/** 查询文本(客户姓名、证件号码、联系电话、卡号) */
|
||||||
customer_name?: string | null;
|
query_text?: string | null;
|
||||||
/** 联系电话 */
|
/** 是否全部 (1-是 0-否) */
|
||||||
phone?: string | null;
|
is_all: number;
|
||||||
/** 身份证号 */
|
/** 是否上午 (1-是 0-否) */
|
||||||
id_no?: string | null;
|
is_morning: number;
|
||||||
/**
|
/** 是否下午 (1-是 0-否) */
|
||||||
* 筛选类型
|
is_afternoon: number;
|
||||||
* 1-全部 2-上午 3-下午 4-高客 5-普客 6-已登记 7-未登记 8-散客 9-团客
|
/** 是否高客 (1-是 0-否) */
|
||||||
*/
|
is_high_customer: number;
|
||||||
filter_type?: number | null;
|
/** 是否普客 (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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,86 +15,40 @@ export const ExamPage = () => {
|
|||||||
const [examFilterTag, setExamFilterTag] = useState<(typeof EXAM_TAGS)[number]>('全部');
|
const [examFilterTag, setExamFilterTag] = useState<(typeof EXAM_TAGS)[number]>('全部');
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
// 将筛选标签映射为接口 filter_type
|
// 构建接口请求参数
|
||||||
const filterType = useMemo(() => {
|
const getRequestPayload = 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 trimmed = searchValue.trim();
|
const trimmed = searchValue.trim();
|
||||||
if (!trimmed) {
|
const query_text = trimmed || null;
|
||||||
return {
|
|
||||||
customer_name: undefined,
|
|
||||||
phone: undefined,
|
|
||||||
id_no: undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断是否为手机号(11位数字,以1开头)
|
// 根据筛选标签设置标志位
|
||||||
if (/^1[3-9]\d{9}$/.test(trimmed)) {
|
const is_all = examFilterTag === '全部' ? 1 : 0;
|
||||||
return {
|
const is_morning = examFilterTag === '上午' ? 1 : 0;
|
||||||
customer_name: undefined,
|
const is_afternoon = examFilterTag === '下午' ? 1 : 0;
|
||||||
phone: trimmed,
|
const is_high_customer = examFilterTag === '高客' ? 1 : 0;
|
||||||
id_no: undefined,
|
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 {
|
return {
|
||||||
customer_name: trimmed,
|
query_text,
|
||||||
phone: undefined,
|
is_all,
|
||||||
id_no: undefined,
|
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(() => {
|
useEffect(() => {
|
||||||
const payload = {
|
|
||||||
...getSearchParams,
|
|
||||||
filter_type: filterType,
|
|
||||||
};
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
getPhysicalExamCustomerList(payload)
|
getPhysicalExamCustomerList(getRequestPayload)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const list = res.Data || [];
|
const list = res.Data || [];
|
||||||
const mapped: ExamClient[] = list.map((item) => {
|
const mapped: ExamClient[] = list.map((item) => {
|
||||||
@@ -166,7 +120,7 @@ export const ExamPage = () => {
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}, [getSearchParams, filterType, examSelectedId]);
|
}, [getRequestPayload, examSelectedId]);
|
||||||
|
|
||||||
const selectedExamClient: ExamClient | undefined = useMemo(
|
const selectedExamClient: ExamClient | undefined = useMemo(
|
||||||
() => clients.find((c) => c.id === examSelectedId) || clients[0],
|
() => clients.find((c) => c.id === examSelectedId) || clients[0],
|
||||||
|
|||||||
Reference in New Issue
Block a user