0
0
Fork 0

refs #6976 total Stems

This commit is contained in:
Carlos Satorres 2024-04-22 11:25:32 +02:00
parent ee80b1d617
commit d2ec47fe1c
1 changed files with 16 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<script setup>
import { useRoute } from 'vue-router';
import { computed, onMounted } from 'vue';
import { computed, onMounted, watch, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
@ -17,7 +17,6 @@ import axios from 'axios';
import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState';
import { useArrayData } from 'composables/useArrayData';
import { onUnmounted } from 'vue';
const state = useState();
const stateStore = useStateStore();
@ -35,6 +34,9 @@ const arrayData = useArrayData('SupplierConsumption', {
const store = arrayData.store;
console.log('route del principio', route.query.from);
watch(() => route.query);
onUnmounted(() => state.unset('SupplierConsumption'));
const dateRanges = computed(() => {
const ranges = {
@ -42,6 +44,7 @@ const dateRanges = computed(() => {
to: null,
};
console.log('route del if', route.query.from);
if (route.query && route.query.params) {
const params = JSON.parse(route.query.params);
if (params.from && params.to) {
@ -52,7 +55,7 @@ const dateRanges = computed(() => {
return ranges;
});
console.log('dataRanges', dateRanges);
const reportParams = computed(() => ({
recipientId: Number(route.params.id),
...dateRanges.value,
@ -112,12 +115,16 @@ const sendCampaignMetricsEmail = ({ address }) => {
const calculateTotal = (buysArray = []) =>
buysArray.reduce((accumulator, { total }) => accumulator + total, 0);
const calculateTotalStems = (buysArray = []) =>
buysArray.reduce((accumulator, { quantity }) => accumulator + quantity, 0);
onMounted(async () => {
stateStore.rightDrawer = true;
await getSupplierConsumptionData();
});
console.log('dateRange From', dateRanges.value.from);
console.log('dateRange value', dateRanges.value);
</script>
<template>
@ -192,10 +199,14 @@ console.log('dateRange From', dateRanges.value.from);
<QTd colspan="2" no-hover> {{ dashIfEmpty(buy.total) }}</QTd>
</QTr>
<QTr>
<QTd colspan="6" no-hover>
<QTd colspan="5" no-hover>
<span class="label">{{ t('Total entry') }}: </span>
<span>{{ calculateTotal(row.buys) }}</span>
</QTd>
<QTd no-hover>
<span class="label">{{ t('Total stems') }}: </span>
<span>{{ calculateTotalStems(row.buys) }}</span>
</QTd>
</QTr>
</template>
</QTable>
@ -211,6 +222,7 @@ console.log('dateRange From', dateRanges.value.from);
<i18n>
es:
Total entry: Total entrada
Total stems: Total tallos
Open as PDF: Abrir como PDF
Send to email: Enviar por email
This supplier does not have a contact with an email address: Este proveedor no tiene un email de contacto