2020-12-29 21:55:21 +03:00
|
|
|
<template>
|
2021-06-28 13:00:24 +03:00
|
|
|
<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
|
2021-06-28 18:23:40 +03:00
|
|
|
}" :value="price" disabled size="5" masked class="disabled-money text-right mr-2 js-conversion-input"></money>
|
2021-06-28 13:00:24 +03:00
|
|
|
<span class="mr-2">{{ currecyCode }}</span>
|
2021-06-28 18:23:40 +03:00
|
|
|
<input name="currency_rate" v-model="currencyRate" @input="onChange" class="text-right js-conversion-input" size="4" />
|
2020-12-29 21:55:21 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-06-28 13:00:24 +03:00
|
|
|
import {Money} from 'v-money';
|
2020-12-29 21:55:21 +03:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'akaunting-currency-conversion',
|
2021-06-28 13:00:24 +03:00
|
|
|
components: {
|
|
|
|
Money
|
|
|
|
},
|
2020-12-29 21:55:21 +03:00
|
|
|
|
|
|
|
props: {
|
|
|
|
currencyConversionText: {
|
|
|
|
type: String,
|
|
|
|
default: 'Currency conversion'
|
|
|
|
},
|
|
|
|
price: {
|
|
|
|
type: String,
|
|
|
|
default: 'sale'
|
|
|
|
},
|
|
|
|
currecyCode: {
|
|
|
|
type: String,
|
|
|
|
default: 'USD'
|
|
|
|
},
|
|
|
|
currencyRate: {
|
|
|
|
default: 1.000,
|
|
|
|
},
|
2021-06-28 13:00:24 +03:00
|
|
|
currencySymbol: {
|
|
|
|
default: {}
|
2021-06-28 18:23:40 +03:00
|
|
|
}
|
2020-12-29 21:55:21 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
conversion: '',
|
2021-06-28 13:00:24 +03:00
|
|
|
rate: this.currencyRate,
|
2021-06-28 18:23:40 +03:00
|
|
|
texts: []
|
2020-12-29 21:55:21 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2021-06-28 13:00:24 +03:00
|
|
|
let conver = this.currencyConversionText.split(':price');
|
|
|
|
|
|
|
|
this.texts.push(conver[0]);
|
|
|
|
this.texts.push(conver[1].replace(':currency_code', this.currecyCode).replace(':currency_rate', this.currencyRate));
|
2020-12-29 21:55:21 +03:00
|
|
|
},
|
2021-06-28 13:00:24 +03:00
|
|
|
|
|
|
|
methods: {
|
|
|
|
onChange() {
|
2021-06-28 18:23:40 +03:00
|
|
|
let self = this;
|
2021-06-28 13:00:24 +03:00
|
|
|
this.$emit('change', this.rate);
|
2021-06-28 18:23:40 +03:00
|
|
|
|
|
|
|
if(self.currencyRate.length !== 0) {
|
|
|
|
window.axios({
|
|
|
|
method: 'PATCH',
|
|
|
|
url: url + "/settings/currencies",
|
|
|
|
data: {
|
|
|
|
name: self.currencySymbol.name,
|
|
|
|
code: self.currecyCode,
|
|
|
|
rate: self.currencyRate
|
|
|
|
}
|
|
|
|
}).then(response => {
|
|
|
|
this.$notify({
|
|
|
|
message: 'SUCCESS',
|
|
|
|
timeout: 200,
|
|
|
|
icon: 'fas fa-bell',
|
|
|
|
type
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
2021-06-28 13:00:24 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-29 21:55:21 +03:00
|
|
|
watch: {
|
|
|
|
currencyConversionText: function (text) {
|
|
|
|
this.conversion = text.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace('', this.currencyRate);
|
|
|
|
},
|
|
|
|
|
|
|
|
price: function (price) {
|
2021-06-28 13:00:24 +03:00
|
|
|
this.conversion = this.currencyConversionText.replace(':price', price).replace(':currency_code', this.currecyCode).replace(':currency_rate', '');
|
2020-12-29 21:55:21 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
currecyCode: function (currecyCode) {
|
2021-06-28 13:00:24 +03:00
|
|
|
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace(':currency_rate', '');
|
2020-12-29 21:55:21 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
currencyRate: function (currencyRate) {
|
2021-06-28 13:00:24 +03:00
|
|
|
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace(':currency_rate', '');
|
|
|
|
},
|
|
|
|
currencySymbol: function (currencySymbol) {
|
|
|
|
this.conversion = this.currencyConversionText.replace(':price', this.price).replace(':currency_code', this.currecyCode).replace(':currency_rate', '');
|
2020-12-29 21:55:21 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|