Browse Source

表格优化提交

main
likunming 11 months ago
parent
commit
b3bf5e4e78
  1. 2
      io.sc.platform.core.frontend/package.json
  2. 80
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

2
io.sc.platform.core.frontend/package.json

@ -1,6 +1,6 @@
{ {
"name": "platform-core", "name": "platform-core",
"version": "8.1.145", "version": "8.1.146",
"description": "前端核心包,用于快速构建前端的脚手架", "description": "前端核心包,用于快速构建前端的脚手架",
"//main": "库的主文件", "//main": "库的主文件",
"main": "dist/platform-core.js", "main": "dist/platform-core.js",

80
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -6,6 +6,7 @@
flat flat
binary-state-sort binary-state-sort
:no-data-label="state.noDataLabel" :no-data-label="state.noDataLabel"
:hide-no-data="true"
:loading-label="state.loadingLabel" :loading-label="state.loadingLabel"
v-bind="attrs" v-bind="attrs"
:selection="selectionComputed" :selection="selectionComputed"
@ -70,6 +71,9 @@
{{ c.label }} {{ c.label }}
</q-th> </q-th>
</q-tr> </q-tr>
<q-tr v-if="table.rows.length === 0" :style="noDataTrHeightComputed" class="noDataTr">
<q-td :colspan="noDataTrColspanComputed" align="center" valian="middle"><q-icon size="2em" :name="IconEnum.提示" />{{ state.noDataLabel }}</q-td>
</q-tr>
</template> </template>
<template v-else> <template v-else>
<q-tr :props="scope"> <q-tr :props="scope">
@ -92,6 +96,9 @@
</q-th> </q-th>
</template> </template>
</q-tr> </q-tr>
<q-tr v-if="table.rows.length === 0" :style="noDataTrHeightComputed" class="noDataTr">
<q-td :colspan="noDataTrColspanComputed" align="center" valian="middle"><q-icon size="2em" :name="IconEnum.提示" />{{ state.noDataLabel }}</q-td>
</q-tr>
</template> </template>
</template> </template>
<template #body="scope"> <template #body="scope">
@ -158,6 +165,11 @@
</template> </template>
</q-tr> </q-tr>
</template> </template>
<!-- <template v-if="table.rows.length === 0" #top-row>
<q-tr>
<q-td >{{ state.noDataLabel }}</q-td>
</q-tr>
</template> -->
<template #loading> <template #loading>
<q-inner-loading :showing="state.loading" style="z-index: 999"> <q-inner-loading :showing="state.loading" style="z-index: 999">
<q-spinner-gears size="50px" color="primary" /> <q-spinner-gears size="50px" color="primary" />
@ -197,6 +209,7 @@
</template> </template>
<template v-else> {{ state.pagination.rowsNumber }} 条记录 </template> <template v-else> {{ state.pagination.rowsNumber }} 条记录 </template>
</template> </template>
<!--
<template v-if="!attrs['hide-bottom']" #no-data="{ message }"> <template v-if="!attrs['hide-bottom']" #no-data="{ message }">
<div class="full-width row flex-center text-dark q-gutter-sm" :style="`height:` + noDataBottomHeightComputed"> <div class="full-width row flex-center text-dark q-gutter-sm" :style="`height:` + noDataBottomHeightComputed">
<q-icon size="2em" :name="IconEnum.提示" /> <q-icon size="2em" :name="IconEnum.提示" />
@ -204,7 +217,7 @@
{{ message }} {{ message }}
</span> </span>
</div> </div>
</template> </template> -->
</q-table> </q-table>
<w-dialog ref="dialogRef" v-bind="editor.dialog" :title="dialog.dialogTitle" :buttons="dialog.dialogButtons"> <w-dialog ref="dialogRef" v-bind="editor.dialog" :title="dialog.dialogTitle" :buttons="dialog.dialogButtons">
<w-form ref="dialogFormRef" v-bind="editor.form" class="pt-1.5 px-1.5"></w-form> <w-form ref="dialogFormRef" v-bind="editor.form" class="pt-1.5 px-1.5"></w-form>
@ -892,6 +905,7 @@ const state = reactive({
// //
refHeightWidth: { refHeightWidth: {
yLocation: 0, // Y yLocation: 0, // Y
noDataTrYLocation: 0, // Y
topHeight: 0, // top topHeight: 0, // top
bottomHeight: 0, // bottom bottomHeight: 0, // bottom
middleWidth: 0, // middle middleWidth: 0, // middle
@ -1145,53 +1159,61 @@ const tableHeightComputed = computed(() => {
mainPaddingBottom - mainPaddingBottom -
mainContainerPaddingBottom - mainContainerPaddingBottom -
otherHeight; otherHeight;
if ((table.rows && table.rows.length > 0) || attrs['hide-bottom']) {
return { return {
height: props.height > 0 ? props.height + 'px' : resultHeight + 'px', height: props.height > 0 ? props.height + 'px' : resultHeight + 'px',
}; };
} else { // if ((table.rows && table.rows.length > 0) || attrs['hide-bottom']) {
return {
height: state.refHeightWidth.middleHeight + 'px', // } else {
}; // return {
} // height: state.refHeightWidth.middleHeight + 'px',
// };
// }
}); });
const noDataBottomHeightComputed = computed(() => { const noDataTrHeightComputed = computed(() => {
// //
const screenHeight = $q.screen.height; const screenHeight = $q.screen.height;
// XX // XX
const footerHeight = gc.theme.footer.show ? gc.theme.footer.height : 0; const footerHeight = gc.theme.footer.show ? gc.theme.footer.height : 0;
// 4px
const otherHeight = table.spaceHeight || 4;
// //
const mainPaddingBottom = gc.theme.main.paddingBottom || 0; const mainPaddingBottom = gc.theme.main.paddingBottom || 0;
// //
const mainContainerPaddingBottom = gc.theme.main.containerPaddingBottom || 0; const mainContainerPaddingBottom = gc.theme.main.containerPaddingBottom || 0;
// 4px
const otherHeight = table.spaceHeight || 4;
const resultHeight = const resultHeight =
screenHeight - screenHeight -
state.refHeightWidth.yLocation - state.refHeightWidth.noDataTrYLocation -
state.refHeightWidth.topHeight - (state.refHeightWidth.bottomHeight || 0) -
state.refHeightWidth.middleHeight - footerHeight -
mainPaddingBottom - mainPaddingBottom -
mainContainerPaddingBottom - mainContainerPaddingBottom -
footerHeight - (state.refHeightWidth.middleScrollWidth - state.refHeightWidth.middleWidth > 0 ? 15 : 0) -
otherHeight; otherHeight;
if (table.rows && table.rows.length > 0) { return {
return '0px'; height: props.height > 0 ? props.height + 'px' : resultHeight + 'px',
} else { };
return table.inFullscreen ? resultHeight + 'px' : props.height > 0 ? props.height + 'px' : resultHeight + 'px'; });
} const noDataTrColspanComputed = computed(() => {
let colspan = excludeColumnNum.value;
colspan += visibleColumnsComputed.value.length;
return colspan;
}); });
// Y0退Y // Y0退Y
let tableY = 0; let tableY = 0;
let noDataTrY = 0;
const tableFullscreenFun = (value) => { const tableFullscreenFun = (value) => {
table.inFullscreen = !table.inFullscreen; table.inFullscreen = !table.inFullscreen;
if (value) { if (value) {
tableY = state.refHeightWidth.yLocation; tableY = state.refHeightWidth.yLocation;
noDataTrY = state.refHeightWidth.noDataTrYLocation;
} else { } else {
state.refHeightWidth.yLocation = tableY; state.refHeightWidth.yLocation = tableY;
state.refHeightWidth.noDataTrYLocation = noDataTrY;
tableY = 0; tableY = 0;
noDataTrY = 0;
} }
}; };
@ -1227,6 +1249,9 @@ const onResize = () => {
handlerQueryFormShowField(); handlerQueryFormShowField();
if (tableRef.value) { if (tableRef.value) {
state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect().y; state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect().y;
if (tableRef.value.$el.getElementsByClassName('noDataTr').length > 0) {
state.refHeightWidth.noDataTrYLocation = tableRef.value.$el.getElementsByClassName('noDataTr')[0].getBoundingClientRect().y;
}
state.refHeightWidth.topHeight = tableRef.value.$el.getElementsByClassName('q-table__top')[0]?.clientHeight; state.refHeightWidth.topHeight = tableRef.value.$el.getElementsByClassName('q-table__top')[0]?.clientHeight;
state.refHeightWidth.middleWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.clientWidth; state.refHeightWidth.middleWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.clientWidth;
state.refHeightWidth.middleScrollWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.scrollWidth; state.refHeightWidth.middleScrollWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.scrollWidth;
@ -1614,6 +1639,9 @@ const stickyHeaderColumn = (time = 500) => {
// //
if (tableRef.value) { if (tableRef.value) {
state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect()?.y; state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect()?.y;
if (tableRef.value.$el.getElementsByClassName('noDataTr').length > 0) {
state.refHeightWidth.noDataTrYLocation = tableRef.value.$el.getElementsByClassName('noDataTr')[0].getBoundingClientRect().y;
}
state.refHeightWidth.topHeight = tableRef.value.$el.getElementsByClassName('q-table__top')[0]?.clientHeight; state.refHeightWidth.topHeight = tableRef.value.$el.getElementsByClassName('q-table__top')[0]?.clientHeight;
state.refHeightWidth.bottomHeight = tableRef.value.$el.getElementsByClassName('q-table__bottom')[0]?.clientHeight; state.refHeightWidth.bottomHeight = tableRef.value.$el.getElementsByClassName('q-table__bottom')[0]?.clientHeight;
state.refHeightWidth.middleWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.clientWidth; state.refHeightWidth.middleWidth = tableRef.value.$el.getElementsByClassName('q-table__middle')[0]?.clientWidth;
@ -1674,9 +1702,14 @@ const stickyHeaderColumn = (time = 500) => {
column1Width + column2Width + column3Width + column4Width + column5Width + column6Width + column7Width + column8Width + column9Width + 'px', column1Width + column2Width + column3Width + column4Width + column5Width + column6Width + column7Width + column8Width + column9Width + 'px',
); );
} }
const titleTotalHeight = tableDom.getElementsByTagName('thead')[0].offsetHeight; let titleTotalHeight = tableDom.getElementsByTagName('thead')[0].offsetHeight;
// top
if (table.rows.length === 0) {
const noDataTrHeight = tableRef.value.$el.getElementsByClassName('noDataTr')[0].offsetHeight;
titleTotalHeight = titleTotalHeight - noDataTrHeight;
}
const titleRowHeight = titleTotalHeight / columnTitleState.columnTitleRowNum; const titleRowHeight = titleTotalHeight / columnTitleState.columnTitleRowNum;
if (columnTitleState.columnTitleRowNum > 1) { if (columnTitleState.columnTitleRowNum) {
const row1Height = titleRowHeight * 1; const row1Height = titleRowHeight * 1;
const row2Height = titleRowHeight * 2; const row2Height = titleRowHeight * 2;
const row3Height = titleRowHeight * 3; const row3Height = titleRowHeight * 3;
@ -1717,7 +1750,10 @@ const stickyHeaderColumn = (time = 500) => {
if (denseBottomComputed.value && (!attrs.hasOwnProperty('hide-bottom') || attrs['hide-bottom'] === false)) { if (denseBottomComputed.value && (!attrs.hasOwnProperty('hide-bottom') || attrs['hide-bottom'] === false)) {
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 33 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 33 + 'px');
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 24 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 24 + 'px');
} else if (!attrs.hasOwnProperty('hide-bottom') || attrs['hide-bottom'] === false) { } else if (
(!attrs.hasOwnProperty('hide-bottom') || attrs['hide-bottom'] === false) &&
tableRef.value.$el.getElementsByClassName('q-table__bottom').length > 0
) {
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 50 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 50 + 'px');
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 40 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 40 + 'px');
} }

Loading…
Cancel
Save