Skip to content

Commit e29cf88

Browse files
committed
style: 调整字典的操作菜单弹出方式,由右键弹出调整为点击更多按钮弹出
1 parent 47a5c44 commit e29cf88

File tree

2 files changed

+53
-42
lines changed

2 files changed

+53
-42
lines changed

src/views/system/dict/tree/RightMenu.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<template>
22
<a-menu class="right-menu">
33
<a-menu-item v-permission="['system:dict:update']" @click="onClick('update')">
4-
<template #icon><icon-edit :size="16" :stroke-width="3" /></template>
54
<span>修改</span>
65
</a-menu-item>
7-
8-
<a-menu-item v-permission="['system:dict:delete']" :title="data.isSystem ? '系统内置数据不能删除' : undefined" :disabled="data.isSystem" @click="onClick('delete')">
9-
<template #icon><icon-delete :size="16" :stroke-width="3" /></template>
6+
<a-menu-item v-permission="['system:dict:delete']" class="danger" :title="data.isSystem ? '系统内置数据不能删除' : undefined" :disabled="data.isSystem" @click="onClick('delete')">
107
<span>删除</span>
118
</a-menu-item>
129
</a-menu>
@@ -38,14 +35,18 @@ const onClick = (mode: string) => {
3835
.arco-menu-item {
3936
height: 34px;
4037
41-
&:not(.arco-menu-selected) {
42-
color: $color-text-1;
43-
}
44-
4538
&:last-child {
4639
margin-bottom: 0;
4740
}
4841
}
42+
43+
.danger {
44+
color: rgb(var(--danger-6));
45+
}
46+
47+
.danger.arco-menu-disabled {
48+
color: var(--color-danger-light-3);
49+
}
4950
}
5051
5152
.right-menu {

src/views/system/dict/tree/index.vue

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,36 @@
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>(), {
5161
const emit = defineEmits<{
5262
(e: 'node-click', keys: Array<any>): void
5363
}>()
64+
65+
const selectKey = ref()
5466
// 选中节点
5567
const 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-
105108
const DictAddModalRef = ref<InstanceType<typeof DictAddModal>>()
106109
// 新增
107110
const onAdd = () => {
108111
DictAddModalRef.value?.onAdd()
109112
}
110113
111-
// 右键菜单项点击
114+
// 点击菜单项
112115
const 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

Comments
 (0)