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, '');
}
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) {
const res = await api('searchCorpCustomerForCaseList', params);
if (!res?.success) {
@ -254,44 +212,11 @@ const doSearch = useDebounce(async () => {
const seq = (searchSeq.value += 1);
searching.value = true;
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({
corpId,
userId,
teamId,
name: q,
keyword: q,
page: 1,
pageSize: 50,
});