el-collapse 嵌套中 el-checkbox作为标题,选中复选框与el-tree联动

该文章详细介绍了如何在Vue项目中使用el-drawer和el-collapse展示应用授权功能,涉及数据获取、动态过滤和状态同步。
摘要由CSDN通过智能技术生成
<el-drawer
      title="应用授权"
      :visible.sync="menuDrawer">
      <el-collapse accordion style="padding: 15px">
        <el-collapse-item v-for="item in platList">
          <template slot="title">
            <el-checkbox v-model="item.isCheck" :label="item.platformName" @click.stop.native="()=>{}"
                         @change="checkedAll(item.platformId, item.isCheck, item.treeIdList)"></el-checkbox>
          </template>
          <el-input
          v-model="filterText"
            @input="(val) => handleInputFilter(val, item.platformId)"
            size="mini"
            placeholder="请输入内容"
            style="width: 100%">
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
          <el-tree
            :ref="`tree${item.platformId}`"
            style="padding-top: 7px"
            :data="item.treeData"
            :filter-node-method="filterNode"
            show-checkbox
            highlight-current
            check-strictly
            node-key="menuId"
            empty-text="暂无数据" :props="{id: 'menuId',label: 'menuName'}">
          </el-tree>
        </el-collapse-item>
      </el-collapse>
    </el-drawer>
getPlatformList(tenantId) {
      const loading = this.$loading({
        lock: true,
        text: '拼命加载中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      allPlatform(tenantId).then(async response => {
        this.platList = response.data;
        for (let item of this.platList) {
          await getMenuListByPlatform(item.platformId).then(res => {
            item.treeData = this.handleTree(res.data.menus, 'menuId')
            item.treeIdList = res.data.menuIds
          })
        }
        getMenusByTenant(tenantId).then(res=>{
          if (res.code === 200) {
            this.platList.forEach(item => {
              this.$refs[`tree${item.platformId}`][0].setCheckedKeys(res.data);
            })
          }
        })
        loading.close()
        this.menuDrawer = true
      });
    },

效果图:
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值