somewhere
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div>
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
||||
<CButton size="sm" color="primary" class="mr-auto" :to="{ name: 'admin-faq' }">برگشت به صفحه قبل</CButton>
|
||||
<CButton size="sm" color="success" style="margin-right: 10px" @click="upload">بروزرسانی</CButton>
|
||||
</CustomSubHeader>
|
||||
<CRow>
|
||||
<CCol xl="6">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<CForm>
|
||||
<CInput
|
||||
v-model="faq.question"
|
||||
label="سوال"
|
||||
horizontal
|
||||
:description="validation.question ? validation.question.msg : null"
|
||||
:class="validation.question ? 'err' : null"
|
||||
/>
|
||||
|
||||
<CTextarea
|
||||
v-model="faq.answer"
|
||||
label="پاسخ"
|
||||
horizontal
|
||||
rows="3"
|
||||
:description="validation.answer ? validation.answer.msg : null"
|
||||
:class="validation.answer ? 'err' : null"
|
||||
/>
|
||||
</CForm>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
</CRow>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AddminFAQDetails',
|
||||
layout: 'admin',
|
||||
async asyncData({ $axios, params, error }) {
|
||||
try {
|
||||
const faq = await $axios.get(`/api/public/faq/${params.item}`)
|
||||
return {
|
||||
faq: faq.data
|
||||
}
|
||||
} catch (e) {
|
||||
error({ status: 404, message: 'Page not found' })
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: 'ویرایش سوال متداول',
|
||||
faq: null,
|
||||
validation: {}
|
||||
}
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
upload() {
|
||||
this.validation = {}
|
||||
|
||||
this.$axios
|
||||
.put(`/api/admin/faq/${this.faq._id}`, this.faq)
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
this.$message({
|
||||
message: 'آیتم با موفقیت بروزرسانی شد.',
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.response.status === 422) {
|
||||
this.validation = error.response.data.validation
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: 'اطلاعات رو بررسی و دوباره تلاش کنید'
|
||||
})
|
||||
} else {
|
||||
this.$alert(error.response.data.message, 'خطا', {
|
||||
confirmButtonText: 'باشه'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user