diff --git a/src/components/Form/src/BasicForm.vue b/src/components/Form/src/BasicForm.vue index b43f88c34..fec566c9a 100644 --- a/src/components/Form/src/BasicForm.vue +++ b/src/components/Form/src/BasicForm.vue @@ -53,7 +53,6 @@ export default defineComponent({ name: 'BasicForm', components: { FormItem, Form, Row, FormAction }, - inheritAttrs: false, props: basicProps, emits: ['advanced-change', 'reset', 'submit', 'register'], setup(props, { emit }) { @@ -279,7 +278,7 @@ &--compact { .ant-form-item { - margin-bottom: 8px; + margin-bottom: 8px !important; } } } diff --git a/src/components/Form/src/components/FormAction.vue b/src/components/Form/src/components/FormAction.vue index 3881a9380..3db7208d1 100644 --- a/src/components/Form/src/components/FormAction.vue +++ b/src/components/Form/src/components/FormAction.vue @@ -55,7 +55,7 @@ export default defineComponent({ name: 'BasicFormAction', components: { - FormItem: Form, + FormItem: Form.Item, Button, BasicArrow, }, diff --git a/src/components/Form/src/components/FormItem.tsx b/src/components/Form/src/components/FormItem.tsx index 48626123f..7f1e9a6aa 100644 --- a/src/components/Form/src/components/FormItem.tsx +++ b/src/components/Form/src/components/FormItem.tsx @@ -97,7 +97,7 @@ export default defineComponent({ return disabled; }); - const getShow = computed(() => { + function getShow() { const { show, ifShow } = props.schema; const { showAdvancedButton } = props.formProps; const itemIsAdvanced = showAdvancedButton @@ -122,7 +122,7 @@ export default defineComponent({ } isShow = isShow && itemIsAdvanced; return { isShow, isIfShow }; - }); + } function handleRules(): ValidationRule[] { const { @@ -310,7 +310,7 @@ export default defineComponent({ const { baseColProps = {} } = props.formProps; const realColProps = { ...baseColProps, ...colProps }; - const { isIfShow, isShow } = unref(getShow); + const { isIfShow, isShow } = getShow(); const getContent = () => { return colSlot diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index 528137cf6..7232f4f64 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/src/components/Form/src/hooks/useFormEvents.ts @@ -178,11 +178,12 @@ export function useFormEvents({ } async function validateFields(nameList?: NamePath[] | undefined) { - return await unref(formElRef)?.validateFields(nameList); + const res = await unref(formElRef)?.validateFields(nameList || []); + return res; } async function validate(nameList?: NamePath[] | undefined) { - return await unref(formElRef)?.validate(nameList); + return await unref(formElRef)?.validate(nameList || []); } async function clearValidate(name?: string | string[]) { diff --git a/src/components/Markdown/src/index.vue b/src/components/Markdown/src/index.vue index 21e011344..d2a1133a9 100644 --- a/src/components/Markdown/src/index.vue +++ b/src/components/Markdown/src/index.vue @@ -75,7 +75,9 @@ onUnmounted(() => { const vditorInstance = unref(vditorRef); if (!vditorInstance) return; - vditorInstance?.destroy?.(); + try { + vditorInstance?.destroy?.(); + } catch (error) {} }); return { diff --git a/src/components/Table/src/BasicTable.vue b/src/components/Table/src/BasicTable.vue index 1b9960f7b..e238fdef6 100644 --- a/src/components/Table/src/BasicTable.vue +++ b/src/components/Table/src/BasicTable.vue @@ -80,14 +80,13 @@ const innerPropsRef = ref>(); const [registerForm, { getFieldsValue }] = useForm(); - const getMergeProps = computed( - (): BasicTableProps => { - return { - ...props, - ...unref(innerPropsRef), - } as BasicTableProps; - } - ); + const getMergeProps = computed(() => { + return { + ...props, + ...unref(innerPropsRef), + } as BasicTableProps; + }); + const { loadingRef } = useLoading(getMergeProps); const { getPaginationRef, setPagination } = usePagination(getMergeProps); const { getColumnsRef, setColumns } = useColumns(getMergeProps, getPaginationRef); @@ -123,7 +122,7 @@ getMergeProps ); const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; - const titleData: any = + const titleData: Recordable = hideTitle && !isString(title) ? {} : { @@ -313,6 +312,7 @@ useExpose(tableAction); emit('register', tableAction); + return { tableElRef, getBindValues, diff --git a/src/components/Table/src/props.ts b/src/components/Table/src/props.ts index 676eb83d0..1406cf437 100644 --- a/src/components/Table/src/props.ts +++ b/src/components/Table/src/props.ts @@ -10,51 +10,31 @@ import type { } from './types/table'; import type { FormProps } from '/@/components/Form'; import { DEFAULT_SORT_FN, FETCH_SETTING } from './const'; +import { propTypes } from '/@/utils/propTypes'; // 注释看 types/table export const basicProps = { tableSetting: { type: Object as PropType, }, - inset: { - type: Boolean as PropType, - default: false, - }, + inset: propTypes.bool, sortFn: { type: Function as PropType<(sortInfo: SorterResult) => any>, default: DEFAULT_SORT_FN, }, - showTableSetting: { - type: Boolean as PropType, - default: false, - }, - autoCreateKey: { - type: Boolean as PropType, - default: true, - }, - striped: { - type: Boolean as PropType, - default: true, - }, - showSummary: { - type: Boolean as PropType, - default: false, - }, + showTableSetting: propTypes.bool, + autoCreateKey: propTypes.bool.def(true), + striped: propTypes.bool.def(true), + showSummary: propTypes.bool, summaryFunc: { type: [Function, Array] as PropType<(...arg: any[]) => any[]>, default: null, }, - canColDrag: { - type: Boolean as PropType, - default: true, - }, - isTreeTable: { - type: Boolean as PropType, - default: false, - }, + canColDrag: propTypes.bool.def(true), + isTreeTable: propTypes.bool, api: { type: Function as PropType<(...arg: any[]) => Promise>, default: null, @@ -78,22 +58,16 @@ export const basicProps = { }, }, // 立即请求接口 - immediate: { type: Boolean as PropType, default: true }, + immediate: propTypes.bool.def(true), - emptyDataIsShowTable: { - type: Boolean as PropType, - default: true, - }, + emptyDataIsShowTable: propTypes.bool.def(true), // 额外的请求参数 searchInfo: { type: Object as PropType, default: null, }, // 使用搜索表单 - useSearchForm: { - type: Boolean as PropType, - default: false, - }, + useSearchForm: propTypes.bool, // 表单配置 formConfig: { type: Object as PropType>, @@ -103,10 +77,7 @@ export const basicProps = { type: [Array] as PropType, default: null, }, - showIndexColumn: { - type: Boolean as PropType, - default: true, - }, + showIndexColumn: propTypes.bool.def(true), indexColumnProps: { type: Object as PropType, default: null, @@ -115,22 +86,10 @@ export const basicProps = { type: Object as PropType, default: null, }, - ellipsis: { - type: Boolean as PropType, - default: true, - }, - canResize: { - type: Boolean as PropType, - default: true, - }, - clearSelectOnPageChange: { - type: Boolean as PropType, - default: false, - }, - resizeHeightOffset: { - type: Number as PropType, - default: 0, - }, + ellipsis: propTypes.bool.def(true), + canResize: propTypes.bool.def(true), + clearSelectOnPageChange: propTypes.bool, + resizeHeightOffset: propTypes.number.def(0), rowSelection: { type: Object as PropType, default: null, @@ -142,30 +101,22 @@ export const basicProps = { titleHelpMessage: { type: [String, Array] as PropType, }, - maxHeight: { - type: Number as PropType, - }, + maxHeight: propTypes.number, dataSource: { - type: Array as PropType, + type: Array as PropType, default: null, }, rowKey: { - type: [String, Function] as PropType string)>, + type: [String, Function] as PropType string)>, default: '', }, - bordered: { - type: Boolean as PropType, - default: false, - }, + bordered: propTypes.bool, pagination: { type: [Object, Boolean] as PropType, default: null, }, - loading: { - type: Boolean as PropType, - default: false, - }, + loading: propTypes.bool, rowClassName: { type: Function as PropType<(record: TableCustomRecord, index: number) => string>, }, diff --git a/src/components/Table/src/types/tableAction.ts b/src/components/Table/src/types/tableAction.ts index 5c9da2a05..ccc432203 100644 --- a/src/components/Table/src/types/tableAction.ts +++ b/src/components/Table/src/types/tableAction.ts @@ -1,6 +1,6 @@ import { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'; export interface ActionItem extends ButtonProps { - onClick?: any; + onClick?: Fn; label: string; color?: 'success' | 'error' | 'warning'; icon?: string; @@ -11,7 +11,7 @@ export interface PopConfirm { title: string; okText?: string; cancelText?: string; - confirm: any; - cancel?: any; + confirm: Fn; + cancel?: Fn; icon?: string; }