王震
2023-09-13 bef0978ab26369e2000820fafe76a1494ef7a3f0
src/components/view/Technicalindex.vue
@@ -91,7 +91,7 @@
                placeholder="请输入搜索内容" 
                size="small" 
                clearable @input="query" ></el-input>
                    <el-tree :data="list" ref="tree" :props="{children: 'children',label: 'father'}" node-key="name" default-expand-all
                    <el-tree :data="list" ref="tree" :props="{children: 'children',label: 'father'}" style="height: 500px;overflow-y: auto;" node-key="name" default-expand-all
                    @node-click="handleNodeClick" highlight-current
                        >
                    <div class="custom-tree-node" slot-scope="{ node, data }">
@@ -107,11 +107,13 @@
         <div class="right">
                <el-table
                    :data="tableData"
                    style="width: 100%;margin-bottom: 20px;"
                    style="width: 100%;margin-bottom: 20px; height: 580px;overflow: auto;"
                    row-key="name"
                    border
                    @select="selectTr"
                    @selection-change="handleSelectionChange"
                    default-expand-all
                    ref="multipleTable"
                    :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                    <el-table-column
                    type="selection"
@@ -397,7 +399,8 @@
                    unit:'',
                    id:'',
                }
                },
                isAllSelect:false,
            }
            
        },
@@ -407,6 +410,44 @@
            
      },
        methods:{
              // 表格树全部选中配置
                // 全选/取消选操作
                selectAll(val) {
                    this.isAllSelect = !this.isAllSelect;
                    let data = this.tableData;
                    this.toggleSelect(data, this.isAllSelect, "all");
                },
             //选择某行
          selectTr(selection, row) {
                console.log(selection,row);
                this.$set(row, "isChecked", !row.isChecked);
                this.$nextTick(() => {
                    this.isAllSelect = row.isChecked;
                    this.toggleSelect(row, row.isChecked, "tr");
                });
            },
             //递归子级
            toggleSelect(data, flag, type) {
                if (type === "all") {
                    console.log('222');
                    if (data.length > 0) {
                        data.forEach((item) => {
                        this.toggleSelection(item, flag);
                        if (item.children && item.children.length > 0) {
                            this.toggleSelect(item.children, flag, type);
                        }
                        });
                    }
                } else {
                    if (data.children && data.children.length > 0) {
                        data.children.forEach((item) => {
                        item.isChecked = !item.isChecked;
                        this.$refs.multipleTable.toggleRowSelection(item, flag);
                        this.toggleSelect(item, flag, type);
                        });
                    }
                }
            },
            handleClose(){
            },
@@ -631,6 +672,7 @@
            // rows.splice(index, 1);
         // },
            handleSelectionChange(val) {
                console.log(val);
            this.selects = val;
         },
            //编辑