From 885ead2d702e88ce3222a06e01141feb42d5d42b Mon Sep 17 00:00:00 2001 From: wangxiangwen <1906413238@qq.com> Date: Fri, 25 Jul 2025 11:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=80=89=E6=8B=A9=E7=8A=B6?= =?UTF-8?q?=E6=80=81+=E5=AF=B9=E6=B7=BB=E5=8A=A0=E5=86=85=E5=AE=9A?= =?UTF-8?q?=E6=8A=BD=E5=A5=96=E7=9A=84=E7=B2=BE=E7=BD=91=E5=8F=B7=E5=92=8C?= =?UTF-8?q?=E5=A7=93=E5=90=8D=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/zhongchou/activity/index.vue | 6 ++--- .../views/zhongchou/gift/importFixedList/index.vue | 27 +++++++++++++++++++-- .../src/views/zhongchou/gift/importuser/index.vue | 28 ++++++++++++++++++++-- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/activitylink/src/views/zhongchou/activity/index.vue b/activitylink/src/views/zhongchou/activity/index.vue index 65c9de8..c6caa59 100644 --- a/activitylink/src/views/zhongchou/activity/index.vue +++ b/activitylink/src/views/zhongchou/activity/index.vue @@ -106,12 +106,12 @@ /> - + @@ -276,7 +276,7 @@ const addActivity = async () => { activityName: activity.value.activityName, marketOne: activity.value.marketOne, marketTwo: activity.value.marketTwo, - status: Number(activity.value.status), + status: 0, startTime: activity.value.startTime, endTime: activity.value.endTime } diff --git a/activitylink/src/views/zhongchou/gift/importFixedList/index.vue b/activitylink/src/views/zhongchou/gift/importFixedList/index.vue index 217c1e0..be684fe 100644 --- a/activitylink/src/views/zhongchou/gift/importFixedList/index.vue +++ b/activitylink/src/views/zhongchou/gift/importFixedList/index.vue @@ -49,7 +49,7 @@ - + @@ -168,6 +168,19 @@ const submitAdd = async () => { ElMessage.error('请填写完整信息') return } + + // 校验用户名长度 + if (addObj.value.username.length > 30) { + ElMessage.error('姓名最长为30个字符') + return + } + + // 校验精网号长度是否在5-12位之间 + if (addObj.value.jwcode.length < 5 || addObj.value.jwcode.length > 12) { + ElMessage.error('精网号必须为5-12位数字') + return + } + try { const response = await addFixUser(addObj.value) if (response.code === 200) { @@ -245,7 +258,17 @@ const trimJwcode = (value) => { searchObj.value.jwcode = value.replace(/\D/g, '') } const trimAddJwcode = (value) => { - addObj.value.jwcode = value.replace(/\D/g, '') + // 限制只允许数字,并且长度在5-12位之间 + const numericValue = value.replace(/\D/g, ''); + addObj.value.jwcode = numericValue.slice(0, 12); // 最多保留12位 +} + +// 添加处理用户名输入的函数 +const trimUsername = (value) => { + // 只允许中文、英文字符 + const filteredValue = value.replace(/[^\u4e00-\u9fa5a-zA-Z]/g, ''); + // 限制最长30个字符 + addObj.value.username = filteredValue.slice(0, 30); } const handleSizeChange = (val) => { pagination.value.pageSize = val diff --git a/activitylink/src/views/zhongchou/gift/importuser/index.vue b/activitylink/src/views/zhongchou/gift/importuser/index.vue index ab53d6e..e08e351 100644 --- a/activitylink/src/views/zhongchou/gift/importuser/index.vue +++ b/activitylink/src/views/zhongchou/gift/importuser/index.vue @@ -50,7 +50,7 @@ - + @@ -145,11 +145,25 @@ const getUsers = async () => { } } // 新增 +// 修改 submitAdd 函数,增加长度校验 const submitAdd = async () => { if (!addObj.value.username || !addObj.value.jwcode) { ElMessage.error('请填写完整信息') return } + + // 校验用户名长度 + if (addObj.value.username.length > 30) { + ElMessage.error('姓名最长为30个字符') + return + } + + // 校验精网号长度是否在5-12位之间 + if (addObj.value.jwcode.length < 5 || addObj.value.jwcode.length > 12) { + ElMessage.error('精网号必须为5-12位数字') + return + } + try { const response = await addUser(addObj.value) if (response.code === 200) { @@ -226,7 +240,17 @@ const trimJwcode = (value) => { searchObj.value.jwcode = value.replace(/\D/g, '') } const trimAddJwcode = (value) => { - addObj.value.jwcode = value.replace(/\D/g, '') + // 限制只允许数字,并且长度在5-12位之间 + const numericValue = value.replace(/\D/g, ''); + addObj.value.jwcode = numericValue.slice(0, 12); // 最多保留12位 +} + +// 添加处理用户名输入的函数 +const trimUsername = (value) => { + // 只允许中文、英文字符 + const filteredValue = value.replace(/[^\u4e00-\u9fa5a-zA-Z]/g, ''); + // 限制最长30个字符 + addObj.value.username = filteredValue.slice(0, 30); } const handleSizeChange = (val) => { pagination.value.pageSize = val