0
0
Fork 0

refs #6907 updates

This commit is contained in:
Javier Segarra 2024-03-21 10:45:30 +01:00
parent 4ffabaa4f2
commit f5d6c45339
3 changed files with 25 additions and 13 deletions

View File

@ -41,8 +41,8 @@ const onEnterPress = () => {
emit('keyup.enter'); emit('keyup.enter');
}; };
const focus = () => { const handleValue = (val = null) => {
vnInputRef.value.focus(); value.value = val;
}; };
defineExpose({ defineExpose({
@ -63,7 +63,7 @@ defineExpose({
:type="$attrs.type" :type="$attrs.type"
:class="{ required: $attrs.required }" :class="{ required: $attrs.required }"
@keyup.enter="onEnterPress()" @keyup.enter="onEnterPress()"
:clearable="focus" :clearable="false"
> >
<template v-if="$slots.prepend" #prepend> <template v-if="$slots.prepend" #prepend>
<slot name="prepend" /> <slot name="prepend" />
@ -71,6 +71,12 @@ defineExpose({
<template #append> <template #append>
<slot name="append" v-if="$slots.append" /> <slot name="append" v-if="$slots.append" />
<QIcon
name="close"
size="xs"
v-if="focus && value"
@click="handleValue(null)"
></QIcon>
</template> </template>
</QInput> </QInput>
</div> </div>

View File

@ -46,7 +46,7 @@ const isPopupOpen = ref(false);
const onDateUpdate = (date) => { const onDateUpdate = (date) => {
value.value = date; value.value = date;
isPopupOpen.value = false; // isPopupOpen.value = false;
}; };
const padDate = (value) => value.toString().padStart(2, '0'); const padDate = (value) => value.toString().padStart(2, '0');

View File

@ -2,7 +2,7 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import isValidDate from 'filters/isValidDate'; import isValidDate from 'filters/isValidDate';
import VnInput from "components/common/VnInput.vue"; import VnInput from 'components/common/VnInput.vue';
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
@ -20,6 +20,8 @@ const props = defineProps({
}); });
const { t } = useI18n(); const { t } = useI18n();
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
const focus = ref(false);
const value = computed({ const value = computed({
get() { get() {
return props.modelValue; return props.modelValue;
@ -27,12 +29,7 @@ const value = computed({
set(value) { set(value) {
const [hours, minutes] = value.split(':'); const [hours, minutes] = value.split(':');
const date = new Date(props.modelValue); const date = new Date(props.modelValue);
date.setHours( date.setHours(Number.parseInt(hours) || 0, Number.parseInt(minutes) || 0, 0, 0);
Number.parseInt(hours) || 0,
Number.parseInt(minutes) || 0,
0,
0
);
emit('update:modelValue', value ? date.toISOString() : null); emit('update:modelValue', value ? date.toISOString() : null);
}, },
}); });
@ -71,14 +68,22 @@ const styleAttrs = computed(() => {
</script> </script>
<template> <template>
<VnInput <!-- <div @mouseover="focus = true" @mouseleave="focus = false"> -->
<QInput
class="vn-input-time" class="vn-input-time"
readonly readonly
:model-value="formatTime(value)" :model-value="formatTime(value)"
v-bind="{ ...$attrs, ...styleAttrs }" v-bind="{ ...$attrs, ...styleAttrs }"
@click="isPopupOpen = true" @click="isPopupOpen = true"
:clearable="false"
> >
<template #append> <template #append>
<!-- <QIcon
name="close"
size="xs"
v-if="focus && value"
@click="value = null"
></QIcon> -->
<QIcon name="event" class="cursor-pointer"> <QIcon name="event" class="cursor-pointer">
<QPopupProxy <QPopupProxy
v-model="isPopupOpen" v-model="isPopupOpen"
@ -111,7 +116,8 @@ const styleAttrs = computed(() => {
</QPopupProxy> </QPopupProxy>
</QIcon> </QIcon>
</template> </template>
</VnInput> </QInput>
<!-- </div> -->
</template> </template>
<style lang="scss"> <style lang="scss">