先上效果图:

在点击确认的时候会验证带有验证的字段

嵌套逻辑:

表单
表格
表格项
表单项
表单项
表格项
表格
表单

代码部分:

<!-- 注意此处的model,需要一个对象,而我们的数据是一个列表,我们列表封装成一个对象放在这里就ok了 这里不需要指定rules-->
<el-form :model="{'sysDictDataList':sysDictDataList}" ref="sysDictDataListRules">
<el-table
:data="sysDictDataList"
style="width: 100%">
<el-table-column
label="字典类型">
<template slot-scope="scope">
<el-form-item>
<el-input v-model="scope.row.dictType" :disabled="true"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="数据标签">
<template slot-scope="scope">
<!-- 注意此处的prop,需要使用此类型,不能直接填字段名 rules指向该字段的验证规则 -->
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictLabel'" :rules="sysDictDataListRules.dictLabel">
<el-input v-model="scope.row.dictLabel" placeholder="请输入数据标签"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="数据键值">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictValue'" :rules="sysDictDataListRules.dictValue">
<el-input v-model="scope.row.dictValue" placeholder="请输入数据键值"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="dictType"
label="显示排序">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.dictSort'" :rules="sysDictDataListRules.dictSort">
<el-input-number v-model="scope.row.dictSort" controls-position="right" :min="0"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="备注">
<template slot-scope="scope">
<el-form-item :prop="'sysDictDataList.'+scope.$index+'.remark'" :rules="sysDictDataListRules.remark">
<el-input v-model="scope.row.remark" placeholder="请输入内容"/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="状态">
<template slot-scope="scope">
<el-form-item>
<el-radio-group v-model="scope.row.status">
<el-radio
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}
</el-radio>
</el-radio-group>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="操作">
<template slot-scope="scope">
<el-form-item>
<el-button @click="deleteDetails(scope.$index,sysDictDataList)">删除</el-button>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>

数据:

            sysDictDataList: [],   // 字典详细列表
sysDictDataListRules: { // 字典详细列表的验证
dictLabel: [
{required: true, message: "数据标签不能为空", trigger: "blur"}
],
dictValue:[
{required: true, message: "数据键值不能为空", trigger: "blur"}
],dictSort:[
{required: true, message: "排序不能为空", trigger: "blur"}
],remark:[
{required: true, message: "备注内容不能为空", trigger: "blur"}
]
}

验证方法:

             this.$refs['sysDictDataListRules'].validate(valid =>{
if (valid){
console.log('验证成功,提交');
}
});

注意:如果是根据不同条件展示不同验证表单,使用v-if可能会有意想不到的错误发生,我使用v-show解决此类问题

最新文章

  1. 一步步学习 Spring Data 系列之JPA(一)
  2. javascript-style-guide
  3. iOS推送(利用极光推送)
  4. Unity3D Multi-Compile Shader
  5. .Net core环境准备
  6. 编码规范&lt;1&gt;
  7. [Java] 对象排序示例
  8. 【BZOJ1875】【矩阵乘法】[SDOI2009]HH去散步
  9. android开发基本流程
  10. 玩转html5(一)-----盘点html5新增的那些酷酷的input类型和属性
  11. 对于反射中的invoke()方法的理解
  12. sqlcmd的使用小结
  13. Web in Linux小笔记001
  14. xadmin库的下载安装及奇葩报错的解决方法
  15. 分布式session个人理解浅谈
  16. python作业(二)实现注册功能和登陆功能
  17. Go的Get命令兼容公司Gitlab仓库的HTTP协议
  18. Markdown 使用技巧
  19. eclipse----&gt;error and exception 和常用配置
  20. mina2中的session

热门文章

  1. 数位dp——BZOJ1026 Windy数
  2. linux系统--C语言程序开发的基本步骤(包含gcc的基本步骤)
  3. 吴裕雄--天生自然 R语言开发学习:回归(续四)
  4. Python之路购物车
  5. SpringMVC之转发重定向
  6. 复合文字(Compound Literals)
  7. Canvas和svg总结比较
  8. 使用Lucene.Net做一个简单的搜索引擎-全文索引
  9. Spark基础全解析
  10. redis BLPOP