el-table 批量删除功能

发布于:2023-01-14 ⋅ 阅读:(717) ⋅ 点赞:(0)

 

// 列表选中事件

    handleSelectionChange: function(selection) {

      this.delItemList = selection;

    },

    // 删除列表数据

    delGroupListClick: function() {

      if (!this.delItemList.length) {

        this.$message({

          message: "请勾选需要删除的列表数据",

          type: "warning"

        });

        return;

      }

      let idsList = [];

      let deleteDataIndexList = [];

      this.$confirm("此操作将永久删除列表勾选数据, 是否继续?", "提示", {

        confirmButtonText: "确定",

        cancelButtonText: "取消",

        type: "warning"

      })

        .then(() => {

            if(this.delItemList.length>0){

              for(var i=0;i<this.delItemList.length;i++){

                  deleteDataIndexList.push(this.delItemList[i].index);

                  if (this.delItemList[i].assayGroupId) {

                    idsList.push(this.delItemList[i].assayGroupId);

                  } else {

                    this.tableData.splice(this.delItemList[i].index,1)

                  }

              }

            }

            let idsStr = idsList.join(",");

            console.log(idsStr);

            if(idsList.length>0){

              assayGroupremove(idsStr).then(res => {

                if (res.code == "200") {

                  this.$message({

                    message: "删除成功",

                    type: "success"

                  });

                  this.getDiagnoseList();

                }

              });

            }

        })

        .catch(() => {

          this.$message({

            type: "info",

            message: "已取消删除"

          });

        });

    },


网站公告

今日签到

点亮在社区的每一天
去签到