mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-11-30 22:42:09 +08:00
style(table): table全屏后居中显示
This commit is contained in:
parent
b3cfc0b5d3
commit
1297939db2
@ -1,7 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="m-fields-table-wrap">
|
<teleport to="body" :disabled="!isFullscreen">
|
||||||
<teleport to="body" :disabled="!isFullscreen">
|
<div
|
||||||
<div ref="mTable" class="m-fields-table" :class="{ 'm-fields-table-item-extra': config.itemExtra }">
|
v-bind="$attrs"
|
||||||
|
class="m-fields-table-wrap"
|
||||||
|
:class="{ fixed: isFullscreen }"
|
||||||
|
:style="isFullscreen ? `z-index: ${nextZIndex()}` : ''"
|
||||||
|
>
|
||||||
|
<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>
|
<span v-if="config.extra" style="color: rgba(0, 0, 0, 0.45)" v-html="config.extra"></span>
|
||||||
<TMagicTooltip content="拖拽可排序" placement="left-start" :disabled="config.dropSort !== true">
|
<TMagicTooltip content="拖拽可排序" placement="left-start" :disabled="config.dropSort !== true">
|
||||||
<TMagicTable
|
<TMagicTable
|
||||||
@ -28,7 +33,6 @@
|
|||||||
<TMagicButton
|
<TMagicButton
|
||||||
:icon="Grid"
|
:icon="Grid"
|
||||||
size="small"
|
size="small"
|
||||||
type="defalut"
|
|
||||||
@click="toggleMode"
|
@click="toggleMode"
|
||||||
v-if="enableToggleMode && config.enableToggleMode !== false && !isFullscreen"
|
v-if="enableToggleMode && config.enableToggleMode !== false && !isFullscreen"
|
||||||
>展开配置</TMagicButton
|
>展开配置</TMagicButton
|
||||||
@ -36,7 +40,6 @@
|
|||||||
<TMagicButton
|
<TMagicButton
|
||||||
:icon="FullScreen"
|
:icon="FullScreen"
|
||||||
size="small"
|
size="small"
|
||||||
type="defalut"
|
|
||||||
@click="toggleFullscreen"
|
@click="toggleFullscreen"
|
||||||
v-if="config.enableFullscreen !== false"
|
v-if="config.enableFullscreen !== false"
|
||||||
>
|
>
|
||||||
@ -76,15 +79,15 @@
|
|||||||
</TMagicPagination>
|
</TMagicPagination>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</teleport>
|
</div>
|
||||||
</div>
|
</teleport>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, useTemplateRef } from 'vue';
|
import { computed, ref, useTemplateRef } from 'vue';
|
||||||
import { FullScreen, Grid } from '@element-plus/icons-vue';
|
import { FullScreen, Grid } from '@element-plus/icons-vue';
|
||||||
|
|
||||||
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload } from '@tmagic/design';
|
import { TMagicButton, TMagicPagination, TMagicTable, TMagicTooltip, TMagicUpload, useZIndex } from '@tmagic/design';
|
||||||
|
|
||||||
import type { SortProp } from '../schema';
|
import type { SortProp } from '../schema';
|
||||||
import { sortChange } from '../utils/form';
|
import { sortChange } from '../utils/form';
|
||||||
@ -121,6 +124,8 @@ const { pageSize, currentPage, paginationData, handleSizeChange, handleCurrentCh
|
|||||||
modelName,
|
modelName,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { nextZIndex } = useZIndex();
|
||||||
|
|
||||||
const { addable, newHandler } = useAdd(props, emit);
|
const { addable, newHandler } = useAdd(props, emit);
|
||||||
const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
|
const { columns } = useTableColumns(props, emit, currentPage, pageSize, modelName);
|
||||||
useSortable(props, emit, tMagicTableRef, modelName);
|
useSortable(props, emit, tMagicTableRef, modelName);
|
||||||
|
|||||||
@ -78,6 +78,7 @@ export const useAdd = (
|
|||||||
if (typeof props.config.defaultAdd === 'function') {
|
if (typeof props.config.defaultAdd === 'function') {
|
||||||
inputs = await props.config.defaultAdd(mForm, {
|
inputs = await props.config.defaultAdd(mForm, {
|
||||||
model: props.model[modelName],
|
model: props.model[modelName],
|
||||||
|
prop: props.prop,
|
||||||
formValue: mForm?.values,
|
formValue: mForm?.values,
|
||||||
});
|
});
|
||||||
} else if (props.config.defaultAdd) {
|
} else if (props.config.defaultAdd) {
|
||||||
|
|||||||
@ -1,22 +1,12 @@
|
|||||||
import { ref, useTemplateRef } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { useZIndex } from '@tmagic/design';
|
|
||||||
|
|
||||||
export const useFullscreen = () => {
|
export const useFullscreen = () => {
|
||||||
const isFullscreen = ref(false);
|
const isFullscreen = ref(false);
|
||||||
const mTableEl = useTemplateRef<HTMLDivElement>('mTable');
|
|
||||||
|
|
||||||
const { nextZIndex } = useZIndex();
|
|
||||||
|
|
||||||
const toggleFullscreen = () => {
|
const toggleFullscreen = () => {
|
||||||
if (!mTableEl.value) return;
|
|
||||||
|
|
||||||
if (isFullscreen.value) {
|
if (isFullscreen.value) {
|
||||||
mTableEl.value.classList.remove('fixed');
|
|
||||||
isFullscreen.value = false;
|
isFullscreen.value = false;
|
||||||
} else {
|
} else {
|
||||||
mTableEl.value.classList.add('fixed');
|
|
||||||
mTableEl.value.style.zIndex = `${nextZIndex()}`;
|
|
||||||
isFullscreen.value = true;
|
isFullscreen.value = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
.m-fields-table-wrap {
|
.m-fields-table-wrap {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
|
||||||
|
|
||||||
.m-fields-table {
|
|
||||||
width: 100%;
|
|
||||||
&.fixed {
|
&.fixed {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -14,6 +11,8 @@
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: rgba(0, 0, 0, 0.5);
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
& > .el-form-item__content {
|
& > .el-form-item__content {
|
||||||
z-index: 101;
|
z-index: 101;
|
||||||
@ -25,6 +24,10 @@
|
|||||||
width: 95vw !important;
|
width: 95vw !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.m-fields-table {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
th {
|
th {
|
||||||
background-color: #f2f2f2 !important;
|
background-color: #f2f2f2 !important;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user