feat: 优化搜索参数,增加手机号、病历号查询

This commit is contained in:
Jafeng 2026-02-10 09:59:38 +08:00
parent fe358efb40
commit 414a32410b

View File

@ -174,48 +174,6 @@ function normalizeDigits(value) {
return s.replace(/\D/g, ''); return s.replace(/\D/g, '');
} }
function isChinaMobile(value) {
const digits = normalizeDigits(value);
return /^1[3-9]\d{9}$/.test(digits);
}
function isLikelyArchiveNo(value) {
const s = normalizeText(value);
if (!s) return false;
if (/[\u4e00-\u9fa5]/.test(s)) return false; // 中文一般是姓名
if (isChinaMobile(s)) return false;
// 病案号一般为数字/字母组合(或纯数字)
return /^[0-9A-Za-z-]{3,}$/.test(s);
}
function matchesAnyArchiveNo(patient, q) {
const needle = normalizeText(q).toLowerCase();
if (!needle) return false;
const values = [
patient?.customerNumber,
patient?.customerProfileNo2,
patient?.customerProfileNo3,
patient?.hospitalId,
].map((v) => normalizeText(v).toLowerCase()).filter(Boolean);
// 优先精确匹配
if (values.some((v) => v === needle)) return true;
// 兜底:包含匹配(部分医院病案号前后可能带前缀/后缀)
return values.some((v) => v.includes(needle));
}
function matchesAnyMobile(patient, q) {
const needle = normalizeDigits(q);
if (!needle) return false;
const mobiles = [
patient?.mobile,
...(Array.isArray(patient?.mobiles) ? patient.mobiles : []),
patient?.phone,
patient?.phone1,
].map(normalizeDigits).filter(Boolean);
return mobiles.some((m) => m === needle);
}
async function fetchList(params) { async function fetchList(params) {
const res = await api('searchCorpCustomerForCaseList', params); const res = await api('searchCorpCustomerForCaseList', params);
if (!res?.success) { if (!res?.success) {
@ -254,44 +212,11 @@ const doSearch = useDebounce(async () => {
const seq = (searchSeq.value += 1); const seq = (searchSeq.value += 1);
searching.value = true; searching.value = true;
try { try {
if (isChinaMobile(q)) {
const digits = normalizeDigits(q);
const list = await fetchList({
corpId,
userId,
teamId,
page: 1,
pageSize: 50,
mobile: digits,
});
if (seq !== searchSeq.value) return;
// 后端为包含匹配,这里做一次精确过滤,避免“部分号段”带来误命中
searchResultsRaw.value = list.filter((p) => matchesAnyMobile(p, digits));
return;
}
if (isLikelyArchiveNo(q)) {
const list = await fetchList({
corpId,
userId,
teamId,
page: 1,
pageSize: 50,
archiveNo: q,
});
if (seq !== searchSeq.value) return;
// 兜底:后端字段不全时,仍然做一次本地匹配(包含 customerNumber/2/3)
searchResultsRaw.value = list.filter((p) => matchesAnyArchiveNo(p, q));
return;
}
const list = await fetchList({ const list = await fetchList({
corpId, corpId,
userId, userId,
teamId, teamId,
name: q, keyword: q,
page: 1, page: 1,
pageSize: 50, pageSize: 50,
}); });