<Form ref="formInline" :model="formInline" :rules="ruleValidate" :label-width="100" :show-message="true">
<FormItem label="供应商名称" prop="vendorName">
<Input type="text" v-model="formInline.vendorName" style=" 200px;" :disabled="inpDisabled"></Input>
</FormItem>
</Form>
export default {
data(){
//供应商编码验证
const validateCode = (rule, value, callback) => {
if (!value) {
return callback(new Error("供应商编码不能为空"));
} else if (!/^d{5}$/.test(value)) {
callback("请输入5位纯数字");
} else {
callback();
}
};
//手机号验证
const validatePhone = (rule, value, callback) => {
if (!value) {
return callback();
} else if (!/^1[345678]d{9}$/.test(value)) {
callback("手机号格式不正确");
} else {
callback();
}
};
//电话号验证
const validatePhone1 = (rule, value, callback) => {
if (!value) {
return callback();
} else if (!/^0d{2,3}-d{7,8}$$/.test(value)) {
callback("请输入区号-号码格式");
} else {
callback();
}
};
// 供应商名称
const validateName1 = (rule, value, callback) => {
if (!value) {
return callback();
} else if (!/^ +| +$/g.test(value)) {
callback("不支持输入空格");//中文
} else {
callback();
}
};
ruleValidate: {
vendorCode: [
{ required: true, message: '供应商编码不能为空', pattern: /.+/, trigger: 'blur' }
{ required: true, validator: validateCode, trigger: "blur" }
],
vendorName: [
{
required: true,
message: "供应商名称不能为空",
pattern: /.+/,
trigger: "blur",
},
{ required: true, validator: validateName1, trigger: "blur" }
],
cvenHand2: [{ validator: validatePhone, trigger: "blur" }],
cvenPhone: [{ validator: validatePhone1, trigger: "blur" }]
}
}
}
}