zoukankan      html  css  js  c++  java
  • 表格增加整行和删除整行

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

      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 ); }); },
  • 相关阅读:
    JavaScript跨域总结与解决办法
    css IFC 与 BFC分析
    JavaScript Note
    Knowledge Architecture
    BSP
    Olympiad
    Software Engineering
    Assembly Language
    Algorithm
    Data Structure
  • 原文地址:https://www.cnblogs.com/0520euv/p/12183202.html
Copyright ? 2011-2022 开发猿


http://www.vxiaotou.com