From b0ef42dc1dbbe2f13fe17e8fc7c156ccdbbf05b7 Mon Sep 17 00:00:00 2001 From: Gary Fu Date: Sun, 28 Jul 2024 21:41:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9E=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8C=85=E8=A3=85=E6=8E=A7=E4=BB=B6=202.=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96tooltip=E6=98=BE=E7=A4=BA=203.=20=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=B1=9E=E6=80=A7slots=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/MockMenus.js | 2 +- src/components/common-descriptions/index.vue | 83 +++++++++++++++++++ .../common-descriptions/public.d.ts | 30 +++++++ .../common-form-control/control-child.vue | 3 +- src/components/common-form-control/index.vue | 34 +++++++- src/components/index.js | 2 + src/components/utils/index.js | 24 +++++- 7 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 src/components/common-descriptions/index.vue create mode 100644 src/components/common-descriptions/public.d.ts diff --git a/mock/MockMenus.js b/mock/MockMenus.js index acde6be..c9695e1 100644 --- a/mock/MockMenus.js +++ b/mock/MockMenus.js @@ -78,7 +78,7 @@ const allMenus = [ { id: 25, parentId: 2, - iconCls: 'PieChartSharp', + iconCls: 'PieChart', nameCn: '图表示例', nameEn: 'Charts', menuUrl: '/charts' diff --git a/src/components/common-descriptions/index.vue b/src/components/common-descriptions/index.vue new file mode 100644 index 0000000..02b7f3a --- /dev/null +++ b/src/components/common-descriptions/index.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/components/common-descriptions/public.d.ts b/src/components/common-descriptions/public.d.ts new file mode 100644 index 0000000..2f10b73 --- /dev/null +++ b/src/components/common-descriptions/public.d.ts @@ -0,0 +1,30 @@ +import { VNode } from 'vue' +import { descriptionItemProps } from 'element-plus/es/components/descriptions/src/description-item' + +export interface CommonDescriptionItem { + label?: string; + labelKey?: string; + value?: string; + span?: number; + width?: string; + minWidth?: string; + className?: string; + labelClassName?: string; + align?: 'left' | 'right' | 'center'; + labelAlign?: string; + slots?: any; + formatter?: (item: CommonDescriptionItem) => string | VNode; + attrs?: descriptionItemProps; +} + +export interface CommonDescriptionProps { + border?: boolean; + column?: number; + direction?: 'horizontal' | 'vertical'; + size?: 'default' | 'small' | 'large'; + title?: string; + extra?: string; + items?: Array; + width?: string; + minWidth?: string; +} diff --git a/src/components/common-form-control/control-child.vue b/src/components/common-form-control/control-child.vue index f91a86a..0118d16 100644 --- a/src/components/common-form-control/control-child.vue +++ b/src/components/common-form-control/control-child.vue @@ -48,11 +48,12 @@ const tooltipFunc = ($event) => { {{ label }} { return null }) +const slotsResult = computed(() => { + const results = {} + if (calcOption.value?.slots) { + const slots = calcOption.value.slots + for (const slotKey in slots) { + const slot = slots[slotKey] + if (isFunction(slot)) { + const slotResult = slot(modelValue.value, calcOption.value) + results[slotKey] = { + result: slotResult, + vnode: isVNode(slotResult) + } + } + } + } + return results +}) +