Compare commits

...

11 Commits

Author SHA1 Message Date
Javier Segarra 98f928fd42 Merge branch 'master' into 8110_itemDiary_scroll
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-25 08:34:32 +00:00
Javier Segarra f79ac38cf1 style: refs #8110 #8110 perf sticky VnSubtoolbar sticky
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-24 20:41:23 +02:00
Javier Segarra 991cbb8534 style: refs #8110 #8110 perf sticky VnSubtoolbar sticky
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-24 20:34:54 +02:00
Javier Segarra 1670c40a31 Merge branch '8110_itemDiary_scroll' of https://gitea.verdnatura.es/verdnatura/salix-front into 8110_itemDiary_scroll
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-24 20:25:58 +02:00
Javier Segarra 30f990ac2f Merge branch 'master' into 8110_itemDiary_scroll
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-22 23:15:45 +00:00
Javier Segarra a63766a836 perf: refs #8110 #8110 use QPagintaion as QFooter 2024-10-22 11:05:32 +02:00
Javier Segarra e4985064c1 feat: refs #8110 #8110 apply pagination
gitea/salix-front/pipeline/pr-dev This commit looks good Details
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-21 11:37:49 +02:00
Javier Segarra 066b0ffca0 Merge branch 'master' into 8110_itemDiary_scroll
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-18 11:11:23 +02:00
Javier Segarra dc814ac09b style: refs #8110 #8110 remove sticky 2024-10-18 11:10:54 +02:00
Javier Segarra 67fc3b1e4a feat: refs #8110 #8110 sticky header class
gitea/salix-front/pipeline/pr-master This commit looks good Details
2024-10-16 16:02:32 +02:00
Javier Segarra 17675fb857 feat: refs #8110 #8110 apply onScroll 2024-10-16 16:02:18 +02:00
6 changed files with 92 additions and 70 deletions

View File

@ -22,7 +22,7 @@ const pinnedModulesRef = ref();
</script>
<template>
<QHeader color="white" elevated>
<QHeader color="white" elevated reveal>
<QToolbar class="q-py-sm q-px-md">
<QBtn
@click="stateStore.toggleLeftDrawer()"

View File

@ -1,5 +1,5 @@
<script setup>
import { onBeforeMount, computed } from 'vue';
import { onBeforeMount, computed, onMounted, ref } from 'vue';
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
import { useArrayData } from 'src/composables/useArrayData';
import { useStateStore } from 'stores/useStateStore';
@ -8,6 +8,7 @@ import VnSubToolbar from '../ui/VnSubToolbar.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import LeftMenu from 'components/LeftMenu.vue';
import RightMenu from 'components/common/RightMenu.vue';
import { useQuasar } from 'quasar';
const props = defineProps({
dataKey: { type: String, required: true },
baseUrl: { type: String, default: undefined },
@ -21,6 +22,7 @@ const props = defineProps({
});
const stateStore = useStateStore();
const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const url = computed(() => {
@ -57,6 +59,12 @@ if (props.baseUrl) {
}
});
}
const headerHeight = ref(0);
onMounted(() => {
const spacing = quasar.platform.is.mobile ? 30 : 0;
headerHeight.value =
document.querySelector('.q-toolbar')?.offsetHeight + spacing + 'px';
});
</script>
<template>
<QDrawer
@ -80,11 +88,12 @@ if (props.baseUrl) {
</template>
</RightMenu>
<QPageContainer>
<QPage>
<VnSubToolbar />
<QPage padding :style="{ 'margin-top': headerHeight }">
<div :class="[useCardSize(), $attrs.class]">
<RouterView :key="route.path" />
</div>
</QPage>
<RouterView :key="route.path" /></div
></QPage>
<QPageSticky expand position="top">
<VnSubToolbar />
</QPageSticky>
</QPageContainer>
</template>

View File

@ -1,7 +1,6 @@
<script setup>
import { onMounted, onBeforeUnmount, ref } from 'vue';
import { useStateStore } from 'stores/useStateStore';
const stateStore = useStateStore();
const actions = ref(null);
const data = ref(null);
@ -24,14 +23,13 @@ onMounted(() => {
if (actions.value) observer.observe(actions.value, opts);
if (data.value) observer.observe(data.value, opts);
});
onBeforeUnmount(() => stateStore.toggleSubToolbar());
</script>
<template>
<QToolbar
id="subToolbar"
class="justify-end sticky"
class="justify-end shadow-10"
v-show="hasContent || $slots['st-actions'] || $slots['st-data']"
>
<slot name="st-data">
@ -43,9 +41,3 @@ onBeforeUnmount(() => stateStore.toggleSubToolbar());
</slot>
</QToolbar>
</template>
<style lang="scss" scoped>
.sticky {
position: sticky;
z-index: 1;
}
</style>

View File

@ -5,7 +5,7 @@ const quasar = useQuasar();
</script>
<template>
<QLayout view="hHh LpR fFf" v-shortcut>
<QLayout view="hHh lpR lFr" v-shortcut class="shadow-2">
<Navbar />
<RouterView></RouterView>
<QFooter v-if="quasar.platform.is.mobile"></QFooter>

View File

@ -185,8 +185,8 @@ const showBalancePdf = ({ id }) => {
@on-fetch="getCurrentBalance"
></FetchData>
<VnSubToolbar class="q-mb-md">
<template #st-data>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#st-data">
<div class="column justify-center q-px-md q-py-sm">
<span class="text-bold">{{ t('Total by company') }}</span>
<div class="row justify-center">
@ -194,8 +194,8 @@ const showBalancePdf = ({ id }) => {
{{ toCurrency(currentBalance[companyId]?.amount) }}
</div>
</div>
</template>
<template #st-actions>
</Teleport>
<Teleport to="#st-actions">
<div>
<VnSelect
:label="t('Company')"
@ -207,8 +207,8 @@ const showBalancePdf = ({ id }) => {
option-value="id"
></VnSelect>
</div>
</template>
</VnSubToolbar>
</Teleport>
</template>
<VnTable
ref="tableRef"
data-key="CustomerBalance"

View File

@ -36,7 +36,14 @@ const itemBalances = ref([]);
const warehouseFk = ref(null);
const _showWhatsBeforeInventory = ref(false);
const inventoriedDate = ref(null);
const loading = ref(true);
const pagination = ref({
rowsPerPage: 20,
sortBy: 'desc',
descending: false,
page: 1,
});
const filterWarehouses = "{ fields: ['id', 'name'], order: 'name ASC' }";
const columns = computed(() => [
{
name: 'claim',
@ -104,6 +111,11 @@ const showWhatsBeforeInventory = computed({
else itemsBalanceFilter.where.date = inventoriedDate.value ?? new Date();
},
});
async function handleOnFetch(data) {
itemBalances.value = data;
if (data.length < 1) return;
await scrollToToday();
}
const fetchItemBalances = async () => await itemBalancesRef.value.fetch();
@ -120,15 +132,12 @@ const scrollToToday = async () => {
await nextTick();
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
const todayCell = document.querySelector(`td[data-date="${today.toISOString()}"]`);
if (todayCell) {
todayCell.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
};
const formatDateForAttribute = (dateValue) => {
if (dateValue instanceof Date) return date.formatDate(dateValue, 'YYYY-MM-DD');
return dateValue;
const todayIndex = itemBalances.value.findIndex((item) =>
date.isSameDate(today.toISOString(), item.shipped)
);
if (todayIndex > -1)
pagination.value.page = Math.ceil(todayIndex / pagination.value.rowsPerPage);
loading.value = false;
};
const originTypeMap = {
@ -166,7 +175,6 @@ onMounted(async () => {
const { data } = await axios.get('Configs/findOne');
inventoriedDate.value = data.inventoried;
await fetchItemBalances();
await scrollToToday();
});
onUnmounted(() => (stateStore.rightDrawer = false));
@ -178,6 +186,9 @@ watch(
itemBalancesRef.value.fetch();
}
);
const pagesNumber = computed(() =>
Math.ceil(itemBalances.value.length / pagination.value.rowsPerPage)
);
</script>
<template>
@ -185,50 +196,51 @@ watch(
ref="itemBalancesRef"
url="Items/getBalance"
:filter="itemsBalanceFilter"
@on-fetch="(data) => (itemBalances = data)"
@on-fetch="handleOnFetch"
/>
<FetchData
url="Warehouses"
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
:filter="filterWarehouses"
auto-load
@on-fetch="(data) => (warehousesOptions = data)"
/>
<QToolbar class="justify-end">
<div id="st-data" class="row">
<VnSelect
:label="t('itemDiary.warehouse')"
:options="warehousesOptions"
hide-selected
option-label="name"
option-value="id"
dense
v-model="itemsBalanceFilter.where.warehouseFk"
@update:model-value="fetchItemBalances"
class="q-mr-lg"
/>
<QCheckbox
:label="t('itemDiary.showBefore')"
v-model="showWhatsBeforeInventory"
@update:model-value="fetchItemBalances"
class="q-mr-lg"
/>
<VnInputDate
v-if="showWhatsBeforeInventory"
:label="t('itemDiary.since')"
dense
v-model="itemsBalanceFilter.where.date"
@update:model-value="fetchItemBalances"
/>
</div>
<QSpace />
<div id="st-actions"></div>
</QToolbar>
<QPage class="column items-center q-pa-md">
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#st-data">
<div class="row">
<VnSelect
:label="t('itemDiary.warehouse')"
:options="warehousesOptions"
hide-selected
option-label="name"
option-value="id"
dense
v-model="itemsBalanceFilter.where.warehouseFk"
@update:model-value="fetchItemBalances"
class="q-mr-lg"
/>
<QCheckbox
:label="t('itemDiary.showBefore')"
v-model="showWhatsBeforeInventory"
@update:model-value="fetchItemBalances"
class="q-mr-lg"
/>
<VnInputDate
v-if="showWhatsBeforeInventory"
:label="t('itemDiary.since')"
dense
v-model="itemsBalanceFilter.where.date"
@update:model-value="fetchItemBalances"
/>
</div>
</Teleport>
</template>
<QPage>
<QTable
:loading="loading"
:rows="itemBalances"
:columns="columns"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
class="full-width"
v-model:pagination="pagination"
>
<template #body-cell-claim="{ row }">
<QTd @click.stop>
@ -247,7 +259,7 @@ watch(
</QTd>
</template>
<template #body-cell-date="{ row }">
<QTd @click.stop :data-date="formatDateForAttribute(row.shipped)">
<QTd @click.stop>
<QBadge
v-bind="getBadgeAttrs(row.shipped)"
class="q-ma-none"
@ -334,6 +346,15 @@ watch(
</QTd>
</template>
</QTable>
<QFooter elevated style="background-color: var(--vn-section-color)">
<QPagination
v-model="pagination.page"
:max="pagesNumber"
style="justify-content: center"
size="sm"
input
/>
</QFooter>
</QPage>
</template>