Wizard edited
This commit is contained in:
@ -26,8 +26,11 @@
|
||||
/>
|
||||
<p class="mb-0 mt--3">
|
||||
<small>
|
||||
<div><a href="https://akaunting.com/dashboard" target="_blank">Click here</a>
|
||||
to get your API key.
|
||||
<div>
|
||||
<a href="https://akaunting.com/dashboard" target="_blank"
|
||||
>Click here</a
|
||||
>
|
||||
to get your API key.
|
||||
</div>
|
||||
</small>
|
||||
</p>
|
||||
@ -71,14 +74,16 @@
|
||||
</base-input>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<label class="form-control-label">{{ translations.company.logo }}</label>
|
||||
<akaunting-dropzone-file-upload
|
||||
ref="dropzoneWizard"
|
||||
preview-classes="single"
|
||||
:attachments="logo"
|
||||
:v-model="logo"
|
||||
>
|
||||
</akaunting-dropzone-file-upload>
|
||||
<label class="form-control-label">{{
|
||||
translations.company.logo
|
||||
}}</label>
|
||||
<akaunting-dropzone-file-upload
|
||||
ref="dropzoneWizard"
|
||||
preview-classes="single"
|
||||
:attachments="logo"
|
||||
:v-model="logo"
|
||||
>
|
||||
</akaunting-dropzone-file-upload>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -86,7 +91,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<base-button
|
||||
id="button"
|
||||
id="button"
|
||||
type="success"
|
||||
native-type="submit"
|
||||
@click="onEditSave()"
|
||||
@ -107,11 +112,11 @@
|
||||
import { Step, Steps } from "element-ui";
|
||||
import AkauntingDropzoneFileUpload from "./../../components/AkauntingDropzoneFileUpload";
|
||||
import AkauntingDate from "./../../components/AkauntingDate";
|
||||
import MixinsSpaGlobal from "./../../mixins/spa-global";
|
||||
import WizardAction from "./wizardAction";
|
||||
|
||||
export default {
|
||||
name: "Company",
|
||||
mixins: [MixinsSpaGlobal],
|
||||
mixins: [WizardAction],
|
||||
components: {
|
||||
[Step.name]: Step,
|
||||
[Steps.name]: Steps,
|
||||
@ -127,8 +132,8 @@ export default {
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: 'text'
|
||||
}
|
||||
default: "text",
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -139,40 +144,40 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
let company_data = this.company;
|
||||
this.dataWatch(company_data);
|
||||
this.onDataWatch(company_data);
|
||||
},
|
||||
watch: {
|
||||
company: function (company) {
|
||||
this.dataWatch(company);
|
||||
this.onDataWatch(company);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
dataWatch(company) {
|
||||
if(Object.keys(company).length) {
|
||||
let logo_arr = [
|
||||
{
|
||||
id: company.logo.id,
|
||||
name: company.logo.filename + "." + company.logo.extension,
|
||||
path: company.logo.path,
|
||||
type: company.logo.mime_type,
|
||||
size: company.logo.size,
|
||||
downloadPath: false,
|
||||
},
|
||||
];
|
||||
this.logo.push(logo_arr);
|
||||
this.real_date = company.financial_start;
|
||||
onDataWatch(company) {
|
||||
if (Object.keys(company).length) {
|
||||
let logo_arr = [
|
||||
{
|
||||
id: company.logo.id,
|
||||
name: company.logo.filename + "." + company.logo.extension,
|
||||
path: company.logo.path,
|
||||
type: company.logo.mime_type,
|
||||
size: company.logo.size,
|
||||
downloadPath: false,
|
||||
},
|
||||
];
|
||||
this.logo.push(logo_arr);
|
||||
this.real_date = company.financial_start;
|
||||
}
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
|
||||
onEditSave() {
|
||||
this.onEditCompany();
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
@ -20,7 +20,7 @@
|
||||
type="success"
|
||||
native-type="button"
|
||||
class="btn-sm"
|
||||
@click="addItem()"
|
||||
@click="onAddItem()"
|
||||
>{{ translations.currencies.add_new }}</base-button
|
||||
>
|
||||
</div>
|
||||
@ -63,7 +63,7 @@
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="item.enabled"
|
||||
@input="inputHandle(item)"
|
||||
@input="onSwitchUpdate(item)"
|
||||
/>
|
||||
<span
|
||||
class="custom-toggle-slider rounded-circle status-green"
|
||||
@ -92,7 +92,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
@click="handeClickEdit(item, index)"
|
||||
@click="onEditItem(item, index)"
|
||||
>
|
||||
{{ translations.currencies.edit }}
|
||||
</button>
|
||||
@ -100,14 +100,14 @@
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
@click="handleClickDelete(item)"
|
||||
@click="onClickDelete(item)"
|
||||
>
|
||||
{{ translations.currencies.delete }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-100 p-0 current-tab" v-if="currentTab == index">
|
||||
<td class="w-100 p-0 current-tab" v-if="current_tab == index">
|
||||
<div class="row pt-3 pb-3">
|
||||
<div
|
||||
class="form-container col-12 d-flex justify-content-between align-items-start"
|
||||
@ -132,7 +132,7 @@
|
||||
<el-select
|
||||
name="code"
|
||||
v-model="model.select"
|
||||
@change="onChangeCode(model.select)"
|
||||
@change="onChangeCodeItem(model.select)"
|
||||
filterable
|
||||
>
|
||||
<template slot="prefix">
|
||||
@ -167,14 +167,14 @@
|
||||
<base-button
|
||||
type="white"
|
||||
native-type="button"
|
||||
@click="handleClickCancel()"
|
||||
@click="onCancelItem()"
|
||||
>
|
||||
{{ translations.currencies.cancel }}</base-button
|
||||
>
|
||||
<base-button
|
||||
type="success"
|
||||
native-type="button"
|
||||
@click="onEditSave(item)"
|
||||
@click="onEditForm(item)"
|
||||
>
|
||||
{{ translations.currencies.save }}</base-button
|
||||
>
|
||||
@ -183,7 +183,7 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="newDatas">
|
||||
<tr v-if="new_datas">
|
||||
<td class="p-0">
|
||||
<div class="row pt-3 pb-3">
|
||||
<div
|
||||
@ -208,7 +208,7 @@
|
||||
name="code"
|
||||
v-model="model.select"
|
||||
required="required"
|
||||
@change="onChangeCode(model.select)"
|
||||
@change="onChangeCodeItem(model.select)"
|
||||
filterable
|
||||
>
|
||||
<template slot="prefix">
|
||||
@ -271,7 +271,7 @@
|
||||
<form id="form-dynamic-component" method="POST" action="#"></form>
|
||||
<component
|
||||
v-bind:is="component"
|
||||
@deleted="deleteCurrency($event)"
|
||||
@deleted="onDeleteCurrency($event)"
|
||||
></component>
|
||||
</div>
|
||||
|
||||
@ -296,11 +296,11 @@ import { Step, Steps, Select, Option } from "element-ui";
|
||||
import AkauntingRadioGroup from "./../../components/forms/AkauntingRadioGroup";
|
||||
import BulkAction from "./../../plugins/bulk-action";
|
||||
import MixinsGlobal from "./../../mixins/global";
|
||||
import MixinsSpaGlobal from "./../../mixins/spa-global";
|
||||
import WizardAction from "./wizardAction";
|
||||
|
||||
export default {
|
||||
name: "Currencies",
|
||||
mixins: [MixinsGlobal, MixinsSpaGlobal],
|
||||
mixins: [MixinsGlobal, WizardAction],
|
||||
components: {
|
||||
[Step.name]: Step,
|
||||
[Steps.name]: Steps,
|
||||
@ -326,12 +326,12 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
inputHandle(item) {
|
||||
onSwitchUpdate(item) {
|
||||
this.onStatus(item.id, event);
|
||||
this.onStatusControl(this.currencies, item.id, event);
|
||||
},
|
||||
|
||||
handleClickDelete(item) {
|
||||
onClickDelete(item) {
|
||||
this.confirmDelete(
|
||||
`${
|
||||
new URL(url).protocol +
|
||||
@ -348,17 +348,11 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/taxes");
|
||||
onDeleteCurrency(event) {
|
||||
this.onEjetItem(event, this.currencies, event.currency_id);
|
||||
},
|
||||
|
||||
prev() {
|
||||
if (this.active-- > 2);
|
||||
this.$router.push("/wizard/companies");
|
||||
},
|
||||
|
||||
onChangeCode(code) {
|
||||
onChangeCodeItem(code) {
|
||||
const formData = new FormData(this.$refs["form"]);
|
||||
const data = {
|
||||
rate: "",
|
||||
@ -394,8 +388,8 @@ export default {
|
||||
}, this);
|
||||
},
|
||||
|
||||
onEditSave(item) {
|
||||
this.onEditEvent(
|
||||
onEditForm(item) {
|
||||
this.onEditItemEvent(
|
||||
"PATCH",
|
||||
url + "/wizard/currencies/" + item.id,
|
||||
"",
|
||||
@ -413,8 +407,14 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
deleteCurrency(event) {
|
||||
this.onDeleteEvent(event, this.currencies, event.currency_id);
|
||||
prev() {
|
||||
if (this.active-- > 2);
|
||||
this.$router.push("/wizard/companies");
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/taxes");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="is_loaded">
|
||||
<h1 class="text-white">{{ translations.finish.title }}</h1>
|
||||
<div class="card">
|
||||
<div class="card-header wizard-header p-3">
|
||||
@ -14,34 +14,47 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
||||
<div class="content-header">
|
||||
<h3 class="text-white">{{ translations.finish.recommended_apps }}</h3>
|
||||
<h3 class="text-white">
|
||||
{{ translations.finish.recommended_apps }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div v-for="(item, index) in modules" :key="index" class="col-md-3">
|
||||
<div
|
||||
v-for="(item, index) in modules"
|
||||
:key="index"
|
||||
class="col-md-3"
|
||||
>
|
||||
<div class="card">
|
||||
<div class="card-header py-2">
|
||||
<h4 class="ml--3 mb-0 float-left">
|
||||
<a
|
||||
:href="item.slug"
|
||||
>{{ item.name }}</a
|
||||
>
|
||||
<a :href="item.slug">{{ item.name }}</a>
|
||||
</h4>
|
||||
</div>
|
||||
<a :href="route_url + '/' + item.slug"
|
||||
><img
|
||||
v-for="(file, indis) in item.files" :key="indis"
|
||||
v-if="file.media_type == 'image' && file.pivot.zone == 'thumbnail'"
|
||||
v-for="(file, indis) in item.files"
|
||||
:key="indis"
|
||||
v-if="
|
||||
file.media_type == 'image' &&
|
||||
file.pivot.zone == 'thumbnail'
|
||||
"
|
||||
:src="file.path_string"
|
||||
:alt="item.name"
|
||||
class="card-img-top border-radius-none"
|
||||
/></a>
|
||||
<div class="card-footer py-2">
|
||||
<div class="float-left ml--3 mt--1">
|
||||
<i v-for="(stars, indis) in item.vote" :key="indis" class="fa fa-star text-xs text-yellow"></i>
|
||||
<i
|
||||
v-for="(stars, indis) in item.vote"
|
||||
:key="indis"
|
||||
class="fa fa-star text-xs text-yellow"
|
||||
></i>
|
||||
<small class="text-xs"> {{ item.total_review }} </small>
|
||||
</div>
|
||||
<div class="float-right mr--3">
|
||||
<small><strong> {{ item.price }} </strong></small>
|
||||
<small
|
||||
><strong> {{ item.price }} </strong></small
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -54,10 +67,13 @@
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-12 d-flex justify-content-between">
|
||||
<base-button type="white" native-type="submit" @click="prev()"
|
||||
>{{ translations.finish.previous }}</base-button
|
||||
>
|
||||
<base-button type="success" native-type="submit" v-if="button_show" @click="finish()"
|
||||
<base-button type="white" native-type="submit" @click="prev()">{{
|
||||
translations.finish.previous
|
||||
}}</base-button>
|
||||
<base-button
|
||||
type="success"
|
||||
native-type="submit"
|
||||
@click="finish()"
|
||||
>{{ translations.finish.go_to_dashboard }}</base-button
|
||||
>
|
||||
</div>
|
||||
@ -68,7 +84,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { Step, Steps } from "element-ui";
|
||||
|
||||
export default {
|
||||
@ -78,41 +93,51 @@ export default {
|
||||
[Steps.name]: Steps,
|
||||
},
|
||||
created() {
|
||||
window.axios({
|
||||
method: 'PATCH',
|
||||
url: url + '/wizard/finish'
|
||||
}).then(response => {
|
||||
if(response.status == "200") {
|
||||
this.button_show = true;
|
||||
}
|
||||
window
|
||||
.axios({
|
||||
method: "PATCH",
|
||||
url: url + "/wizard/finish",
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status == "200") {
|
||||
this.is_loaded = true;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notify({
|
||||
message: this.translations.finish.error_message,
|
||||
timeout: 1000,
|
||||
icon: "fas fa-bell",
|
||||
type: 0
|
||||
});
|
||||
|
||||
}).catch(error => {
|
||||
|
||||
});
|
||||
this.prev();
|
||||
});
|
||||
},
|
||||
props: {
|
||||
modules: {
|
||||
type: [Object, Array]
|
||||
type: [Object, Array],
|
||||
},
|
||||
translations: {
|
||||
type: [Object, Array]
|
||||
type: [Object, Array],
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
active: 3,
|
||||
route_url: url,
|
||||
button_show: false
|
||||
is_loaded: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
finish() {
|
||||
window.location.href = url;
|
||||
},
|
||||
prev() {
|
||||
if (this.active-- > 2);
|
||||
this.$router.push("/wizard/taxes");
|
||||
},
|
||||
|
||||
finish() {
|
||||
window.location.href = url;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -16,7 +16,7 @@
|
||||
type="success"
|
||||
native-type="button"
|
||||
class="btn-sm"
|
||||
@click="addItem()"
|
||||
@click="onAddItem()"
|
||||
>{{ translations.taxes.add_new }}</base-button
|
||||
>
|
||||
</div>
|
||||
@ -54,7 +54,7 @@
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="item.enabled"
|
||||
@input="inputHandle(item)"
|
||||
@input="onSwitchUpdate(item)"
|
||||
/>
|
||||
<span
|
||||
class="custom-toggle-slider rounded-circle status-green"
|
||||
@ -83,7 +83,7 @@
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
@click="handeClickEdit(item, index)"
|
||||
@click="onEditItem(item, index)"
|
||||
>
|
||||
{{ translations.taxes.edit }}
|
||||
</button>
|
||||
@ -91,14 +91,14 @@
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item"
|
||||
@click="handleClickDelete(item)"
|
||||
@click="onClickDelete(item)"
|
||||
>
|
||||
{{ translations.taxes.delete }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="w-100 p-0 current-tab" v-if="currentTab == index">
|
||||
<td class="w-100 p-0 current-tab" v-if="current_tab == index">
|
||||
<div class="row pt-3 pb-3">
|
||||
<div
|
||||
class="form-container col-12 d-flex justify-content-between align-items-start"
|
||||
@ -129,14 +129,14 @@
|
||||
<base-button
|
||||
type="white"
|
||||
native-type="button"
|
||||
@click="handleClickCancel()"
|
||||
@click="onCancelItem()"
|
||||
>
|
||||
{{ translations.taxes.cancel }}</base-button
|
||||
>
|
||||
<base-button
|
||||
type="success"
|
||||
native-type="button"
|
||||
@click="onEditSave(item)"
|
||||
@click="onEditForm(item)"
|
||||
>{{ translations.taxes.save }}</base-button
|
||||
>
|
||||
</div>
|
||||
@ -144,7 +144,7 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="newDatas">
|
||||
<tr v-if="new_datas">
|
||||
<td class="p-0">
|
||||
<div class="row pt-3 pb-3">
|
||||
<div
|
||||
@ -202,7 +202,7 @@
|
||||
<form id="form-dynamic-component" method="POST" action="#"></form>
|
||||
<component
|
||||
v-bind:is="component"
|
||||
@deleted="deleteCurrency($event)"
|
||||
@deleted="onDeleteCurrency($event)"
|
||||
></component>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
@ -226,11 +226,11 @@ import { Step, Steps } from "element-ui";
|
||||
import AkauntingRadioGroup from "./../../components/forms/AkauntingRadioGroup";
|
||||
import BulkAction from "./../../plugins/bulk-action";
|
||||
import MixinsGlobal from "./../../mixins/global";
|
||||
import MixinsSpaGlobal from "./../../mixins/spa-global";
|
||||
import WizardAction from "./wizardAction";
|
||||
|
||||
export default {
|
||||
name: "Taxes",
|
||||
mixins: [MixinsGlobal, MixinsSpaGlobal],
|
||||
mixins: [MixinsGlobal, WizardAction],
|
||||
components: {
|
||||
[Step.name]: Step,
|
||||
[Steps.name]: Steps,
|
||||
@ -251,12 +251,12 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
inputHandle(item) {
|
||||
onSwitchUpdate(item) {
|
||||
this.onStatus(item.id, event);
|
||||
this.onStatusControl(this.taxes, item.id, event);
|
||||
},
|
||||
|
||||
handleClickDelete(item) {
|
||||
onClickDelete(item) {
|
||||
this.confirmDelete(
|
||||
`${
|
||||
new URL(url).protocol +
|
||||
@ -277,18 +277,12 @@ export default {
|
||||
);
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/finish");
|
||||
onDeleteCurrency(event) {
|
||||
this.onEjetItem(event, this.taxes, event.tax_id);
|
||||
},
|
||||
|
||||
prev() {
|
||||
if (this.active-- > 2);
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
|
||||
onEditSave(item) {
|
||||
this.onEditEvent(
|
||||
onEditForm(item) {
|
||||
this.onEditItemEvent(
|
||||
"PATCH",
|
||||
url + "/wizard/taxes/" + item.id,
|
||||
"type",
|
||||
@ -300,9 +294,15 @@ export default {
|
||||
onSubmitForm() {
|
||||
this.onSubmitEvent("POST", url + "/wizard/taxes", "type", this.taxes);
|
||||
},
|
||||
|
||||
deleteCurrency(event) {
|
||||
this.onDeleteEvent(event, this.taxes, event.tax_id);
|
||||
|
||||
prev() {
|
||||
if (this.active-- > 2);
|
||||
this.$router.push("/wizard/currencies");
|
||||
},
|
||||
|
||||
next() {
|
||||
if (this.active++ > 2);
|
||||
this.$router.push("/wizard/finish");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
253
resources/assets/js/views/wizard/wizardAction.js
vendored
Normal file
253
resources/assets/js/views/wizard/wizardAction.js
vendored
Normal file
@ -0,0 +1,253 @@
|
||||
|
||||
export default {
|
||||
data: function () {
|
||||
return {
|
||||
current_tab: undefined,
|
||||
new_datas: false,
|
||||
model: {
|
||||
name: "",
|
||||
rate: "",
|
||||
select: "",
|
||||
enabled: 1
|
||||
},
|
||||
error_field: {},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onAddItem() {
|
||||
this.new_datas = true;
|
||||
this.current_tab = undefined;
|
||||
this.error_field = {};
|
||||
|
||||
if (this.model) {
|
||||
this.model.name = '';
|
||||
this.model.rate = '';
|
||||
this.model.select = '';
|
||||
}
|
||||
},
|
||||
|
||||
onEditItem(item, index) {
|
||||
this.new_datas = false;
|
||||
this.current_tab = index;
|
||||
this.error_field = {};
|
||||
|
||||
if (this.model) {
|
||||
this.model.name = item.name ? item.name : '';
|
||||
this.model.rate = item.rate ? item.rate : '';
|
||||
this.model.select = item.code ? item.code : '';
|
||||
}
|
||||
},
|
||||
|
||||
onCancelItem() {
|
||||
this.current_tab = undefined;
|
||||
},
|
||||
|
||||
onDataChange() {
|
||||
this.new_datas = false;
|
||||
this.current_tab = undefined;
|
||||
this.model.name = '';
|
||||
this.model.rate = '';
|
||||
this.model.select = '';
|
||||
this.model.enabled = 1;
|
||||
},
|
||||
|
||||
onSuccessMessage(response) {
|
||||
let type = response.data.success ? 'success' : 'error';
|
||||
let timeout = 1000;
|
||||
|
||||
if (response.data.important) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
this.$notify({
|
||||
message: response.data.message,
|
||||
timeout: timeout,
|
||||
icon: "fas fa-bell",
|
||||
type,
|
||||
});
|
||||
|
||||
this.onDataChange();
|
||||
},
|
||||
|
||||
onDeleteItemMessage(event) {
|
||||
let type = event.success ? 'success' : 'error';
|
||||
let timeout = 1000;
|
||||
|
||||
if (event.important) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
this.$notify({
|
||||
message: event.message,
|
||||
timeout: timeout,
|
||||
icon: "fas fa-bell",
|
||||
type,
|
||||
});
|
||||
|
||||
this.onDataChange();
|
||||
},
|
||||
|
||||
onStatusControl(status_form, status_item, event) {
|
||||
status_form.forEach((status) => {
|
||||
if (status.id == status_item) {
|
||||
status.enabled = event.target.checked;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onEditItemEvent(form_method, form_url, plus_data, form_list, form_id) {
|
||||
const formData = new FormData(this.$refs["form"]);
|
||||
const data = {};
|
||||
|
||||
for (let [key, val] of formData.entries()) {
|
||||
Object.assign(data, {
|
||||
[key]: val,
|
||||
});
|
||||
}
|
||||
|
||||
if(plus_data == 'type') {
|
||||
Object.assign(data, {
|
||||
['type']: 'normal',
|
||||
});
|
||||
}
|
||||
|
||||
window.axios({
|
||||
method: form_method,
|
||||
url: form_url,
|
||||
data: data,
|
||||
})
|
||||
.then(response => {
|
||||
if (form_list.length) {
|
||||
form_list.forEach(item => {
|
||||
if (item.id == form_id) {
|
||||
item.name = response.data.data.name;
|
||||
item.code = response.data.data.code;
|
||||
item.rate = response.data.data.rate;
|
||||
item.type = plus_data == undefined ? 'normal' : ''
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.onSuccessMessage(response);
|
||||
}, this)
|
||||
.catch(error => {
|
||||
this.onFailError(error)
|
||||
}, this);
|
||||
},
|
||||
|
||||
onSubmitEvent(form_method, form_url, plus_data, form_list) {
|
||||
const formData = new FormData(this.$refs["form"]);
|
||||
const data = {};
|
||||
|
||||
for (let [key, val] of formData.entries()) {
|
||||
Object.assign(data, {
|
||||
[key]: val,
|
||||
});
|
||||
}
|
||||
|
||||
if(plus_data == 'type') {
|
||||
Object.assign(data, {
|
||||
['type']: 'normal',
|
||||
});
|
||||
}
|
||||
|
||||
window.axios({
|
||||
method: form_method,
|
||||
url: form_url,
|
||||
data: data,
|
||||
})
|
||||
.then(response => {
|
||||
form_list.push({
|
||||
"id": response.data.data.id,
|
||||
"name": response.data.data.name,
|
||||
"code": response.data.data.code,
|
||||
"rate": response.data.data.rate,
|
||||
"enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true'
|
||||
});
|
||||
|
||||
this.onSuccessMessage(response);
|
||||
}, this)
|
||||
.catch(error => {
|
||||
this.onFailError(error);
|
||||
}, this);
|
||||
},
|
||||
|
||||
onEditCompany() {
|
||||
FormData.prototype.appendRecursive = function(data, wrapper = null) {
|
||||
for(var name in data) {
|
||||
if (name == "previewElement" || name == "previewTemplate") {
|
||||
continue;
|
||||
}
|
||||
if (wrapper) {
|
||||
if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
|
||||
this.appendRecursive(data[name], wrapper + '[' + name + ']');
|
||||
} else {
|
||||
this.append(wrapper + '[' + name + ']', data[name]);
|
||||
}
|
||||
} else {
|
||||
if ((typeof data[name] == 'object' || Array.isArray(data[name])) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
|
||||
this.appendRecursive(data[name], name);
|
||||
} else {
|
||||
this.append(name, data[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const formData = new FormData(this.$refs["form"]);
|
||||
let data_name = {};
|
||||
|
||||
for (let [key, val] of formData.entries()) {
|
||||
Object.assign(data_name, {
|
||||
[key]: val,
|
||||
['logo']: this.$refs.dropzoneWizard.files[1] ? this.$refs.dropzoneWizard.files[1] : this.$refs.dropzoneWizard.files[0],
|
||||
['_prefix']: 'company',
|
||||
['_token']: window.Laravel.csrfToken,
|
||||
['_method']: 'POST',
|
||||
});
|
||||
}
|
||||
|
||||
formData.appendRecursive(data_name);
|
||||
|
||||
window.axios({
|
||||
method: 'POST',
|
||||
url: url + "/wizard/companies",
|
||||
data: formData,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': window.Laravel.csrfToken,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
this.onSuccessMessage(response);
|
||||
}, this)
|
||||
.catch(error => {
|
||||
this.onFailError(error)
|
||||
}, this);
|
||||
},
|
||||
|
||||
onEjetItem(event, form_list, event_id) {
|
||||
form_list.forEach(function (item, index) {
|
||||
if (item.id == event_id) {
|
||||
form_list.splice(index, 1);
|
||||
return;
|
||||
}
|
||||
}, this);
|
||||
|
||||
this.component = "";
|
||||
|
||||
this.onDeleteItemMessage(event);
|
||||
},
|
||||
|
||||
onFailErrorGet(field_name) {
|
||||
if(this.error_field[field_name]) {
|
||||
return this.error_field[field_name][0];
|
||||
}
|
||||
},
|
||||
|
||||
onFailError(error) {
|
||||
this.error_field = error.response.data.errors;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user