88 <template #icon ><icon-plus /></template >
99 </a-button >
1010 </div >
11- <div class =" dict-tree__container" >
12- <div class =" dict-tree__tree" >
11+ <a class =" dict-tree__container" >
12+ <a class =" dict-tree__tree" >
1313 <a-tree :data =" (treeData as unknown as TreeNodeData[])" :field-names =" { key: 'id' }" block-node
1414 @select =" select" >
1515 <template #title =" node " >
16- <a-trigger v-model:popup-visible =" node.popupVisible" trigger =" contextMenu" align-point
17- animation-name =" slide-dynamic-origin" auto-fit-transform-origin position =" bl" scroll-to-close >
18- <a-tooltip v-if =" node.description" :content =" node.description" background-color =" rgb(var(--primary-6))" position =" right" >
19- <div @contextmenu =" onContextmenu(node)" >{{ node.name }} ({{ node.code }})</div >
20- </a-tooltip >
21- <div v-else @contextmenu =" onContextmenu(node)" >{{ node.name }} ({{ node.code }})</div >
16+ <a-typography-paragraph
17+ :ellipsis =" {
18+ rows: 1,
19+ showTooltip: true,
20+ css: true,
21+ }"
22+ >
23+ {{ node.name }} ({{ node.code }})
24+ </a-typography-paragraph >
25+ </template >
26+ <template #extra =" node " >
27+ <a-trigger trigger =" click" align-point animation-name =" slide-dynamic-origin" auto-fit-transform-origin position =" bl" scroll-to-close >
28+ <icon-more-vertical class =" action" />
2229 <template #content >
23- <RightMenu v-if =" has.hasPermOr(['system:dict:update', 'system:dict:delete'])" :data =" node"
24- @on-menu-item-click =" onMenuItemClick" />
30+ <RightMenu
31+ v-if =" has.hasPermOr(['system:dict:update', 'system:dict:delete'])"
32+ :data =" node"
33+ @on-menu-item-click =" onMenuItemClick"
34+ />
2535 </template >
2636 </a-trigger >
2737 </template >
2838 </a-tree >
29- </div >
30- </div >
39+ </a >
40+ </a >
3141 </div >
3242
3343 <DictAddModal ref =" DictAddModalRef" @save-success =" getTreeData" />
@@ -51,8 +61,14 @@ const props = withDefaults(defineProps<Props>(), {
5161const emit = defineEmits <{
5262 (e : ' node-click' , keys : Array <any >): void
5363}>()
64+
65+ const selectKey = ref ()
5466// 选中节点
5567const select = (keys : Array <any >) => {
68+ if (selectKey .value === keys [0 ]) {
69+ return
70+ }
71+ selectKey .value = keys [0 ]
5672 emit (' node-click' , keys )
5773}
5874
@@ -89,28 +105,14 @@ watch(inputValue, (val) => {
89105 getTreeData ()
90106})
91107
92- // 保存当前右键的节点
93- const contextmenuNode = ref <TreeItem | null >(null )
94- const onContextmenu = (node : TreeItem ) => {
95- contextmenuNode .value = node
96- }
97-
98- // 关闭右键菜单弹框
99- const closeRightMenuPopup = () => {
100- if (contextmenuNode .value ?.popupVisible ) {
101- contextmenuNode .value .popupVisible = false
102- }
103- }
104-
105108const DictAddModalRef = ref <InstanceType <typeof DictAddModal >>()
106109// 新增
107110const onAdd = () => {
108111 DictAddModalRef .value ?.onAdd ()
109112}
110113
111- // 右键菜单项点击
114+ // 点击菜单项
112115const onMenuItemClick = (mode : string , node : DictResp ) => {
113- closeRightMenuPopup ()
114116 if (mode === ' update' ) {
115117 DictAddModalRef .value ?.onUpdate (node .id )
116118 } else if (mode === ' delete' ) {
@@ -141,16 +143,18 @@ onMounted(() => {
141143 </script >
142144
143145<style lang="scss" scoped>
144- :deep(.arco-tree-node-title-text ) {
145- width : 100% ;
146- white-space : nowrap ;
147- }
148-
149146:deep(.arco-tree-node ) {
150147 line-height : normal ;
151148 border-radius : var (--border-radius-medium );
149+ margin : 5px 0 ;
150+ .action {
151+ opacity : 0 ;
152+ }
152153 & :hover {
153154 background-color : var (--color-secondary-hover );
155+ .action {
156+ opacity : 1 ;
157+ }
154158 }
155159
156160 .arco-tree-node-switcher {
@@ -163,13 +167,19 @@ onMounted(() => {
163167 background-color : transparent ;
164168 }
165169 }
170+
171+ .arco-tree-node-title-text {
172+ width : 100% ;
173+ white-space : normal ;
174+ overflow-wrap : anywhere;
175+ }
166176}
167177
168178:deep(.arco-tree-node-selected ) {
169179 font-weight : bold ;
170180 background-color : rgba (var (--primary-6 ), 0.1 );
171- & :hover {
172- background- color : rgba (var (--primary-6 ), 0.1 );
181+ .arco-typography {
182+ color : rgb (var (--primary-6 ));
173183 }
174184}
175185
0 commit comments