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