index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="dashboard-container">
  3. <div class="dashboard-text">月度报告</div>
  4. <el-tree default-expand-all :data="data">
  5. <span
  6. class="custom-tree-node"
  7. :default-slot="{node,data}"
  8. style="width: 100%"
  9. @mouseenter="mouseenter(data)"
  10. @mouseleave="mouseleave(data)"
  11. >
  12. <span>{{ node.label }}</span>
  13. <el-link
  14. v-show="data.show"
  15. size="mini"
  16. style="margin-left: 5px"
  17. type="primary"
  18. icon="el-icon-plus"
  19. ></el-link>
  20. <el-link
  21. v-show="data.show"
  22. size="mini"
  23. style="margin-left: 5px"
  24. type="primary"
  25. icon="el-icon-delete"
  26. ></el-link>
  27. </span>
  28. </el-tree>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapGetters } from "vuex";
  33. export default {
  34. name: "Dashboard",
  35. computed: {
  36. ...mapGetters(["name"]),
  37. },
  38. data() {
  39. return {
  40. data: [
  41. {
  42. id: 0,
  43. label: "水果",
  44. show: false,
  45. children: [
  46. {
  47. id: 1,
  48. label: "苹果",
  49. show: false,
  50. },
  51. {
  52. id: 2,
  53. label: "芒果",
  54. show: false,
  55. },
  56. ],
  57. },
  58. ],
  59. };
  60. },
  61. methods: {
  62. mouseenter(data) {
  63. alert(1)
  64. console.log(data);
  65. data.show = true;
  66. },
  67. mouseleave(data) {
  68. console.log(data);
  69. data.show = false;
  70. },
  71. },
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. .dashboard {
  76. &-container {
  77. margin: 30px;
  78. }
  79. &-text {
  80. font-size: 30px;
  81. line-height: 46px;
  82. }
  83. }
  84. </style>