2021-05-20 15:18:43 +03:00
|
|
|
<template>
|
2022-06-01 10:15:55 +03:00
|
|
|
<div class="relative bg-body z-10 rounded-lg shadow-2xl p-10" style="height:675px;">
|
|
|
|
<WizardSteps :active_state="active"></WizardSteps>
|
|
|
|
|
|
|
|
<div class="flex flex-col justify-between overflow-y-auto" style="height: calc(100% - 53px)">
|
|
|
|
<div v-if="pageLoad" class="absolute left-0 right-0 top-0 bottom-0 w-full h-full bg-white rounded-lg flex items-center justify-center z-50">
|
|
|
|
<span class="material-icons form-spin animate-spin text-9xl">data_usage</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="overflow-x-visible menu-scroll mt-1">
|
|
|
|
<form ref="form" class="py-2 align-middle inline-block min-w-full">
|
|
|
|
<table id="tbl-currencies" class="min-w-full divide-y divide-gray-200">
|
|
|
|
<thead>
|
|
|
|
<tr class="flex items-center px-1">
|
|
|
|
<th class="w-4/12 ltr:pr-6 rtl:pl-6 py-3 ltr:text-left rtl:text-right text-sm font-bold text-black tracking-wider">
|
|
|
|
{{ translations.currencies.name }}
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<th class="w-4/12 ltr:pr-6 rtl:pl-6 py-3 text-center text-sm font-bold text-black tracking-wider">
|
|
|
|
{{ translations.currencies.code }}
|
|
|
|
</th>
|
|
|
|
|
|
|
|
<th class="w-4/12 ltr:pr-6 rtl:pl-6 py-3 ltr:text-right rtl:text-left text-sm font-bold text-black tracking-wider">
|
|
|
|
{{ translations.currencies.rate }}
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody data-table-body>
|
|
|
|
<tr v-for="(item, index) in currencies" :key="index" data-table-list class="relative flex items-center border-b hover:bg-gray-100 px-1 flex-wrap group">
|
|
|
|
<td :class="current_tab == index ? 'hidden' : ''" class="w-4/12 ltr:pr-6 rtl:pl-6 py-4 ltr:text-left rtl:text-right whitespace-nowrap text-sm font-medium text-black">
|
|
|
|
{{ item.name }}
|
|
|
|
</td>
|
|
|
|
<td :class="current_tab == index ? 'hidden' : ''" class="w-4/12 ltr:pr-6 rtl:pl-6 py-4 text-center whitespace-nowrap text-sm font-medium text-black">
|
|
|
|
{{ item.code }}
|
|
|
|
</td>
|
|
|
|
<td :class="current_tab == index ? 'hidden' : ''" class="w-4/12 relative ltr:pr-6 rtl:pl-6 py-4 ltr:text-right rtl:text-left whitespace-nowrap text-sm font-medium text-black">
|
|
|
|
{{ item.rate }}
|
|
|
|
|
|
|
|
<div class="absolute ltr:right-12 rtl:left-12 -top-4 hidden items-center group-hover:flex">
|
|
|
|
<button type="button" class="relative bg-white hover:bg-gray-100 border py-0.5 px-1 cursor-pointer index-actions " @click="onEditItem(item, index)">
|
|
|
|
<span class="material-icons-outlined text-purple text-lg">edit</span>
|
|
|
|
|
|
|
|
<div class="inline-block absolute invisible z-20 py-1 px-2 text-sm font-medium text-gray-900 bg-white rounded-lg border border-gray-200 shadow-sm opacity-0 whitespace-nowrap tooltip-content -top-10 -left-2" data-tooltip-placement="top">
|
|
|
|
<span>{{ translations.currencies.edit }}</span>
|
|
|
|
<div class="absolute w-2 h-2 -bottom-1 before:content-[' '] before:absolute before:w-2 before:h-2 before:bg-white before:border-gray-200 before:transform before:rotate-45 before:border before:border-t-0 before:border-l-0" data-popper-arrow></div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button type="button" class="relative bg-white hover:bg-gray-100 border py-0.5 px-1 cursor-pointer index-actions " @click="onClickDelete(item)">
|
|
|
|
<span class="material-icons-outlined text-purple text-lg">delete</span>
|
|
|
|
|
|
|
|
<div class="inline-block absolute invisible z-20 py-1 px-2 text-sm font-medium text-gray-900 bg-white rounded-lg border border-gray-200 shadow-sm opacity-0 whitespace-nowrap tooltip-content -top-10 -left-2" data-tooltip-placement="top">
|
|
|
|
<span>{{ translations.currencies.delete }}</span>
|
|
|
|
<div class="absolute w-2 h-2 -bottom-1 before:content-[' '] before:absolute before:w-2 before:h-2 before:bg-white before:border-gray-200 before:transform before:rotate-45 before:border before:border-t-0 before:border-l-0" data-popper-arrow></div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="w-full p-0 current-tab" v-if="current_tab == index">
|
|
|
|
<div class="grid sm:grid-cols-6 gap-x-8 gap-y-6 py-3">
|
|
|
|
<base-input name="name" data-name="name"
|
|
|
|
form-classes="sm:col-span-2"
|
|
|
|
class="required"
|
|
|
|
v-model="model.name"
|
|
|
|
:error="onFailErrorGet('name')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<base-input class="sm:col-span-2 required" :error="onFailErrorGet('code')">
|
|
|
|
<el-select name="code" v-model="model.select" @change="onChangeCodeItem(model.select)" filterable>
|
|
|
|
<el-option
|
|
|
|
v-for="option in currency_codes"
|
|
|
|
:key="option"
|
|
|
|
:label="option"
|
|
|
|
:value="option"
|
|
|
|
>
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</base-input>
|
|
|
|
|
|
|
|
<base-input name="rate" data-name="rate" :placeholder="translations.currencies.rate"
|
|
|
|
form-classes="sm:col-span-2"
|
|
|
|
class="required"
|
|
|
|
v-model="model.rate"
|
|
|
|
:error="onFailErrorGet('rate')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="flex justify-end items-center sm:col-span-6">
|
|
|
|
<base-button class=" flex items-center justify-center px-6 py-1.5 text-base rounded-lg bg-transparent hover:bg-gray-100 ltr:mr-2 rtl:ml-2" @click="onCancelItem()">
|
|
|
|
{{ translations.currencies.cancel }}
|
|
|
|
</base-button>
|
|
|
|
|
2022-06-07 15:53:42 +03:00
|
|
|
<base-button
|
|
|
|
:disabled="button_loading"
|
|
|
|
class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100"
|
|
|
|
@click="onEditForm(item)"
|
|
|
|
>
|
|
|
|
<i v-if="button_loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i>
|
|
|
|
<span :class="[{'opacity-0': button_loading}]">
|
|
|
|
{{ translations.currencies.save }}
|
|
|
|
</span>
|
2022-06-01 10:15:55 +03:00
|
|
|
</base-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div class="flex flex-col items-center">
|
|
|
|
<div v-if="!currencies.length" class="flex flex-col items-center gap-y-2">
|
|
|
|
<span class="text-dark">
|
|
|
|
{{ translations.currencies.no_currency }}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="text-gray-700">
|
|
|
|
{{ translations.currencies.create_currency }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2021-09-08 11:40:03 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
<div v-if="currencies.length" class="w-full border-b hover:bg-gray-100" style="height:53px;">
|
|
|
|
<button type="button" class="w-full h-full flex items-center justify-center text-purple font-medium disabled:bg-gray-200" @click="onAddItem()">
|
|
|
|
<span class="material-icons-outlined text-base font-bold ltr:mr-1 rtl:ml-1">add</span>
|
2022-06-23 14:21:07 +03:00
|
|
|
<span class="bg-no-repeat bg-0-2 bg-0-full hover:bg-full-2 bg-gradient-to-b from-transparent to-purple transition-backgroundSize">{{ translations.currencies.new_currency }}</span>
|
2022-06-01 10:15:55 +03:00
|
|
|
</button>
|
|
|
|
</div>
|
2021-05-20 15:18:43 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
<button v-else type="button" class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100 mt-3" @click="onAddItem()">
|
|
|
|
{{ translations.currencies.new_currency }}
|
2021-05-20 15:18:43 +03:00
|
|
|
</button>
|
2022-06-01 10:15:55 +03:00
|
|
|
|
|
|
|
<div v-if="new_datas" class="grid sm:grid-cols-7 gap-x-8 gap-y-6 my-3.5 w-full">
|
|
|
|
<base-input :label="translations.currencies.name" name="name" data-name="name" :placeholder="translations.currencies.name"
|
|
|
|
class="sm:col-span-3 required"
|
|
|
|
v-model="model.name"
|
|
|
|
:error="onFailErrorGet('name')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<base-input :label="translations.currencies.code" class="sm:col-span-2 required" :error="onFailErrorGet('code')">
|
|
|
|
<el-select name="code" v-model="model.select" required="required" @change="onChangeCodeItem(model.select)"filterable>
|
|
|
|
<el-option
|
|
|
|
v-for="option in currency_codes"
|
|
|
|
:key="option"
|
|
|
|
:label="option"
|
|
|
|
:value="option"
|
|
|
|
>
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</base-input>
|
|
|
|
|
|
|
|
<base-input :label="translations.currencies.rate" name="rate" data-name="rate" :placeholder="translations.currencies.rate"
|
|
|
|
class="sm:col-span-2 required"
|
|
|
|
v-model="model.rate"
|
|
|
|
:error="onFailErrorGet('rate')"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="flex items-center justify-end sm:col-span-7">
|
|
|
|
<base-button class=" flex items-center justify-center px-6 py-1.5 text-base rounded-lg bg-transparent hover:bg-gray-100 ltr:mr-2 rtl:ml-2" @click="new_datas = false">
|
|
|
|
{{ translations.currencies.cancel }}
|
|
|
|
</base-button>
|
|
|
|
|
|
|
|
<base-button :disabled="button_loading" class="relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100" @click="onSubmitForm()">
|
2022-06-07 15:53:42 +03:00
|
|
|
<i v-if="button_loading" class="animate-submit delay-[0.28s] absolute w-2 h-2 rounded-full left-0 right-0 -top-3.5 m-auto before:absolute before:w-2 before:h-2 before:rounded-full before:animate-submit before:delay-[0.14s] after:absolute after:w-2 after:h-2 after:rounded-full after:animate-submit before:-left-3.5 after:-right-3.5 after:delay-[0.42s]"></i>
|
2022-06-01 10:15:55 +03:00
|
|
|
<span :class="[{'opacity-0': button_loading}]">
|
|
|
|
{{ translations.currencies.save }}
|
|
|
|
</span>
|
|
|
|
</base-button>
|
|
|
|
</div>
|
2021-05-20 16:03:57 +03:00
|
|
|
</div>
|
2021-05-20 15:18:43 +03:00
|
|
|
</div>
|
2022-06-01 10:15:55 +03:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex items-center justify-center mt-5 gap-x-10">
|
|
|
|
<base-button class="w-1/2 flex items-center justify-center px-6 py-1.5 text-base rounded-lg bg-transparent hover:bg-gray-100" @click="prev()">
|
|
|
|
{{ translations.currencies.previous }}
|
|
|
|
</base-button>
|
|
|
|
|
|
|
|
<base-button class="w-1/2 relative flex items-center justify-center bg-green hover:bg-green-700 text-white px-6 py-1.5 text-base rounded-lg disabled:bg-green-100" @click="next()">
|
|
|
|
{{translations.currencies.next}}
|
|
|
|
</base-button>
|
|
|
|
</div>
|
2021-05-20 15:18:43 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<notifications></notifications>
|
2021-09-08 11:40:03 +03:00
|
|
|
|
2021-05-20 15:18:43 +03:00
|
|
|
<form id="form-dynamic-component" method="POST" action="#"></form>
|
2021-09-08 11:40:03 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
<component v-bind:is="component" @deleted="onDeleteCurrency($event)"></component>
|
2021-05-20 15:18:43 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-06-01 10:15:55 +03:00
|
|
|
import { Select, Option } from "element-ui";
|
|
|
|
import AkauntingRadioGroup from "./../../components/AkauntingRadioGroup";
|
2021-05-20 15:18:43 +03:00
|
|
|
import BulkAction from "./../../plugins/bulk-action";
|
|
|
|
import MixinsGlobal from "./../../mixins/global";
|
2021-05-29 17:01:22 +03:00
|
|
|
import WizardAction from "./../../mixins/wizardAction";
|
2022-06-01 10:15:55 +03:00
|
|
|
import WizardSteps from "./Steps.vue";
|
2021-05-20 15:18:43 +03:00
|
|
|
|
|
|
|
export default {
|
2021-05-30 17:17:37 +03:00
|
|
|
name: "Currencies",
|
2021-05-20 15:18:43 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
mixins: [MixinsGlobal, WizardAction],
|
2021-05-20 15:18:43 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
components: {
|
|
|
|
[Select.name]: Select,
|
|
|
|
[Option.name]: Option,
|
|
|
|
AkauntingRadioGroup,
|
2022-06-01 10:15:55 +03:00
|
|
|
WizardSteps
|
2021-05-20 15:18:43 +03:00
|
|
|
},
|
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
props: {
|
|
|
|
currencies: {
|
|
|
|
type: [Object, Array],
|
|
|
|
},
|
2021-05-20 16:03:57 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
currency_codes: {
|
|
|
|
type: [Object, Array],
|
|
|
|
},
|
2021-05-20 15:18:43 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
translations: {
|
|
|
|
type: [Object, Array],
|
|
|
|
},
|
2021-06-01 10:43:26 +03:00
|
|
|
|
|
|
|
pageLoad: {
|
|
|
|
type: [Boolean, String]
|
|
|
|
}
|
2021-05-20 15:18:43 +03:00
|
|
|
},
|
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
active: 1,
|
|
|
|
bulk_action: new BulkAction(url + "/settings/currencies"),
|
|
|
|
};
|
2021-05-20 15:18:43 +03:00
|
|
|
},
|
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
methods: {
|
|
|
|
onClickDelete(item) {
|
|
|
|
this.confirmDelete(
|
|
|
|
`${
|
|
|
|
new URL(url).protocol +
|
|
|
|
"//" +
|
|
|
|
location.host +
|
|
|
|
location.pathname +
|
|
|
|
"/" +
|
|
|
|
item.id
|
|
|
|
}`,
|
|
|
|
this.translations.currencies.title,
|
|
|
|
`Confirm Delete <strong>${item.name}</strong> ${this.translations.currencies.title}?`,
|
|
|
|
this.translations.currencies.cancel,
|
|
|
|
this.translations.currencies.delete
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
onDeleteCurrency(event) {
|
|
|
|
this.onEjetItem(event, this.currencies, event.currency_id);
|
|
|
|
},
|
|
|
|
|
|
|
|
onChangeCodeItem(code) {
|
|
|
|
const formData = new FormData(this.$refs["form"]);
|
|
|
|
const data = {
|
|
|
|
rate: "",
|
|
|
|
precision: "",
|
|
|
|
symbol: "",
|
|
|
|
symbol_first: "",
|
|
|
|
decimal_mark: "",
|
|
|
|
thousands_separator: "",
|
|
|
|
};
|
|
|
|
|
|
|
|
for (let [key, val] of formData.entries()) {
|
|
|
|
Object.assign(data, {
|
|
|
|
[key]: val,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
window.axios({
|
|
|
|
method: "GET",
|
|
|
|
url: url + "/settings/currencies/config",
|
|
|
|
params: {
|
|
|
|
code: code,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
data.rate = response.data.rate;
|
|
|
|
data.precision = response.data.precision;
|
|
|
|
data.symbol = response.data.symbol;
|
|
|
|
data.symbol_first = response.data.symbol_first;
|
|
|
|
data.decimal_mark = response.data.decimal_mark;
|
|
|
|
data.thousands_separator = response.data.thousands_separator;
|
|
|
|
|
|
|
|
this.model.rate = response.data.rate;
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onEditForm(item) {
|
|
|
|
this.onSubmitEvent(
|
|
|
|
"PATCH",
|
|
|
|
url + "/wizard/currencies/" + item.id,
|
|
|
|
"",
|
|
|
|
this.currencies,
|
|
|
|
item.id
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
onSubmitForm() {
|
|
|
|
this.onSubmitEvent(
|
|
|
|
"POST",
|
|
|
|
url + "/wizard/currencies",
|
|
|
|
"",
|
|
|
|
this.currencies
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
prev() {
|
|
|
|
if (this.active-- > 2);
|
2021-05-30 17:35:19 +03:00
|
|
|
//history.back()
|
2021-05-30 17:17:37 +03:00
|
|
|
|
|
|
|
this.$router.push("/wizard/companies");
|
|
|
|
},
|
2021-05-28 15:45:19 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
next() {
|
|
|
|
if (this.active++ > 2);
|
2021-05-30 17:35:19 +03:00
|
|
|
|
2021-05-30 17:17:37 +03:00
|
|
|
this.$router.push("/wizard/taxes");
|
|
|
|
},
|
2021-05-20 15:18:43 +03:00
|
|
|
},
|
|
|
|
};
|
2021-06-01 10:43:26 +03:00
|
|
|
</script>
|