|
@ -1,5 +1,6 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div style="height: 100%"> |
|
|
<div style="height: 100%"> |
|
|
|
|
|
<q-resize-observer debounce="500" @resize="onResize" /> |
|
|
<q-table |
|
|
<q-table |
|
|
ref="tableRef" |
|
|
ref="tableRef" |
|
|
v-model:pagination="state.pagination" |
|
|
v-model:pagination="state.pagination" |
|
@ -16,14 +17,14 @@ |
|
|
:rows-per-page-options="pageable && !tree && state.refHeightWidth.middleWidth > 600 ? state.pagination.rowsPerPageOptions : []" |
|
|
:rows-per-page-options="pageable && !tree && state.refHeightWidth.middleWidth > 600 ? state.pagination.rowsPerPageOptions : []" |
|
|
:loading="state.loading" |
|
|
:loading="state.loading" |
|
|
:class="tableClassComputed" |
|
|
:class="tableClassComputed" |
|
|
:table-style="tableHeightComputed()" |
|
|
:table-style="tableHeightComputed" |
|
|
:row-key="rowKey_" |
|
|
:row-key="rowKey_" |
|
|
:visible-columns="visibleColumnsComputed" |
|
|
:visible-columns="visibleColumnsComputed" |
|
|
@request="onRequest" |
|
|
@request="onRequest" |
|
|
@fullscreen="tableFullscreenFun" |
|
|
@fullscreen="tableFullscreenFun" |
|
|
> |
|
|
> |
|
|
<template #top="scope"> |
|
|
<template #top="scope"> |
|
|
<q-resize-observer @resize="onResize" /> |
|
|
<q-resize-observer debounce="100" @resize="onResize" /> |
|
|
<div class="col"> |
|
|
<div class="col"> |
|
|
<w-form ref="queryFormRef" v-bind="props.queryFormAttrs" :fields="table.queryFormFields" :cols-num="queryFormColsNum"></w-form> |
|
|
<w-form ref="queryFormRef" v-bind="props.queryFormAttrs" :fields="table.queryFormFields" :cols-num="queryFormColsNum"></w-form> |
|
|
<div |
|
|
<div |
|
@ -71,7 +72,7 @@ |
|
|
{{ 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-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-td :colspan="noDataTrColspanComputed" align="center" valian="middle"><q-icon size="2em" :name="IconEnum.提示" />{{ state.noDataLabel }}</q-td> |
|
|
</q-tr> |
|
|
</q-tr> |
|
|
</template> |
|
|
</template> |
|
@ -96,7 +97,7 @@ |
|
|
</q-th> |
|
|
</q-th> |
|
|
</template> |
|
|
</template> |
|
|
</q-tr> |
|
|
</q-tr> |
|
|
<q-tr v-if="table.rows.length === 0" :style="noDataTrHeightComputed()" class="noDataTr"> |
|
|
<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-td :colspan="noDataTrColspanComputed" align="center" valian="middle"><q-icon size="2em" :name="IconEnum.提示" />{{ state.noDataLabel }}</q-td> |
|
|
</q-tr> |
|
|
</q-tr> |
|
|
</template> |
|
|
</template> |
|
@ -251,6 +252,7 @@ const darkBgColor = getCssVar('dark'); |
|
|
const tableHeadBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.headBgColor || '#f5f7fa'; |
|
|
const tableHeadBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.headBgColor || '#f5f7fa'; |
|
|
const tableBorderColor = gc.theme?.grid?.borderColor || 'rgba(0, 0, 0, 0.12)'; |
|
|
const tableBorderColor = gc.theme?.grid?.borderColor || 'rgba(0, 0, 0, 0.12)'; |
|
|
const stickyBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.stickyBgColor || '#ffffff'; |
|
|
const stickyBgColor = gc.theme.dark ? darkBgColor : gc.theme?.grid?.stickyBgColor || '#ffffff'; |
|
|
|
|
|
const onResizeRef = ref(false); |
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
const props = defineProps({ |
|
|
height: { type: Number, default: 0 }, // 表格高度 |
|
|
height: { type: Number, default: 0 }, // 表格高度 |
|
@ -1148,7 +1150,8 @@ const selectionComputed = computed(() => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const tableHeightComputed = () => { |
|
|
const tableHeightComputed = computed(() => { |
|
|
|
|
|
onResizeRef.value; |
|
|
let availableHeight = 0; |
|
|
let availableHeight = 0; |
|
|
const parentHtmlElement = tableRef?.value?.$el?.parentElement; |
|
|
const parentHtmlElement = tableRef?.value?.$el?.parentElement; |
|
|
if (parentHtmlElement) { |
|
|
if (parentHtmlElement) { |
|
@ -1163,9 +1166,10 @@ const tableHeightComputed = () => { |
|
|
height: props.height > 0 ? props.height + 'px' : availableHeight > 0 ? availableHeight + 'px' : '0px', |
|
|
height: props.height > 0 ? props.height + 'px' : availableHeight > 0 ? availableHeight + 'px' : '0px', |
|
|
}; |
|
|
}; |
|
|
return style; |
|
|
return style; |
|
|
}; |
|
|
}); |
|
|
|
|
|
|
|
|
const noDataTrHeightComputed = () => { |
|
|
const noDataTrHeightComputed = computed(() => { |
|
|
|
|
|
onResizeRef.value; |
|
|
let availableHeight = 0; |
|
|
let availableHeight = 0; |
|
|
let otherHeight = 0; |
|
|
let otherHeight = 0; |
|
|
let otherHeight2 = 0; |
|
|
let otherHeight2 = 0; |
|
@ -1186,10 +1190,10 @@ const noDataTrHeightComputed = () => { |
|
|
availableHeight -= 1; //无数据增加的title行,下边框所占边框 |
|
|
availableHeight -= 1; //无数据增加的title行,下边框所占边框 |
|
|
|
|
|
|
|
|
const style = { |
|
|
const style = { |
|
|
height: props.height > 0 ? props.height - otherHeight2 + 'px' : availableHeight > 0 ? availableHeight + 'px' : '0px', |
|
|
height: props.height > 0 ? props.height - otherHeight2 - 1 + 'px' : availableHeight > 0 ? availableHeight + 'px' : '0px', |
|
|
}; |
|
|
}; |
|
|
return style; |
|
|
return style; |
|
|
}; |
|
|
}); |
|
|
|
|
|
|
|
|
const noDataTrColspanComputed = computed(() => { |
|
|
const noDataTrColspanComputed = computed(() => { |
|
|
let colspan = excludeColumnNum.value; |
|
|
let colspan = excludeColumnNum.value; |
|
@ -1242,6 +1246,7 @@ const updateTicked = (evt: Event, row: any) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const onResize = () => { |
|
|
const onResize = () => { |
|
|
|
|
|
onResizeRef.value = !onResizeRef.value; |
|
|
handlerQueryFormShowField(); |
|
|
handlerQueryFormShowField(); |
|
|
if (tableRef.value) { |
|
|
if (tableRef.value) { |
|
|
state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect().y; |
|
|
state.refHeightWidth.yLocation = tableRef.value.$el.getBoundingClientRect().y; |
|
@ -1397,6 +1402,7 @@ const onRequest = async (ops: any) => { |
|
|
addRowKey(table.rows); |
|
|
addRowKey(table.rows); |
|
|
stickyHeaderColumn(); |
|
|
stickyHeaderColumn(); |
|
|
emit('afterRequestData'); |
|
|
emit('afterRequestData'); |
|
|
|
|
|
table.treeExpand = false; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const addRowKey = (rows: []) => { |
|
|
const addRowKey = (rows: []) => { |
|
@ -1756,6 +1762,7 @@ const stickyHeaderColumn = (time = 500) => { |
|
|
} |
|
|
} |
|
|
}, time); |
|
|
}, time); |
|
|
|
|
|
|
|
|
|
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('table-layout', 'fixed'); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableHeadBgColor', tableHeadBgColor); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableHeadBgColor', tableHeadBgColor); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--stickyBgColor', stickyBgColor); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--stickyBgColor', stickyBgColor); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBorderColor', tableBorderColor); |
|
|
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBorderColor', tableBorderColor); |
|
|