This commit is contained in:
2020-07-14 15:37:10 +00:00
parent 21f7024ad9
commit e76ac3d884
3 changed files with 59 additions and 64 deletions

View File

@@ -3,8 +3,8 @@
<template v-if="!readonly"> <template v-if="!readonly">
<v-text-field <v-text-field
ref="dateField" ref="dateField"
:value="dateControlFormat()" :value="dateValue"
@input="handleDateInput" @input="updateValue()"
:readonly="readonly" :readonly="readonly"
:disabled="disabled" :disabled="disabled"
:label="label" :label="label"
@@ -29,16 +29,9 @@
export default { export default {
data() { data() {
return { return {
internalValue: null,
timeZoneName: window.$gz.locale.getBrowserTimeZoneName() timeZoneName: window.$gz.locale.getBrowserTimeZoneName()
}; };
}, },
watch: {
value(val) {
console.log("date-control watch value is", val);
this.internalValue = val;
}
},
props: { props: {
label: String, label: String,
rules: Array, rules: Array,
@@ -52,6 +45,14 @@ export default {
}, },
testId: String testId: String
}, },
computed: {
dateValue() {
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
this.value,
this.timeZoneName
);
}
},
methods: { methods: {
allErrors() { allErrors() {
let ret = ""; let ret = "";
@@ -71,28 +72,54 @@ export default {
this.hour12 this.hour12
); );
}, },
dateControlFormat() { updateValue() {
//yyyy-mm-dd let vm = this;
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString( let dateValue = vm.$refs.dateField.$refs.input.value;
this.internalValue, if (!dateValue) {
this.timeZoneName let v = new Date();
); let fullYear = v.getFullYear();
}, let fullMonth = v.getMonth() + 1;
handleDateInput(value) { if (fullMonth < 10) {
//combine the time and dates into a consolidated value fullMonth = "0" + fullMonth.toString();
let TimePortion = window.$gz.locale.utcDateStringToLocal8601TimeOnlyString( }
this.internalValue, let fullDay = v.getDate();
this.timeZoneName if (fullDay < 10) {
); fullDay = "0" + fullDay.toString();
if (!TimePortion) { }
TimePortion = "00:00:00"; dateValue = fullYear + "-" + fullMonth + "-" + fullDay;
} }
let newValue = window.$gz.locale.localTimeDateStringToUTC8601String(
value + "T" + TimePortion, let timeValue = window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
this.timeZoneName vm.value,
vm.timeZoneName
); );
this.$emit("input", newValue); if (!timeValue) {
timeValue = "00:00:00";
}
let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
dateValue + "T" + timeValue,
vm.timeZoneName
);
vm.$emit("input", ret);
} }
// ,
// handleDateInput(value) {
// //combine the time and dates into a consolidated value
// let TimePortion = window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
// this.internalValue,
// this.timeZoneName
// );
// if (!TimePortion) {
// TimePortion = "00:00:00";
// }
// let newValue = window.$gz.locale.localTimeDateStringToUTC8601String(
// value + "T" + TimePortion,
// this.timeZoneName
// );
// this.$emit("input", newValue);
// }
} }
}; };
</script> </script>

View File

@@ -117,9 +117,9 @@ export default {
let ret = window.$gz.locale.localTimeDateStringToUTC8601String( let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
dateValue + "T" + timeValue, dateValue + "T" + timeValue,
this.timeZoneName vm.timeZoneName
); );
this.$emit("input", ret); vm.$emit("input", ret);
} }
} }
}; };

View File

@@ -102,42 +102,10 @@ export default {
let ret = window.$gz.locale.localTimeDateStringToUTC8601String( let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
dateValue + "T" + timeValue, dateValue + "T" + timeValue,
this.timeZoneName vm.timeZoneName
); );
this.$emit("input", ret); vm.$emit("input", ret);
} }
} }
// timeControlFormat() {
// //hh:mm:ss in 24 hour format
// return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
// this.internalValue,
// this.timeZoneName
// );
// },
// handleTimeInput(value) {
// let DatePortion = window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
// this.internalValue,
// this.timeZoneName
// );
// if (!DatePortion) {
// let v = new Date();
// let fullYear = v.getFullYear();
// let fullMonth = v.getMonth() + 1;
// if (fullMonth < 10) {
// fullMonth = "0" + fullMonth.toString();
// }
// let fullDay = v.getDate();
// if (fullDay < 10) {
// fullDay = "0" + fullDay.toString();
// }
// DatePortion = fullYear + "-" + fullMonth + "-" + fullDay;
// }
// let newValue = window.$gz.locale.localTimeDateStringToUTC8601String(
// DatePortion + "T" + value,
// this.timeZoneName
// );
// this.$emit("input", newValue);
// }
// }
}; };
</script> </script>