From f8ced1c19d3b7c7798681c87b26af240a70fceae Mon Sep 17 00:00:00 2001 From: "@changcode" Date: Mon, 29 Aug 2022 14:43:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8A=A5=E5=91=8A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=88=A4=E6=96=AD=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/rightBox/report/ReportBox.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/rightBox/report/ReportBox.vue b/src/components/rightBox/report/ReportBox.vue index 6d591ade..ff0af79b 100644 --- a/src/components/rightBox/report/ReportBox.vue +++ b/src/components/rightBox/report/ReportBox.vue @@ -276,7 +276,6 @@ import { api } from '@/utils/api' import _ from 'lodash' import { get, post, put } from '@/utils/http' import { dateFormat, getMillisecond } from '@/utils/date-util' - const paramValidator = (rule, value, callback) => { let validate = true if (value && value.length > 0) { @@ -287,6 +286,16 @@ const paramValidator = (rule, value, callback) => { } return validate } +const nameValidator = (rule, value, callback) => { + let validate = true + const reg = /^[\u4e00-\u9fa5A-Za-z\-\_]*$/ + if (reg.test(value)) { + validate = true + } else { + validate = false + } + return validate +} export default { name: 'ReportBox', @@ -324,7 +333,8 @@ export default { rules: { // 表单校验规则 name: [ - { required: true, message: this.$t('validate.required'), trigger: 'blur' } + { required: true, message: this.$t('validate.required'), trigger: 'blur' }, + { validator: nameValidator, message: this.$t('validate.wrongFrom'), trigger: 'blur' } ], categoryId: [ { required: true, message: this.$t('validate.required'), trigger: 'change' } @@ -409,7 +419,7 @@ export default { if (category && category.config && category.config.queryParam) { this.editObject.categoryParams = category.config.queryParam if (!this.editObject.id) { - this.editObject.categoryParams.forEach(t => {t.value = ''}) + this.editObject.categoryParams.forEach(t => { t.value = '' }) } this.loadParamOptions() } else {