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 @@
+
+
+
+
+
+
+
+
+ {{ calcItem.slotsResult[slotKey].result }}
+
+
+
+
+
+
+
+
+
+
+
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
+})
+
@@ -252,11 +270,12 @@ const formatResult = computed(() => {
{
:readonly="calcOption.readonly"
@change="controlChange"
>
+
+
+
+ {{ slotsResult[slotKey].result }}
+
+
{
return toLabelByKey(menuInfo.labelKey)
}
}
- if (item.meta && item.meta.labelKey) {
- return toLabelByKey(item.meta.labelKey)
+ if (item.meta && (item.meta.label || item.meta.labelKey)) {
+ return item.meta.label || toLabelByKey(item.meta.labelKey)
}
return item.name || 'No Name'
}
@@ -154,6 +154,24 @@ export const proxyMethod = (targets = [], methodName) => {
}
}
+export const calcSlotsResult = (config, data) => {
+ const results = {}
+ if (config?.slots) {
+ const slots = config.slots
+ for (const slotKey in slots) {
+ const slot = slots[slotKey]
+ if (isFunction(slot)) {
+ const slotResult = slot(data, config)
+ results[slotKey] = {
+ result: slotResult,
+ vnode: isVNode(slotResult)
+ }
+ }
+ }
+ }
+ return results
+}
+
/**
* 定义表单选项,带有jsdoc注解,方便代码提示
* @param {CommonFormOption|CommonFormOption[]} formOptions 表单选项