当前位置: 首页 > news >正文

element表格+表单+表单验证结合u

一、结果展示

1、图片

2、描述

table中放form表单,放输入框或下拉框或多选框等;

点击添加按钮,首先验证表单,如果存在没填的就验证提醒,都填了就向下添加一行表单表格;

点击当前行删除按钮,清除行。

二、实现代码

 <el-form :model="formother" ref="paramsForm" :rules="tablerule"><el-table :data="formother.customerAddressList" border style="width: 100%;"><el-table-column prop="consignee" label="收货人"><template slot-scope="scope"><el-form-item :prop="`customerAddressList[${scope.$index}].consignee`" :rules=" [{ required: true, message: '请输入收货人', trigger: 'blur' }]"><el-input v-model="scope.row.consignee" placeholder="请输入收货人"></el-input></el-form-item></template></el-table-column><el-table-column prop="phone" label="联系电话"><template slot-scope="scope"><el-form-item :prop="`customerAddressList[${scope.$index}].phone`":rules="[{ required: true, message: '请输入联系电话', trigger: 'blur' }]"><el-input v-model="scope.row.phone" placeholder="请输入联系电话"></el-input></el-form-item></template></el-table-column><el-table-column prop="address" label="收货地址"><template slot-scope="scope"><el-form-item :prop="`customerAddressList[${scope.$index}].address`":rules="[{ required: true, message: '请输入收货地址', trigger: 'blur' }]"><el-input v-model="scope.row.address" placeholder="请输入收货地址"></el-input></el-form-item></template></el-table-column><el-table-column prop="warehouse" label="仓库名称"><template slot-scope="scope"><el-form-item :prop="`customerAddressList[${scope.$index}].warehouse`":rules="[{ required: true, message: '请输入仓库名称', trigger: 'blur' }]"><el-input v-model="scope.row.warehouse" placeholder="请输入仓库名称"></el-input></el-form-item></template></el-table-column><el-table-column label="操作" align="center" width="100"><template slot-scope="scope"><el-button type="danger" icon="el-icon-delete" size="mini"@click="deleteParams(scope.$index)">删除</el-button></template></el-table-column></el-table></el-form>
    addAddress() {this.$refs['paramsForm'].validate().then(vaild => {if (!vaild) return;this.formother.customerAddressList.push({consignee: "",phone: "",address: "",warehouse: ""})}).catch(error => {console.log(error)})},deleteParams(index) {this.formother.customerAddressList.splice(index, 1)}

 

http://www.lryc.cn/news/109407.html

相关文章:

  • 数据库:MYSQL参数max_allowed_packet 介绍
  • 基于DiscordMidjourney API接口实现文生图
  • springboot+vue农产品特产商城销售平台_50kf2 多商家
  • 【深度学习_TensorFlow】感知机、全连接层、神经网络
  • 软件测试(功能、接口、性能、自动化)详解
  • Oracle表段中的高水位线HWM
  • 【福建事业单位-推理判断】03类别推理
  • Leetcode-每日一题【剑指 Offer 05. 替换空格】
  • zookeeper+kafka分布式消息队列集群的部署
  • VR全景旅游,智慧文旅发展新趋势!
  • 详解EMBER数据集中对PE文件提取ByteEntropyHistogram特征
  • 垃圾回收机制和常用的算法
  • 【PostgreSQL】系列之 一 schema详解(二)
  • 性能优化-react路由懒加载和组件懒加载
  • 静态网页加速器:优化性能和交付速度的 Node.js 最佳实践
  • Spring 非自定义Bean注解
  • 微信小程序:点击按钮实现数据加载(带模糊查询)
  • 2023-2029年中国烘焙工坊市场经营管理风险与未来竞争优势分析报告
  • 用Rust实现23种设计模式之适配器
  • 替换开源LDAP,西井科技用宁盾目录统一身份,为业务敏捷提供支撑
  • 靶形数独
  • C语言阶段性测试题
  • java工厂设计模式
  • idea运行web老项目
  • JS进阶-Day3
  • springboot后端用WebSocket每秒向前端传递数据,python接收数据
  • 记录uniapp 滚动后溢出显示空白的办法
  • 设计原则学习之里氏替换原则
  • 排序进行曲-v4.0
  • Flink 系列四 Flink 运行时架构