From 49e415d27788cb468c96f2a828f1df7ae65b7a3c Mon Sep 17 00:00:00 2001 From: kailong321200875 <321200875@qq.com> Date: Sun, 25 Jun 2023 16:02:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Descriptions=E7=BB=84=E4=BB=B6=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ConfigGlobal/index.ts | 2 + src/components/ContextMenu/index.ts | 2 + .../ContextMenu/src/ContextMenu.vue | 6 +- src/components/ContextMenu/src/types/index.ts | 4 +- src/components/Descriptions/index.ts | 2 + .../Descriptions/src/Descriptions.vue | 215 +++++++++--------- .../Descriptions/src/types/index.ts | 4 + src/components/Form/src/types/index.ts | 1 - .../Search/src/components/ActionButton.vue | 2 +- src/components/Setting/src/Setting.vue | 2 +- src/hooks/web/useConfigGlobal.ts | 2 +- src/router/index.ts | 32 +-- src/views/Components/Descriptions.vue | 151 +++++++----- uno.config.ts | 8 +- 14 files changed, 247 insertions(+), 186 deletions(-) diff --git a/src/components/ConfigGlobal/index.ts b/src/components/ConfigGlobal/index.ts index dda2462..eaeb7d0 100644 --- a/src/components/ConfigGlobal/index.ts +++ b/src/components/ConfigGlobal/index.ts @@ -1,3 +1,5 @@ import ConfigGlobal from './src/ConfigGlobal.vue' +export type { ConfigGlobalTypes } from './src/types' + export { ConfigGlobal } diff --git a/src/components/ContextMenu/index.ts b/src/components/ContextMenu/index.ts index 2a7c1f0..1b5442d 100644 --- a/src/components/ContextMenu/index.ts +++ b/src/components/ContextMenu/index.ts @@ -2,6 +2,8 @@ import ContextMenu from './src/ContextMenu.vue' import { ElDropdown } from 'element-plus' import type { RouteLocationNormalizedLoaded } from 'vue-router' +export type { ContextMenuSchema } from './src/types' + export interface ContextMenuExpose { elDropdownMenuRef: ComponentRef tagItem: RouteLocationNormalizedLoaded diff --git a/src/components/ContextMenu/src/ContextMenu.vue b/src/components/ContextMenu/src/ContextMenu.vue index ddba8be..9583037 100644 --- a/src/components/ContextMenu/src/ContextMenu.vue +++ b/src/components/ContextMenu/src/ContextMenu.vue @@ -4,7 +4,7 @@ import { PropType, ref } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { useDesign } from '@/hooks/web/useDesign' import type { RouteLocationNormalizedLoaded } from 'vue-router' -import { contextMenuSchema } from './types' +import { ContextMenuSchema } from './types' const { getPrefixCls } = useDesign() const prefixCls = getPrefixCls('context-menu') @@ -15,7 +15,7 @@ const emit = defineEmits(['visibleChange']) const props = defineProps({ schema: { - type: Array as PropType, + type: Array as PropType, default: () => [] }, trigger: { @@ -28,7 +28,7 @@ const props = defineProps({ } }) -const command = (item: contextMenuSchema) => { +const command = (item: ContextMenuSchema) => { item.command && item.command(item) } diff --git a/src/components/ContextMenu/src/types/index.ts b/src/components/ContextMenu/src/types/index.ts index 0738d0e..b2be72b 100644 --- a/src/components/ContextMenu/src/types/index.ts +++ b/src/components/ContextMenu/src/types/index.ts @@ -1,7 +1,7 @@ -export type contextMenuSchema = { +export interface ContextMenuSchema { disabled?: boolean divided?: boolean icon?: string label: string - command?: (item: contextMenuSchema) => void + command?: (item: ContextMenuSchema) => void } diff --git a/src/components/Descriptions/index.ts b/src/components/Descriptions/index.ts index 91b0eb4..8f9a0f0 100644 --- a/src/components/Descriptions/index.ts +++ b/src/components/Descriptions/index.ts @@ -1,3 +1,5 @@ import Descriptions from './src/Descriptions.vue' +export type { DescriptionsSchema } from './src/types' + export { Descriptions } diff --git a/src/components/Descriptions/src/Descriptions.vue b/src/components/Descriptions/src/Descriptions.vue index a9948d1..ef5fd6b 100644 --- a/src/components/Descriptions/src/Descriptions.vue +++ b/src/components/Descriptions/src/Descriptions.vue @@ -1,130 +1,135 @@ - + const toggleClick = () => { + if (props.collapse) { + show.value = !unref(show) + } + } - + +
+ + {{ + extra: () => (slots['extra'] ? slots['extra']() : props.extra), + default: () => { + return props.schema.map((item) => { + return ( + + {{ + label: () => (item.slots?.label ? item.slots?.label(item) : item.label), + default: () => + item.slots?.default + ? item.slots?.default(item) + : props.data[item.field] + }} + + ) + }) + } + }} + +
+
+ + ) + } + } +}) +