From e1f18cfc4826da668c13419bf8b15dd82381f1c4 Mon Sep 17 00:00:00 2001 From: dzq Date: Sat, 24 May 2025 16:24:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=A8=E6=88=B7=E6=90=9C=E7=B4=A2):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=9F=E4=B8=80=E6=90=9C=E7=B4=A2=E6=A1=86?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在用户管理页面中,将原有的姓名、手机号、身份证号三个独立搜索框合并为一个统一搜索框,并根据输入内容自动识别搜索类型。新增 `handleSearchInput` 方法,通过正则表达式判断输入内容为身份证号、手机号或姓名,并动态更新搜索参数。简化了用户操作,提升了搜索体验。 --- src/views/user/ab98/index.vue | 40 +++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/views/user/ab98/index.vue b/src/views/user/ab98/index.vue index fd750dc..22ca413 100644 --- a/src/views/user/ab98/index.vue +++ b/src/views/user/ab98/index.vue @@ -19,11 +19,12 @@ defineOptions({ const router = useRouter(); const formRef = ref(); const tagOptions = ref([]); -const searchFormParams = reactive({ +const searchFormParams = reactive({ name: undefined, tel: undefined, idnum: undefined, - tagName: undefined + tagName: undefined, + search: undefined }); const pageLoading = ref(false); @@ -54,6 +55,27 @@ async function getList() { pagination.total = data.total; } +const handleSearchInput = (value) => { + // 身份证号正则(18位) + const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/; + // 手机号正则 + const phoneRegex = /^1[3-9]\d{9}$/; + + if (idCardRegex.test(value)) { + searchFormParams.idnum = value; + searchFormParams.name = ''; + searchFormParams.tel = ''; + } else if (phoneRegex.test(value)) { + searchFormParams.tel = value; + searchFormParams.name = ''; + searchFormParams.idnum = ''; + } else { + searchFormParams.name = value; + searchFormParams.tel = ''; + searchFormParams.idnum = ''; + } +}; + const resetForm = formEl => { if (!formEl) return; formEl.resetFields(); @@ -92,17 +114,9 @@ onMounted(() => {
- - - - - - - - + +