From 85f5da0e3c60a97a995e3e49e78bef1af274b85e Mon Sep 17 00:00:00 2001 From: roger_home_pc Date: Wed, 11 Oct 2023 22:11:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Form_Demo3.vue | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/views/Form_Demo3.vue b/src/views/Form_Demo3.vue index 375d5d5..23a4233 100644 --- a/src/views/Form_Demo3.vue +++ b/src/views/Form_Demo3.vue @@ -58,6 +58,7 @@ export default { name: "Form_Demo1", data() { + const that = this; return { form: { name: "", @@ -75,7 +76,24 @@ export default { {required: true, message: '请输入活动名称', trigger: 'blur'}, {min: 3, max: 10, message: '长度在3到10个字符', trigger: 'blur'}, {pattern: /^[a-zA-Z][a-zA-Z0-9_-]/, message: '活动名需要以字母开头,仅包含字母数字_-', trigger: 'blur'} - ] + ], + region: [{required: true, message: '请选择活动区域', trigger: 'change'}], + date1: [{required: true, message: '请选择活动日期', trigger: 'change'}], + date2: [ + {required: true, message: '请选择活动时间', trigger: 'change'}, + { + validator: (rule, value, callback) => { + const h = new Date(value).getHours() + if (that.form.type.includes('线下活动') && (h > 20 || h < 6)) { + return callback(new Error('线下活动不能夜间举行')) + } + return callback() + }, + trigger: 'change' + } + ], + type: [{required: true, type: 'array', message: '至少选择一个活动类型', trigger: 'change'}], + resource: [{required: true, message: '请选择活动资源', trigger: 'change'}] }, } }, @@ -106,4 +124,4 @@ export default { .text-center { text-align: center } - \ No newline at end of file +