This commit is contained in:
2021-04-29 18:36:31 +00:00
parent fa4349fc02
commit 89fabfe3fd
6 changed files with 46 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
<v-text-field
ref="textField"
:value="currencyValue"
@change="updateValue"
@input="updateValue"
v-currency="{
currency: currencyName,
locale: languageName
@@ -29,7 +29,8 @@ export default {
data() {
return {
currencyName: window.$gz.locale.getCurrencyName(),
languageName: window.$gz.locale.getResolvedLanguage()
languageName: window.$gz.locale.getResolvedLanguage(),
initializing: true
};
},
props: {
@@ -48,11 +49,30 @@ export default {
},
methods: {
updateValue() {
//this is required because the initial setting triggers an input event
//however the two values differ because it comes from the server in much higher precision
//and this control rounds it down
//so the first trigger must be ignored until it "settles"
if (this.initializing) {
this.initializing = false;
return;
}
let val = this.$refs.textField.$refs.input.value;
// //_value contains the actual underlying numeric value without text
// //value contains the entered text
// if (this.$refs.textField.$refs.input._value == this.value) {
// return;
// }
let parsedValue = parseCurrency(val, {
currency: this.currencyName,
locale: this.languageName
});
// //this.value on init is a very long string of digits / decimal places triggering a variance once rounded
// let parsedOldValue = parseCurrency(this.value.toString(), {
// currency: this.currencyName,
// locale: this.languageName
// });
if (parsedValue != this.value) {
this.$emit("input", parsedValue);
}