115 lines
3.3 KiB
JavaScript
Raw Normal View History

2019-11-16 10:21:14 +03:00
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('../../bootstrap');
import Vue from 'vue';
2020-01-03 12:10:07 +03:00
import DashboardPlugin from './../../plugins/dashboard-plugin';
2019-11-16 10:21:14 +03:00
import Global from '../../mixins/global';
import Form from '../../plugins/form';
import BulkAction from './../../plugins/bulk-action';
2020-01-15 19:48:53 +03:00
import {Step, Steps} from 'element-ui';
2020-01-03 12:10:07 +03:00
// plugin setup
2020-01-15 19:48:53 +03:00
Vue.use(DashboardPlugin, Step, Steps);
2020-01-03 12:10:07 +03:00
2019-11-16 10:21:14 +03:00
const app = new Vue({
el: '#app',
mixins: [
Global
],
2020-01-15 19:48:53 +03:00
components: {
[Step.name]: Step,
[Steps.name]: Steps,
},
2019-11-16 10:21:14 +03:00
data: function () {
return {
form: new Form('currency'),
2020-01-15 19:48:53 +03:00
active: 1,
2019-11-16 10:21:14 +03:00
bulk_action: new BulkAction(url + '/settings/currencies'),
show: false,
currency: {
name: '',
code: '',
rate: '1',
enabled: 1
},
2020-01-15 19:48:53 +03:00
submit_function: '',
2019-11-16 10:21:14 +03:00
}
},
methods: {
onAddCurrency() {
this.submit_function = 'onStoreCurrency';
this.form.method = 'post';
this.form.action = url + '/wizard/currencies';
this.form.name = '';
this.form.code = '';
this.form.rate = '';
this.form.enabled = 1;
this.form.precision = '';
this.form.symbol = '';
this.form.symbol_first = '';
this.form.decimal_mark = '';
this.form.thousands_separator = '';
this.show = true;
},
onEditCurrency(currency_id) {
this.submit_function = 'onUpdateCurrency';
this.form.method = 'patch';
this.form.action = url + '/wizard/currencies/' + currency_id;
currencies.forEach(currency => {
if (currency.id == currency_id) {
this.form.name = currency.name;
this.form.code = currency.code;
this.form.rate = currency.rate;
this.form.enabled = currency.enabled;
this.form.precision = currency.precision;
this.form.symbol = currency.symbol;
this.form.symbol_first = currency.symbol_first;
this.form.decimal_mark = currency.decimal_mark;
this.form.thousands_separator = currency.thousands_separator;
}
});
this.show = true;
},
onChangeCode(code) {
axios.get(url + '/settings/currencies/config', {
params: {
code: code
}
2020-01-21 16:24:56 +03:00
})
2019-11-16 10:21:14 +03:00
.then(response => {
this.form.rate = response.data.rate;
this.form.precision = response.data.precision;
this.form.symbol = response.data.symbol;
this.form.symbol_first = response.data.symbol_first;
this.form.decimal_mark = response.data.decimal_mark;
this.form.thousands_separator = response.data.thousands_separator;
})
.catch(error => {
});
2020-01-15 19:48:53 +03:00
},
2020-04-22 14:50:30 +03:00
onSubmit() {
this.form.oldSubmit();
},
2019-11-16 10:21:14 +03:00
}
});