|
@@ -49,7 +49,7 @@
|
|
SizeType,
|
|
SizeType,
|
|
ColumnChangeParam,
|
|
ColumnChangeParam,
|
|
} from './types/table';
|
|
} from './types/table';
|
|
- import { ref, computed, unref, toRaw, inject, watchEffect, useAttrs, useSlots } from 'vue';
|
|
|
|
|
|
+ import { ref, computed, unref, toRaw, inject, watch, useAttrs, useSlots } from 'vue';
|
|
import { Table } from 'ant-design-vue';
|
|
import { Table } from 'ant-design-vue';
|
|
import { BasicForm, useForm } from '@/components/Form';
|
|
import { BasicForm, useForm } from '@/components/Form';
|
|
import { PageWrapperFixedHeightKey } from '@/enums/pageEnum';
|
|
import { PageWrapperFixedHeightKey } from '@/enums/pageEnum';
|
|
@@ -70,10 +70,10 @@
|
|
import { useTableFooter } from './hooks/useTableFooter';
|
|
import { useTableFooter } from './hooks/useTableFooter';
|
|
import { useTableForm } from './hooks/useTableForm';
|
|
import { useTableForm } from './hooks/useTableForm';
|
|
import { useDesign } from '@/hooks/web/useDesign';
|
|
import { useDesign } from '@/hooks/web/useDesign';
|
|
- import { omit } from 'lodash-es';
|
|
|
|
|
|
+ import { omit, debounce } from 'lodash-es';
|
|
|
|
+ import { useElementSize } from '@vueuse/core';
|
|
import { basicProps } from './props';
|
|
import { basicProps } from './props';
|
|
import { isFunction } from '@/utils/is';
|
|
import { isFunction } from '@/utils/is';
|
|
- import { warn } from '@/utils/log';
|
|
|
|
|
|
|
|
defineOptions({ name: 'BasicTable' });
|
|
defineOptions({ name: 'BasicTable' });
|
|
|
|
|
|
@@ -108,6 +108,8 @@
|
|
const formRef = ref(null);
|
|
const formRef = ref(null);
|
|
const innerPropsRef = ref<Partial<BasicTableProps>>();
|
|
const innerPropsRef = ref<Partial<BasicTableProps>>();
|
|
|
|
|
|
|
|
+ const { height } = useElementSize(wrapRef);
|
|
|
|
+
|
|
const { prefixCls } = useDesign('basic-table');
|
|
const { prefixCls } = useDesign('basic-table');
|
|
const [registerForm, formActions] = useForm();
|
|
const [registerForm, formActions] = useForm();
|
|
|
|
|
|
@@ -116,13 +118,6 @@
|
|
});
|
|
});
|
|
|
|
|
|
const isFixedHeightPage = inject(PageWrapperFixedHeightKey, false);
|
|
const isFixedHeightPage = inject(PageWrapperFixedHeightKey, false);
|
|
- watchEffect(() => {
|
|
|
|
- unref(isFixedHeightPage) &&
|
|
|
|
- props.canResize &&
|
|
|
|
- warn(
|
|
|
|
- "'canResize' of BasicTable may not work in PageWrapper with 'fixedHeight' (especially in hot updates)",
|
|
|
|
- );
|
|
|
|
- });
|
|
|
|
|
|
|
|
const { getLoading, setLoading } = useLoading(getProps);
|
|
const { getLoading, setLoading } = useLoading(getProps);
|
|
const { getPaginationInfo, getPagination, setPagination, setShowPagination, getShowPagination } =
|
|
const { getPaginationInfo, getPagination, setPagination, setShowPagination, getShowPagination } =
|
|
@@ -196,6 +191,7 @@
|
|
wrapRef,
|
|
wrapRef,
|
|
formRef,
|
|
formRef,
|
|
);
|
|
);
|
|
|
|
+ const debounceRedoHeight = debounce(redoHeight, 50);
|
|
|
|
|
|
const { scrollTo } = useTableScrollTo(tableElRef, getDataSourceRef);
|
|
const { scrollTo } = useTableScrollTo(tableElRef, getDataSourceRef);
|
|
|
|
|
|
@@ -278,6 +274,10 @@
|
|
return !!unref(getDataSourceRef).length;
|
|
return !!unref(getDataSourceRef).length;
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ watch(height, () => {
|
|
|
|
+ unref(isFixedHeightPage) && props.canResize && debounceRedoHeight();
|
|
|
|
+ });
|
|
|
|
+
|
|
function setProps(props: Partial<BasicTableProps>) {
|
|
function setProps(props: Partial<BasicTableProps>) {
|
|
innerPropsRef.value = { ...unref(innerPropsRef), ...props };
|
|
innerPropsRef.value = { ...unref(innerPropsRef), ...props };
|
|
}
|
|
}
|