0
0
Fork 0

fix: column hidden v-if

This commit is contained in:
Javier Segarra 2024-06-25 13:35:16 +02:00
parent ea7ee97867
commit 9817ae8c2c
1 changed files with 11 additions and 3 deletions

View File

@ -45,15 +45,18 @@ watch(
const columns = computed(() => [ const columns = computed(() => [
{ {
required: true,
label: t('basicData.item'), label: t('basicData.item'),
name: 'item', name: 'item',
align: 'left', align: 'left',
format: (val) => val.name, format: (val) => val.name,
}, },
{ {
required: true,
label: t('basicData.description'), label: t('basicData.description'),
name: 'description', name: 'description',
align: 'left', align: 'left',
hidden: true,
}, },
{ {
label: t('basicData.movable'), label: t('basicData.movable'),
@ -61,12 +64,14 @@ const columns = computed(() => [
align: 'left', align: 'left',
}, },
{ {
required: true,
label: t('basicData.quantity'), label: t('basicData.quantity'),
name: 'quantity', name: 'quantity',
field: 'quantity', field: 'quantity',
align: 'left', align: 'left',
}, },
{ {
required: true,
label: t('basicData.pricePPU'), label: t('basicData.pricePPU'),
name: 'price', name: 'price',
field: 'price', field: 'price',
@ -74,6 +79,7 @@ const columns = computed(() => [
format: (val) => toCurrency(val), format: (val) => toCurrency(val),
}, },
{ {
required: true,
label: t('basicData.newPricePPU'), label: t('basicData.newPricePPU'),
name: 'newPrice', name: 'newPrice',
field: (row) => row.component.newPrice, field: (row) => row.component.newPrice,
@ -81,6 +87,7 @@ const columns = computed(() => [
format: (val) => toCurrency(val), format: (val) => toCurrency(val),
}, },
{ {
required: true,
label: t('basicData.difference'), label: t('basicData.difference'),
name: 'difference', name: 'difference',
field: (row) => row.component.difference, field: (row) => row.component.difference,
@ -108,18 +115,18 @@ const totalNewPrice = computed(() => {
const totalDifference = computed(() => { const totalDifference = computed(() => {
return rows.value.reduce((acc, item) => acc + item.component.difference, 0); return rows.value.reduce((acc, item) => acc + item.component.difference, 0);
}); });
const showMovablecolumn = computed(() => (haveDifferences.value > 0 ? ['movable'] : []));
const haveDifferences = computed(() => _ticketData.value.sale.haveDifferences);
const ticketHaveNegatives = () => { const ticketHaveNegatives = () => {
let _haveNegatives = false; let _haveNegatives = false;
let haveNotNegatives = false; let haveNotNegatives = false;
_ticketData.value.withoutNegatives = false; _ticketData.value.withoutNegatives = false;
const haveDifferences = _ticketData.value.sale.haveDifferences;
_ticketData.value.sale.items.forEach((item) => { _ticketData.value.sale.items.forEach((item) => {
if (item.quantity > item.movable) _haveNegatives = true; if (item.quantity > item.movable) _haveNegatives = true;
else haveNotNegatives = true; else haveNotNegatives = true;
}); });
haveNegatives.value = _haveNegatives && haveNotNegatives && haveDifferences; haveNegatives.value = _haveNegatives && haveNotNegatives && haveDifferences.value;
if (haveNegatives.value) _ticketData.value.withoutNegatives = true; if (haveNegatives.value) _ticketData.value.withoutNegatives = true;
}; };
@ -216,6 +223,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</template> </template>
</RightMenu> </RightMenu>
<QTable <QTable
:visible-columns="showMovablecolumn"
:rows="rows" :rows="rows"
:columns="columns" :columns="columns"
row-key="id" row-key="id"