feat: 优化搜索参数,增加手机号、病历号查询
This commit is contained in:
parent
fe358efb40
commit
414a32410b
@ -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,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user