fix: refs #8388 update the right row

This commit is contained in:
Jorge Penadés 2025-01-31 14:17:08 +01:00
parent 6a7fcd1afe
commit 8d0d19d4c7
1 changed files with 25 additions and 11 deletions

View File

@ -25,7 +25,6 @@ const sageTaxTypes = ref([]);
const sageTransactionTypes = ref([]);
const rowsSelected = ref([]);
const invoiceInFormRef = ref();
const expenseRef = ref();
defineProps({
actionIcon: {
@ -139,7 +138,7 @@ function taxRate(invoiceInTax) {
return ((taxTypeSage / 100) * taxableBase).toFixed(2);
}
function autocompleteExpense(evt, row, col) {
function autocompleteExpense(evt, row, col, ref) {
const val = evt.target.value;
if (!val) return;
@ -148,7 +147,7 @@ function autocompleteExpense(evt, row, col) {
({ id }) => id == useAccountShortToStandard(param),
);
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
ref.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
}
function setCursor(ref) {
@ -156,7 +155,9 @@ function setCursor(ref) {
const select = ref.vnSelectDialogRef
? ref.vnSelectDialogRef.vnSelectRef
: ref.vnSelectRef;
select.$el.querySelector('input').setSelectionRange(0, 0);
const input = select.$el.querySelector('input');
input.focus();
input.setSelectionRange(0, 0);
});
}
</script>
@ -196,15 +197,24 @@ function setCursor(ref) {
<template #body-cell-expense="{ row, col }">
<QTd>
<VnSelectDialog
ref="expenseRef"
:ref="`expenseRef-${row.$index}`"
v-model="row[col.model]"
:options="col.options"
:option-value="col.optionValue"
:option-label="col.optionLabel"
:filter-options="['id', 'name']"
:tooltip="t('Create a new expense')"
@keydown.tab="autocompleteExpense($event, row, col)"
@update:model-value="setCursor($refs.expenseRef)"
@keydown.tab="
autocompleteExpense(
$event,
row,
col,
$refs[`expenseRef-${row.$index}`],
)
"
@update:model-value="
setCursor($refs[`expenseRef-${row.$index}`])
"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
@ -231,14 +241,16 @@ function setCursor(ref) {
<template #body-cell-sageiva="{ row, col }">
<QTd>
<VnSelect
ref="sageivaRef"
:ref="`sageivaRef-${row.$index}`"
v-model="row[col.model]"
:options="col.options"
:option-value="col.optionValue"
:option-label="col.optionLabel"
:filter-options="['id', 'vat']"
data-cy="vat-sageiva"
@update:model-value="setCursor($refs.sageivaRef)"
@update:model-value="
setCursor($refs[`sageivaRef-${row.$index}`])
"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
@ -256,13 +268,15 @@ function setCursor(ref) {
<template #body-cell-sagetransaction="{ row, col }">
<QTd>
<VnSelect
ref="sagetransactionRef"
:ref="`sagetransactionRef-${row.$index}`"
v-model="row[col.model]"
:options="col.options"
:option-value="col.optionValue"
:option-label="col.optionLabel"
:filter-options="['id', 'transaction']"
@update:model-value="setCursor($refs.sagetransactionRef)"
@update:model-value="
setCursor($refs[`sagetransactionRef-${row.$index}`])
"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">