diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index d9b0c1efd..1d5072646 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -13,6 +13,7 @@ import VnLv from 'components/ui/VnLv.vue'; import VnTableColumn from 'components/VnTable/VnColumn.vue'; import VnTableFilter from 'components/VnTable/VnFilter.vue'; import VnTableChip from 'components/VnTable/VnChip.vue'; +import TableVisibleColumns from 'src/components/VnTable/VnVisibleColumn.vue'; const $props = defineProps({ columns: { @@ -67,6 +68,10 @@ const $props = defineProps({ type: Object, default: () => ({ card: false, table: false }), }, + tableCode: { + type: String, + default: null, + }, table: { type: Object, default: () => ({}), @@ -119,6 +124,14 @@ watch( (val) => setUserParams(val) ); +const rowClickFunction = computed(() => { + if ($props.rowClick) return $props.rowClick; + if ($props.redirect) return ({ id }) => redirectFn(id); + return () => {}; +}); + +const isTableMode = computed(() => mode.value == TABLE_MODE); + function setUserParams(watchedParams) { if (!watchedParams) return; @@ -162,12 +175,6 @@ function splitColumns(columns) { } } -const rowClickFunction = computed(() => { - if ($props.rowClick) return $props.rowClick; - if ($props.redirect) return ({ id }) => redirectFn(id); - return () => {}; -}); - function redirectFn(id) { router.push({ path: `/${$props.redirect}/${id}` }); } @@ -240,7 +247,7 @@ defineExpose({ :limit="20" ref="CrudModelRef" :search-url="searchUrl" - :disable-infinite-scroll="mode == TABLE_MODE" + :disable-infinite-scroll="isTableMode" @save-changes="reload" :has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable" > @@ -258,11 +265,11 @@ defineExpose({ :columns="splittedColumns.columns" :rows="rows" v-model:selected="selected" - :grid="mode != TABLE_MODE" + :grid="!isTableMode" table-header-class="bg-header" card-container-class="grid-three" flat - :style="mode == TABLE_MODE && 'max-height: 90vh'" + :style="isTableMode && 'max-height: 90vh'" virtual-scroll @virtual-scroll=" (event) => @@ -276,13 +283,12 @@ defineExpose({