fix: 添加验证电话号码是否合法
This commit is contained in:
@@ -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: { // 表单校验规则
|
||||
|
||||
Reference in New Issue
Block a user