From da3c102e0a47b5fe755bdf270c192b9714656381 Mon Sep 17 00:00:00 2001 From: wangxiangwen <1906413238@qq.com> Date: Thu, 24 Jul 2025 17:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B4=BB=E5=8A=A8=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E4=B8=8D=E8=83=BD=E6=9C=89=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/zhongchou/activity/index.vue | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/activitylink/src/views/zhongchou/activity/index.vue b/activitylink/src/views/zhongchou/activity/index.vue index 1f6c9be..ae875d1 100644 --- a/activitylink/src/views/zhongchou/activity/index.vue +++ b/activitylink/src/views/zhongchou/activity/index.vue @@ -79,7 +79,11 @@ > - + @@ -243,6 +247,19 @@ const addActivity = async () => { return; } + // 验证活动名称是否包含空格(双重保险) + if (!activity.value.activityName || activity.value.activityName.trim() === '') { + ElMessage.error('活动名称不能为空'); + return; + } + + // 确保活动名称中没有空格 + const cleanedActivityName = activity.value.activityName.replace(/\s/g, ''); + if (cleanedActivityName !== activity.value.activityName) { + ElMessage.error('活动名称中不能包含空格'); + return; + } + // 表单验证通过,继续提交逻辑 const activityData = { activityName: activity.value.activityName, @@ -317,6 +334,7 @@ const activity = ref({ const rules = { activityName: [ { required: true, message: '请输入活动名称', trigger: 'blur' } + // 移除了自定义验证器,因为清理逻辑在提交时处理 ], marketOne: [ { required: true, message: '请选择市场一', trigger: 'change' } @@ -334,7 +352,6 @@ const rules = { { required: true, message: '请选择结束时间', trigger: 'change' } ] } - // 分页配置 const currentPage = ref(1); const pageSize = ref(10); // 每页显示 10 条 @@ -346,6 +363,13 @@ const currentPageData = computed(() => { return tableData.value.slice(start, end); }); +// 处理活动名称输入,自动清除所有空格 +const handleActivityNameInput = (value) => { + // 清除所有空格 + const cleanedValue = value.replace(/\s/g, ''); + activity.value.activityName = cleanedValue; +}; + // 分页事件处理 const handleSizeChange = (val) => { pageSize.value = val;