fix(component): resovle fullscreen content issues with "fixedHeight" and "contentFullHeight" combined (#3721)
This commit is contained in:
parent
890ff8f338
commit
212e78fa76
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="getClass" ref="wrapperRef">
|
<div :class="getClass" :style="getStyle" ref="wrapperRef">
|
||||||
<PageHeader
|
<PageHeader
|
||||||
:ghost="ghost"
|
:ghost="ghost"
|
||||||
:title="title"
|
:title="title"
|
||||||
|
|
@ -39,7 +39,8 @@
|
||||||
import { useDesign } from '@/hooks/web/useDesign';
|
import { useDesign } from '@/hooks/web/useDesign';
|
||||||
import { propTypes } from '@/utils/propTypes';
|
import { propTypes } from '@/utils/propTypes';
|
||||||
import { PageHeader } from 'ant-design-vue';
|
import { PageHeader } from 'ant-design-vue';
|
||||||
import { omit } from 'lodash-es';
|
import { omit, debounce } from 'lodash-es';
|
||||||
|
import { useElementSize } from '@vueuse/core';
|
||||||
import {
|
import {
|
||||||
CSSProperties,
|
CSSProperties,
|
||||||
PropType,
|
PropType,
|
||||||
|
|
@ -82,6 +83,9 @@
|
||||||
const headerRef = ref(null);
|
const headerRef = ref(null);
|
||||||
const contentRef = ref(null);
|
const contentRef = ref(null);
|
||||||
const footerRef = ref(null);
|
const footerRef = ref(null);
|
||||||
|
|
||||||
|
const { height } = useElementSize(wrapperRef);
|
||||||
|
|
||||||
const { prefixCls } = useDesign('page-wrapper');
|
const { prefixCls } = useDesign('page-wrapper');
|
||||||
|
|
||||||
provide(
|
provide(
|
||||||
|
|
@ -101,6 +105,7 @@
|
||||||
[contentRef],
|
[contentRef],
|
||||||
getUpwardSpace,
|
getUpwardSpace,
|
||||||
);
|
);
|
||||||
|
const debounceRedoHeight = debounce(redoHeight, 50);
|
||||||
setCompensation({ useLayoutFooter: true, elements: [footerRef] });
|
setCompensation({ useLayoutFooter: true, elements: [footerRef] });
|
||||||
|
|
||||||
const getClass = computed(() => {
|
const getClass = computed(() => {
|
||||||
|
|
@ -113,6 +118,13 @@
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getStyle = computed(() => {
|
||||||
|
const { contentFullHeight, fixedHeight } = props;
|
||||||
|
return {
|
||||||
|
...(contentFullHeight && fixedHeight ? { height: '100%' } : {}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const getHeaderStyle = computed((): CSSProperties => {
|
const getHeaderStyle = computed((): CSSProperties => {
|
||||||
const { headerSticky } = props;
|
const { headerSticky } = props;
|
||||||
if (!headerSticky) {
|
if (!headerSticky) {
|
||||||
|
|
@ -172,6 +184,11 @@
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(height, () => {
|
||||||
|
const { contentFullHeight, fixedHeight } = props;
|
||||||
|
contentFullHeight && fixedHeight && debounceRedoHeight();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
@prefix-cls: ~'@{namespace}-page-wrapper';
|
@prefix-cls: ~'@{namespace}-page-wrapper';
|
||||||
|
|
|
||||||
|
|
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue