ProjectExplorer.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <script setup lang="ts">
  2. import {onMounted, reactive, ref, PropType} from "vue";
  3. const props = defineProps({
  4. data: {
  5. type: Array as PropType<SubjectTreeNode[]>,
  6. required: true,
  7. },
  8. })
  9. // 上下文菜单设置
  10. const menuGroup: Comp.ContextMenu.MenuGroup[] = [
  11. [
  12. {
  13. text: '新建单项工程',
  14. icon: 'dsk-home-two-add',
  15. disable() {
  16. return false;
  17. },
  18. callback() {
  19. console.log('新建单项工程')
  20. },
  21. },
  22. {
  23. text: '新建单位工程',
  24. icon: 'dsk-file-addition-one',
  25. disable() {
  26. return false;
  27. },
  28. callback() {
  29. console.log('新建单位工程')
  30. },
  31. },
  32. {
  33. text: '重命名',
  34. icon: 'dsk-edit',
  35. disable() {
  36. return false;
  37. },
  38. callback() {
  39. console.log('重命名')
  40. },
  41. },
  42. {
  43. text: '删除',
  44. icon: 'dsk-delete-one',
  45. disable() {
  46. return false;
  47. },
  48. callback() {
  49. console.log('删除')
  50. },
  51. },
  52. {
  53. text: '分享协作',
  54. icon: 'dsk-peoples',
  55. disable() {
  56. return false;
  57. },
  58. callback() {
  59. console.log('分享协作')
  60. },
  61. },
  62. ],
  63. ];
  64. const readOnly = ref(false)
  65. const loading = ref(false)
  66. const data = [
  67. {
  68. label: '市妇幼保健院新址配套市政道路',
  69. icon: 'dsk-city-one',
  70. children: [
  71. {
  72. label: '单项工程1',
  73. icon: 'dsk-home-two',
  74. children: [
  75. {
  76. label: '单位工程1.1',
  77. },
  78. {
  79. label: '单位工程1.2',
  80. },
  81. ],
  82. },
  83. {
  84. label: '单项工程2',
  85. icon: 'dsk-home-two',
  86. children: [
  87. {
  88. label: '单位工程2.1',
  89. },
  90. {
  91. label: '单位工程2.2',
  92. },
  93. ],
  94. },
  95. ],
  96. },
  97. ]
  98. </script>
  99. <template>
  100. <section class="project-explorer">
  101. <ul class="tabs">
  102. <li class="tab active">原始结构</li>
  103. <li class="tab">整理结构</li>
  104. </ul>
  105. <div class="tree-wrap">
  106. <context-menu :item-groups="menuGroup" ref="contextMenuRef" :readOnly="readOnly" auto-size>
  107. <el-tree
  108. class="subject-tree"
  109. v-loading="loading"
  110. icon-class="el-icon-arrow-right"
  111. :data="data"
  112. default-expand-all
  113. :expand-on-click-node="false"
  114. node-key="id"
  115. highlight-current
  116. :current-node-key="currentNodeKey"
  117. @node-click="handleNodeClick"
  118. @node-contextmenu="handleNodeContextmenu"
  119. ref="treeRef"
  120. >
  121. <template #default="{ data }">
  122. <span class="custom-tree-node">
  123. <iconfont class="subject-icon" :class="data.icon"/>
  124. <span class="text-wrap">
  125. <i class="text" :title="data.label">{{ data.label }}</i>
  126. </span>
  127. </span>
  128. </template>
  129. </el-tree>
  130. </context-menu>
  131. </div>
  132. </section>
  133. </template>
  134. <style lang="scss" src="./style.scss" scoped></style>