vue树形表格的做法

效果:

做法:

<template>
  <el-table :data="menuTreeList" max-height="100%" height="calc(100% - 20px)" row-key="businessKey"
    @selection-change="handleSelectionChange" ref="multipleTable" border>
    <el-table-column prop="businessCode" label="事业群编码"></el-table-column>
    <el-table-column prop="businessName" label="事业群名称"></el-table-column>
    <el-table-column prop="currencyCode" label="币种"></el-table-column>
    <el-table-column prop="businessName" label="状态">
      <template slot-scope="scope">
        <span>{{ scope.row.status == 1 ? '未启用' : (scope.row.status == 2 ? '启用' : '停用') }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="version" label="版本"></el-table-column>
    <el-table-column prop="createdBy" label="创建人"></el-table-column>
    <el-table-column prop="updatedBy" label="修改人"></el-table-column>
    <el-table-column prop="description" label="备注"></el-table-column>
    <el-table-column label="操作" width="120">
      <template slot-scope="scope">
        <slot name="table-work" :item="scope.row"></slot>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  props: {
    menuTreeList: { type: Array, default: () => [] }
  },
  data() {
    return {
      multipleSelection: []
    }
  },
  created() {
  },
  methods: {
    handleSelectionChange(val) {
        this.multipleSelection = val;
        console.log("已选中:",this.multipleSelection)
      }
  }
}
</script>

<style lang="scss" scoped>
.tree-menu {
  height: calc(100% - 50px);
}

/deep/.ans-table .table-header-row {
  background: none;
}

.menu /deep/.el-table .el-table__cell {
  padding: 4px 0;
}

.menu /deep/.el-table th.el-table__cell>.cell {
  font-size: 12px;
  color: #555;
  border-top: 1px solid #ebeef5;
  padding-top: 10px;
}

.menu /deep/.el-table td.el-table__cell>.cell {
  font-size: 12px;
  color: #666;
}
</style>
      <v-tree :menu-tree-list="tableData">
        <template slot="table-work" slot-scope="props">
            <el-button class="prohibitclick" @click="editRow(props.item)" type="text" size="small">编辑</el-button>
            <el-button class="prohibitclick" @click="deleteRow(props.item)" type="text" size="small">删除</el-button>
          </template>
      </v-tree>

数据结构:

{
  "businessTeamKey": "134",
  "businessTeamCode": "TM0112",
  "businessTeamName": "哈哈哈",
  "description": "测试测试",
  "businessGroupCode": "20",
  "businessUnitCode": "BU0101",
  "parentBusinessTeamCode": "",
  "lastStage": 0,
  "businessTeamFunction": "3",
  "businessTeamType": 3,
  "status": 2
  "children": [
    {
      "businessTeamKey": "160",
      "businessTeamCode": "TM哈哈哈0009",
      "businessTeamName": "哈哈哈",
      "description": "",
      "businessGroupCode": "20",
      "businessUnitCode": "BU0101",
      "parentBusinessTeamCode": "TM0112",
      "lastStage": 1,
      "businessTeamFunction": "3",
      "businessTeamType": 3,
      "status": 2
    },
    {
      "businessTeamKey": "159",
      "businessTeamCode": "TM哈哈哈0008",
      "businessTeamName": "哈哈哈",
      "description": "",
      "businessGroupCode": "20",
      "businessUnitCode": "BU0101",
      "parentBusinessTeamCode": "TM0112",
      "lastStage": 1,
      "businessTeamFunction": "3",
      "businessTeamType": 3,
      "status": 2
    },
    {
      "businessTeamKey": "163",
      "businessTeamCode": "TM0012",
      "businessTeamName": "哈哈哈",
      "description": "",
      "businessGroupCode": "20",
      "businessUnitCode": "BU0101",
      "parentBusinessTeamCode": "TM0112",
      "lastStage": 1,
      "businessTeamFunction": "3",
      "businessTeamType": 3,
      "status": 2
    },
    {
      "businessTeamKey": "161",
      "businessTeamCode": "TM哈哈哈0010",
      "businessTeamName": "哈哈哈",
      "description": "",
      "businessGroupCode": "20",
      "businessUnitCode": "BU0101",
      "parentBusinessTeamCode": "TM0112",
      "lastStage": 1,
      "businessTeamFunction": "3",
      "businessTeamType": 3,
      "status": 2
    },
    {
      "businessTeamKey": "162",
      "businessTeamCode": "TM哈哈哈0011",
      "businessTeamName": "哈哈哈",
      "description": "",
      "businessGroupCode": "20",
      "businessUnitCode": "BU0101",
      "parentBusinessTeamCode": "TM0112",
      "lastStage": 1,
      "businessTeamFunction": "3",
      "businessTeamType": 3,
      "status": 2
    }
  ]
}
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值