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