el-tree改成表格样式

本文介绍了一种使用Element UI的El-Tree组件并结合jQuery实现的自定义样式方法,该方法支持最多四级权限显示,并调整了不同层级节点的显示方式。

 最近公司ui出了个这样做的权限,emmm

这是我写的,样式只支持四级,最后一级横着排,其余都竖直排 

需要用到jq

  <el-tree :data="data"
                   show-checkbox
                   node-key="id"
                   default-expand-all
                   ref="channelTree"
                   @check-change="nodecheck">
          </el-tree>
addClass() {
      // eslint-disable-next-line no-undef
      $('.is-leaf').parent().parent().parent().addClass('addclass');
      // eslint-disable-next-line no-undef
      $('.expanded').parent().parent().parent().removeClass('addclass');
      // eslint-disable-next-line no-undef
      $('.is-leaf').parent().addClass('removeclass');
    },
  created() {
    this.$nextTick(() => {
      this.addClass();
    });
  },
/deep/.el-tree {
        border-top: 1px solid #E5E7ED;
        border-left: 1px solid #E5E7ED;
        border-right: 1px solid #E5E7ED;
        width: 98%;
        margin-bottom: 40px;
        .el-tree-node__label{
            margin:10px 70px 10px 0;
        }
    .el-tree-node{
        .el-tree-node{
            .el-tree-node__children{
                width: 100%;
            }
            .el-tree-node{
                &:not(:first-child){
                .el-tree-node__content{
                    border-right: 1px solid #E5E7ED;
                }
                border-top: 1px solid #E5E7ED;
            }
            }

        }
    }
                .removeclass{
                    border-right: none !important;
                }
                .removetop{
                    border-top: none !important;
                }
            .addclass{
                    .el-tree-node:not(:first-child){
                        .el-tree-node__content{
                        border-left: none !important;
                    }
                    }
            }
                .el-tree-node__content {
                    padding: 5px 10px !important;
                    height: auto;
                    .el-tree-node__expand-icon.el-icon-caret-right {
                    display: none;
                    }
                }
                > .el-tree-node {
                    padding: 0 !important;
                    display: flex;
                    border-bottom: 1px solid #E5E7ED;

                    > .el-tree-node__children {
                    width: 100%;
                    > .el-tree-node {
                        &:not(:first-child) {
                        border-top: 1px solid #E5E7ED;
                        }
                        >.el-tree-node__content{
                            border-left: 1px solid #E5E7ED;
                            border-right: 1px solid #E5E7ED;
                        }
                    }
                    }
                }
        /deep/ .addclass{
            display: flex;
            flex-direction: row !important;
            flex-wrap: wrap;
        >.el-tree-node{
            border-top: none !important;
            }
        }
  .el-tree-node__children {
    display: flex;
    flex-direction: column;
    .el-tree-node {
      display: flex;
      padding: 0px !important;
      .el-tree-node__content {
        border-bottom: none;
        .custom-tree-node {
          height: 24px;
          display: flex;
          align-items: center;
          .tree-btn {
            margin-left: 10px;
            display: none;
          }
          .el-button {
            padding: 0px !important;
            border-radius: 4px;
            background: #363554;
            color: #ffffff;
          }
        }
      }
      .el-tree-node__children {
        .el-tree-node {
          &:not(:first-child) {
            .el-tree-node__content {
              border-left: none;
            }
          }
        }
      }
    }
  }
}

大概是这样吧

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值