XiaoRuby
2023-08-28 8231542d77a49f80a49434be6ca8bfb3ae9e1efe
src/views/basicData/index.vue
@@ -52,12 +52,8 @@
          width="30%"
          right
          :before-close="handleClose"
          :title="isUpdate ? '更新' : '新增'"
        >
          <template slot="title">
            <div class="addTop">
              <span>{{ isUpdate ? "更新" : "新增" }}基础数据</span>
            </div>
          </template>
          <el-form :model="form" :rules="rules" ref="ruleForm" class="addForm">
            <el-form-item prop="material" required>
              <span>样品名称:</span>
@@ -136,13 +132,14 @@
      <el-table
        :data="tableData"
        style="width: 100%; margin-bottom: 20px"
        row-key="name"
        row-key="id"
        border
        height="calc(100vh - 250px)"
        default-expand-all
        ref="multipleTable"
        @select="selectTr"
        @select-all="selectAll"
        @selection-change="handleSelectionChange"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      >
        <el-table-column type="selection" label="序号"> </el-table-column>
@@ -344,20 +341,6 @@
      this.isAllSelect = !this.isAllSelect;
      let data = this.tableData;
      this.toggleSelect(data, this.isAllSelect, "all");
      // 自定义
      if (this.isAllSelect) {
        val.forEach((i) => {
          if (i.id !== undefined) {
            this.deleteList.push(i.id);
          } else {
            i.children.forEach((c) => {
              this.deleteList.push(c.id);
            });
          }
        });
      } else {
        this.deleteList.splice(0, this.deleteList.length);
      }
    },
    //选择某行
    selectTr(selection, row) {
@@ -366,33 +349,6 @@
        this.isAllSelect = row.isChecked;
        this.toggleSelect(row, row.isChecked, "tr");
      });
      if (row.isChecked === true) {
        if (row.children !== undefined) {
          row.children.forEach((i) => {
            this.deleteList.push(i.id);
          });
        } else {
          this.deleteList.push(row.id);
        }
      } else if (row.isChecked === false) {
        if (row.children !== undefined) {
          row.children.forEach((i) => {
            this.deleteList.findIndex((c, index) => {
              if (c === i.id) {
                this.deleteList.splice(index, 1);
                return;
              }
            });
          });
        }
        this.deleteList.findIndex((c, index) => {
          if (c === row.id) {
            this.deleteList.splice(index, 1);
            return;
          }
        });
      }
    },
    //递归子级
    toggleSelect(data, flag, type) {
@@ -425,6 +381,15 @@
          this.$refs.multipleTable.clearSelection();
        }
      });
    },
    handleSelectionChange(val) {
      this.deleteList = [];
      val.forEach((v) => {
        if (v.id !== undefined) {
          this.deleteList.push(v.id);
        }
      });
      console.log(`output->this.deleteList`, this.deleteList);
    },
    // 表格树全部选中配置  结束
    deleteListClick() {
@@ -489,12 +454,6 @@
  position: relative;
  padding: 0 10px 10px 10px;
}
.el-dialog__header {
  padding: 0;
}
.el-dialog__headerbtn {
  top: 0;
}
.el-dialog__close {
  padding: 8px 0;
  color: #ffffff !important;
@@ -510,20 +469,6 @@
}
.el-dialog__body {
  padding: 30px 20px 0 20px;
}
.addTop {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  background-color: #00a5ff;
  color: #ffffff;
  padding: 8px 20px;
  float: left;
  height: 30px;
  width: 100%;
}
.addTop span {
  font-size: 16px;
  font-weight: 700;
}
.table_div {
  margin-top: 10px;