This commit is contained in:
@@ -782,7 +782,7 @@ export default function initialize() {
|
|||||||
//TODO: also need the other locale settings such as number and date formats etc to be added at server
|
//TODO: also need the other locale settings such as number and date formats etc to be added at server
|
||||||
window.$gz.store.commit("setLocale", {
|
window.$gz.store.commit("setLocale", {
|
||||||
decimalSeparator: ".",
|
decimalSeparator: ".",
|
||||||
currencyName: "USD",
|
currencyName: "EUR",
|
||||||
hour12: true,
|
hour12: true,
|
||||||
// shortDate: "YYYY-MM-DD",
|
// shortDate: "YYYY-MM-DD",
|
||||||
// shortTime: "hh:mm:ss A",
|
// shortTime: "hh:mm:ss A",
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
|
ref="textField"
|
||||||
|
:value="formattedValue"
|
||||||
|
@input="handleInput"
|
||||||
v-currency="{
|
v-currency="{
|
||||||
currency: currencyName,
|
currency: currencyName,
|
||||||
locale: languageName
|
locale: languageName
|
||||||
}"
|
}"
|
||||||
v-model="workingAmount"
|
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
v-bind:label="label"
|
v-bind:label="label"
|
||||||
v-bind:rules="rules"
|
v-bind:rules="rules"
|
||||||
@@ -14,22 +16,31 @@
|
|||||||
<p v-show="error" class="form__error v-messages theme--light error--text">
|
<p v-show="error" class="form__error v-messages theme--light error--text">
|
||||||
{{ error }}
|
{{ error }}
|
||||||
</p>
|
</p>
|
||||||
|
<!-- currency:{{ currencyName }}, locale:{{ languageName }}, amount:{{ amount }}
|
||||||
|
<span class="title">v-currency-field</span>
|
||||||
|
<v-currency-field v-model="value" /> -->
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
/* Xeslint-disable */
|
/* Xeslint-disable */
|
||||||
//******************************** NOTE: this control also captures the TIME even though it's DATE only, this is an intentional design decision to support field change to amount or amount AND time and is considered a display issue */
|
import { setValue, parseCurrency } from "vue-currency-input";
|
||||||
export default {
|
export default {
|
||||||
data: () => ({
|
data() {
|
||||||
amount: null,
|
return {
|
||||||
oldAmount: null,
|
formattedValue: this.value,
|
||||||
currencyName: window.$gz.locale.getCurrencyName(),
|
currencyName: window.$gz.locale.getCurrencyName(),
|
||||||
languageName: window.$gz.locale.getBrowserFirstLanguage()
|
languageName: window.$gz.locale.getBrowserFirstLanguage()
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
value(value) {
|
||||||
|
setValue(this.$refs.textField.$refs.input, value);
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
label: String,
|
label: String,
|
||||||
rules: Array,
|
rules: Array,
|
||||||
value: Number,
|
value: { type: Number, default: null },
|
||||||
required: { type: Boolean, default: false },
|
required: { type: Boolean, default: false },
|
||||||
readonly: { type: Boolean, default: false },
|
readonly: { type: Boolean, default: false },
|
||||||
error: {
|
error: {
|
||||||
@@ -43,37 +54,41 @@ export default {
|
|||||||
},
|
},
|
||||||
locale() {
|
locale() {
|
||||||
return window.$gz.locale;
|
return window.$gz.locale;
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
amount() {
|
|
||||||
//abstract change of value to filter out no change and control when change happens to parent
|
|
||||||
var hasChanged = false;
|
|
||||||
|
|
||||||
if (this.amount != this.oldAmount) {
|
|
||||||
hasChanged = true;
|
|
||||||
}
|
|
||||||
this.oldAmount = this.amount;
|
|
||||||
if (hasChanged) {
|
|
||||||
this.$emit("input", this.amount);
|
|
||||||
this.$emit("change", this.amount);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
value() {
|
handleInput(value) {
|
||||||
this.amount = this.value;
|
this.$emit(
|
||||||
}
|
"input",
|
||||||
},
|
parseCurrency(value, {
|
||||||
computed: {
|
currency: this.currencyName,
|
||||||
workingAmount: {
|
locale: this.languageName
|
||||||
get() {
|
})
|
||||||
return this.amount;
|
);
|
||||||
},
|
this.formattedValue = value;
|
||||||
set(value) {
|
|
||||||
console.log("STUB: setvalue ");
|
|
||||||
console.log(value);
|
|
||||||
//this.amount = parseCurrencyHere(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ,
|
||||||
|
// computed: {
|
||||||
|
// amountLocal: {
|
||||||
|
// get: function() {
|
||||||
|
// console.log("Control getting amount: " + this.amount);
|
||||||
|
// if (this.amount == null) {
|
||||||
|
// return "0";
|
||||||
|
// } else {
|
||||||
|
// return this.amount.toString();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// set: function(value) {
|
||||||
|
// var parsedValue = this.$parseCurrency(this.amount, {
|
||||||
|
// currency: this.currencyName,
|
||||||
|
// locale: this.languageName
|
||||||
|
// });
|
||||||
|
// console.log("Control SETTING amount: " + parsedValue);
|
||||||
|
// //https://vuejs.org/v2/guide/components-custom-events.html#sync-Modifier
|
||||||
|
// //https://stackoverflow.com/a/51722100/8939
|
||||||
|
// this.$emit("update:amount", parsedValue);
|
||||||
|
// this.$emit("change", parsedValue);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import tagPicker from "./components/tag-picker.vue";
|
|||||||
import customFieldsControl from "./components/custom-fields-control.vue";
|
import customFieldsControl from "./components/custom-fields-control.vue";
|
||||||
import currencyControl from "./components/currency-control.vue";
|
import currencyControl from "./components/currency-control.vue";
|
||||||
import errorhandler from "./api/errorhandler";
|
import errorhandler from "./api/errorhandler";
|
||||||
|
import VCurrencyField from "./components/VCurrencyField";
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// LIBS AND GLOBAL ITEMS
|
// LIBS AND GLOBAL ITEMS
|
||||||
@@ -180,6 +181,7 @@ Vue.component("gz-time-picker", timeControl);
|
|||||||
Vue.component("gz-tag-picker", tagPicker);
|
Vue.component("gz-tag-picker", tagPicker);
|
||||||
Vue.component("gz-custom-fields", customFieldsControl);
|
Vue.component("gz-custom-fields", customFieldsControl);
|
||||||
Vue.component("gz-currency", currencyControl);
|
Vue.component("gz-currency", currencyControl);
|
||||||
|
Vue.component("v-currency-field", VCurrencyField);
|
||||||
|
|
||||||
//3rd party components
|
//3rd party components
|
||||||
Vue.use(VueCurrencyInput);
|
Vue.use(VueCurrencyInput);
|
||||||
|
|||||||
@@ -96,12 +96,11 @@
|
|||||||
:rules="[form().decimalValid(this, 'dollarAmount')]"
|
:rules="[form().decimalValid(this, 'dollarAmount')]"
|
||||||
:error-messages="form().serverErrors(this, 'dollarAmount')"
|
:error-messages="form().serverErrors(this, 'dollarAmount')"
|
||||||
@change="onChange('dollarAmount')"
|
@change="onChange('dollarAmount')"
|
||||||
></v-text-field> -->
|
></v-text-field>v-model="obj.dollarAmount" -->
|
||||||
|
<span class="title">v-currency-field</span>
|
||||||
|
<v-currency-field v-model="obj.dollarAmount" />
|
||||||
|
DOLLAR AMOUNT: {{ obj.dollarAmount }}
|
||||||
<gz-currency
|
<gz-currency
|
||||||
v-currency="{
|
|
||||||
currency: locale().getCurrencyName(),
|
|
||||||
locale: locale().getBrowserFirstLanguage()
|
|
||||||
}"
|
|
||||||
v-model="obj.dollarAmount"
|
v-model="obj.dollarAmount"
|
||||||
:readonly="this.formState.readOnly"
|
:readonly="this.formState.readOnly"
|
||||||
:label="lt('WidgetDollarAmount')"
|
:label="lt('WidgetDollarAmount')"
|
||||||
@@ -434,7 +433,7 @@ export default {
|
|||||||
},
|
},
|
||||||
onChange(ref) {
|
onChange(ref) {
|
||||||
if (!this.formState.loading && !this.formState.readOnly) {
|
if (!this.formState.loading && !this.formState.readOnly) {
|
||||||
debugger;
|
console.log("Onchange: " + ref);
|
||||||
window.$gz.form.onChange(this, ref);
|
window.$gz.form.onChange(this, ref);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -465,6 +464,7 @@ export default {
|
|||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
} else {
|
} else {
|
||||||
vm.obj = res.data;
|
vm.obj = res.data;
|
||||||
|
console.log("GetData dollarAmount:" + res.data.dollarAmount);
|
||||||
//Update the form status
|
//Update the form status
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
|
|||||||
Reference in New Issue
Block a user