Node.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <script setup lang="ts">
  2. import { toRefs } from "vue";
  3. import type Node from "element-plus/es/components/tree/src/model/node";
  4. import {
  5. Delete,
  6. Plus,
  7. } from "@element-plus/icons-vue";
  8. import _ from "lodash";
  9. import type { TreeData } from "./Tree";
  10. const props = defineProps<{
  11. node: Node;
  12. data: TreeData;
  13. }>();
  14. const emit = defineEmits(["append", "remove"]);
  15. const { node, data } = toRefs(props);
  16. </script>
  17. <template>
  18. <div class="node">
  19. <el-tooltip :content="node.label" :show-after="500">
  20. <span class="label">{{ node.label }}</span>
  21. </el-tooltip>
  22. <el-button-group>
  23. <el-button
  24. v-if="data.isDir"
  25. type="primary"
  26. link
  27. @click.stop="() => emit('append')"
  28. :icon="Plus"
  29. >
  30. </el-button>
  31. <el-button
  32. type="danger"
  33. link
  34. @click.stop="() => emit('remove')"
  35. :icon="Delete"
  36. >
  37. </el-button>
  38. </el-button-group>
  39. </div>
  40. </template>
  41. <style lang="scss" scoped>
  42. .node {
  43. flex: 1;
  44. display: flex;
  45. overflow: hidden;
  46. .label {
  47. text-overflow: ellipsis;
  48. overflow: hidden;
  49. flex: 1;
  50. }
  51. }
  52. </style>