Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions packages/form/src/table/Table.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<template>
<teleport to="body" :disabled="!isFullscreen">
<div
v-bind="$attrs"
class="m-fields-table-wrap"
:class="{ fixed: isFullscreen }"
:style="isFullscreen ? `z-index: ${nextZIndex()}` : ''"
>
<div v-bind="$attrs" class="m-fields-table-wrap" :class="{ fixed: isFullscreen }" :style="fullscreenZIndexStyle">
<div class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
<span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
<TMagicTooltip
Expand Down Expand Up @@ -96,7 +91,7 @@
</template>

<script setup lang="ts">
import { computed, ref, useTemplateRef } from 'vue';
import { computed, ref, useTemplateRef, watch } from 'vue';
import { FullScreen, Grid, Plus } from '@element-plus/icons-vue';

import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload, useZIndex } from '@tmagic/design';
Expand Down Expand Up @@ -137,6 +132,11 @@ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentCh
);

const { nextZIndex } = useZIndex();
/** 全屏层 z-index:仅在进入全屏时取一次 nextZIndex,避免每次重渲染累加后盖住 append 到 body 的下拉层 */
const fullscreenZIndex = ref<number | null>(null);
const fullscreenZIndexStyle = computed(() =>
fullscreenZIndex.value != null ? `z-index: ${fullscreenZIndex.value}` : '',
);
const updateKey = ref(1);

const { addable, newHandler } = useAdd(props, emit);
Expand Down Expand Up @@ -179,6 +179,15 @@ const sortChangeHandler = (sortOptions: SortProp) => {
sortChange(props.model[modelName], sortOptions);
};

// 监听全屏状态,仅在进入全屏时取一次 nextZIndex,避免每次重渲染累加后盖住 append 到 body 的下拉层
watch(isFullscreen, (on) => {
if (on) {
fullscreenZIndex.value = nextZIndex();
} else {
fullscreenZIndex.value = null;
}
});

defineExpose({
toggleRowSelection,
});
Expand Down