业务场景:当人员核实为证件号码变更时正确身份证号码为必填项

2022-07-23T16:07:42.png

我们可以给单个的form-item添加rules
2022-07-23T16:08:21.png
2022-07-23T16:07:58.png

<el-form-item label="正确证件号码" class="x-flex-a" label-width="110px" prop="type" :rules="infoForm.personType === 17 ? infoFormRules.currentIdCard : [{ required: false }]">
    <el-input :disabled="isAudit" maxlength="20" v-model.trim="infoForm.currentIdCard"></el-input>
</el-form-item>

也可以把el-form的rules判断给不给这个el-form-itemprop传的规则动态的判断有或者没有
2022-07-24T04:55:30.png

<el-form-item label="正确证件号码" class="x-flex-a" label-width="110px" :prop="this.infoForm.personType === 17 ? 'currentIdCard':'type' " >
 <el-input :disabled="isAudit" maxlength="20" v-model.trim="infoForm.currentIdCard"></el-input>
</el-form-item>

发表评论