forked from verdnatura/salix-front
Compare commits
9 Commits
dev
...
8110_itemD
Author | SHA1 | Date |
---|---|---|
Javier Segarra | 991cbb8534 | |
Javier Segarra | 1670c40a31 | |
Javier Segarra | 30f990ac2f | |
Javier Segarra | a63766a836 | |
Javier Segarra | e4985064c1 | |
Javier Segarra | 066b0ffca0 | |
Javier Segarra | dc814ac09b | |
Javier Segarra | 67fc3b1e4a | |
Javier Segarra | 17675fb857 |
|
@ -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()"
|
||||
|
|
|
@ -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';
|
||||
|
@ -57,6 +57,10 @@ if (props.baseUrl) {
|
|||
}
|
||||
});
|
||||
}
|
||||
const headerHeight = ref(0);
|
||||
onMounted(() => {
|
||||
headerHeight.value = document.querySelector('.q-toolbar')?.offsetHeight + 'px';
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<QDrawer
|
||||
|
@ -80,11 +84,12 @@ if (props.baseUrl) {
|
|||
</template>
|
||||
</RightMenu>
|
||||
<QPageContainer>
|
||||
<QPage>
|
||||
<VnSubToolbar />
|
||||
<QPage padding :style="{ 'padding-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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
</Teleport>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="CustomerBalance"
|
||||
|
|
|
@ -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,16 +196,17 @@ 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">
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#st-data">
|
||||
<div class="row">
|
||||
<VnSelect
|
||||
:label="t('itemDiary.warehouse')"
|
||||
:options="warehousesOptions"
|
||||
|
@ -220,15 +232,15 @@ watch(
|
|||
@update:model-value="fetchItemBalances"
|
||||
/>
|
||||
</div>
|
||||
<QSpace />
|
||||
<div id="st-actions"></div>
|
||||
</QToolbar>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
</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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue