feat: refs #8388 add setCursor

This commit is contained in:
Jorge Penadés 2025-01-31 13:44:30 +01:00
parent 42b86f05ce
commit 6a7fcd1afe
1 changed files with 27 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, nextTick } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
@ -97,6 +97,20 @@ const columns = computed(() => [
}, },
]); ]);
const taxableBaseTotal = computed(() => {
return getTotal(invoiceInFormRef.value.formData, 'taxableBase');
});
const taxRateTotal = computed(() => {
return getTotal(invoiceInFormRef.value.formData, null, {
cb: taxRate,
});
});
const combinedTotal = computed(() => {
return +taxableBaseTotal.value + +taxRateTotal.value;
});
const filter = { const filter = {
fields: [ fields: [
'id', 'id',
@ -137,19 +151,14 @@ function autocompleteExpense(evt, row, col) {
expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup); expenseRef.value.vnSelectDialogRef.vnSelectRef.toggleOption(lookup);
} }
const taxableBaseTotal = computed(() => { function setCursor(ref) {
return getTotal(invoiceInFormRef.value.formData, 'taxableBase'); nextTick(() => {
}); const select = ref.vnSelectDialogRef
? ref.vnSelectDialogRef.vnSelectRef
const taxRateTotal = computed(() => { : ref.vnSelectRef;
return getTotal(invoiceInFormRef.value.formData, null, { select.$el.querySelector('input').setSelectionRange(0, 0);
cb: taxRate,
});
});
const combinedTotal = computed(() => {
return +taxableBaseTotal.value + +taxRateTotal.value;
}); });
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -195,6 +204,7 @@ const combinedTotal = computed(() => {
: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)"
@update:model-value="setCursor($refs.expenseRef)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -221,12 +231,14 @@ const combinedTotal = computed(() => {
<template #body-cell-sageiva="{ row, col }"> <template #body-cell-sageiva="{ row, col }">
<QTd> <QTd>
<VnSelect <VnSelect
ref="sageivaRef"
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" :option-label="col.optionLabel"
:filter-options="['id', 'vat']" :filter-options="['id', 'vat']"
data-cy="vat-sageiva" data-cy="vat-sageiva"
@update:model-value="setCursor($refs.sageivaRef)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
@ -244,11 +256,13 @@ const combinedTotal = computed(() => {
<template #body-cell-sagetransaction="{ row, col }"> <template #body-cell-sagetransaction="{ row, col }">
<QTd> <QTd>
<VnSelect <VnSelect
ref="sagetransactionRef"
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" :option-label="col.optionLabel"
:filter-options="['id', 'transaction']" :filter-options="['id', 'transaction']"
@update:model-value="setCursor($refs.sagetransactionRef)"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">