From 7b3db26b06c1f61f10bf4ac5682401130fa48b6d Mon Sep 17 00:00:00 2001 From: songjie Date: Wed, 1 Apr 2026 17:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=88=A4=E6=96=AD=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=92=8C=E9=82=AE=E7=AE=B1=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/UserPermissions/UserList.vue | 35 ++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/views/UserPermissions/UserList.vue b/src/views/UserPermissions/UserList.vue index f88a80c..70cd42f 100644 --- a/src/views/UserPermissions/UserList.vue +++ b/src/views/UserPermissions/UserList.vue @@ -263,10 +263,28 @@ const fetchOriginList = async () => { } }; +// 判断输入是手机号还是邮箱 +const isEmail = (value) => { + const trimmedValue = value?.trim() || ''; + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return emailRegex.test(trimmedValue); +}; + +const isPhone = (value) => { + const trimmedValue = value?.trim() || ''; + const phoneRegex = /^\d{11}$/; + return phoneRegex.test(trimmedValue); +}; + // 获取表格数据 const fetchTableData = async () => { try { tableLoading.value = true; + + // 根据输入判断是手机号还是邮箱 + const registerType = searchForm.register_type?.trim() || ''; + const isEmailValue = isEmail(registerType); + const isPhoneValue = isPhone(registerType); const requestParams = { token: token, page: currentPage.value, @@ -276,9 +294,9 @@ const fetchTableData = async () => { origin_id: searchForm.origin_id, country: searchForm.country, is_login: searchForm.is_login, - phone: searchForm.register_type, - is_phone: searchForm.register_type ? 1 : 0, - email: searchForm.register_type, + phone: isPhoneValue ? registerType : '', + is_phone: isPhoneValue ? 1 : 0, + email: isEmailValue ? registerType : '', reg_time_start: searchForm.regTimeRange && searchForm.regTimeRange[0] ? searchForm.regTimeRange[0] : '', reg_time_end: searchForm.regTimeRange && searchForm.regTimeRange[1] ? searchForm.regTimeRange[1] : '', list_login_time_start: searchForm.loginTimeRange && searchForm.loginTimeRange[0] ? searchForm.loginTimeRange[0] : '', @@ -308,6 +326,11 @@ const handleSearch = () => { // 导出Excel const handleExport = async () => { try { + // 根据输入判断是手机号还是邮箱 + const registerType = searchForm.register_type?.trim() || ''; + const isEmailValue = isEmail(registerType); + const isPhoneValue = isPhone(registerType); + const requestParams = { token: token, dccode: searchForm.dccode, @@ -315,9 +338,9 @@ const handleExport = async () => { origin_id: searchForm.origin_id, country: searchForm.country, is_login: searchForm.is_login, - phone: searchForm.register_type, - is_phone: searchForm.register_type ? 1 : 0, - email: searchForm.register_type, + phone: isPhoneValue ? registerType : '', + is_phone: isPhoneValue ? 1 : 0, + email: isEmailValue ? registerType : '', reg_time_start: searchForm.regTimeRange && searchForm.regTimeRange[0] ? searchForm.regTimeRange[0] : '', reg_time_end: searchForm.regTimeRange && searchForm.regTimeRange[1] ? searchForm.regTimeRange[1] : '', list_login_time_start: searchForm.loginTimeRange && searchForm.loginTimeRange[0] ? searchForm.loginTimeRange[0] : '',