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>
|
||||
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div>
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
||||
<CButton size="sm" color="success" :to="{ name: 'admin-faq-new' }" class="mr-auto">افزودن</CButton>
|
||||
</CustomSubHeader>
|
||||
|
||||
<CCard>
|
||||
<CCardHeader>
|
||||
<slot name="header">
|
||||
<CIcon name="cil-grid" />
|
||||
{{ list_title }}
|
||||
</slot>
|
||||
</CCardHeader>
|
||||
<CCardBody>
|
||||
<el-table :data="faqs" style="width: 100%">
|
||||
<el-table-column type="index" label="#"> </el-table-column>
|
||||
|
||||
<el-table-column prop="question" label="سوال" width=""> </el-table-column>
|
||||
|
||||
<el-table-column label="ویرایش" width="105" align="left">
|
||||
<template slot-scope="scope">
|
||||
<CButton :key="scope.row._id" color="warning" variant="outline" :to="`/admin/faq/${scope.row._id}`">
|
||||
<i class="fal fa-pencil"></i>
|
||||
</CButton>
|
||||
<CButton color="danger" variant="outline" @click="del(scope.row._id)">
|
||||
<i class="fal fa-trash-alt"></i>
|
||||
</CButton>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AddminFAQList',
|
||||
layout: 'admin',
|
||||
async asyncData({ $axios, error }) {
|
||||
try {
|
||||
const faqs = await $axios.get(`/api/public/faq`)
|
||||
return {
|
||||
faqs: faqs.data
|
||||
}
|
||||
} catch (e) {
|
||||
error({ status: 404, message: 'There is a problem here' })
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: 'سوالات متداول',
|
||||
list_title: 'لیست',
|
||||
faqs: null
|
||||
}
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
del(id) {
|
||||
this.$confirm('این مورد حذف شود؟', 'هشدار', {
|
||||
confirmButtonText: 'بله',
|
||||
cancelButtonText: 'لغو',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
this.$axios
|
||||
.delete(`/api/admin/faq/${id}`)
|
||||
.then(response => {
|
||||
this.faqs = this.faqs.filter(item => item._id !== id)
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'آیتم حذف شد'
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: err.response.data.message
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: 'عملیات لغو شد'
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,87 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user