码迷,mamicode.com
首页 > 其他好文 > 详细

表格增加整行和删除整行

时间:2020-01-12 18:27:02      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:each   ice   选择   row   color   his   需求   led   ddr   

需求: 表格增加整行和删除整行,因为后台数据的特殊性,增加行没有索引。

  addRow() {
      if (this.checkBoxData.length > 1 || this.checkBoxData.length < 1) {
        this.$message.error({
          message: "请选择一行进行添加",
          duration: 2000
        });
      } else {
       //因为增加表格没有索引,所以自己做了个
        let str = Math.floor(Math.random() * 10000).toString();
        let list = {
          idnex: str,
          newIndex: this.checkBoxData[0].purchaseOrderDetailId + str,
          //复制原表格行内容到新增加的表格
         goods: this.checkBoxData[0].goods,
        };
        this.tableData.push(list);
      }
    },    

删除增加的行

  


//删除批号 delRow() { if (this.checkBoxData.length < 1) { this.$message.error({ message: "请至少选择一行进行删除", duration: 2000 }); return; } this.checkBoxData.forEach(e => { this.tableData.splice( this.tableData.findIndex(item => item.newIndex == e.newIndex), 1 ); }); },

表格增加整行和删除整行

标签:each   ice   选择   row   color   his   需求   led   ddr   

原文地址:https://www.cnblogs.com/0520euv/p/12183202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!