perf: use composable
This commit is contained in:
parent
6bf6ae0288
commit
4caf496bd6
|
@ -19,6 +19,7 @@ import { useQuasar, date } from 'quasar';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||||
import { dashIfEmpty, toDate } from 'src/filters';
|
import { dashIfEmpty, toDate } from 'src/filters';
|
||||||
|
import { useTableHeight } from './filters/useTableHeight';
|
||||||
|
|
||||||
import CrudModel from 'src/components/CrudModel.vue';
|
import CrudModel from 'src/components/CrudModel.vue';
|
||||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
|
@ -118,7 +119,7 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
tableHeight: {
|
tableHeight: {
|
||||||
type: String,
|
type: String,
|
||||||
default: calcTableHeight,
|
default: undefined,
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
@ -167,6 +168,7 @@ const tableRef = ref();
|
||||||
const params = ref(useFilterParams($attrs['data-key']).params);
|
const params = ref(useFilterParams($attrs['data-key']).params);
|
||||||
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
const orders = ref(useFilterParams($attrs['data-key']).orders);
|
||||||
const app = inject('app');
|
const app = inject('app');
|
||||||
|
const tableHeight = useTableHeight();
|
||||||
|
|
||||||
const editingRow = ref(null);
|
const editingRow = ref(null);
|
||||||
const editingField = ref(null);
|
const editingField = ref(null);
|
||||||
|
@ -679,7 +681,7 @@ const rowCtrlClickFunction = computed(() => {
|
||||||
table-header-class="bg-header"
|
table-header-class="bg-header"
|
||||||
card-container-class="grid-three"
|
card-container-class="grid-three"
|
||||||
flat
|
flat
|
||||||
:style="isTableMode && `max-height: ${tableHeight}`"
|
:style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`"
|
||||||
:virtual-scroll="isTableMode"
|
:virtual-scroll="isTableMode"
|
||||||
@virtual-scroll="handleScroll"
|
@virtual-scroll="handleScroll"
|
||||||
@row-click="(event, row) => handleRowClick(event, row)"
|
@row-click="(event, row) => handleRowClick(event, row)"
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { onMounted, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
|
export function useTableHeight() {
|
||||||
|
const tableHeight = ref('100vh');
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await nextTick();
|
||||||
|
let height = 100;
|
||||||
|
Array.from(document.querySelectorAll('[role="toolbar"]'))
|
||||||
|
.filter((element) => window.getComputedStyle(element).display !== 'none')
|
||||||
|
.forEach(() => {
|
||||||
|
height -= 10;
|
||||||
|
});
|
||||||
|
tableHeight.value = `${height}vh`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return tableHeight;
|
||||||
|
}
|
Loading…
Reference in New Issue