当前位置:   article > 正文

vue树形表格的做法

vue树形表格

效果:

做法:

  1. <template>
  2. <el-table :data="menuTreeList" max-height="100%" height="calc(100% - 20px)" row-key="businessKey"
  3. @selection-change="handleSelectionChange" ref="multipleTable" border>
  4. <el-table-column prop="businessCode" label="事业群编码"></el-table-column>
  5. <el-table-column prop="businessName" label="事业群名称"></el-table-column>
  6. <el-table-column prop="currencyCode" label="币种"></el-table-column>
  7. <el-table-column prop="businessName" label="状态">
  8. <template slot-scope="scope">
  9. <span>{{ scope.row.status == 1 ? '未启用' : (scope.row.status == 2 ? '启用' : '停用') }}</span>
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="version" label="版本"></el-table-column>
  13. <el-table-column prop="createdBy" label="创建人"></el-table-column>
  14. <el-table-column prop="updatedBy" label="修改人"></el-table-column>
  15. <el-table-column prop="description" label="备注"></el-table-column>
  16. <el-table-column label="操作" width="120">
  17. <template slot-scope="scope">
  18. <slot name="table-work" :item="scope.row"></slot>
  19. </template>
  20. </el-table-column>
  21. </el-table>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. menuTreeList: { type: Array, default: () => [] }
  27. },
  28. data() {
  29. return {
  30. multipleSelection: []
  31. }
  32. },
  33. created() {
  34. },
  35. methods: {
  36. handleSelectionChange(val) {
  37. this.multipleSelection = val;
  38. console.log("已选中:",this.multipleSelection)
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="scss" scoped>
  44. .tree-menu {
  45. height: calc(100% - 50px);
  46. }
  47. /deep/.ans-table .table-header-row {
  48. background: none;
  49. }
  50. .menu /deep/.el-table .el-table__cell {
  51. padding: 4px 0;
  52. }
  53. .menu /deep/.el-table th.el-table__cell>.cell {
  54. font-size: 12px;
  55. color: #555;
  56. border-top: 1px solid #ebeef5;
  57. padding-top: 10px;
  58. }
  59. .menu /deep/.el-table td.el-table__cell>.cell {
  60. font-size: 12px;
  61. color: #666;
  62. }
  63. </style>
  1. <v-tree :menu-tree-list="tableData">
  2. <template slot="table-work" slot-scope="props">
  3. <el-button class="prohibitclick" @click="editRow(props.item)" type="text" size="small">编辑</el-button>
  4. <el-button class="prohibitclick" @click="deleteRow(props.item)" type="text" size="small">删除</el-button>
  5. </template>
  6. </v-tree>

数据结构:

  1. {
  2. "businessTeamKey": "134",
  3. "businessTeamCode": "TM0112",
  4. "businessTeamName": "哈哈哈",
  5. "description": "测试测试",
  6. "businessGroupCode": "20",
  7. "businessUnitCode": "BU0101",
  8. "parentBusinessTeamCode": "",
  9. "lastStage": 0,
  10. "businessTeamFunction": "3",
  11. "businessTeamType": 3,
  12. "status": 2
  13. "children": [
  14. {
  15. "businessTeamKey": "160",
  16. "businessTeamCode": "TM哈哈哈0009",
  17. "businessTeamName": "哈哈哈",
  18. "description": "",
  19. "businessGroupCode": "20",
  20. "businessUnitCode": "BU0101",
  21. "parentBusinessTeamCode": "TM0112",
  22. "lastStage": 1,
  23. "businessTeamFunction": "3",
  24. "businessTeamType": 3,
  25. "status": 2
  26. },
  27. {
  28. "businessTeamKey": "159",
  29. "businessTeamCode": "TM哈哈哈0008",
  30. "businessTeamName": "哈哈哈",
  31. "description": "",
  32. "businessGroupCode": "20",
  33. "businessUnitCode": "BU0101",
  34. "parentBusinessTeamCode": "TM0112",
  35. "lastStage": 1,
  36. "businessTeamFunction": "3",
  37. "businessTeamType": 3,
  38. "status": 2
  39. },
  40. {
  41. "businessTeamKey": "163",
  42. "businessTeamCode": "TM0012",
  43. "businessTeamName": "哈哈哈",
  44. "description": "",
  45. "businessGroupCode": "20",
  46. "businessUnitCode": "BU0101",
  47. "parentBusinessTeamCode": "TM0112",
  48. "lastStage": 1,
  49. "businessTeamFunction": "3",
  50. "businessTeamType": 3,
  51. "status": 2
  52. },
  53. {
  54. "businessTeamKey": "161",
  55. "businessTeamCode": "TM哈哈哈0010",
  56. "businessTeamName": "哈哈哈",
  57. "description": "",
  58. "businessGroupCode": "20",
  59. "businessUnitCode": "BU0101",
  60. "parentBusinessTeamCode": "TM0112",
  61. "lastStage": 1,
  62. "businessTeamFunction": "3",
  63. "businessTeamType": 3,
  64. "status": 2
  65. },
  66. {
  67. "businessTeamKey": "162",
  68. "businessTeamCode": "TM哈哈哈0011",
  69. "businessTeamName": "哈哈哈",
  70. "description": "",
  71. "businessGroupCode": "20",
  72. "businessUnitCode": "BU0101",
  73. "parentBusinessTeamCode": "TM0112",
  74. "lastStage": 1,
  75. "businessTeamFunction": "3",
  76. "businessTeamType": 3,
  77. "status": 2
  78. }
  79. ]
  80. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/1021879
推荐阅读
相关标签
  

闽ICP备14008679号