0
0
Fork 0

set columns default attrs to avoid repeating code

This commit is contained in:
William Buezas 2024-04-22 11:30:16 -03:00
parent dce48b536d
commit e11625e05f
1 changed files with 28 additions and 51 deletions

View File

@ -93,14 +93,7 @@ const getColumnInputEvents = (col) => {
}; };
}; };
const columns = computed(() => [ const defaultColumnFilter = {
{
label: t('item.fixedPrice.itemId'),
name: 'itemId',
field: 'itemFk',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput, component: VnInput,
type: 'text', type: 'text',
filterValue: null, filterValue: null,
@ -108,38 +101,39 @@ const columns = computed(() => [
attrs: { attrs: {
dense: true, dense: true,
}, },
};
const defaultColumnAttrs = {
align: 'left',
sortable: true,
};
const columns = computed(() => [
{
label: t('item.fixedPrice.itemId'),
name: 'itemId',
field: 'itemFk',
...defaultColumnAttrs,
columnFilter: {
...defaultColumnFilter,
}, },
}, },
{ {
label: t('globals.description'), label: t('globals.description'),
field: 'name', field: 'name',
name: 'description', name: 'description',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, ...defaultColumnFilter,
type: 'text',
filterValue: null,
event: getColumnInputEvents,
attrs: {
dense: true,
},
}, },
}, },
{ {
label: t('item.fixedPrice.groupingPrice'), label: t('item.fixedPrice.groupingPrice'),
field: 'rate2', field: 'rate2',
name: 'groupingPrice', name: 'groupingPrice',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, ...defaultColumnFilter,
type: 'text',
filterValue: null,
event: getColumnInputEvents,
attrs: {
dense: true,
},
}, },
format: (val) => toCurrency(val), format: (val) => toCurrency(val),
}, },
@ -147,16 +141,9 @@ const columns = computed(() => [
label: t('item.fixedPrice.packingPrice'), label: t('item.fixedPrice.packingPrice'),
field: 'rate3', field: 'rate3',
name: 'packingPrice', name: 'packingPrice',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, ...defaultColumnFilter,
type: 'text',
filterValue: null,
event: getColumnInputEvents,
attrs: {
dense: true,
},
}, },
format: (val) => dashIfEmpty(val), format: (val) => dashIfEmpty(val),
}, },
@ -165,32 +152,23 @@ const columns = computed(() => [
label: t('item.fixedPrice.minPrice'), label: t('item.fixedPrice.minPrice'),
field: 'minPrice', field: 'minPrice',
name: 'minPrice', name: 'minPrice',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, ...defaultColumnFilter,
type: 'text',
filterValue: null,
event: getColumnInputEvents,
attrs: {
dense: true,
},
}, },
}, },
{ {
label: t('item.fixedPrice.started'), label: t('item.fixedPrice.started'),
field: 'started', field: 'started',
name: 'started', name: 'started',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: null, columnFilter: null,
}, },
{ {
label: t('item.fixedPrice.ended'), label: t('item.fixedPrice.ended'),
field: 'ended', field: 'ended',
name: 'ended', name: 'ended',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: null, columnFilter: null,
}, },
@ -198,8 +176,7 @@ const columns = computed(() => [
label: t('item.fixedPrice.warehouse'), label: t('item.fixedPrice.warehouse'),
field: 'warehouseFk', field: 'warehouseFk',
name: 'warehouse', name: 'warehouse',
align: 'left', ...defaultColumnAttrs,
sortable: true,
columnFilter: { columnFilter: {
component: VnSelectFilter, component: VnSelectFilter,
type: 'select', type: 'select',