mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-11-04 10:57:08 +08:00 
			
		
		
		
	style: 调整字典的操作菜单弹出方式,由右键弹出调整为点击更多按钮弹出
This commit is contained in:
		@@ -1,12 +1,9 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <a-menu class="right-menu">
 | 
					  <a-menu class="right-menu">
 | 
				
			||||||
    <a-menu-item v-permission="['system:dict:update']" @click="onClick('update')">
 | 
					    <a-menu-item v-permission="['system:dict:update']" @click="onClick('update')">
 | 
				
			||||||
      <template #icon><icon-edit :size="16" :stroke-width="3" /></template>
 | 
					 | 
				
			||||||
      <span>修改</span>
 | 
					      <span>修改</span>
 | 
				
			||||||
    </a-menu-item>
 | 
					    </a-menu-item>
 | 
				
			||||||
 | 
					    <a-menu-item v-permission="['system:dict:delete']" class="danger" :title="data.isSystem ? '系统内置数据不能删除' : undefined" :disabled="data.isSystem" @click="onClick('delete')">
 | 
				
			||||||
    <a-menu-item v-permission="['system:dict:delete']" :title="data.isSystem ? '系统内置数据不能删除' : undefined" :disabled="data.isSystem" @click="onClick('delete')">
 | 
					 | 
				
			||||||
      <template #icon><icon-delete :size="16" :stroke-width="3" /></template>
 | 
					 | 
				
			||||||
      <span>删除</span>
 | 
					      <span>删除</span>
 | 
				
			||||||
    </a-menu-item>
 | 
					    </a-menu-item>
 | 
				
			||||||
  </a-menu>
 | 
					  </a-menu>
 | 
				
			||||||
@@ -38,14 +35,18 @@ const onClick = (mode: string) => {
 | 
				
			|||||||
  .arco-menu-item {
 | 
					  .arco-menu-item {
 | 
				
			||||||
    height: 34px;
 | 
					    height: 34px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    &:not(.arco-menu-selected) {
 | 
					 | 
				
			||||||
      color: $color-text-1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    &:last-child {
 | 
					    &:last-child {
 | 
				
			||||||
      margin-bottom: 0;
 | 
					      margin-bottom: 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .danger {
 | 
				
			||||||
 | 
					    color: rgb(var(--danger-6));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .danger.arco-menu-disabled {
 | 
				
			||||||
 | 
					    color: var(--color-danger-light-3);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.right-menu {
 | 
					.right-menu {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,26 +8,36 @@
 | 
				
			|||||||
        <template #icon><icon-plus /></template>
 | 
					        <template #icon><icon-plus /></template>
 | 
				
			||||||
      </a-button>
 | 
					      </a-button>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class="dict-tree__container">
 | 
					    <a class="dict-tree__container">
 | 
				
			||||||
      <div class="dict-tree__tree">
 | 
					      <a class="dict-tree__tree">
 | 
				
			||||||
        <a-tree :data="(treeData as unknown as TreeNodeData[])" :field-names="{ key: 'id' }" block-node
 | 
					        <a-tree :data="(treeData as unknown as TreeNodeData[])" :field-names="{ key: 'id' }" block-node
 | 
				
			||||||
          @select="select">
 | 
					          @select="select">
 | 
				
			||||||
          <template #title="node">
 | 
					          <template #title="node">
 | 
				
			||||||
            <a-trigger v-model:popup-visible="node.popupVisible" trigger="contextMenu" align-point
 | 
					            <a-typography-paragraph
 | 
				
			||||||
              animation-name="slide-dynamic-origin" auto-fit-transform-origin position="bl" scroll-to-close>
 | 
					              :ellipsis="{
 | 
				
			||||||
              <a-tooltip v-if="node.description" :content="node.description" background-color="rgb(var(--primary-6))" position="right">
 | 
					                rows: 1,
 | 
				
			||||||
                <div @contextmenu="onContextmenu(node)">{{ node.name }} ({{ node.code }})</div>
 | 
					                showTooltip: true,
 | 
				
			||||||
              </a-tooltip>
 | 
					                css: true,
 | 
				
			||||||
              <div v-else @contextmenu="onContextmenu(node)">{{ node.name }} ({{ node.code }})</div>
 | 
					              }"
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
 | 
					              {{ node.name }} ({{ node.code }})
 | 
				
			||||||
 | 
					            </a-typography-paragraph>
 | 
				
			||||||
 | 
					          </template>
 | 
				
			||||||
 | 
					          <template #extra="node">
 | 
				
			||||||
 | 
					            <a-trigger trigger="click" align-point animation-name="slide-dynamic-origin" auto-fit-transform-origin position="bl" scroll-to-close>
 | 
				
			||||||
 | 
					              <icon-more-vertical class="action" />
 | 
				
			||||||
              <template #content>
 | 
					              <template #content>
 | 
				
			||||||
                <RightMenu v-if="has.hasPermOr(['system:dict:update', 'system:dict:delete'])" :data="node"
 | 
					                <RightMenu
 | 
				
			||||||
                  @on-menu-item-click="onMenuItemClick" />
 | 
					                  v-if="has.hasPermOr(['system:dict:update', 'system:dict:delete'])"
 | 
				
			||||||
 | 
					                  :data="node"
 | 
				
			||||||
 | 
					                  @on-menu-item-click="onMenuItemClick"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
              </template>
 | 
					              </template>
 | 
				
			||||||
            </a-trigger>
 | 
					            </a-trigger>
 | 
				
			||||||
          </template>
 | 
					          </template>
 | 
				
			||||||
        </a-tree>
 | 
					        </a-tree>
 | 
				
			||||||
      </div>
 | 
					      </a>
 | 
				
			||||||
    </div>
 | 
					    </a>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
 | 
					  <DictAddModal ref="DictAddModalRef" @save-success="getTreeData" />
 | 
				
			||||||
@@ -51,8 +61,14 @@ const props = withDefaults(defineProps<Props>(), {
 | 
				
			|||||||
const emit = defineEmits<{
 | 
					const emit = defineEmits<{
 | 
				
			||||||
  (e: 'node-click', keys: Array<any>): void
 | 
					  (e: 'node-click', keys: Array<any>): void
 | 
				
			||||||
}>()
 | 
					}>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const selectKey = ref()
 | 
				
			||||||
// 选中节点
 | 
					// 选中节点
 | 
				
			||||||
const select = (keys: Array<any>) => {
 | 
					const select = (keys: Array<any>) => {
 | 
				
			||||||
 | 
					  if (selectKey.value === keys[0]) {
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  selectKey.value = keys[0]
 | 
				
			||||||
  emit('node-click', keys)
 | 
					  emit('node-click', keys)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -89,28 +105,14 @@ watch(inputValue, (val) => {
 | 
				
			|||||||
  getTreeData()
 | 
					  getTreeData()
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 保存当前右键的节点
 | 
					 | 
				
			||||||
const contextmenuNode = ref<TreeItem | null>(null)
 | 
					 | 
				
			||||||
const onContextmenu = (node: TreeItem) => {
 | 
					 | 
				
			||||||
  contextmenuNode.value = node
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// 关闭右键菜单弹框
 | 
					 | 
				
			||||||
const closeRightMenuPopup = () => {
 | 
					 | 
				
			||||||
  if (contextmenuNode.value?.popupVisible) {
 | 
					 | 
				
			||||||
    contextmenuNode.value.popupVisible = false
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const DictAddModalRef = ref<InstanceType<typeof DictAddModal>>()
 | 
					const DictAddModalRef = ref<InstanceType<typeof DictAddModal>>()
 | 
				
			||||||
// 新增
 | 
					// 新增
 | 
				
			||||||
const onAdd = () => {
 | 
					const onAdd = () => {
 | 
				
			||||||
  DictAddModalRef.value?.onAdd()
 | 
					  DictAddModalRef.value?.onAdd()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 右键菜单项点击
 | 
					// 点击菜单项
 | 
				
			||||||
const onMenuItemClick = (mode: string, node: DictResp) => {
 | 
					const onMenuItemClick = (mode: string, node: DictResp) => {
 | 
				
			||||||
  closeRightMenuPopup()
 | 
					 | 
				
			||||||
  if (mode === 'update') {
 | 
					  if (mode === 'update') {
 | 
				
			||||||
    DictAddModalRef.value?.onUpdate(node.id)
 | 
					    DictAddModalRef.value?.onUpdate(node.id)
 | 
				
			||||||
  } else if (mode === 'delete') {
 | 
					  } else if (mode === 'delete') {
 | 
				
			||||||
@@ -141,16 +143,18 @@ onMounted(() => {
 | 
				
			|||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style lang="scss" scoped>
 | 
					<style lang="scss" scoped>
 | 
				
			||||||
:deep(.arco-tree-node-title-text) {
 | 
					 | 
				
			||||||
  width: 100%;
 | 
					 | 
				
			||||||
  white-space: nowrap;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
:deep(.arco-tree-node) {
 | 
					:deep(.arco-tree-node) {
 | 
				
			||||||
  line-height: normal;
 | 
					  line-height: normal;
 | 
				
			||||||
  border-radius: var(--border-radius-medium);
 | 
					  border-radius: var(--border-radius-medium);
 | 
				
			||||||
 | 
					  margin: 5px 0;
 | 
				
			||||||
 | 
					  .action {
 | 
				
			||||||
 | 
					    opacity: 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  &:hover {
 | 
					  &:hover {
 | 
				
			||||||
    background-color: var(--color-secondary-hover);
 | 
					    background-color: var(--color-secondary-hover);
 | 
				
			||||||
 | 
					    .action {
 | 
				
			||||||
 | 
					      opacity: 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .arco-tree-node-switcher {
 | 
					  .arco-tree-node-switcher {
 | 
				
			||||||
@@ -163,13 +167,19 @@ onMounted(() => {
 | 
				
			|||||||
      background-color: transparent;
 | 
					      background-color: transparent;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .arco-tree-node-title-text {
 | 
				
			||||||
 | 
					    width: 100%;
 | 
				
			||||||
 | 
					    white-space: normal;
 | 
				
			||||||
 | 
					    overflow-wrap: anywhere;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
:deep(.arco-tree-node-selected) {
 | 
					:deep(.arco-tree-node-selected) {
 | 
				
			||||||
  font-weight: bold;
 | 
					  font-weight: bold;
 | 
				
			||||||
  background-color: rgba(var(--primary-6), 0.1);
 | 
					  background-color: rgba(var(--primary-6), 0.1);
 | 
				
			||||||
  &:hover {
 | 
					  .arco-typography {
 | 
				
			||||||
    background-color: rgba(var(--primary-6), 0.1);
 | 
					    color: rgb(var(--primary-6));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user