forked from verdnatura/salix-front
feat: improve to set time
This commit is contained in:
parent
39bf7e55c0
commit
493081254d
|
@ -54,8 +54,8 @@ const formattedDate = computed({
|
|||
);
|
||||
}
|
||||
}
|
||||
let ymd = value.split('-').map((e) => parseInt(e));
|
||||
newDate = new Date(ymd[0], ymd[1] - 1, ymd[2]);
|
||||
const [year, month, day] = value.split('-').map((e) => parseInt(e));
|
||||
newDate = new Date(year, month - 1, day);
|
||||
if (model.value) {
|
||||
const orgDate =
|
||||
model.value instanceof Date ? model.value : new Date(model.value);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { watch, computed, ref } from 'vue';
|
||||
import { watch, computed, ref, nextTick } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { date } from 'quasar';
|
||||
|
||||
|
@ -20,6 +20,7 @@ const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
|||
const dateFormat = 'HH:mm';
|
||||
const isPopupOpen = ref();
|
||||
const hover = ref();
|
||||
const inputRef = ref();
|
||||
|
||||
const styleAttrs = computed(() => {
|
||||
return props.isOutlined
|
||||
|
@ -42,13 +43,14 @@ const formattedTime = computed({
|
|||
if (time) {
|
||||
if (time?.length > 5) time = dateToTime(time);
|
||||
else {
|
||||
if (time.length == 1 && parseInt(time) > 2) time = time.padStart(2, '0');
|
||||
time = time.padEnd(5, '0');
|
||||
if (!time.includes(':'))
|
||||
time = time.substring(0, 2) + ':' + time.substring(3, 4);
|
||||
time = time.substring(0, 2) + ':' + time.substring(3, 5);
|
||||
}
|
||||
if (!props.timeOnly) {
|
||||
const hours = time.split(':');
|
||||
const date = new Date(model.value);
|
||||
const date = new Date(model.value ? model.value : null);
|
||||
date.setHours(hours[0] ?? 0, hours[1] ?? 0, 0);
|
||||
time = date?.toISOString();
|
||||
}
|
||||
|
@ -66,11 +68,28 @@ watch(
|
|||
(val) => (formattedTime.value = val),
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => formattedTime.value,
|
||||
async (val) => {
|
||||
const input = inputRef.value?.getNativeElement();
|
||||
if (!val || !input) return;
|
||||
|
||||
const [hh, mm] = val.split(':');
|
||||
if (parseInt(hh) >= 10 || mm != '00') return;
|
||||
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
input.setSelectionRange(3, 3);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div @mouseover="hover = true" @mouseleave="hover = false">
|
||||
<QInput
|
||||
ref="inputRef"
|
||||
class="vn-input-time"
|
||||
mask="##:##"
|
||||
placeholder="--:--"
|
||||
|
@ -130,3 +149,4 @@ watch(
|
|||
es:
|
||||
Open time: Abrir tiempo
|
||||
</i18n>
|
||||
, nextTick
|
||||
|
|
|
@ -176,8 +176,6 @@ function confirmRemove(item) {
|
|||
}
|
||||
|
||||
async function remove(item) {
|
||||
console.log('item: ', item);
|
||||
console.log('id: ', route.params.id);
|
||||
await axios.post('OrderRows/removes', {
|
||||
actualOrderId: route.params.id,
|
||||
rows: [item.id],
|
||||
|
|
|
@ -126,7 +126,6 @@ const columns = computed(() => [
|
|||
]);
|
||||
|
||||
async function fetchClientAddress(id, data) {
|
||||
console.log('data: ', data);
|
||||
const clientData = await axios.get(`Clients/${id}`);
|
||||
selectedAddress.value = clientData.data.defaultAddressFk;
|
||||
data.addressId = selectedAddress.value;
|
||||
|
|
Loading…
Reference in New Issue