akaunting/resources/assets/js/components/AkauntingCurrencyConversion.vue

92 lines
2.9 KiB
Vue
Raw Normal View History

2021-06-29 09:33:07 +03:00
<template>
<div class="d-flex align-items-center justify-content-end mt-3">
<span>{{ texts[0] }}</span>
<money v-bind="{
decimal: this.currencySymbol.decimal_mark,
thousands: this.currencySymbol.thousands_separator,
prefix: (this.currencySymbol.symbol_first) ? this.currencySymbol.symbol : '',
suffix: (!this.currencySymbol.symbol_first) ? this.currencySymbol.symbol : '',
precision: parseInt(this.currencySymbol.precision),
masked: true
}" :value="price" disabled size="5" masked class="disabled-money text-right mr-2 js-conversion-input"></money>
2021-06-30 19:00:58 +03:00
<span class="mr-2">{{ texts[1] }}</span>
2021-06-29 09:33:07 +03:00
<input name="currency_rate" v-model="rate" @input="onChange" class="form-control text-right mwpx-100 h-auto js-conversion-input" />
</div>
</template>
2020-12-29 21:55:21 +03:00
2021-06-29 09:33:07 +03:00
<script>
import {Money} from 'v-money';
2020-12-29 21:55:21 +03:00
2021-06-29 09:33:07 +03:00
export default {
name: 'akaunting-currency-conversion',
components: {
Money
},
2020-12-29 21:55:21 +03:00
2021-06-29 09:33:07 +03:00
props: {
currencyConversionText: {
type: String,
default: 'Currency conversion'
},
price: {
type: String,
default: 'sale'
},
currecyCode: {
type: String,
default: 'USD'
},
currencyRate: {
default: 1.000,
},
currencySymbol: {
default: {}
}
},
data() {
return {
conversion: '',
rate: this.currencyRate,
2021-06-30 19:00:58 +03:00
texts: [],
2021-06-29 09:33:07 +03:00
};
},
created() {
let conver = this.currencyConversionText.split(':price');
2021-06-30 19:00:58 +03:00
2021-06-29 09:33:07 +03:00
this.texts.push(conver[0]);
2021-07-01 10:23:15 +03:00
this.texts.push(conver[1].replace(':currency_code', company_currency_code).replace(':currency_rate', ''));
2021-06-29 09:33:07 +03:00
},
methods: {
onChange() {
this.$emit('change', this.rate);
2021-07-01 10:23:15 +03:00
this.currencySymbol.rate = this.rate;
2021-06-29 09:33:07 +03:00
}
},
watch: {
currencyConversionText: function (text) {
this.conversion = text.replace(':price', this.price).replace(':currency_code', this.currecyCode);
},
price: function (price) {
2021-06-30 19:00:58 +03:00
this.conversion = this.currencyConversionText.replace(':price', price).replace(':currency_code', this.currecyCode).replace();
2021-06-29 09:33:07 +03:00
},
currecyCode: function (currecyCode) {
2021-06-30 19:00:58 +03:00
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace();
2021-06-29 09:33:07 +03:00
},
currencyRate: function (currencyRate) {
this.rate = currencyRate;
2021-06-30 19:00:58 +03:00
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace();
2021-06-29 09:33:07 +03:00
},
currencySymbol: function (currencySymbol) {
2021-06-30 19:00:58 +03:00
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace();
2021-06-29 09:33:07 +03:00
},
},
};
</script>