100 lines
2.6 KiB
Vue
100 lines
2.6 KiB
Vue
<template>
|
|
<div>
|
|
<CustomSubHeader>
|
|
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
|
</CustomSubHeader>
|
|
<CCard>
|
|
<CCardBody>
|
|
<CRow>
|
|
<CCol>
|
|
<el-checkbox label="نمایش دکمه سوییچ بین 'ستاد انتخابات' و 'استانداری'" v-model="yearBanner.electionBtn" @change="update"/>
|
|
</CCol>
|
|
</CRow>
|
|
</CCardBody>
|
|
</CCard>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
title: "دکمه سوییچ بین 'ستاد انتخابات' و 'استانداری'",
|
|
yearBanner: null,
|
|
}
|
|
},
|
|
methods: {
|
|
update() {
|
|
this.validation = {}
|
|
const data = {
|
|
iranFlag: this.yearBanner.iranFlag,
|
|
electionBtn: this.yearBanner.electionBtn,
|
|
// socialLinks
|
|
hasEmail: this.yearBanner.hasEmail,
|
|
hasGPlus: this.yearBanner.hasGPlus,
|
|
hasTweeter: this.yearBanner.hasTweeter,
|
|
hasInstagram: this.yearBanner.hasInstagram,
|
|
email: this.yearBanner.email,
|
|
gPlus: this.yearBanner.gPlus,
|
|
tweeter: this.yearBanner.tweeter,
|
|
instagram: this.yearBanner.instagram
|
|
}
|
|
|
|
this.$axios.post('/api/admin/yearBanner', data)
|
|
.then(res => {
|
|
this.$message({
|
|
type: 'success',
|
|
message: 'تغییرات با موفقیت انجام شد'
|
|
})
|
|
})
|
|
.catch(err => {
|
|
if (err.response?.status === 422) {
|
|
this.validations = err.response.data.validation
|
|
this.$message({
|
|
type: 'warning',
|
|
message: 'پارامترها را بررسی کنید'
|
|
})
|
|
} else console.log(e)
|
|
})
|
|
}
|
|
},
|
|
head() {
|
|
return {
|
|
title: this.title,
|
|
};
|
|
},
|
|
layout: "admin",
|
|
async asyncData({$axios, error}) {
|
|
try {
|
|
const yearBanner = await $axios.get('/api/public/yearBanner')
|
|
return {
|
|
yearBanner: yearBanner.data
|
|
}
|
|
} catch (e) {
|
|
if (e?.response?.status === 401) {
|
|
error({
|
|
status: 401,
|
|
message: "لطفا دوباره وارد سیستم شوید.",
|
|
});
|
|
}
|
|
if (e?.response?.status === 403) {
|
|
error({
|
|
status: 403,
|
|
message: e?.response?.data?.message,
|
|
});
|
|
}
|
|
if (e?.response?.status === 500) {
|
|
error({
|
|
status: 500,
|
|
message: "مشکلی در گرفتن اطلاعات پیش آمده",
|
|
});
|
|
} else
|
|
error({
|
|
status: 404,
|
|
message: "اسلایدر مورد نظر پیدا نشد",
|
|
});
|
|
}
|
|
},
|
|
}
|
|
</script>
|