forked from verdnatura/salix-front
Add input focus
This commit is contained in:
parent
84a9dc8319
commit
485e916f55
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, nextTick } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
@ -11,7 +11,20 @@ const { t } = useI18n();
|
||||||
|
|
||||||
const itemBarcodeRef = ref(null);
|
const itemBarcodeRef = ref(null);
|
||||||
|
|
||||||
onMounted(() => {
|
const insertRow = () => {
|
||||||
|
itemBarcodeRef.value.insert();
|
||||||
|
focusLastInput();
|
||||||
|
};
|
||||||
|
|
||||||
|
const focusLastInput = () => {
|
||||||
|
nextTick(() => {
|
||||||
|
const inputs = document.querySelectorAll('[focusable-input]');
|
||||||
|
const lastInput = inputs[inputs.length - 1];
|
||||||
|
if (lastInput) lastInput.focus();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
if (itemBarcodeRef.value) itemBarcodeRef.value.reload();
|
if (itemBarcodeRef.value) itemBarcodeRef.value.reload();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -31,7 +44,7 @@ onMounted(() => {
|
||||||
url="ItemBarcodes"
|
url="ItemBarcodes"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<QCard class="q-px-lg q-py-md">
|
<QCard v-if="rows.length > 0" class="q-px-lg q-py-md">
|
||||||
<div
|
<div
|
||||||
v-for="(row, index) in rows"
|
v-for="(row, index) in rows"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
@ -41,6 +54,7 @@ onMounted(() => {
|
||||||
:label="t('Code')"
|
:label="t('Code')"
|
||||||
v-model="row.code"
|
v-model="row.code"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
|
focusable-input
|
||||||
/>
|
/>
|
||||||
<QIcon
|
<QIcon
|
||||||
@click="itemBarcodeRef.remove([row])"
|
@click="itemBarcodeRef.remove([row])"
|
||||||
|
@ -55,7 +69,7 @@ onMounted(() => {
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</div>
|
</div>
|
||||||
<QIcon
|
<QIcon
|
||||||
@click="itemBarcodeRef.insert()"
|
@click="insertRow()"
|
||||||
class="cursor-pointer fill-icon-on-hover"
|
class="cursor-pointer fill-icon-on-hover"
|
||||||
color="primary"
|
color="primary"
|
||||||
name="add_circle"
|
name="add_circle"
|
||||||
|
|
Loading…
Reference in New Issue