This commit is contained in:
parent
408bd274b4
commit
9611ea47cf
|
@ -6,6 +6,7 @@ import toDateHourMinSec from './toDateHourMinSec';
|
||||||
import toRelativeDate from './toRelativeDate';
|
import toRelativeDate from './toRelativeDate';
|
||||||
import toCurrency from './toCurrency';
|
import toCurrency from './toCurrency';
|
||||||
import toPercentage from './toPercentage';
|
import toPercentage from './toPercentage';
|
||||||
|
import toNumber from './toNumber';
|
||||||
import toLowerCamel from './toLowerCamel';
|
import toLowerCamel from './toLowerCamel';
|
||||||
import dashIfEmpty from './dashIfEmpty';
|
import dashIfEmpty from './dashIfEmpty';
|
||||||
import dateRange from './dateRange';
|
import dateRange from './dateRange';
|
||||||
|
@ -34,6 +35,7 @@ export {
|
||||||
toRelativeDate,
|
toRelativeDate,
|
||||||
toCurrency,
|
toCurrency,
|
||||||
toPercentage,
|
toPercentage,
|
||||||
|
toNumber,
|
||||||
dashIfEmpty,
|
dashIfEmpty,
|
||||||
dateRange,
|
dateRange,
|
||||||
getParamWhere,
|
getParamWhere,
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function (value, fractionSize = 2) {
|
||||||
|
if (isNaN(value)) return value;
|
||||||
|
return new Intl.NumberFormat('es-ES', {
|
||||||
|
style: 'decimal',
|
||||||
|
minimumFractionDigits: 0,
|
||||||
|
maximumFractionDigits: fractionSize,
|
||||||
|
}).format(value);
|
||||||
|
}
|
|
@ -122,6 +122,7 @@ globals:
|
||||||
producer: Producer
|
producer: Producer
|
||||||
origin: Origin
|
origin: Origin
|
||||||
state: State
|
state: State
|
||||||
|
total: Total
|
||||||
subtotal: Subtotal
|
subtotal: Subtotal
|
||||||
visible: Visible
|
visible: Visible
|
||||||
price: Price
|
price: Price
|
||||||
|
|
|
@ -126,6 +126,7 @@ globals:
|
||||||
producer: Productor
|
producer: Productor
|
||||||
origin: Origen
|
origin: Origen
|
||||||
state: Estado
|
state: Estado
|
||||||
|
total: Total
|
||||||
subtotal: Subtotal
|
subtotal: Subtotal
|
||||||
visible: Visible
|
visible: Visible
|
||||||
price: Precio
|
price: Precio
|
||||||
|
|
|
@ -7,16 +7,18 @@ import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||||
import SupplierConsumptionFilter from './SupplierConsumptionFilter.vue';
|
import SupplierConsumptionFilter from './SupplierConsumptionFilter.vue';
|
||||||
|
|
||||||
import { dateRange, toCurrency, toDate } from 'src/filters';
|
import { dateRange, toCurrency, toNumber, toDate } from 'src/filters';
|
||||||
|
|
||||||
import EntryDescriptorProxy from 'src/pages/Entry/Card/EntryDescriptorProxy.vue';
|
import EntryDescriptorProxy from 'src/pages/Entry/Card/EntryDescriptorProxy.vue';
|
||||||
import { usePrintService } from 'composables/usePrintService';
|
import { usePrintService } from 'composables/usePrintService';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
|
import { toDateHourMin } from 'src/filters';
|
||||||
|
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
||||||
|
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
@ -28,7 +30,7 @@ const { notify } = useNotify();
|
||||||
const totalRows = ref({});
|
const totalRows = ref({});
|
||||||
const arrayData = useArrayData('SupplierConsumption', {
|
const arrayData = useArrayData('SupplierConsumption', {
|
||||||
url: 'Suppliers/consumption',
|
url: 'Suppliers/consumption',
|
||||||
order: ['itemTypeFk', 'itemName', 'itemSize'],
|
order: ['itemTypeFk', 'item', 'itemSize'],
|
||||||
userFilter: { where: { supplierFk: route.params.id } },
|
userFilter: { where: { supplierFk: route.params.id } },
|
||||||
});
|
});
|
||||||
const headerColumns = computed(() => [
|
const headerColumns = computed(() => [
|
||||||
|
@ -41,30 +43,33 @@ const headerColumns = computed(() => [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'invoiceNumber',
|
name: 'invoiceNumber',
|
||||||
label: t('globals.subItem'),
|
label: t('globals.params.supplierRef'),
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'invoiceNumber',
|
field: 'invoiceNumber',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'shipped',
|
||||||
|
label: t('globals.shipped'),
|
||||||
|
align: 'center',
|
||||||
|
field: 'shipped',
|
||||||
|
format: toDateHourMin,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'quantity',
|
name: 'quantity',
|
||||||
label: t('globals.quantity'),
|
label: t('item.list.stems'),
|
||||||
align: 'left',
|
align: 'center',
|
||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
|
format: (value) => toNumber(value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'total',
|
name: 'total',
|
||||||
label: t('globals.quantity'),
|
label: t('globals.total'),
|
||||||
align: 'left',
|
align: 'center',
|
||||||
field: 'total',
|
field: 'total',
|
||||||
sortable: true,
|
format: (value) => toCurrency(value),
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'shipped',
|
|
||||||
label: t('globals.quantity'),
|
|
||||||
align: 'left',
|
|
||||||
field: 'shipped',
|
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -79,7 +84,6 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'subName',
|
name: 'subName',
|
||||||
label: t('globals.subItem'),
|
|
||||||
align: 'left',
|
align: 'left',
|
||||||
field: 'subName',
|
field: 'subName',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
@ -87,22 +91,25 @@ const columns = computed(() => [
|
||||||
{
|
{
|
||||||
name: 'quantity',
|
name: 'quantity',
|
||||||
label: t('globals.quantity'),
|
label: t('globals.quantity'),
|
||||||
align: 'left',
|
align: 'right',
|
||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
|
format: (value) => toNumber(value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'price',
|
name: 'price',
|
||||||
label: t('globals.price'),
|
label: t('globals.price'),
|
||||||
align: 'left',
|
align: 'right',
|
||||||
field: 'price',
|
field: 'price',
|
||||||
|
format: (value) => toCurrency(value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'total',
|
name: 'total',
|
||||||
label: t('globals.total'),
|
label: t('globals.total'),
|
||||||
align: 'left',
|
align: 'right',
|
||||||
field: 'total',
|
field: 'total',
|
||||||
|
format: (value) => toCurrency(value),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -204,7 +211,73 @@ onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
await getSupplierConsumptionData();
|
await getSupplierConsumptionData();
|
||||||
});
|
});
|
||||||
|
const lastAction = ref(null);
|
||||||
|
const isAction = (action) => {
|
||||||
|
if (lastAction.value === action) {
|
||||||
|
lastAction.value = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
lastAction.value = action;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
const isActionExpand = (action) => {
|
||||||
|
if (action === 'expand_all') {
|
||||||
|
return isAction('expand_all');
|
||||||
|
}
|
||||||
|
if (action === 'unfold_all') {
|
||||||
|
return isAction('unfold_all');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const isActionExpandAll = computed(() => {
|
||||||
|
return isActionExpand('expand_all');
|
||||||
|
});
|
||||||
|
const isActionUnfoldAll = computed(() => {
|
||||||
|
return isActionExpand('unfold_all');
|
||||||
|
});
|
||||||
|
const isActionExpandAllIcon = computed(() => {
|
||||||
|
return isActionExpandAll.value ? 'unfold_less' : 'expand_more';
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllIcon = computed(() => {
|
||||||
|
return isActionUnfoldAll.value ? 'expand_more' : 'unfold_less';
|
||||||
|
});
|
||||||
|
const isActionExpandAllLabel = computed(() => {
|
||||||
|
return isActionExpandAll.value ? t('globals.unfold_all') : t('globals.expand_all');
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllLabel = computed(() => {
|
||||||
|
return isActionUnfoldAll.value ? t('globals.expand_all') : t('globals.unfold_all');
|
||||||
|
});
|
||||||
|
const isActionExpandAllDisabled = computed(() => {
|
||||||
|
return !rows.value.length;
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllDisabled = computed(() => {
|
||||||
|
return !rows.value.length;
|
||||||
|
});
|
||||||
|
const isActionExpandAllTooltip = computed(() => {
|
||||||
|
return isActionExpandAll.value ? t('globals.unfold_all') : t('globals.expand_all');
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllTooltip = computed(() => {
|
||||||
|
return isActionUnfoldAll.value ? t('globals.expand_all') : t('globals.unfold_all');
|
||||||
|
});
|
||||||
|
const isActionExpandAllIconClass = computed(() => {
|
||||||
|
return isActionExpandAll.value ? 'vn:unfold_less' : 'vn:expand_more';
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllIconClass = computed(() => {
|
||||||
|
return isActionUnfoldAll.value ? 'vn:expand_more' : 'vn:unfold_less';
|
||||||
|
});
|
||||||
|
const isActionExpandAllIconClassColor = computed(() => {
|
||||||
|
return isActionExpandAll.value ? 'primary' : 'grey-4';
|
||||||
|
});
|
||||||
|
const isActionUnfoldAllIconClassColor = computed(() => {
|
||||||
|
return isActionUnfoldAll.value ? 'primary' : 'grey-4';
|
||||||
|
});
|
||||||
|
const actions = (action) => {
|
||||||
|
if (action === 'expand_all') {
|
||||||
|
expanded.value = rows.value.map((r) => r.id);
|
||||||
|
} else if (action === 'unfold_all') {
|
||||||
|
expanded.value = [];
|
||||||
|
}
|
||||||
|
lastAction.value = action;
|
||||||
|
};
|
||||||
const expanded = ref([]);
|
const expanded = ref([]);
|
||||||
// const initialExpanded = rows.filter((r, i) => i % 3 === 0).map((r) => r.index);
|
// const initialExpanded = rows.filter((r, i) => i % 3 === 0).map((r) => r.index);
|
||||||
</script>
|
</script>
|
||||||
|
@ -240,14 +313,14 @@ const expanded = ref([]);
|
||||||
<div>
|
<div>
|
||||||
{{ t('Total entries') }}:
|
{{ t('Total entries') }}:
|
||||||
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
||||||
{{ totalRows.totalPrice }} €
|
{{ toCurrency(totalRows.totalPrice) }}
|
||||||
</QChip>
|
</QChip>
|
||||||
</div>
|
</div>
|
||||||
<QSeparator dark vertical />
|
<QSeparator dark vertical />
|
||||||
<div>
|
<div>
|
||||||
{{ t('Total stems entries') }}:
|
{{ t('Total stems entries') }}:
|
||||||
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
||||||
{{ totalRows.totalQuantity }}
|
{{ toNumber(totalRows.totalQuantity) }}
|
||||||
</QChip>
|
</QChip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -258,34 +331,63 @@ const expanded = ref([]);
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
<QCard class="full-width q-pa-md">
|
<QCard class="full-width q-pa-md">
|
||||||
|
<div class="row">
|
||||||
|
<QBtn
|
||||||
|
v-if="lastAction && lastAction === 'expand_all'"
|
||||||
|
name="expand_all"
|
||||||
|
flat
|
||||||
|
color="primary"
|
||||||
|
icon="expand_all"
|
||||||
|
@click.stop="actions('expand_all')"
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
v-if="lastAction && lastAction === 'unfold_all'"
|
||||||
|
name="unfold_all"
|
||||||
|
flat
|
||||||
|
color="primary"
|
||||||
|
icon="unfold_less"
|
||||||
|
@click.stop="actions('unfold_all')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<QTable
|
<QTable
|
||||||
flat
|
flat
|
||||||
bordered
|
bordered
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="headerColumns"
|
:columns="headerColumns"
|
||||||
:table-colspan="9"
|
|
||||||
row-key="id"
|
row-key="id"
|
||||||
virtual-scroll
|
|
||||||
:virtual-scroll-item-size="48"
|
|
||||||
:pagination="{
|
|
||||||
rowsPerPage: 0,
|
|
||||||
}"
|
|
||||||
:rows-per-page-options="[0]"
|
|
||||||
v-model:expanded="expanded"
|
v-model:expanded="expanded"
|
||||||
|
:grid="$q.screen.lt.md"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template #header="props">
|
||||||
<QTr :props="props">
|
<QTr :props="props">
|
||||||
<QTh auto-width />
|
<QTh auto-width />
|
||||||
|
|
||||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
{{ col.label }}
|
<span v-text="col.label" />
|
||||||
</QTh>
|
</QTh>
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body="props">
|
<!-- Template especial para la columna 'id' -->
|
||||||
<QTr :props="props" :key="`m_${props.row.id}`" class="bg-travel">
|
<template #body-cell-id="{ value }">
|
||||||
|
<div class="custom-id"><strong>ID:</strong> {{ value }}</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Template especial para la columna 'invoiceNumber' -->
|
||||||
|
<template #body-cell-invoiceNumber="{ value }">
|
||||||
|
<div class="custom-invoice">
|
||||||
|
<span class="label">Invoice:</span>
|
||||||
|
<span class="value">{{ value }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #body="props">
|
||||||
|
<QTr
|
||||||
|
:props="props"
|
||||||
|
:key="`movement_${props.row.id}`"
|
||||||
|
class="bg-travel cursor-pointer"
|
||||||
|
@click="props.expand = !props.expand"
|
||||||
|
>
|
||||||
<QTd auto-width>
|
<QTd auto-width>
|
||||||
<QToggle
|
<QToggle
|
||||||
v-model="props.expand"
|
v-model="props.expand"
|
||||||
|
@ -295,55 +397,66 @@ const expanded = ref([]);
|
||||||
</QTd>
|
</QTd>
|
||||||
|
|
||||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
<span @click.stop class="link" v-if="col.name === 'id'">
|
||||||
{{ col.value }}
|
{{ col.value }}
|
||||||
|
<EntryDescriptorProxy :id="col.value" />
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span v-else v-text="col.value" />
|
||||||
</QTd>
|
</QTd>
|
||||||
</QTr>
|
</QTr>
|
||||||
|
|
||||||
<QTr
|
<QTr
|
||||||
v-show="props.expand"
|
v-show="props.expand"
|
||||||
:props="props"
|
:props="props"
|
||||||
:key="`e_${props.row.id}`"
|
:key="`expedition_${props.row.id}`"
|
||||||
class="q-virtual-scroll--with-prev"
|
|
||||||
>
|
>
|
||||||
<QTd colspan="100%">
|
<QTd colspan="12" style="padding: 1px 0">
|
||||||
<QTable
|
<QTable
|
||||||
flat
|
|
||||||
bordered
|
|
||||||
color="secondary"
|
color="secondary"
|
||||||
card-class="bg-travel text-white "
|
card-class="bg-travel text-white "
|
||||||
|
style-class="height: 30px"
|
||||||
table-header-class=" text-white"
|
table-header-class=" text-white"
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
:rows="props.row.buys"
|
:rows="props.row.buys"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
hide-header
|
hide-header
|
||||||
:table-colspan="9"
|
|
||||||
row-key="id"
|
row-key="id"
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
:virtual-scroll-item-size="48"
|
|
||||||
:pagination="{
|
|
||||||
rowsPerPage: 0,
|
|
||||||
}"
|
|
||||||
:rows-per-page-options="[0]"
|
|
||||||
v-model:expanded="expanded"
|
v-model:expanded="expanded"
|
||||||
>
|
>
|
||||||
<template v-slot:header="props">
|
<template #body="props">
|
||||||
<QTr :props="props">
|
<!-- <QTr
|
||||||
<QTh
|
v-if="props.rowIndex === 0"
|
||||||
v-for="col in props.cols"
|
:key="`rowHeader_${props.row.id}`"
|
||||||
:key="col.name"
|
|
||||||
:props="props"
|
:props="props"
|
||||||
>
|
>
|
||||||
{{ col.label }}
|
|
||||||
</QTh>
|
|
||||||
</QTr>
|
|
||||||
</template>
|
|
||||||
<template v-slot:body="props">
|
|
||||||
<QTr :props="props" :key="`m_${props.row.id}`">
|
|
||||||
<QTd
|
<QTd
|
||||||
v-for="col in props.cols"
|
v-for="col in props.cols"
|
||||||
:key="col.name"
|
:key="col.name"
|
||||||
:props="props"
|
:props="props"
|
||||||
>
|
>
|
||||||
{{ col.value }}
|
<span v-text="col.label" />
|
||||||
|
</QTd>
|
||||||
|
</QTr> -->
|
||||||
|
<QTr :props="props" :key="`m_${props.row.id}`">
|
||||||
|
<QTd
|
||||||
|
v-for="col in props.cols"
|
||||||
|
:key="col.name"
|
||||||
|
:title="col.label"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
<!-- <div class="grid-container">
|
||||||
|
<div class="grid-item name" :title="col.name">
|
||||||
|
{{ col.name }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="grid-item value"
|
||||||
|
v-text="col.value"
|
||||||
|
></div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<span v-text="col.value"></span>
|
||||||
</QTd>
|
</QTd>
|
||||||
</QTr>
|
</QTr>
|
||||||
</template>
|
</template>
|
||||||
|
@ -453,6 +566,24 @@ const expanded = ref([]);
|
||||||
background-color: var(--vn-page-color);
|
background-color: var(--vn-page-color);
|
||||||
border-bottom: 2px solid $primary;
|
border-bottom: 2px solid $primary;
|
||||||
}
|
}
|
||||||
|
.grid-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: auto auto; /* Dos filas: una para el nombre y otra para el valor */
|
||||||
|
gap: 4px; /* Espaciado entre filas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-item.name {
|
||||||
|
font-weight: bold; /* Estilo para el nombre */
|
||||||
|
color: var(--vn-label-color); /* Cambia el color según tu diseño */
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-item.value {
|
||||||
|
color: var(--vn-text-color); /* Estilo para el valor */
|
||||||
|
}
|
||||||
|
.q-table thead tr,
|
||||||
|
.q-table tbody td {
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
Loading…
Reference in New Issue