fix: fixed item packaging type field showing repetitive values
gitea/salix-front/pipeline/pr-test This commit looks good Details

This commit is contained in:
Jon Elias 2024-10-23 09:17:14 +02:00
parent 735ee09ef8
commit 4bde0dffa7
1 changed files with 12 additions and 7 deletions

View File

@ -101,7 +101,7 @@ const columns = computed(() => [
align: 'left',
name: 'itemPackingTypeFk',
label: t('ticketSale.packaging'),
format: (row) => getItemPackagingType(row),
format: (row) => getItemPackagingType(row.ticketSales),
},
{
align: 'right',
@ -151,13 +151,18 @@ const setShippedColor = (date) => {
if (difference < 0) return 'success';
};
const getItemPackagingType = (row) => {
const packagingType = row?.ticketSales
.map((sale) => sale.item?.itemPackingTypeFk || '-')
.filter((value) => value !== '-')
.join(', ');
const getItemPackagingType = (ticketSales) => {
if (!ticketSales || ticketSales.length === 0) return '-';
return dashIfEmpty(packagingType);
const packagingTypes = ticketSales
.map((sale) => sale.item?.itemPackingTypeFk)
.filter((type) => type !== undefined && type !== null);
const uniquePackagingTypes = [...new Set(packagingTypes)];
return dashIfEmpty(
uniquePackagingTypes.length > 0 ? uniquePackagingTypes.join(', ') : '-'
);
};
</script>