<div class="customer-form">
<div
class="thress-cont"
v-for="(item, index) in addForm.contactsParamList"
>
<div class="thress-cont-item">
<el-form-item label="姓名" prop="">
<el-input
placeholder="请输入"
size="small"
v-model="item.customerContactsName"
></el-input>
</el-form-item>
</div>
<div class="thress-cont-item">
<el-form-item label="电话" :prop="`contactsParamList[${index}].phone`" :rules="returnRule('电话')">
<el-input
placeholder="请输入"
size="small"
v-model="item.phone"
></el-input>
</el-form-item>
</div>
<div class="thress-cont-item">
<el-form-item label="邮箱" :prop="`contactsParamList[${index}].email`" :rules="returnRule('邮箱')">
<el-input
size="small"
v-model="item.email"
placeholder="请输入"
></el-input>
</el-form-item>
</div>
<div
class="del-cu"
v-if="index > 0"
@click.prevent="removeFormCustmer(item)"
>
<el-link :underline="false" type="primary"
><i class="iconfont icon-delete"></i
></el-link>
</div>
</div>
</div>
returnRule(name){
var rule = []
if(name == '电话'){
var obj = {
pattern: /^1[0-9]{10}$/,
message: '电话格式不对',
trigger: 'blur'
}
rule.push(obj)
}else if(name == '邮箱'){
var obj = {
pattern: /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,
message: '邮箱格式不对',
trigger: 'blur'
}
rule.push(obj)
}
return rule
},
动态增减表单项 判断
最新推荐文章于 2023-09-20 17:53:23 发布