<template>
<div class="page-layout rataMdel">
<el-button type="primary" @click="addItem">+添加一行</el-button>
<el-form
:model="ruleForm"
ref="ruleForm"
label-width="100px"
class="demo-ruleForm"
>
<el-table :data="ruleForm.tableList" style="width: 100%">
<el-table-column prop="name">
<!-- 变量rules -->
<template slot-scope="scope">
<el-form-item
label="活动名称"
:prop="'tableList.' + scope.$index + '.name'"
:rules="rules.name"
>
<el-input v-model="scope.row.name"></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="region">
<!-- 行内rules -->
<template slot-scope="scope">
<el-form-item
label="活动区域"
:prop="'tableList.' + scope.$index + '.region'"
:rules="[{ required: true }]"
>
<el-select v-model="scope.row.region" placeholder="活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
<div style="margin-top: 20px">
<el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
</div>
</div>
</template> <script>
export default {
data() {
return {
ruleForm: {
tableList: []
},
rules: {
name: [
{ required: true, message: "请输入活动名称", trigger: "blur" },
{ min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
]
}
};
},
methods: {
addItem() {
this.ruleForm.tableList.push({
name: "",
region: ""
});
}, submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
alert("submit!");
} else {
console.log("error submit!!");
return false;
}
});
}
}
};
</script> <!-- <style lang='scss' scoped>
.rataMdel {
.el-table td {
padding: 6px 0;
}
.el-form-item__error {
display: none;
}
.header-flex {
display: flex;
align-items: center;
justify-content: space-between;
}
.tableTitle {
font-size: 20px;
margin-bottom: 30px;
}
.charts-box {
width: 100%;
display: flex;
justify-content: center;
}
.tableText {
padding: 15px;
font-size: 15px;
color: #333333;
}
.small-num {
display: inline-block;
width: 70px;
}
.small-string {
display: inline-block;
width: 130px;
}
p {
margin: 0;
padding: 0;
}
.el-form-item {
display: inline-block;
margin-bottom: 0px;
}
}
</style> -->

  

最新文章

  1. UWP 动画系列之模仿网易云音乐动画
  2. Java设计模式之-----策略模式
  3. UML从需求到实现----用例
  4. # 20145210 《Java程序设计》第02周学习总结
  5. Java NIO 操作总结
  6. DbHelper数据操作类
  7. thinkphp模板中使用自定义函数
  8. Java获取ip地址的几种方法
  9. 菜单栏始终浮动在顶部 js
  10. android ndk jni 环境搭建
  11. linux下svn命令大全(转)
  12. 导入TensorFlow报错
  13. Docker系列03—Docker 基础入门
  14. a,b值进行交换的方法
  15. Day8--------------源码安装
  16. springboot-multisource
  17. WebRTC开发基础(WebRTC入门系列2:RTCPeerConnection)
  18. 高可用Hadoop平台-实战尾声篇
  19. JS输入框邮箱自动提示(带有demo和源码)
  20. 利用oneproxy实现mysql读写分离搭建笔记

热门文章

  1. python3.9不支持win7
  2. spring boot 跨域
  3. 银河麒麟服务器V10-SP2安装tomcat
  4. MyBatis-Plus通用Iservice 方法详解
  5. redis运维与管理
  6. Voletile-多线程小例子
  7. 禅道服务崩溃 Can&#39;t init tc log
  8. vim自动输入P的问题
  9. M1芯片使用pod报错 *** for architecture arm64
  10. 如何使用postman