This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
<template v-if="!readonly">
|
||||
<v-text-field
|
||||
ref="dateField"
|
||||
:value="dateControlFormat()"
|
||||
@input="handleDateInput"
|
||||
:value="dateValue"
|
||||
@input="updateValue()"
|
||||
:readonly="readonly"
|
||||
:disabled="disabled"
|
||||
:label="label"
|
||||
@@ -29,16 +29,9 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
internalValue: null,
|
||||
timeZoneName: window.$gz.locale.getBrowserTimeZoneName()
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
console.log("date-control watch value is", val);
|
||||
this.internalValue = val;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
label: String,
|
||||
rules: Array,
|
||||
@@ -52,6 +45,14 @@ export default {
|
||||
},
|
||||
testId: String
|
||||
},
|
||||
computed: {
|
||||
dateValue() {
|
||||
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||
this.value,
|
||||
this.timeZoneName
|
||||
);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
allErrors() {
|
||||
let ret = "";
|
||||
@@ -71,28 +72,54 @@ export default {
|
||||
this.hour12
|
||||
);
|
||||
},
|
||||
dateControlFormat() {
|
||||
//yyyy-mm-dd
|
||||
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||
this.internalValue,
|
||||
this.timeZoneName
|
||||
);
|
||||
},
|
||||
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";
|
||||
updateValue() {
|
||||
let vm = this;
|
||||
let dateValue = vm.$refs.dateField.$refs.input.value;
|
||||
if (!dateValue) {
|
||||
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();
|
||||
}
|
||||
dateValue = fullYear + "-" + fullMonth + "-" + fullDay;
|
||||
}
|
||||
let newValue = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||
value + "T" + TimePortion,
|
||||
this.timeZoneName
|
||||
|
||||
let timeValue = window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
|
||||
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>
|
||||
|
||||
@@ -117,9 +117,9 @@ export default {
|
||||
|
||||
let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||
dateValue + "T" + timeValue,
|
||||
this.timeZoneName
|
||||
vm.timeZoneName
|
||||
);
|
||||
this.$emit("input", ret);
|
||||
vm.$emit("input", ret);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -102,42 +102,10 @@ export default {
|
||||
|
||||
let ret = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user