fix: refs #7936 rollback
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Jorge Penadés 2025-01-20 11:51:53 +01:00
parent 8843318b66
commit ff95882e42
1 changed files with 7 additions and 25 deletions

View File

@ -33,19 +33,15 @@ defineProps({
}, },
}); });
function test(row) {
console.log('test', row);
return `${row.id}: ${row.name}`;
}
const columns = computed(() => [ const columns = computed(() => [
{ {
name: 'expense', name: 'expense',
label: t('Expense'), label: t('Expense'),
field: (row) => row.expenseFk,
options: expenses.value, options: expenses.value,
model: 'expenseFk', model: 'expenseFk',
optionValue: 'id', optionValue: 'id',
optionLabel: (row) => test(row), optionLabel: (row) => `${row.id}: ${row.name}`,
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -123,8 +119,6 @@ function taxRate(invoiceInTax) {
return ((taxTypeSage / 100) * taxableBase).toFixed(2); return ((taxTypeSage / 100) * taxableBase).toFixed(2);
} }
const expensesRef = ref();
const exponseShow = ref(false);
function autocompleteExpense(evt, row, col) { function autocompleteExpense(evt, row, col) {
const val = evt.target.value; const val = evt.target.value;
if (!val) return; if (!val) return;
@ -133,17 +127,9 @@ function autocompleteExpense(evt, row, col) {
const lookup = expenses.value.find( const lookup = expenses.value.find(
({ id }) => id == useAccountShortToStandard(param) ({ id }) => id == useAccountShortToStandard(param)
); );
if (lookup) {
row[col.model] = lookup?.id;
expensesRef.value.showItem = true;
}
}
const formatOpt = (row, { model, options }, prop) => { if (lookup) row[col.model] = lookup;
const obj = row[model]; }
const option = options.find(({ id }) => id == obj);
return option ? `${obj}:${option[prop]}` : '';
};
</script> </script>
<template> <template>
<FetchData <FetchData
@ -181,19 +167,15 @@ const formatOpt = (row, { model, options }, prop) => {
<template #body-cell-expense="{ row, col }"> <template #body-cell-expense="{ row, col }">
<QTd> <QTd>
<VnSelectDialog <VnSelectDialog
ref="expensesRef"
v-model="row[col.model]" v-model="row[col.model]"
:options="col.options" :options="col.options"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel"
:filter-options="['id', 'name']" :filter-options="['id', 'name']"
:tooltip="t('Create a new expense')" :tooltip="t('Create a new expense')"
@keydown.tab="autocompleteExpense($event, row, col)" @keydown.tab="autocompleteExpense($event, row, col)"
@input-value="(data) => (row[col.model] = undefined)"
> >
<template #selected-item="scope"> <template #option="scope">
A{{ scope.opt.id }}B</template
>
<!-- <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
{{ `${scope.opt.id}: ${scope.opt.name}` }} {{ `${scope.opt.id}: ${scope.opt.name}` }}
</QItem> </QItem>
@ -202,7 +184,7 @@ const formatOpt = (row, { model, options }, prop) => {
<CreateNewExpenseForm <CreateNewExpenseForm
@on-data-saved="$refs.expensesRef.fetch()" @on-data-saved="$refs.expensesRef.fetch()"
/> />
</template> --> </template>
</VnSelectDialog> </VnSelectDialog>
</QTd> </QTd>
</template> </template>