88 lines
2.3 KiB
Vue
88 lines
2.3 KiB
Vue
<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="formData.question"
|
|
label="سوال"
|
|
horizontal
|
|
:description="validation.question ? validation.question.msg : null"
|
|
:class="validation.question ? 'err' : null"
|
|
/>
|
|
|
|
<CTextarea
|
|
v-model="formData.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: 'AddminAddNewFAQ',
|
|
layout: 'admin',
|
|
data() {
|
|
return {
|
|
title: 'افزودن سوال متداول',
|
|
formData: {
|
|
question: '',
|
|
answer: ''
|
|
},
|
|
validation: {}
|
|
}
|
|
},
|
|
head() {
|
|
return {
|
|
title: this.title
|
|
}
|
|
},
|
|
methods: {
|
|
upload() {
|
|
this.validation = {}
|
|
|
|
this.$axios
|
|
.post(`/api/admin/faq`, this.formData)
|
|
.then(response => {
|
|
if (response.data) {
|
|
this.$message({
|
|
message: 'آیتم با موفقیت ثبت شد.',
|
|
type: 'success'
|
|
})
|
|
this.$router.push({ name: 'admin-faq' })
|
|
}
|
|
})
|
|
.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>
|