|
@@ -1,28 +1,49 @@
|
|
<script lang="tsx">
|
|
<script lang="tsx">
|
|
- import type { DescOptions, DescInstance, DescItem } from './types';
|
|
|
|
|
|
+ import type { DescriptionProps, DescInstance, DescItem } from './typing';
|
|
import type { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
|
|
import type { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
|
|
import type { CSSProperties } from 'vue';
|
|
import type { CSSProperties } from 'vue';
|
|
import type { CollapseContainerOptions } from '/@/components/Container/index';
|
|
import type { CollapseContainerOptions } from '/@/components/Container/index';
|
|
-
|
|
|
|
import { defineComponent, computed, ref, unref } from 'vue';
|
|
import { defineComponent, computed, ref, unref } from 'vue';
|
|
import { get } from 'lodash-es';
|
|
import { get } from 'lodash-es';
|
|
import { Descriptions } from 'ant-design-vue';
|
|
import { Descriptions } from 'ant-design-vue';
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
-
|
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
-
|
|
|
|
import { isFunction } from '/@/utils/is';
|
|
import { isFunction } from '/@/utils/is';
|
|
import { getSlot } from '/@/utils/helper/tsxHelper';
|
|
import { getSlot } from '/@/utils/helper/tsxHelper';
|
|
-
|
|
|
|
- import descProps from './props';
|
|
|
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
|
|
|
|
|
|
|
+ const props = {
|
|
|
|
+ useCollapse: { type: Boolean, default: true },
|
|
|
|
+ title: { type: String, default: '' },
|
|
|
|
+ size: {
|
|
|
|
+ type: String,
|
|
|
|
+ validator: (v) => ['small', 'default', 'middle', undefined].includes(v),
|
|
|
|
+ default: 'small',
|
|
|
|
+ },
|
|
|
|
+ bordered: { type: Boolean, default: true },
|
|
|
|
+ column: {
|
|
|
|
+ type: [Number, Object] as PropType<number | Recordable>,
|
|
|
|
+ default: () => {
|
|
|
|
+ return { xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 };
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ collapseOptions: {
|
|
|
|
+ type: Object as PropType<CollapseContainerOptions>,
|
|
|
|
+ default: null,
|
|
|
|
+ },
|
|
|
|
+ schema: {
|
|
|
|
+ type: Array as PropType<DescItem[]>,
|
|
|
|
+ default: () => [],
|
|
|
|
+ },
|
|
|
|
+ data: { type: Object },
|
|
|
|
+ };
|
|
|
|
+
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
name: 'Description',
|
|
name: 'Description',
|
|
- props: descProps,
|
|
|
|
|
|
+ props,
|
|
emits: ['register'],
|
|
emits: ['register'],
|
|
setup(props, { slots, emit }) {
|
|
setup(props, { slots, emit }) {
|
|
- const propsRef = ref<Partial<DescOptions> | null>(null);
|
|
|
|
|
|
+ const propsRef = ref<Partial<DescriptionProps> | null>(null);
|
|
|
|
|
|
const { prefixCls } = useDesign('description');
|
|
const { prefixCls } = useDesign('description');
|
|
const attrs = useAttrs();
|
|
const attrs = useAttrs();
|
|
@@ -32,7 +53,7 @@
|
|
return {
|
|
return {
|
|
...props,
|
|
...props,
|
|
...(unref(propsRef) as Recordable),
|
|
...(unref(propsRef) as Recordable),
|
|
- } as DescOptions;
|
|
|
|
|
|
+ } as DescriptionProps;
|
|
});
|
|
});
|
|
|
|
|
|
const getProps = computed(() => {
|
|
const getProps = computed(() => {
|
|
@@ -40,7 +61,7 @@
|
|
...unref(getMergeProps),
|
|
...unref(getMergeProps),
|
|
title: undefined,
|
|
title: undefined,
|
|
};
|
|
};
|
|
- return opt as DescOptions;
|
|
|
|
|
|
+ return opt as DescriptionProps;
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -66,7 +87,7 @@
|
|
/**
|
|
/**
|
|
* @description:设置desc
|
|
* @description:设置desc
|
|
*/
|
|
*/
|
|
- function setDescProps(descProps: Partial<DescOptions>): void {
|
|
|
|
|
|
+ function setDescProps(descProps: Partial<DescriptionProps>): void {
|
|
// Keep the last setDrawerProps
|
|
// Keep the last setDrawerProps
|
|
propsRef.value = { ...(unref(propsRef) as Recordable), ...descProps } as Recordable;
|
|
propsRef.value = { ...(unref(propsRef) as Recordable), ...descProps } as Recordable;
|
|
}
|
|
}
|
|
@@ -79,7 +100,6 @@
|
|
|
|
|
|
const labelStyles: CSSProperties = {
|
|
const labelStyles: CSSProperties = {
|
|
...labelStyle,
|
|
...labelStyle,
|
|
-
|
|
|
|
minWidth: `${labelMinWidth}px `,
|
|
minWidth: `${labelMinWidth}px `,
|
|
};
|
|
};
|
|
return <div style={labelStyles}>{label}</div>;
|
|
return <div style={labelStyles}>{label}</div>;
|
|
@@ -97,7 +117,9 @@
|
|
|
|
|
|
const getContent = () => {
|
|
const getContent = () => {
|
|
const _data = unref(getProps)?.data;
|
|
const _data = unref(getProps)?.data;
|
|
- if (!_data) return null;
|
|
|
|
|
|
+ if (!_data) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
const getField = get(_data, field);
|
|
const getField = get(_data, field);
|
|
return isFunction(render) ? render(getField, _data) : getField ?? '';
|
|
return isFunction(render) ? render(getField, _data) : getField ?? '';
|
|
};
|
|
};
|
|
@@ -131,7 +153,6 @@
|
|
const renderContainer = () => {
|
|
const renderContainer = () => {
|
|
const content = props.useCollapse ? renderDesc() : <div>{renderDesc()}</div>;
|
|
const content = props.useCollapse ? renderDesc() : <div>{renderDesc()}</div>;
|
|
// Reduce the dom level
|
|
// Reduce the dom level
|
|
-
|
|
|
|
if (!props.useCollapse) {
|
|
if (!props.useCollapse) {
|
|
return content;
|
|
return content;
|
|
}
|
|
}
|