0
0
Fork 0

feat(VnTable): refs #6825 addInWhere

This commit is contained in:
Alex Moreno 2024-05-27 09:27:14 +02:00
parent 89e1b3581a
commit 696f6b4c05
2 changed files with 34 additions and 4 deletions

View File

@ -89,11 +89,15 @@ const components = {
async function addFilter(value) { async function addFilter(value) {
if (value && typeof value === 'object') value = model.value; if (value && typeof value === 'object') value = model.value;
value = value === '' ? null : value; value = value === '' ? undefined : value;
let field = columnFilter.value?.name ?? $props.column.name; let field = columnFilter.value?.name ?? $props.column.name;
const toFilter = { [field]: value };
await arrayData.addFilter({ params: toFilter }); let params = { [field]: value };
if (columnFilter.value?.inWhere) {
if (columnFilter.value.prefix) field = columnFilter.value.prefix + '.' + field;
params = { filter: { where: params } };
}
await arrayData.addFilter({ params });
} }
function alignRow() { function alignRow() {

View File

@ -75,11 +75,17 @@ const columns = computed(() => [
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.credit'), label: t('customer.extendedList.tableVisibleColumns.credit'),
name: 'credit', name: 'credit',
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.creditInsurance'), label: t('customer.extendedList.tableVisibleColumns.creditInsurance'),
name: 'creditInsurance', name: 'creditInsurance',
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -98,6 +104,9 @@ const columns = computed(() => [
label: t('customer.extendedList.tableVisibleColumns.mobile'), label: t('customer.extendedList.tableVisibleColumns.mobile'),
name: 'mobile', name: 'mobile',
cardVisible: true, cardVisible: true,
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -108,12 +117,29 @@ const columns = computed(() => [
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.countryFk'), label: t('customer.extendedList.tableVisibleColumns.countryFk'),
name: 'country', name: 'countryFk',
columnFilter: {
component: 'select',
inWhere: true,
prefix: 'c',
attrs: {
url: 'Countries',
},
},
format: (row, dashIfEmpty) => dashIfEmpty(row.country),
}, },
{ {
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.provinceFk'), label: t('customer.extendedList.tableVisibleColumns.provinceFk'),
name: 'provinceFk', name: 'provinceFk',
component: 'select',
attrs: {
url: 'Provinces',
},
columnField: {
component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(row.province),
}, },
{ {
align: 'left', align: 'left',