fix: 添加验证电话号码是否合法

This commit is contained in:
@changcode
2021-05-28 13:12:05 +08:00
parent ccf8013050
commit 6e601b36df
5 changed files with 38 additions and 2 deletions

View File

@@ -81,7 +81,9 @@
</template>
<script>
import { host, port } from '@/components/common/js/validate'
// import { host, port } from '@/components/common/js/validate'
import {isvalidPhone} from "../../../../store/validate";
export default {
name: 'userBox',
components: {
@@ -108,7 +110,16 @@ export default {
} else {
callback()
}
}
};
const phoneVerification = (rule, value,callback) => {
if (!value){
callback(new Error(this.$t('validate.telephone')))
}else if (!isvalidPhone(value)){
callback(new Error(this.$t('validate.tel')))
}else {
callback()
}
};
return {
editUser: {},
url: 'sys/user',
@@ -132,6 +143,10 @@ export default {
],
email: [
{ type: 'email', message: this.$t('validate.email') }
],
mobile: [
{ validator: phoneVerification, required : true, trigger: 'blur' },
{ required: true, message: '', trigger: 'blur' }
]
},
rules2: { // 表单校验规则