forked from verdnatura/salix-front
feat: refs #6825 fix modes
This commit is contained in:
parent
161922da09
commit
e0379dd1bc
|
@ -1,14 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, markRaw } from 'vue';
|
import { ref, onMounted, markRaw, computed } from 'vue';
|
||||||
|
import { QCheckbox, useQuasar } from 'quasar';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnBreadcrumbs from 'components/common/VnBreadcrumbs.vue';
|
import VnBreadcrumbs from 'components/common/VnBreadcrumbs.vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
|
|
||||||
/* basic input */
|
/* basic input */
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import { QCheckbox } from 'quasar';
|
|
||||||
// import VnLv from 'src/components/ui/VnLv.vue';
|
// import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -38,26 +38,32 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const $q = useQuasar();
|
||||||
const mode = ref('list');
|
const mode = ref('list');
|
||||||
const selected = ref([]);
|
const selected = ref([]);
|
||||||
const tableModes = [
|
const tableModes = computed(() => {
|
||||||
{
|
const modes = [
|
||||||
icon: 'view_column',
|
{
|
||||||
title: t('table view'),
|
icon: 'view_column',
|
||||||
class: 'q-mr-lg',
|
title: t('table view'),
|
||||||
value: 'table',
|
value: 'table',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: 'lists',
|
icon: 'lists',
|
||||||
title: t('list view'),
|
title: t('list view'),
|
||||||
value: 'list',
|
value: 'list',
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
icon: 'apps',
|
if (!$q.screen.lt.md)
|
||||||
title: t('grid view'),
|
modes.push({
|
||||||
value: 'card',
|
icon: 'apps',
|
||||||
},
|
title: t('grid view'),
|
||||||
];
|
value: 'card',
|
||||||
|
disable: () => console.log('called'),
|
||||||
|
});
|
||||||
|
|
||||||
|
return modes;
|
||||||
|
});
|
||||||
const basicInputs = {
|
const basicInputs = {
|
||||||
input: markRaw(VnInput),
|
input: markRaw(VnInput),
|
||||||
number: markRaw(VnInput),
|
number: markRaw(VnInput),
|
||||||
|
@ -78,6 +84,7 @@ const basicInputs = {
|
||||||
// 'model-value': Boolean(prop.value),
|
// 'model-value': Boolean(prop.value),
|
||||||
// }),
|
// }),
|
||||||
// },
|
// },
|
||||||
|
// vnTableOpitons y hacer bucle
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
mode.value = $props.defaultMode;
|
mode.value = $props.defaultMode;
|
||||||
});
|
});
|
||||||
|
@ -85,6 +92,7 @@ onMounted(() => {
|
||||||
<template>
|
<template>
|
||||||
<VnPaginate v-bind="$attrs" class="q-px-md">
|
<VnPaginate v-bind="$attrs" class="q-px-md">
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
|
<!-- :grid="($q.screen.lt.md && reponsive) || mode != 'table'" -->
|
||||||
<QTable
|
<QTable
|
||||||
class="vnTable"
|
class="vnTable"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
@ -92,20 +100,28 @@ onMounted(() => {
|
||||||
row-key="$index"
|
row-key="$index"
|
||||||
selection="multiple"
|
selection="multiple"
|
||||||
v-model:selected="selected"
|
v-model:selected="selected"
|
||||||
:grid="($q.screen.lt.md && reponsive) || mode != 'table'"
|
:grid="mode != 'table'"
|
||||||
table-header-class="bg-grey-8"
|
table-header-class="bg-grey-8"
|
||||||
flat
|
|
||||||
:virtual-scroll-item-size="48"
|
:virtual-scroll-item-size="48"
|
||||||
:pagination="pagination"
|
:pagination="pagination"
|
||||||
:rows-per-page-options="[0]"
|
:rows-per-page-options="[0]"
|
||||||
style="height: 85vh"
|
style="max-height: 90vh"
|
||||||
:card-container-class="mode == 'list' ? 'grid-one' : 'grid-three'"
|
:card-container-class="
|
||||||
|
mode == 'list' || $q.screen.lt.md ? 'grid-one' : 'grid-three'
|
||||||
|
"
|
||||||
|
flat
|
||||||
>
|
>
|
||||||
<template #top-left>
|
<template #top-left>
|
||||||
<VnBreadcrumbs />
|
<VnBreadcrumbs />
|
||||||
</template>
|
</template>
|
||||||
<template #top-right>
|
<template #top-right>
|
||||||
<QBtn icon="visibility" title="asd" class="bg-dark q-mr-lg" dense />
|
<QBtn
|
||||||
|
icon="visibility"
|
||||||
|
title="asd"
|
||||||
|
class="bg-dark q-mr-md"
|
||||||
|
dense
|
||||||
|
v-if="mode == 'table'"
|
||||||
|
/>
|
||||||
<QBtnToggle
|
<QBtnToggle
|
||||||
v-model="mode"
|
v-model="mode"
|
||||||
toggle-color="primary"
|
toggle-color="primary"
|
||||||
|
@ -113,17 +129,20 @@ onMounted(() => {
|
||||||
dense
|
dense
|
||||||
:options="tableModes"
|
:options="tableModes"
|
||||||
/>
|
/>
|
||||||
<QBtn icon="filter_alt" title="asd" class="bg-dark q-ml-lg" dense />
|
<QBtn icon="filter_alt" title="asd" class="bg-dark q-ml-md" dense />
|
||||||
</template>
|
</template>
|
||||||
<!-- VnTableColumn¿?-->
|
<!-- VnTableColumn¿?-->
|
||||||
<template #header-cell="{ col }">
|
<template #header-cell="{ col }">
|
||||||
<QTh auto-width :class="`text-${col.align ?? 'left'}`">
|
<QTh auto-width>
|
||||||
<span>{{ col.label }}</span>
|
<div class="q-pa-sm" :class="`text-${col.align ?? 'left'}`">
|
||||||
|
{{ col.label }}
|
||||||
|
</div>
|
||||||
|
<hr class="q-ma-none divisor-line" />
|
||||||
<QInput
|
<QInput
|
||||||
v-if="columnSearch"
|
v-if="columnSearch"
|
||||||
dense
|
dense
|
||||||
outlined
|
|
||||||
:type="col.component == 'number' ? 'number' : 'text'"
|
:type="col.component == 'number' ? 'number' : 'text'"
|
||||||
|
class="q-px-md q-pb-xs"
|
||||||
/>
|
/>
|
||||||
</QTh>
|
</QTh>
|
||||||
</template>
|
</template>
|
||||||
|
@ -132,7 +151,6 @@ onMounted(() => {
|
||||||
<!-- {{ row[col.field] }} -->
|
<!-- {{ row[col.field] }} -->
|
||||||
<component
|
<component
|
||||||
v-if="col.component"
|
v-if="col.component"
|
||||||
class="col-content"
|
|
||||||
:is="basicInputs[col.component] ?? col.component"
|
:is="basicInputs[col.component] ?? col.component"
|
||||||
v-bind="col.props && col.props(props)"
|
v-bind="col.props && col.props(props)"
|
||||||
@click="col.event && col.event(props)"
|
@click="col.event && col.event(props)"
|
||||||
|
@ -143,9 +161,21 @@ onMounted(() => {
|
||||||
<template #item="{ row, cols }">
|
<template #item="{ row, cols }">
|
||||||
<QCard bordered flat>
|
<QCard bordered flat>
|
||||||
<QCardSection horizontal>
|
<QCardSection horizontal>
|
||||||
<QChip color="primary">1234123</QChip>
|
<span
|
||||||
|
v-for="(prop, index) of Object.entries(row)"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<QChip
|
||||||
|
color="primary"
|
||||||
|
v-if="cols[index]?.isId"
|
||||||
|
square
|
||||||
|
:title="t(cols[index].label)"
|
||||||
|
>
|
||||||
|
{{ prop[1] }}
|
||||||
|
</QChip>
|
||||||
|
</span>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
<QCardSection class="q-pa-md">
|
<QCardSection>
|
||||||
<div
|
<div
|
||||||
v-for="(prop, index) of Object.entries(row)"
|
v-for="(prop, index) of Object.entries(row)"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
@ -153,9 +183,9 @@ onMounted(() => {
|
||||||
<div
|
<div
|
||||||
v-if="cols[index]?.cardVisible && !cols[index]?.isId"
|
v-if="cols[index]?.cardVisible && !cols[index]?.isId"
|
||||||
>
|
>
|
||||||
|
{{ t(cols[index].label) }} :
|
||||||
<component
|
<component
|
||||||
v-if="cols[index]?.component"
|
v-if="cols[index]?.component"
|
||||||
class="cols[index]-content"
|
|
||||||
:is="
|
:is="
|
||||||
basicInputs[cols[index]?.component] ??
|
basicInputs[cols[index]?.component] ??
|
||||||
cols[index]?.component
|
cols[index]?.component
|
||||||
|
@ -167,10 +197,27 @@ onMounted(() => {
|
||||||
cols[index]?.event && cols[index]?.event(row)
|
cols[index]?.event && cols[index]?.event(row)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
<span v-else> {{ prop[0] }} : {{ prop[1] }}</span>
|
<span v-else>
|
||||||
|
{{ prop[1] }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</QCardSection>
|
</QCardSection>
|
||||||
|
<QCardSection>
|
||||||
|
<span
|
||||||
|
v-for="(prop, index) of Object.entries(row)"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<QChip
|
||||||
|
color="primary"
|
||||||
|
v-if="cols[index]?.isId"
|
||||||
|
square
|
||||||
|
:title="t(cols[index].label)"
|
||||||
|
>
|
||||||
|
{{ prop[1] }}
|
||||||
|
</QChip>
|
||||||
|
</span>
|
||||||
|
</QCardSection>
|
||||||
</QCard>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
</QTable>
|
</QTable>
|
||||||
|
@ -231,7 +278,17 @@ onMounted(() => {
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*.vnTable {
|
.divisor-line {
|
||||||
|
height: 1px;
|
||||||
|
background-color: var(--vn-section-color);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.q-table th {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vnTable {
|
||||||
thead tr th {
|
thead tr th {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
@ -239,5 +296,5 @@ onMounted(() => {
|
||||||
thead tr:first-child th {
|
thead tr:first-child th {
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue