From 4202890d07ce9c584b083ed6258bcbb5bc305a71 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Tue, 14 Nov 2023 15:05:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AD=98=E4=B8=BB=E6=9C=BA?= =?UTF-8?q?=E5=88=86=E7=BB=84=E6=95=B0=E6=8D=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asset/entity/vo/HostGroupTreeVO.java | 3 - .../service/impl/DataGroupRelServiceImpl.java | 6 +- orion-ops-ui/src/api/asset/host-group.ts | 6 +- orion-ops-ui/src/hooks/copy.ts | 4 +- orion-ops-ui/src/store/modules/cache/index.ts | 5 +- orion-ops-ui/src/store/modules/cache/types.ts | 2 + orion-ops-ui/src/types/arco.d.ts | 1 - .../host-group/components/host-group-tree.vue | 36 +++++-- .../components/host-group-view-setting.vue | 40 +++----- .../host-group/components/host-transfer.vue | 96 ++++++++++++++++--- .../src/views/asset/host-group/index.vue | 30 ++---- orion-ops-ui/src/views/asset/host/index.vue | 2 +- .../src/views/system/dict-value/index.vue | 2 +- 13 files changed, 148 insertions(+), 85 deletions(-) diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostGroupTreeVO.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostGroupTreeVO.java index 1ffdc78c..15439884 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostGroupTreeVO.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/entity/vo/HostGroupTreeVO.java @@ -36,9 +36,6 @@ public class HostGroupTreeVO implements Serializable { @Schema(description = "组名称") private String name; - @Schema(description = "排序") - private Integer sort; - @Schema(description = "子节点") private List children; diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java index 8dcf4e7f..fb1f866f 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataGroupRelServiceImpl.java @@ -179,7 +179,7 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { @Override public List getGroupRelListByCache(String type, Long groupId) { return this.getGroupRelListByCache( - DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP.format(type), + DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP.format(groupId), DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP, () -> dataGroupRelDAO.of() .createWrapper() @@ -203,11 +203,11 @@ public class DataGroupRelServiceImpl implements DataGroupRelService { Supplier> valueSupplier) { // 查询缓存 List list = RedisStrings.getJsonArray(key, define); - if (list.isEmpty()) { + if (Lists.isEmpty(list)) { // 查询数据库 list = valueSupplier.get(); // 添加默认值 防止穿透 - if (list.isEmpty()) { + if (Lists.isEmpty(list)) { list.add(DataGroupRelCacheDTO.builder() .id(Const.NONE_ID) .build()); diff --git a/orion-ops-ui/src/api/asset/host-group.ts b/orion-ops-ui/src/api/asset/host-group.ts index cdaf1a36..215cc6b9 100644 --- a/orion-ops-ui/src/api/asset/host-group.ts +++ b/orion-ops-ui/src/api/asset/host-group.ts @@ -39,7 +39,7 @@ export interface HostGroupQueryResponse { */ export interface HostGroupRelUpdateRequest { groupId?: number; - relIdList?: Array; + relIdList?: Array; } /** @@ -80,8 +80,8 @@ export function deleteHostGroup(id: number) { /** * 查询分组内主机 */ -export function getHostGroupRelList() { - return axios.get>('/asset/host-group/rel-list'); +export function getHostGroupRelList(groupId: number) { + return axios.get>('/asset/host-group/rel-list', { params: { groupId } }); } /** diff --git a/orion-ops-ui/src/hooks/copy.ts b/orion-ops-ui/src/hooks/copy.ts index f1b3b801..12e89a16 100644 --- a/orion-ops-ui/src/hooks/copy.ts +++ b/orion-ops-ui/src/hooks/copy.ts @@ -3,13 +3,13 @@ import { Message } from '@arco-design/web-vue'; export default function useCopy() { const { isSupported, copy: c, text, copied } = useClipboard(); - const copy = async (value: string, tips = `${ value } 已复制`) => { + const copy = async (value: string, tips = `${value} 已复制`) => { try { await c(value); if (tips) { Message.success(tips); } - } catch { + } catch (e) { Message.error('复制失败'); } }; diff --git a/orion-ops-ui/src/store/modules/cache/index.ts b/orion-ops-ui/src/store/modules/cache/index.ts index 4ebb8be4..fcb571ad 100644 --- a/orion-ops-ui/src/store/modules/cache/index.ts +++ b/orion-ops-ui/src/store/modules/cache/index.ts @@ -1,13 +1,16 @@ import type { CacheState } from './types'; import { defineStore } from 'pinia'; -export type CacheType = 'users' | 'menus' | 'roles' | 'hostTags' | 'hostKeys' | 'hostIdentities' | 'dictKeys' | string +export type CacheType = 'users' | 'menus' | 'roles' + | 'host' | 'hostTags' | 'hostKeys' | 'hostIdentities' + | 'dictKeys' | string export default defineStore('cache', { state: (): CacheState => ({ users: [], menus: [], roles: [], + hosts: [], hostTags: [], hostKeys: [], hostIdentities: [], diff --git a/orion-ops-ui/src/store/modules/cache/types.ts b/orion-ops-ui/src/store/modules/cache/types.ts index 7b87109e..c8415a4f 100644 --- a/orion-ops-ui/src/store/modules/cache/types.ts +++ b/orion-ops-ui/src/store/modules/cache/types.ts @@ -5,12 +5,14 @@ import type { TagQueryResponse } from '@/api/meta/tag'; import type { HostKeyQueryResponse } from '@/api/asset/host-key'; import type { HostIdentityQueryResponse } from '@/api/asset/host-identity'; import type { DictKeyQueryResponse } from '@/api/system/dict-key'; +import type { HostQueryResponse } from '@/api/asset/host'; export interface CacheState { users: UserQueryResponse[]; menus: MenuQueryResponse[]; roles: RoleQueryResponse[]; hostTags: TagQueryResponse[]; + hosts: HostQueryResponse[]; hostKeys: HostKeyQueryResponse[]; hostIdentities: HostIdentityQueryResponse[]; dictKeys: DictKeyQueryResponse[]; diff --git a/orion-ops-ui/src/types/arco.d.ts b/orion-ops-ui/src/types/arco.d.ts index 8363c000..3077df97 100644 --- a/orion-ops-ui/src/types/arco.d.ts +++ b/orion-ops-ui/src/types/arco.d.ts @@ -4,6 +4,5 @@ import type { NodeData } from './global'; declare module '@arco-design/web-vue' { interface TreeNodeData extends NodeData { - [key: string]: any; } } diff --git a/orion-ops-ui/src/views/asset/host-group/components/host-group-tree.vue b/orion-ops-ui/src/views/asset/host-group/components/host-group-tree.vue index 6d13edfb..c897a0e4 100644 --- a/orion-ops-ui/src/views/asset/host-group/components/host-group-tree.vue +++ b/orion-ops-ui/src/views/asset/host-group/components/host-group-tree.vue @@ -36,7 +36,7 @@ + @click="() => emits('selectNode', node)"> {{ node.title }} @@ -94,7 +94,7 @@ const props = defineProps({ loading: Boolean }); - const emits = defineEmits(['loading', 'selectKey']); + const emits = defineEmits(['loading', 'selectNode']); const tree = ref(); const modCount = ref(0); @@ -278,7 +278,14 @@ emits('loading', true); const { data } = await getHostGroupTree(); treeData.value = data; - } catch { + // 未选择则选择首个 + if (!tree.value?.getSelectedNodes()?.length && data.length) { + await nextTick(() => { + tree.value?.selectNode(data[0].key); + emits('selectNode', data[0]); + }); + } + } catch (e) { } finally { emits('loading', false); } @@ -308,7 +315,17 @@ color: var(--color-text-3); } + :deep(.arco-tree-node) { + cursor: unset; + + .arco-tree-node-switcher { + margin-left: 8px; + } + } + :deep(.arco-tree-node-selected) { + background-color: var(--color-fill-2); + .arco-tree-node-title { &:hover { background-color: var(--color-fill-2); @@ -317,7 +334,8 @@ } :deep(.arco-tree-node-title) { - padding-right: 48px; + padding: 0 68px 0 0; + height: 32px; &:hover { background-color: var(--color-fill-1); @@ -325,17 +343,19 @@ .arco-tree-node-title-text { width: 100%; + height: 100%; display: flex; align-items: center; + cursor: pointer; } } - :deep(.arco-tree-node-selected) { - background-color: var(--color-fill-2); - } - .node-title-wrapper { width: 100%; + height: 100%; + display: flex; + align-items: center; + padding-left: 8px; } .tree-icon { diff --git a/orion-ops-ui/src/views/asset/host-group/components/host-group-view-setting.vue b/orion-ops-ui/src/views/asset/host-group/components/host-group-view-setting.vue index 30f08bd3..db550cba 100644 --- a/orion-ops-ui/src/views/asset/host-group/components/host-group-view-setting.vue +++ b/orion-ops-ui/src/views/asset/host-group/components/host-group-view-setting.vue @@ -28,13 +28,15 @@ + @select-node="selectGroup" /> - + @@ -45,6 +47,7 @@ @@ -127,10 +111,14 @@ display: flex; .handler-icon-wrapper { - margin-left: 8px; - color: rgb(var(--primary-6)); + margin-left: 2px; padding: 4px; font-size: 16px; + background: unset; + + &:hover { + background: var(--color-fill-3); + } } } diff --git a/orion-ops-ui/src/views/asset/host-group/components/host-transfer.vue b/orion-ops-ui/src/views/asset/host-group/components/host-transfer.vue index aecbbc8e..dfeec7cc 100644 --- a/orion-ops-ui/src/views/asset/host-group/components/host-transfer.vue +++ b/orion-ops-ui/src/views/asset/host-group/components/host-transfer.vue @@ -3,10 +3,21 @@
- 123123 + + + + + + - 保存