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