This commit is contained in:
@@ -27,9 +27,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
internalValue: null,
|
||||
internalChange: false,
|
||||
currencyName: window.$gz.locale.getCurrencyName(),
|
||||
languageName: window.$gz.locale.getBrowserFirstLanguage(),
|
||||
internalChange: false
|
||||
languageName: window.$gz.locale.getBrowserFirstLanguage()
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -51,30 +51,23 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
handleInput(value) {
|
||||
let ret = parseCurrency(value, {
|
||||
let parsedValue = parseCurrency(value, {
|
||||
currency: this.currencyName,
|
||||
locale: this.languageName
|
||||
});
|
||||
if (this.internalChange) {
|
||||
this.internalValue = ret;
|
||||
this.internalValue = parsedValue;
|
||||
this.internalChange = false;
|
||||
return;
|
||||
}
|
||||
console.log(
|
||||
`handleInput, comparing value of ${value} to internalValue of ${this.internalValue}`
|
||||
);
|
||||
if (ret == this.internalValue) {
|
||||
|
||||
if (parsedValue == this.internalValue) {
|
||||
//nothing changed
|
||||
return;
|
||||
}
|
||||
|
||||
// let ret = parseCurrency(value, {
|
||||
// currency: this.currencyName,
|
||||
// locale: this.languageName
|
||||
// });
|
||||
console.log("currency-control emitting INPUT on value", ret);
|
||||
this.$emit("input", ret);
|
||||
this.internalValue = ret;
|
||||
this.$emit("input", parsedValue);
|
||||
this.internalValue = parsedValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
<div>
|
||||
<v-text-field
|
||||
ref="textField"
|
||||
:value="formattedValue"
|
||||
@input="handleInput"
|
||||
v-currency="{
|
||||
currency: null,
|
||||
locale: languageName
|
||||
}"
|
||||
:readonly="readonly"
|
||||
:disabled="disabled"
|
||||
:label="label"
|
||||
:rules="rules"
|
||||
></v-text-field>
|
||||
@@ -27,12 +27,14 @@ import { setValue, parseCurrency } from "vue-currency-input";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formattedValue: this.value,
|
||||
internalValue: null,
|
||||
internalChange: false,
|
||||
languageName: window.$gz.locale.getBrowserFirstLanguage()
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value(value) {
|
||||
this.internalChange = true;
|
||||
setValue(this.$refs.textField.$refs.input, value);
|
||||
}
|
||||
},
|
||||
@@ -41,6 +43,7 @@ export default {
|
||||
rules: Array,
|
||||
value: { type: Number, default: null },
|
||||
readonly: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
error: {
|
||||
type: String,
|
||||
required: false
|
||||
@@ -48,14 +51,22 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
handleInput(value) {
|
||||
this.$emit(
|
||||
"input",
|
||||
parseCurrency(value, {
|
||||
currency: null,
|
||||
locale: this.languageName
|
||||
})
|
||||
);
|
||||
this.formattedValue = value;
|
||||
let parsedValue = parseCurrency(value, {
|
||||
currency: null,
|
||||
locale: this.languageName
|
||||
});
|
||||
if (this.internalChange) {
|
||||
this.internalValue = parsedValue;
|
||||
this.internalChange = false;
|
||||
return;
|
||||
}
|
||||
if (parsedValue == this.internalValue) {
|
||||
//nothing changed
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit("input", parsedValue);
|
||||
this.internalValue = parsedValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user