0
0
Fork 0

Add focus to amount input in customer unpaid

This commit is contained in:
William Buezas 2024-04-04 11:30:09 -03:00
parent 94644de4fa
commit 82f259be32
1 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, onBeforeMount, ref, watch } from 'vue'; import { computed, onBeforeMount, ref, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -15,6 +15,7 @@ const route = useRoute();
const { notify } = useNotify(); const { notify } = useNotify();
const stateStore = useStateStore(); const stateStore = useStateStore();
const amountInputRef = ref(null);
const initialDated = Date.vnNew(); const initialDated = Date.vnNew();
const unpaidClient = ref(false); const unpaidClient = ref(false);
const isLoading = ref(false); const isLoading = ref(false);
@ -96,6 +97,14 @@ const onSubmit = async () => {
isLoading.value = false; isLoading.value = false;
} }
}; };
watch(
() => unpaidClient.value,
async (val) => {
await nextTick();
if (val) amountInputRef.value.focus();
}
);
</script> </script>
<template> <template>
@ -131,12 +140,13 @@ const onSubmit = async () => {
</div> </div>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md" v-if="unpaidClient"> <VnRow class="row q-gutter-md q-mb-md" v-show="unpaidClient">
<div class="col"> <div class="col">
<VnInputDate :label="t('Date')" v-model="dated" /> <VnInputDate :label="t('Date')" v-model="dated" />
</div> </div>
<div class="col"> <div class="col">
<VnInput <VnInput
ref="amountInputRef"
:label="t('Amount')" :label="t('Amount')"
clearable clearable
type="number" type="number"