update:add ci cd files ==> do not edit those file

This commit is contained in:
mahyargdz
2024-10-10 21:49:00 +03:30
parent 6fe34708a2
commit 8cf0492c87
464 changed files with 79533 additions and 0 deletions
+136
View File
@@ -0,0 +1,136 @@
<template>
<CRow class="justify-content-center">
<CCol lg="5">
<CCardGroup>
<CCard class="p-4">
<CCardBody>
<CForm @submit.prevent="doLogin">
<h1 class="text-muted text-center mb-5">پنل مدیریت اُریس اوکسین</h1>
<CInput
:class="validation.username ? 'err' : null"
placeholder="نام کاربری"
:description="validation.username ? validation.username.msg : null"
autocomplete="username email"
v-model="login.username"
>
<template #prepend-content>
<CIcon name="cil-user"/>
</template>
</CInput>
<div class="butt">
<CInput
:class="validation.password ? 'err' : null"
placeholder="کلمه عبور"
:type="passwordState"
:description="validation.password ? validation.password.msg : null"
autocomplete="curent-password"
v-model="login.password"
>
<template #prepend-content>
<CIcon name="cil-lock-locked"/>
</template>
</CInput>
<i @click="showPass = !showPass" class="far fa-eye"></i>
</div>
<CInputCheckbox label="مرا به خاطر بسپار" @update:checked="val => login.remember_me = val"/>
<p class="text-muted mt-3" style="font-size: 11px;">*درصورتی که گزیه "مرا به خاطر بسپار" را فعال نکنید بعد از 1 ساعت باید دوباره وارد سیستم شوید.</p>
<CRow>
<CCol col="12" class="text-right mt-2">
<CButton color="primary" type="submit" class="px-4">ورود</CButton>
</CCol>
<!-- <CCol col="6" class="text-right">-->
<!-- <CButton color="link" class="px-0">Forgot password?</CButton>-->
<!-- <CButton color="link" class="d-lg-none">Register now!</CButton>-->
<!-- </CCol>-->
</CRow>
</CForm>
</CCardBody>
</CCard>
<!-- <CCard-->
<!-- color="primary"-->
<!-- text-color="white"-->
<!-- class="text-center py-5 d-md-down-none"-->
<!-- body-wrapper>-->
<!-- <CCardBody>-->
<!-- <h2>Sign up</h2>-->
<!-- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>-->
<!-- <CButton-->
<!-- color="light"-->
<!-- variant="outline"-->
<!-- size="lg"-->
<!-- >-->
<!-- Register Now!-->
<!-- </CButton>-->
<!-- </CCardBody>-->
<!-- </CCard>-->
</CCardGroup>
</CCol>
</CRow>
</template>
<script>
export default {
data() {
return {
showPass: false,
login: {
username: '',
password: '',
remember_me: false
},
validation: {}
}
},
computed: {
passwordState() {
return this.showPass ? "text" : "password"
}
},
methods: {
doLogin() {
this.validation = {}
this.$auth.loginWith('local', {
data: this.login
})
.then(response => {
window.location.replace('/admin')
})
.catch(err => {
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
}
},
layout: 'admin-auth'
}
</script>
<style lang="scss">
.butt {
position: relative;
i {
position: absolute;
left: 7px;
top: 11px;
z-index: 3;
cursor: pointer;
color: rgba(#000, 0.5);
-webkit-transition: 0.2s;
-moz-transition: 0.2s;
-ms-transition: 0.2s;
-o-transition: 0.2s;
transition: 0.2s;
&:hover {
color: #000;
}
}
}
</style>
+156
View File
@@ -0,0 +1,156 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-categories'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.category === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="blogCategory.locale.fa.title"
/>
<CInput
:class="validation.fa_description ? 'err' : null"
label="توضیح فارسی"
:description="validation.fa_description ? validation.fa_description.msg : null"
v-model="blogCategory.locale.fa.description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="blogCategory.locale.en.title"
/>
<CInput
:class="validation.en_description ? 'err' : null"
label="توضیح انگلیسی"
:description="validation.en_description ? validation.en_description.msg : null"
v-model="blogCategory.locale.en.description"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
blogCategory: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.category === 'new' ? 'افزودن دسته بندی' : 'مشاهده دسته بندی'
}
},
methods: {
post() {
this.validation = {}
const data = {
fa_title: this.blogCategory.locale.fa.title,
en_title: this.blogCategory.locale.en.title,
fa_description: this.blogCategory.locale.fa.description,
en_description: this.blogCategory.locale.en.description
}
this.$axios.post(`/api/admin/blogCategory`, data)
.then(response => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-blog-categories'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = {
fa_title: this.blogCategory.locale.fa.title,
en_title: this.blogCategory.locale.en.title,
fa_description: this.blogCategory.locale.fa.description,
en_description: this.blogCategory.locale.en.description
}
this.$axios.put(`/api/admin/blogCategory/${this.blogCategory._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.category !== 'new') {
const blogCategory = await $axios.get(`/api/admin/blogCategory/${params.category}`)
return {
blogCategory: blogCategory.data
}
} else {
return {
blogCategory: {
locale: {
fa: {
title: '',
description: ''
},
en: {
title: '',
description: ''
}
}
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+120
View File
@@ -0,0 +1,120 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-blog-categories-category',params:{category: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="blogCategories"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-blog-categories-category',params: {category: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست دسته بندی ها',
list_title: 'لیست',
blogCategories: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/blogCategory/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت حذف شد'
})
this.blogCategories = this.blogCategories.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const blogCategories = await $axios.get(`/api/public/blogCategories`)
return {
blogCategories: blogCategories.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+276
View File
@@ -0,0 +1,276 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-posts'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="12">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<p>دسته بندی</p>
<el-select v-model="blogPost.category" filterable :class="validation.category? 'err' : null">
<el-option v-for="item in blogCategories" :label="item.locale.fa.title" :value="item._id" :key="item._id"/>
</el-select>
<p class="text-danger" v-if="validation.category">{{ validation.category.msg }}</p>
<el-divider></el-divider>
</CCol>
<div>
<el-checkbox v-model="blogPost.published" label="پست منتشر شود"/>
</div>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h4>فارسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="blogPost.locale.fa.title"
/>
<CTextarea
:class="validation.fa_short_description ? 'err' : null"
label="توضیح کوتاه فارسی"
:description="validation.fa_short_description ? validation.fa_short_description.msg : null"
v-model="blogPost.locale.fa.short_description"
/>
<CInput
:class="validation.fa_last_section_image_title ? 'err' : null"
label="عنوان روی تصویر بخش آخر"
:description="validation.fa_last_section_image_title ? validation.fa_last_section_image_title.msg : null"
v-model="blogPost.locale.fa.last_section_image_title"
/>
<CTextarea
:class="validation.fa_last_section_image_description ? 'err' : null"
label="توضیحات روی تصویر بخش آخر"
:description="validation.fa_last_section_image_description ? validation.fa_last_section_image_description.msg : null"
v-model="blogPost.locale.fa.last_section_image_description"
/>
<CInput
:class="validation.fa_last_section_title ? 'err' : null"
label="عنوان زیر تصویر بخش آخر"
:description="validation.fa_last_section_title ? validation.fa_last_section_title.msg : null"
v-model="blogPost.locale.fa.last_section_title"
/>
<CTextarea
:class="validation.fa_last_section_description ? 'err' : null"
label="توضیحات زیر تصویر بخش آخر"
:description="validation.fa_last_section_description ? validation.fa_last_section_description.msg : null"
v-model="blogPost.locale.fa.last_section_description"
/>
<client-only>
<p>توضیحات فارسی</p>
<ckeditor v-model="blogPost.locale.fa.description" :config="editorConfigFa"></ckeditor>
<p class="text-danger" v-if="validation.fa_description">{{ validation.fa_description.msg }}</p>
</client-only>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h4>انگلیسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="blogPost.locale.en.title"
/>
<CTextarea
:class="validation.en_short_description ? 'err' : null"
label="توضیح کوتاه انگلیسی"
:description="validation.en_short_description ? validation.en_short_description.msg : null"
v-model="blogPost.locale.en.short_description"
/>
<CInput
:class="validation.en_last_section_image_title ? 'err' : null"
label="عنوان روی تصویر بخش آخر"
:description="validation.en_last_section_image_title ? validation.en_last_section_image_title.msg : null"
v-model="blogPost.locale.en.last_section_image_title"
/>
<CTextarea
:class="validation.en_last_section_image_description ? 'err' : null"
label="توضیحات روی تصویر بخش آخر"
:description="validation.en_last_section_image_description ? validation.en_last_section_image_description.msg : null"
v-model="blogPost.locale.en.last_section_image_description"
/>
<CInput
:class="validation.en_last_section_title ? 'err' : null"
label="عنوان زیر تصویر بخش آخر"
:description="validation.en_last_section_title ? validation.en_last_section_title.msg : null"
v-model="blogPost.locale.en.last_section_title"
/>
<CTextarea
:class="validation.en_last_section_description ? 'err' : null"
label="توضیحات زیر تصویر بخش آخر"
:description="validation.en_last_section_description ? validation.en_last_section_description.msg : null"
v-model="blogPost.locale.en.last_section_description"
/>
<client-only>
<p>توضیحات انگلیسی</p>
<ckeditor v-model="blogPost.locale.en.description" :config="editorConfigEn"></ckeditor>
<p class="text-danger" v-if="validation.en_description">{{ validation.en_description.msg }}</p>
</client-only>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>کاور</p>
<img :src="blogPost.cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر بخش آخر</p>
<img :src="blogPost.last_section_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="last_section_image" @change="preview2">
<p class="text-danger" v-if="validation.last_section_image">{{ validation.last_section_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12">
<CCard>
<CCardBody>
<p>آپلود ویدیو</p>
<input type="file" ref="video" placeholder="انتخاب فایل ویدیو"/>
<p class="text-danger" v-if="validation.last_section_image">{{ validation.last_section_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12" v-if="blogPost.video">
<CCard>
<CCardBody>
<video class="mt-3" width="100%" height="400" muted controls
:src="blogPost.video"></video>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
title: 'مشاهده پست',
blogPost: null,
blogCategories: null,
editorConfigFa: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
editorConfigEn: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
validation: {}
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.blogPost.cover = URL.createObjectURL(event.target.files[0])
},
preview2() {
this.blogPost.last_section_image = URL.createObjectURL(event.target.files[0])
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.blogPost?.locale?.fa?.title || '')
data.append('en_title', this.blogPost?.locale?.en?.title || '')
data.append('fa_description', this.blogPost?.locale?.fa?.description || '')
data.append('en_description', this.blogPost?.locale?.en?.description || '')
data.append('fa_short_description', this.blogPost?.locale?.fa?.short_description || '')
data.append('en_short_description', this.blogPost?.locale?.en?.short_description || '')
data.append('fa_last_section_image_title', this.blogPost?.locale?.fa?.last_section_image_title || '')
data.append('en_last_section_image_title', this.blogPost?.locale?.en?.last_section_image_title || '')
data.append('fa_last_section_image_description', this.blogPost?.locale?.fa?.last_section_image_description || '')
data.append('en_last_section_image_description', this.blogPost?.locale?.en?.last_section_image_description || '')
data.append('fa_last_section_title', this.blogPost?.locale?.fa?.last_section_title || '')
data.append('en_last_section_title', this.blogPost?.locale?.en?.last_section_title || '')
data.append('fa_last_section_description', this.blogPost?.locale?.fa?.last_section_description || '')
data.append('en_last_section_description', this.blogPost?.locale?.en?.last_section_description || '')
data.append('category', this.blogPost.category)
data.append('published', this.blogPost.published)
console.log(this.$refs)
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
if (this.$refs.last_section_image.files[0]) data.append('last_section_image', this.$refs.last_section_image.files[0])
if (this.$refs?.video?.files[0]) data.append('video', this.$refs?.video?.files[0])
this.$axios.put(`/api/admin/blogPost/${this.blogPost._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.cover.value = null
this.$refs.last_section_image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const blogCategories = await $axios.get(`/api/public/blogCategories`)
const blogPost = await $axios.get(`/api/public/blogPost/${params.post}?noCategory=true`)
return {
blogCategories: blogCategories.data,
blogPost: blogPost.data
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+141
View File
@@ -0,0 +1,141 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-blog-posts-new'}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<CRow>
<CCol>
<el-table
:data="blogPosts"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="کاور"
width="200">
<template slot-scope="scope">
<img :src="scope.row.thumb" alt="" style="width: 100%">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="وضعیت انتشار پست"
>
<template slot-scope="scope">
<span class="text-success" v-if="scope.row.published">منتشر شده</span>
<span class="text-danger" v-else>منتشر نشده</span>
</template>
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-blog-posts-post',params: {post: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست پست های رویدادها',
list_title: 'لیست',
blogPosts: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/blogPost/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'پست با موفقیت حذف شد'
})
this.blogPosts = this.blogPosts.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const blogPosts = await $axios.get(`/api/public/blogPosts?getAll=true`)
return {
blogPosts: blogPosts.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+114
View File
@@ -0,0 +1,114 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-blog-posts'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="fa_title"
/>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="en_title"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>کاور</p>
<img :src="cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
title: 'افزودن پست',
fa_title: '',
en_title: '',
cover: '',
blogCategories: null,
editorConfig: {
language: 'en',
extraPlugins: ['bidi', 'justify']
},
validation: {}
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.cover = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.fa_title)
data.append('en_title', this.en_title)
data.append('cover', this.$refs.cover.files[0])
this.$axios.post(`/api/admin/blogPost`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'پست با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-blog-posts-post', params: {post: response.data._id}})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin'
}
</script>
+194
View File
@@ -0,0 +1,194 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-catalogs'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.catalog === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="catalog.locale.fa.title"
/>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="catalog.locale.en.title"
/>
<div>
<el-checkbox v-model="catalog.showInFa" label="در نسخه فارسی سایت نمایش داده شود"/>
</div>
<div>
<el-checkbox v-model="catalog.showInEn" label="در نسخه انگلیسی سایت نمایش داده شود"/>
</div>
<el-divider></el-divider>
<p>فایل کاتلوگ:</p>
<input type="file" ref="file">
<p class="text-danger" v-if="validation.file">{{ validation.file.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر</p>
<img :src="catalog.cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
catalog: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.image === 'new' ? 'افزودن کاتالوگ جدید' : 'ویرایش کاتالوگ'
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.catalog.cover = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
if (!this.$refs.file.files[0]) {
return this.$message({
type: 'error',
message: 'فایل کاتالوگ اجباری میباشد'
})
}
if (!this.$refs.cover.files[0]) {
return this.$message({
type: 'error',
message: 'کاور اجباری میباشد'
})
}
const data = new FormData()
data.append('fa_title', this.catalog.locale.fa.title)
data.append('en_title', this.catalog.locale.en.title)
data.append('showInFa', this.catalog.showInFa)
data.append('showInEn', this.catalog.showInEn)
data.append('file', this.$refs.file.files[0])
data.append('cover', this.$refs.cover.files[0])
this.$axios.post(`/api/admin/catalog`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'کاتالوگ با موفقیت افزوده شد'
})
this.$router.push({name: 'admin-catalogs'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.catalog.locale.fa.title)
data.append('en_title', this.catalog.locale.en.title)
data.append('showInFa', this.catalog.showInFa)
data.append('showInEn', this.catalog.showInEn)
if (this.$refs.file.files[0]) data.append('file', this.$refs.file.files[0])
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
this.$axios.put(`/api/admin/catalog/${this.catalog._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.cover.value = null
this.$refs.file.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.catalog !== 'new') {
const catalog = await $axios.get(`/api/public/catalog/${params.catalog}`)
return {
catalog: catalog.data
}
} else {
return {
catalog: {
locale: {
fa: {
title: ''
},
en: {
title: ''
}
},
file: '',
cover: '',
showInFa: true,
showInEn: false
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+143
View File
@@ -0,0 +1,143 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-catalogs-catalog',params: {catalog: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<CRow>
<CCol>
<el-table
:data="catalogs"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="عکس"
width="200">
<template slot-scope="scope">
<img :src="scope.row.cover" alt="" style="width: 100%">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="حالت نمایش"
width="">
<template slot-scope="scope">
<b class="text-success" v-if="scope.row.showInFa && scope.row.showInEn">فارسی و انگلیسی</b>
<b class="text-danger" v-if="!scope.row.showInFa && !scope.row.showInEn">نمایش داده نشود</b>
<b class="text-warning" v-if="!scope.row.showInEn && scope.row.showInFa">فارسی</b>
<b class="text-warning" v-if="!scope.row.showInFa && scope.row.showInEn">انگلیسی</b>
</template>
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-catalogs-catalog',params: {catalog: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست کاتالوگ ها',
list_title: 'لیست',
catalogs: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/catalog/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'کاتالوگ با موفقیت حذف شد'
})
this.catalogs = this.catalogs.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const catalogs = await $axios.get(`/api/public/catalogs`)
return {
catalogs: catalogs.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+206
View File
@@ -0,0 +1,206 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-comments'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.comment === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<h4 class="mt-5">فارسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.fa_name ? 'err' : null"
label="نام فارسی"
:description="validation.fa_name ? validation.fa_name.msg : null"
v-model="comment.locale.fa.name"
/>
<CInput
:class="validation.fa_position ? 'err' : null"
label="سمت فارسی"
:description="validation.fa_position ? validation.fa_position.msg : null"
v-model="comment.locale.fa.position"
/>
<CTextarea
:class="validation.fa_comment ? 'err' : null"
label="کامنت فارسی"
:description="validation.fa_comment ? validation.fa_comment.msg : null"
v-model="comment.locale.fa.comment"
/>
<h4 class="mt-5">انگلیسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.en_name ? 'err' : null"
label="نام انگلیسی"
:description="validation.en_name ? validation.en_name.msg : null"
v-model="comment.locale.en.name"
/>
<CInput
:class="validation.en_position ? 'err' : null"
label="سمت انگلیسی"
:description="validation.en_position ? validation.en_position.msg : null"
v-model="comment.locale.en.position"
/>
<CTextarea
:class="validation.en_comment ? 'err' : null"
label="کامنت انگلیسی"
:description="validation.en_comment ? validation.en_comment.msg : null"
v-model="comment.locale.en.comment"
/>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر</h2>
<el-divider></el-divider>
<img :src="comment.image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
comment: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.comment === 'new' ? 'افزودن کامنت جدید' : 'مشاهده اطلاعات کامنت'
}
},
methods: {
preview() {
this.comment.image = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_name', this.comment.locale.fa.name)
data.append('en_name', this.comment.locale.en.name)
data.append('fa_position', this.comment.locale.fa.position)
data.append('en_position', this.comment.locale.en.position)
data.append('fa_comment', this.comment.locale.fa.comment)
data.append('en_comment', this.comment.locale.en.comment)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/comment`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'کامنت با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-comments'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_name', this.comment.locale.fa.name)
data.append('en_name', this.comment.locale.en.name)
data.append('fa_position', this.comment.locale.fa.position)
data.append('en_position', this.comment.locale.en.position)
data.append('fa_comment', this.comment.locale.fa.comment)
data.append('en_comment', this.comment.locale.en.comment)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.put(`/api/admin/comment/${this.comment._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.comment !== 'new') {
const team = await $axios.get(`/api/admin/comment/${params.comment}`)
return {
comment: team.data
}
} else {
return {
comment: {
locale: {
fa: {
name: '',
position: '',
comment: ''
},
en: {
name: '',
position: '',
comment: ''
}
},
image: ''
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+128
View File
@@ -0,0 +1,128 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-comments-comment',params:{comment: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="comments"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="عکس"
width="200">
<template slot-scope="scope">
<img :src="scope.row.image || '/img/avatar.png'" alt="" style="width: 100%;">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.name"
label="نام"
width="">
</el-table-column>
<el-table-column
prop="locale.fa.position"
label="سمت"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-comments-comment',params: {comment: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست نظرات مشتریان',
list_title: 'لیست',
comments: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/comment/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'مورد با موفقیت حذف شد'
})
this.comments = this.comments.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const comments = await $axios.get(`/api/public/comments`)
return {
comments: comments.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
@@ -0,0 +1,96 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-contact-us-messages'}">برگشت به صفحه قبل</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<!-- <i class="fal fa-bars"></i>-->
<!-- <span>{{ list_title }}</span>-->
</slot>
</CCardHeader>
<CCardBody>
<CRow>
<CCol md="6">
<CForm class="message">
<CRow>
<CCol sm="12">
<CInput
label="زبان سایت هنگام بازدید کاربر"
:value="message.locale === 'fa' ? 'فارسی' : 'انگلیسی'"
disabled
/>
<CInput
label="نام"
:value="message.name"
disabled
/>
<CInput
label="ایمیل"
:value="message.email"
disabled
/>
<CInput
label="موضوع"
:value="message.subject"
disabled
/>
<CTextarea
label="پیام"
disabled=""
:value="message.message"
rows="10"
/>
</CCol>
</CRow>
</CForm>
</CCol>
</CRow>
</CCardBody>
</CCard>
</div>
</template>
<script>
import unreadMessagesCounter from "@/mixins/unreadMessagesCounter"
export default {
data() {
return {
title: 'مشاهده پیام',
message: null,
validation: {}
}
},
mixins: [unreadMessagesCounter],
mounted() {
this.checkMessages()
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const message = await $axios.get(`/api/admin/contactUsMessages/${params.message}`)
return {
message: message.data
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
<style lang="scss">
.message {
input:disabled, textarea:disabled {
color: #000 !important;
}
}
</style>
+137
View File
@@ -0,0 +1,137 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
</CustomSubHeader>
<CRow>
<CCol col="col">
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-filter"></i>
<span>فیلتر</span>
</slot>
</CCardHeader>
<CCardBody>
<CButtonGroup>
<CButton color="primary" :class="filter === 'all' && 'selected'" @click="filter = 'all'">همه</CButton>
<CButton color="warning" :class="filter === 'fa_unread' && 'selected'" @click="filter = 'fa_unread'">خوانده نشده فارسی</CButton>
<CButton color="warning" :class="filter === 'en_unread' && 'selected'" @click="filter = 'en_unread'">خوانده نشده انگلیسی</CButton>
<CButton color="success" :class="filter === 'fa_read' && 'selected'" @click="filter = 'fa_read'">خوانده شده فارسی</CButton>
<CButton color="success" :class="filter === 'en_read' && 'selected'" @click="filter = 'en_read'">خوانده شده انگلیسی</CButton>
</CButtonGroup>
</CCardBody>
</CCard>
</CCol>
</CRow>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="filteredMessages"
style="width: 100%"
:row-class-name="readStatus">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
prop="name"
label="نام"
width="">
</el-table-column>
<el-table-column
prop="email"
label="ایمیل"
width="">
</el-table-column>
<!-- <el-table-column-->
<!-- prop="phone"-->
<!-- label="شماره تماس"-->
<!-- width=""-->
<!-- class-name="phoneNumber">-->
<!-- </el-table-column>-->
<el-table-column
label="مشاهده"
width="80"
align="center">
<template slot-scope="scope">
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-contact-us-messages-message',params: {message: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست پیغام های کاربران',
list_title: 'لیست',
messages: null,
filter: 'all'
}
},
computed: {
filteredMessages() {
const filter = this.filter
if (filter === 'all') return this.messages
else if (filter === 'fa_unread') return this.messages.filter(item => item.locale === 'fa' && !item.read)
else if (filter === 'en_unread') return this.messages.filter(item => item.locale === 'en' && !item.read)
else if (filter === 'fa_read') return this.messages.filter(item => item.locale === 'fa' && item.read)
else if (filter === 'en_read') return this.messages.filter(item => item.locale === 'en' && item.read)
}
},
methods: {
readStatus({row, rowIndex}) {
return row.read ? null : 'unread'
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const messages = await $axios.get('/api/admin/contactUsMessages')
return {
messages: messages.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
<style lang="scss">
.phoneNumber {
div {
direction: ltr;
text-align: right;
}
}
.unread {
background: rgba(255, 173, 0, 0.12) !important;
}
</style>
+182
View File
@@ -0,0 +1,182 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-gallery'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.image === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<div>
<p>دسته بندی</p>
<el-select v-model="image.category" filterable :disabled="image.noCategory" :class="validation.category? 'err' : null">
<el-option v-for="item in galleryCategories" :label="item.locale.fa.title" :value="item._id" :key="item._id"/>
</el-select>
<p class="text-danger" v-if="validation.category">{{ validation.category.msg }}</p>
</div>
<div class="mt-3">
<el-checkbox v-model="image.noCategory" label="بدون دسته بندی"/>
</div>
<el-divider></el-divider>
<CInput
:class="validation.fa_caption ? 'err' : null"
label="کپشن فارسی"
:description="validation.fa_caption ? validation.fa_caption.msg : null"
v-model="image.locale.fa.caption"
/>
<CInput
:class="validation.en_caption ? 'err' : null"
label="کپشن انگلیسی"
:description="validation.en_caption ? validation.en_caption.msg : null"
v-model="image.locale.en.caption"
/>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>تصویر</p>
<img :src="image.image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
galleryCategories: null,
image: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.image === 'new' ? 'افزودن تصویر جدید' : 'ویرایش تصویر'
}
},
mixins: [axiosUploadProcess],
methods: {
preview() {
this.image.image = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_caption', this.image.locale.fa.caption)
data.append('en_caption', this.image.locale.en.caption)
data.append('category', this.image.category)
data.append('noCategory', this.image.noCategory)
data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/gallery`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت افزوده شد'
})
this.$router.push({name: 'admin-gallery'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_caption', this.image.locale.fa.caption)
data.append('en_caption', this.image.locale.en.caption)
data.append('category', this.image.category)
data.append('noCategory', this.image.noCategory)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.put(`/api/admin/gallery/${this.image._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
this.$message({
type: 'error',
message: 'پارامتر هارو بررسی کنید'
})
} else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const galleryCategories = await $axios.get(`/api/public/galleryCategories`)
if (params.image !== 'new') {
const image = await $axios.get(`/api/public/galleryImage/${params.image}`)
return {
galleryCategories: galleryCategories.data,
image: image.data
}
} else {
return {
galleryCategories: galleryCategories.data,
image: {
locale: {
fa: {
caption: ''
},
en: {
caption: ''
}
},
image: '',
category: '',
noCategory: false
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+142
View File
@@ -0,0 +1,142 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-gallery-image',params: {image: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<CRow>
<CCol>
<el-table
:data="galleryImages"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="عکس"
width="200">
<template slot-scope="scope">
<img :src="scope.row.thumb" alt="" style="width: 100%">
</template>
</el-table-column>
<el-table-column
label="دسته بندی"
width="">
<template slot-scope="scope">
<span v-if="!scope.row.noCategory">{{ scope.row.category.locale.fa.title }}</span>
<span v-else class="text-danger">بدون دسته بندی</span>
</template>
</el-table-column>
<el-table-column
prop="locale.fa.caption"
label="کپشن فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.caption"
label="کپشن انگلیسی"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-gallery-image',params: {image: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست تصاویر گالری',
list_title: 'لیست',
galleryImages: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/gallery/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت حذف شد'
})
this.galleryImages = this.galleryImages.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const galleryImages = await $axios.get(`/api/public/gallery`)
return {
galleryImages: galleryImages.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+192
View File
@@ -0,0 +1,192 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-galleryCategories'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.category === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="galleryCategory.locale.fa.title"
/>
<CInput
:class="validation.fa_description ? 'err' : null"
label="توضیح فارسی"
:description="validation.fa_description ? validation.fa_description.msg : null"
v-model="galleryCategory.locale.fa.description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="galleryCategory.locale.en.title"
/>
<CInput
:class="validation.en_description ? 'err' : null"
label="توضیح انگلیسی"
:description="validation.en_description ? validation.en_description.msg : null"
v-model="galleryCategory.locale.en.description"
/>
<span style="font-weight: 600">ترتیب نمایش</span>
<el-select v-model="galleryCategory.index" filterable style="width: 100%;margin-top: 5px;">
<el-option
v-for="item in galleryCategories.length + 20"
v-if="galleryCategories.filter(item2=>Number(item2.index) !== item+1)"
:key="item + 202"
:value="item+1"
:label="item+1"/>
</el-select>
<p v-if="validation.index" class="text-danger" style="margin-top: 5px;">{{ validation.index.msg }}</p>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<p>کاور</p>
<img :src="galleryCategory.cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
galleryCategory: null,
galleryCategories: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.category === 'new' ? 'افزودن دسته بندی' : 'مشاهده دسته بندی'
}
},
methods: {
preview() {
this.galleryCategory.cover = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.galleryCategory.locale.fa.title)
data.append('en_title', this.galleryCategory.locale.en.title)
data.append('fa_description', this.galleryCategory.locale.fa.description)
data.append('en_description', this.galleryCategory.locale.en.description)
data.append('index', this.galleryCategory.index)
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
this.$axios.post(`/api/admin/galleryCategory`, data)
.then(response => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-galleryCategories'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.galleryCategory.locale.fa.title)
data.append('en_title', this.galleryCategory.locale.en.title)
data.append('fa_description', this.galleryCategory.locale.fa.description)
data.append('en_description', this.galleryCategory.locale.en.description)
data.append('index', this.galleryCategory.index)
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
this.$axios.put(`/api/admin/galleryCategory/${this.galleryCategory._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const galleryCategories = await $axios.$get(`/api/public/galleryCategories`)
if (params.category !== 'new') {
const galleryCategory = await $axios.$get(`/api/admin/galleryCategory/${params.category}`)
return {
galleryCategory,
galleryCategories,
}
} else {
return {
galleryCategories,
galleryCategory: {
locale: {
fa: {
title: '',
description: ''
},
en: {
title: '',
description: ''
}
},
index : 0
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+128
View File
@@ -0,0 +1,128 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-galleryCategories-category',params:{category: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="galleryCategories"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="کاور"
width="200">
<template slot-scope="scope">
<img :src="!scope.row.thumb.includes('undefined') ? scope.row.thumb : '/img/default-img.png'" alt="" style="width: 50%">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-galleryCategories-category',params: {category: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست دسته بندی گالری تصاویر',
list_title: 'لیست',
galleryCategories: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/galleryCategory/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت حذف شد'
})
this.galleryCategories = this.galleryCategories.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const galleryCategories = await $axios.get(`/api/public/galleryCategories`)
return {
galleryCategories: galleryCategories.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+36
View File
@@ -0,0 +1,36 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<h1>به پنل مدیریت وبسایت خوش آمدید</h1>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'داشبورد',
list_title: 'لیست'
}
},
head() {
return {
title: this.title
}
},
layout: 'admin'
}
</script>
+248
View File
@@ -0,0 +1,248 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-projectCategories'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.category === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<CInput
:class="validation.fa_name ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_name ? validation.fa_name.msg : null"
v-model="projectCategory.locale.fa.name"
/>
<CInput
:class="validation.en_name ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_name ? validation.en_name.msg : null"
v-model="projectCategory.locale.en.name"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<!-- tags -->
<CCol v-if="$route.params.category !== 'new'" lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<h4>افزودن دسته بندی زیر مجموعه:</h4>
<el-divider></el-divider>
<CInput
:class="validation.fa_tagName ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_tagName ? validation.fa_tagName.msg : null"
v-model="tag.fa_tagName"
/>
<CInput
:class="validation.en_tagName ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_tagName ? validation.en_tagName.msg : null"
v-model="tag.en_tagName"
/>
</CCol>
<CCol sm="12">
<el-button type="success" size="small" @click="addTag">افزودن</el-button>
</CCol>
<el-divider></el-divider>
<div>
<el-tag
v-for="tag in projectCategory.tags"
:key="tag._id"
closable
@click="removeTag(tag._id)"
style="margin-left: 10px;margin-bottom: 5px;cursor: pointer"
>
{{ tag.locale.fa.name }}
</el-tag>
</div>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
projectCategory: null,
tag: {
fa_tagName: '',
en_tagName: ''
},
validation: {}
}
},
computed: {
title() {
return this.$route.params.category === 'new' ? 'افزودن دسته بندی' : 'مشاهده دسته بندی'
}
},
methods: {
post() {
this.validation = {}
const data = {
fa_name: this.projectCategory.locale.fa.name,
en_name: this.projectCategory.locale.en.name
}
this.$axios.post(`/api/admin/projectCategory`, data)
.then(response => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-projectCategories'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = {
fa_name: this.projectCategory.locale.fa.name,
en_name: this.projectCategory.locale.en.name
}
this.$axios.put(`/api/admin/projectCategory/${this.projectCategory._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
addTag() {
this.validation = {}
const data = {
fa_tagName: this.tag.fa_tagName,
en_tagName: this.tag.en_tagName
}
this.$axios.post(`/api/admin/categoryTag/${this.projectCategory._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت ایجاد شد.'
})
this.tag = {
fa_tagName: '',
en_tagName: ''
}
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
removeTag(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/categoryTag/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'دسته بندی زیر مجموعه با موفقیت حذف شد'
})
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
},
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.category !== 'new') {
const projectCategory = await $axios.get(`/api/admin/projectCategory/${params.category}`)
return {
projectCategory: projectCategory.data
}
} else {
return {
projectCategory: {
locale: {
fa: {
name: ''
},
en: {
name: ''
}
}
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+120
View File
@@ -0,0 +1,120 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-projectCategories-category',params:{category: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="projectCategories"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
prop="locale.fa.name"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.name"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-projectCategories-category',params: {category: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست دسته بندی پروژه',
list_title: 'لیست',
projectCategories: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/projectCategory/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'دسته بندی با موفقیت حذف شد'
})
this.projectCategories = this.projectCategories.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const projectCategories = await $axios.get(`/api/public/projectCategories`)
return {
projectCategories: projectCategories.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+545
View File
@@ -0,0 +1,545 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-projects'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<!-- ### category | title | description | settings ###-->
<CCol lg="12">
<CCard>
<CCardBody>
<CForm>
<CRow class="align-items-stretch">
<CCol sm="12">
<p>دسته بندی</p>
<el-select v-model="project.category" filterable :class="validation.category? 'err' : null">
<el-option v-for="item in projectCategories" :label="item.locale.fa.name" :value="item._id" :key="item._id"/>
</el-select>
<p class="text-danger" v-if="validation.category">{{ validation.category.msg }}</p>
<el-divider></el-divider>
<p>دسته بندی زیر مجموعه</p>
<el-select v-model="project.tag" filterable clearable>
<el-option v-for="item in availableTags" :label="item.locale.fa.name" :value="item._id" :key="item._id"/>
</el-select>
<el-divider></el-divider>
<el-checkbox label="دارای صفحه توضیحات میباشد" v-model="project.has_details"/>
<el-divider></el-divider>
<CInput
:class="validation.project_date ? 'err' : null"
style="width: 300px;"
label="سال اجرای پروژه (سال شمسی)"
placeholder="مثال: 1390"
:description="validation.project_date ? validation.project_date.msg : null"
v-model="project.project_date"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_size || validation.en_size ? 'err' : null"
label="حجم"
style="width: 300px;"
placeholder="کیلوگرم"
:description="validation.fa_size || validation.en_size ? validation.fa_size.msg || validation.en_size.msg : null"
v-model="project.locale.fa.size"
/>
<CInput
:class="validation.fa_area || validation.en_area ? 'err' : null"
label="متراژ"
style="width: 300px;"
placeholder="متر"
:description="validation.fa_area || validation.en_area ? validation.fa_area.msg || validation.en_area.msg : null"
v-model="project.locale.fa.area"
/>
<el-divider></el-divider>
</CCol>
<CCol sm="6">
<h2>نسخه انگلیسی</h2>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="project.locale.en.title"
/>
<CTextarea
:class="validation.en_short_description ? 'err' : null"
label="توضیح کوتاه انگلیسی"
:description="validation.en_short_description ? validation.en_short_description.msg : null"
v-model="project.locale.en.short_description"
/>
<CTextarea
:class="validation.en_description ? 'err' : null"
label="توضیحات انگلیسی"
:description="validation.en_description ? validation.en_description.msg : null"
v-model="project.locale.en.description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_client ? 'err' : null"
label="نام مشتری"
:description="validation.en_client ? validation.en_client.msg : null"
v-model="project.locale.en.client"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_s3_title ? 'err' : null"
label="عنوان بخش سوم صفحه"
:description="validation.en_s3_title ? validation.en_s3_title.msg : null"
v-model="project.locale.en.s3_title"
/>
<CTextarea
:class="validation.en_s3_description ? 'err' : null"
label="توضیحات بخش سوم صفحه"
:description="validation.en_s3_description ? validation.en_s3_description.msg : null"
v-model="project.locale.en.s3_description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_s5_title ? 'err' : null"
label="عنوان بخش پنجم صفحه"
:description="validation.en_s5_title ? validation.en_s5_title.msg : null"
v-model="project.locale.en.s5_title"
/>
<CTextarea
:class="validation.en_s5_description ? 'err' : null"
label="توضیحات بخش پنجم صفحه"
:description="validation.en_s5_description ? validation.en_s5_description.msg : null"
v-model="project.locale.en.s5_description"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_s6_title ? 'err' : null"
label="عنوان بخش ششم صفحه"
:description="validation.en_s6_title ? validation.en_s6_title.msg : null"
v-model="project.locale.en.s6_title"
/>
<CTextarea
:class="validation.en_s6_description ? 'err' : null"
label="توضیحات بخش ششم صفحه"
:description="validation.en_s6_description ? validation.en_s6_description.msg : null"
v-model="project.locale.en.s6_description"
/>
</CCol>
<CCol sm="6">
<h2>نسخه فارسی</h2>
<el-divider></el-divider>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="project.locale.fa.title"
/>
<CTextarea
:class="validation.fa_short_description ? 'err' : null"
label="توضیح کوتاه فارسی"
:description="validation.fa_short_description ? validation.fa_short_description.msg : null"
v-model="project.locale.fa.short_description"
/>
<CTextarea
:class="validation.fa_description ? 'err' : null"
label="توضیحات فارسی"
:description="validation.fa_description ? validation.fa_description.msg : null"
v-model="project.locale.fa.description"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_client ? 'err' : null"
label="نام مشتری"
:description="validation.fa_client ? validation.fa_client.msg : null"
v-model="project.locale.fa.client"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_s3_title ? 'err' : null"
label="عنوان بخش سوم صفحه"
:description="validation.fa_s3_title ? validation.fa_s3_title.msg : null"
v-model="project.locale.fa.s3_title"
/>
<CTextarea
:class="validation.fa_s3_description ? 'err' : null"
label="توضیحات بخش سوم صفحه"
:description="validation.fa_s3_description ? validation.fa_s3_description.msg : null"
v-model="project.locale.fa.s3_description"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_s5_title ? 'err' : null"
label="عنوان بخش پنجم صفحه"
:description="validation.fa_s5_title ? validation.fa_s5_title.msg : null"
v-model="project.locale.fa.s5_title"
/>
<CTextarea
:class="validation.fa_s5_description ? 'err' : null"
label="توضیحات بخش پنجم صفحه"
:description="validation.fa_s5_description ? validation.fa_s5_description.msg : null"
v-model="project.locale.fa.s5_description"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_s6_title ? 'err' : null"
label="عنوان بخش ششم صفحه"
:description="validation.fa_s6_title ? validation.fa_s6_title.msg : null"
v-model="project.locale.fa.s6_title"
/>
<CTextarea
:class="validation.fa_s6_description ? 'err' : null"
label="توضیحات بخش ششم صفحه"
:description="validation.fa_s6_description ? validation.fa_s6_description.msg : null"
v-model="project.locale.fa.s6_description"
/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
<!-- ### add hero cover ###-->
<CCol lg="6">
<CCard>
<CCardBody>
<h2>کاور صفحه</h2>
<el-divider></el-divider>
<img :src="project.cover" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="cover" @change="preview">
<p class="text-danger" v-if="validation.cover">{{ validation.cover.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<!-- ### add s2_image ###-->
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر بخش دوم صفحه</h2>
<el-divider></el-divider>
<img :src="project.s2_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="s2_image" @change="preview2">
<p class="text-danger" v-if="validation.s2_image">{{ validation.s2_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<!-- ### add s4_image ###-->
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر بخش چهارم صفحه</h2>
<el-divider></el-divider>
<img :src="project.s4_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="s4_image" @change="preview3">
<p class="text-danger" v-if="validation.s4_image">{{ validation.s4_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<!-- ### add s5_image ###-->
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر بخش پنجم صفحه</h2>
<el-divider></el-divider>
<img :src="project.s5_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="s5_image" @change="preview4">
<p class="text-danger" v-if="validation.s5_image">{{ validation.s5_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<!-- ### add s6_image ###-->
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر بخش ششم صفحه</h2>
<el-divider></el-divider>
<img :src="project.s6_image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="s6_image" @change="preview5">
<p class="text-danger" v-if="validation.s6_image">{{ validation.s6_image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<!-- ### project gallery ###-->
<CCol sm="12">
<CCard>
<CCardBody>
<h2>گالری تصاویر پروژه</h2>
<el-divider></el-divider>
<img :src="imageGallery" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview6">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
<el-button type="success" @click="addImage">افزودن</el-button>
<el-divider></el-divider>
<h2>تصاویر</h2>
<div class="images">
<div class="row">
<div class="col-4 col-md-2 image" v-for="item in project.images" :key="item._id">
<img :src="item.image" alt="">
<i class="far fa-trash-alt" title="حذف" @click="removeImage(item._id)"></i>
</div>
</div>
</div>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "@/mixins/axiosUploadProcess"
export default {
data() {
return {
project: null,
projectCategories: null,
imageGallery: '',
validation: {}
}
},
mixins: [axiosUploadProcess],
computed: {
title() {
return this.$route.params.post === 'new' ? 'افزودن پست' : 'مشاهده پست'
},
availableTags() {
return this.projectCategories.find(item => item._id === this.project.category)?.tags || []
}
},
methods: {
addImage() {
this.validation = {}
const data = new FormData()
data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/projectImage/${this.project._id}`, data)
.then(response => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت افزوده شد.'
})
this.$refs.image.value = null
this.imageGallery = ''
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
},
removeImage(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/projectImage/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'تصویر با موفقیت حذف شد'
})
this.project.images = this.project.images.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('fa_title', this.project.locale.fa.title || '')
data.append('en_title', this.project.locale.en.title || '')
data.append('fa_short_description', this.project.locale.fa.short_description || '')
data.append('en_short_description', this.project.locale.en.short_description || '')
data.append('fa_description', this.project.locale.fa.description || '')
data.append('en_description', this.project.locale.en.description || '')
data.append('fa_client', this.project.locale.fa.client || '')
data.append('en_client', this.project.locale.en.client || '')
data.append('fa_size', this.project.locale.fa.size || '')
data.append('en_size', this.project.locale.fa.size || '')
data.append('fa_area', this.project.locale.fa.area || '')
data.append('en_area', this.project.locale.fa.area || '')
data.append('fa_s3_title', this.project.locale.fa.s3_title || '')
data.append('en_s3_title', this.project.locale.en.s3_title || '')
data.append('fa_s3_description', this.project.locale.fa.s3_description || '')
data.append('en_s3_description', this.project.locale.en.s3_description || '')
data.append('fa_s5_title', this.project.locale.fa.s5_title || '')
data.append('en_s5_title', this.project.locale.en.s5_title || '')
data.append('fa_s5_description', this.project.locale.fa.s5_description || '')
data.append('en_s5_description', this.project.locale.en.s5_description || '')
data.append('fa_s6_title', this.project.locale.fa.s6_title || '')
data.append('en_s6_title', this.project.locale.en.s6_title || '')
data.append('fa_s6_description', this.project.locale.fa.s6_description || '')
data.append('en_s6_description', this.project.locale.en.s6_description || '')
data.append('category', this.project.category || '')
data.append('tag', this.project.tag || '')
data.append('has_details', this.project.has_details)
data.append('project_date', this.project.project_date)
if (this.$refs.cover.files[0]) data.append('cover', this.$refs.cover.files[0])
if (this.$refs.s2_image.files[0]) data.append('s2_image', this.$refs.s2_image.files[0])
if (this.$refs.s4_image.files[0]) data.append('s4_image', this.$refs.s4_image.files[0])
if (this.$refs.s5_image.files[0]) data.append('s5_image', this.$refs.s5_image.files[0])
if (this.$refs.s6_image.files[0]) data.append('s6_image', this.$refs.s6_image.files[0])
this.$axios.put(`/api/admin/project/${this.project._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.cover.value = null
this.$refs.s2_image.value = null
this.$refs.s4_image.value = null
this.$refs.s5_image.value = null
this.$refs.s6_image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
},
preview() {
this.project.cover = URL.createObjectURL(event.target.files[0])
},
preview2() {
this.project.s2_image = URL.createObjectURL(event.target.files[0])
},
preview3() {
this.project.s4_image = URL.createObjectURL(event.target.files[0])
},
preview4() {
this.project.s5_image = URL.createObjectURL(event.target.files[0])
},
preview5() {
this.project.s6_image = URL.createObjectURL(event.target.files[0])
},
preview6() {
this.imageGallery = URL.createObjectURL(event.target.files[0])
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const projectCategories = await $axios.get(`/api/public/projectCategories`)
const project = await $axios.get(`/api/public/project/${params.project}`)
return {
projectCategories: projectCategories.data,
project: project.data
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
<style lang="scss" scoped>
.images {
.image {
position: relative;
box-sizing: border-box;
text-align: center;
img {
width: 95%;
height: 100%;
object-fit: cover;
}
i {
padding: 15px;
background-color: rgba(red, 0.5);
color: #fff;
border-radius: 5px;
font-size: 25px;
cursor: pointer;
transition: 0.3s;
position: absolute;
bottom: 10px;
right: 20px;
&:hover {
background-color: red;
}
}
}
}
</style>
+157
View File
@@ -0,0 +1,157 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-projects-new'}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="projects"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="تصویر"
width="150">
<template slot-scope="scope">
<img :src="scope.row.thumb" alt="" style="width: 100%;">
</template>
</el-table-column>
<el-table-column
prop="locale.fa.title"
label="عنوان فارسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.title"
label="عنوان انگلیسی"
width="">
</el-table-column>
<el-table-column
prop="locale.en.client"
label="نام انگلیسی کارفرما"
width="">
</el-table-column>
<el-table-column
prop="locale.fa.client"
label="نام فارسی کارفرما"
width="">
</el-table-column>
<el-table-column
label="دسته بندی"
width="">
<template slot-scope="scope">
<span>{{ scope.row.category.locale.fa.name }}</span>
<span v-if="scope.row.tag"> ({{ getTagName(scope.row.category._id, scope.row.tag) }}) </span>
<span></span>
</template>
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-projects-project',params: {project: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست پروژه ها',
list_title: 'لیست',
projects: null,
projectCategories: null
}
},
methods: {
getTagName(categoryId, tagId) {
const category = this.projectCategories.find(item => item._id === categoryId)
return category?.tags?.find(item => item._id === tagId)?.locale.fa.name || ''
},
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/project/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'پروژه با موفقیت حذف شد'
})
this.projects = this.projects.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const projects = await $axios.get(`/api/public/projects`)
const projectCategories = await $axios.get(`/api/public/projectCategories`)
return {
projects: projects.data,
projectCategories: projectCategories.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+151
View File
@@ -0,0 +1,151 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-projects'}">برگشت به صفحه قبل</CButton>
<CButton size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<CRow>
<CCol sm="12">
<p>دسته بندی</p>
<el-select v-model="project.category" filterable :class="validation.category? 'err' : null">
<el-option v-for="item in projectCategories" :label="item.locale.fa.name" :value="item._id" :key="item._id"/>
</el-select>
<p class="text-danger" v-if="validation.category">{{ validation.category.msg }}</p>
<el-divider></el-divider>
<p>دسته بندی زیر مجموعه</p>
<el-select v-model="project.tag" filterable clearable>
<el-option v-for="item in availableTags" :label="item.locale.fa.name" :value="item._id" :key="item._id"/>
</el-select>
<el-divider></el-divider>
<CInput
:class="validation.project_date ? 'err' : null"
label="سال اجرای پروژه (سال شمسی)"
placeholder="مثال: 1390"
:description="validation.project_date ? validation.project_date.msg : null"
v-model="project.project_date"
/>
<el-divider></el-divider>
<CInput
:class="validation.fa_title ? 'err' : null"
label="عنوان فارسی"
:description="validation.fa_title ? validation.fa_title.msg : null"
v-model="project.fa_title"
/>
<CInput
:class="validation.fa_client ? 'err' : null"
label="نام مشتری فارسی"
:description="validation.fa_client ? validation.fa_client.msg : null"
v-model="project.fa_client"
/>
<el-divider></el-divider>
<CInput
:class="validation.en_title ? 'err' : null"
label="عنوان انگلیسی"
:description="validation.en_title ? validation.en_title.msg : null"
v-model="project.en_title"
/>
<CInput
:class="validation.en_client ? 'err' : null"
label="نام مشتری انگلیسی"
:description="validation.en_client ? validation.en_client.msg : null"
v-model="project.en_client"
/>
<el-divider></el-divider>
<el-checkbox label="دارای صفحه توضیحات میباشد" v-model="project.has_details"/>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
title: 'افزودن پروژه جدید',
projectCategories: null,
project: {
fa_title: '',
en_title: '',
fa_client: '',
en_client: '',
has_details: false,
category: '',
tag: ''
},
validation: {}
}
},
computed: {
availableTags() {
return this.projectCategories.find(item => item._id === this.project.category)?.tags || []
}
},
methods: {
post() {
this.validation = {}
this.$axios.post(`/api/admin/project`, this.project)
.then(response => {
this.$message({
type: 'success',
message: 'محصول با موفقیت ایجاد شد.'
})
if (this.project.has_details) this.$router.push({name: 'admin-projects-project', params: {project: response.data._id}})
else this.$router.push({name: 'admin-projects'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
},
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const projectCategories = await $axios.get(`/api/public/projectCategories`)
return {
projectCategories: projectCategories.data
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+265
View File
@@ -0,0 +1,265 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin'}">برگشت به صفحه قبل</CButton>
<!-- <CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>-->
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه درباره ما</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه درباره ما</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/aboutUS`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.aboutUS && !setting.aboutUS.includes('undefined')" :src="setting.aboutUS" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.aboutUS">{{ validation.aboutUS.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه فعالیت ها</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه فعالیت ها</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/activity`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.activity && !setting.activity.includes('undefined')" :src="setting.activity" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.activity">{{ validation.activity.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه پروژه ها</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه پروژه ها</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/projects`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.projects && !setting.projects.includes('undefined')" :src="setting.projects" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.projects">{{ validation.projects.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه گالری</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه گالری</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/gallery`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.gallery && !setting.gallery.includes('undefined')" :src="setting.gallery" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.gallery">{{ validation.gallery.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه کاتالوگ</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه کاتالوگ</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/catalog`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.catalog && !setting.catalog.includes('undefined')" :src="setting.catalog" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.catalog">{{ validation.catalog.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardHeader><h4>کاور صفحه رویداد</h4></CCardHeader>
<CCardBody>
<!-- <h2>کاور صفحه رویداد</h2>-->
<!-- <el-divider></el-divider>-->
<el-upload :show-file-list="false" :action="`/api/admin/setting/blogs`" class="avatar-uploader"
name="file"
:headers="{'Authorization' : `Bearer ${$auth.user.token}`}"
:on-success="fileUploadSuccess"
:on-progress="handleProcess" :on-error="fileUploadError">
<img v-if="setting.blogs && !setting.blogs.includes('undefined')" :src="setting.blogs" class="avatar" alt="">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<p class="mt-3 text-muted text-center">
عکس 600*1920 باشد. در غیر این صورت اتوماتیک بریده می شود.
</p>
<p class="text-danger text-center" v-if="validation.blogs">{{ validation.blogs.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
setting: null,
loading: false,
validation: {}
}
},
computed: {
title() {
return this.$route.params.team === 'new' ? 'افزودن عضو جدید' : 'مشاهده اطلاعات شخص'
}
},
methods: {
preview() {
this.team.image = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('index', this.team.index)
data.append('fa_first_name', this.team.locale.fa.first_name)
data.append('en_first_name', this.team.locale.en.first_name)
data.append('fa_last_name', this.team.locale.fa.last_name)
data.append('en_last_name', this.team.locale.en.last_name)
data.append('fa_position', this.team.locale.fa.position)
data.append('en_position', this.team.locale.en.position)
data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/team`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'عضو با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-team'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('index', this.team.index)
data.append('fa_first_name', this.team.locale.fa.first_name)
data.append('en_first_name', this.team.locale.en.first_name)
data.append('fa_last_name', this.team.locale.fa.last_name)
data.append('en_last_name', this.team.locale.en.last_name)
data.append('fa_position', this.team.locale.fa.position)
data.append('en_position', this.team.locale.en.position)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.put(`/api/admin/team/${this.team._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
fileUploadSuccess(res, file, fileList) {
this.loading = false;
this.$nuxt.refresh();
},
handleProcess(err, file, fileList) {
this.loading = true;
},
fileUploadError(err, file, fileList) {
this.validation = JSON.parse(err.message).validation;
},
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const setting = await $axios.$get(`/api/admin/setting`)
return {
setting
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+213
View File
@@ -0,0 +1,213 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-slider'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.slide === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<!-- <CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>-->
</CustomSubHeader>
<CRow>
<!-- <CCol lg="6">-->
<!-- <CCard>-->
<!-- <CCardBody>-->
<!-- <CForm>-->
<!-- <h4 class="mt-5">فارسی</h4>-->
<!-- <el-divider></el-divider>-->
<!-- <CInput-->
<!-- :class="validation.fa_name ? 'err' : null"-->
<!-- label="نام فارسی"-->
<!-- :description="validation.fa_name ? validation.fa_name.msg : null"-->
<!-- v-model="slide.locale.fa.name"-->
<!-- />-->
<!-- <CInput-->
<!-- :class="validation.fa_position ? 'err' : null"-->
<!-- label="سمت فارسی"-->
<!-- :description="validation.fa_position ? validation.fa_position.msg : null"-->
<!-- v-model="slide.locale.fa.position"-->
<!-- />-->
<!-- <CTextarea-->
<!-- :class="validation.fa_slide ? 'err' : null"-->
<!-- label="کامنت فارسی"-->
<!-- :description="validation.fa_slide ? validation.fa_slide.msg : null"-->
<!-- v-model="slide.locale.fa.slide"-->
<!-- />-->
<!-- <h4 class="mt-5">انگلیسی</h4>-->
<!-- <el-divider></el-divider>-->
<!-- <CInput-->
<!-- :class="validation.en_name ? 'err' : null"-->
<!-- label="نام انگلیسی"-->
<!-- :description="validation.en_name ? validation.en_name.msg : null"-->
<!-- v-model="slide.locale.en.name"-->
<!-- />-->
<!-- <CInput-->
<!-- :class="validation.en_position ? 'err' : null"-->
<!-- label="سمت انگلیسی"-->
<!-- :description="validation.en_position ? validation.en_position.msg : null"-->
<!-- v-model="slide.locale.en.position"-->
<!-- />-->
<!-- <CTextarea-->
<!-- :class="validation.en_slide ? 'err' : null"-->
<!-- label="کامنت انگلیسی"-->
<!-- :description="validation.en_slide ? validation.en_slide.msg : null"-->
<!-- v-model="slide.locale.en.slide"-->
<!-- />-->
<!-- </CForm>-->
<!-- </CCardBody>-->
<!-- </CCard>-->
<!-- </CCol>-->
<CCol sm="12">
<CCard>
<CCardBody>
<el-switch style="direction: ltr" v-model="slide.isImage" active-text="عکس" inactive-text="ویدیو" inactive-color="#ff4949"></el-switch>
</CCardBody>
</CCard>
</CCol>
<CCol v-if="slide.isImage" lg="6">
<CCard>
<CCardBody>
<h2>عکس</h2>
<el-divider></el-divider>
<img :src="slide.image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
<CCol v-else lg="6">
<CCard>
<CCardBody>
<h2>ویدیو</h2>
<el-divider></el-divider>
<video :src="slide.video" style="width: 100%;max-width: 600px;" controls muted autoplay></video>
<input type="file" ref="video" @change="preview2">
<p class="text-danger" v-if="validation.video">{{ validation.video.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
import axiosUploadProcess from "~/mixins/axiosUploadProcess"
export default {
data() {
return {
slide: null,
validation: {}
}
},
mixins: [axiosUploadProcess],
computed: {
title() {
return this.$route.params.slide === 'new' ? 'افزودن اسلاید جدید' : 'مشاهده اطلاعات اسلاید'
}
},
methods: {
preview() {
this.slide.image = URL.createObjectURL(event.target.files[0])
},
preview2() {
this.slide.video = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('isImage', this.slide.isImage)
if (this.slide.isImage) data.append('image', this.$refs.image.files[0])
else data.append('video', this.$refs.video.files[0])
this.$axios.post(`/api/admin/slide`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اسلاید با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-slider'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
},
// update() {
// this.validation = {}
// const data = new FormData()
// data.append('fa_name', this.slide.locale.fa.name)
// data.append('en_name', this.slide.locale.en.name)
//
// data.append('fa_position', this.slide.locale.fa.position)
// data.append('en_position', this.slide.locale.en.position)
//
// data.append('fa_slide', this.slide.locale.fa.slide)
// data.append('en_slide', this.slide.locale.en.slide)
//
// if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
//
// this.$axios.put(`/api/admin/slide/${this.slide._id}`, data, this.axiosConfig)
// .then(response => {
// this.$message({
// type: 'success',
// message: 'اطلاعات بروزرسانی شد.'
// })
// this.$refs.image.value = null
// this.$nuxt.refresh()
// })
// .catch(err => {
// if (err.response.status === 401) {
// return this.$message({
// type: 'error',
// message: 'لطفا دوباره وارد سیستم شوید.'
// })
// }
// if (err.response.status === 422) this.validation = err.response.data.validation
// else console.log(err.response.data)
// })
// }
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
if (params.slide !== 'new') {
const slide = await $axios.get(`/api/public/slide/${params.slide}`)
return {
slide: slide.data
}
} else {
return {
slide: {
isImage: true,
image: '',
video: ''
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+126
View File
@@ -0,0 +1,126 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-slider-slide',params:{slide: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="slides"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="مدیا"
width="250">
<template slot-scope="scope">
<img v-if="scope.row.isImage" :src="scope.row.image" alt="" style="width: 100%;">
<video v-else :src="scope.row.video" style="width: 100%;" controls muted></video>
</template>
</el-table-column>
<el-table-column
label="نوع"
width="">
<template slot-scope="scope">
<span v-if="scope.row.isImage">عکس</span>
<span v-else>ویدیو</span>
</template>
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<!-- <CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-slider-slide',params: {slide: scope.row._id}}">-->
<!-- <i class="far fa-eye"></i>-->
<!-- </CButton>-->
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست اسلاید های صفحه اصلی',
list_title: 'لیست',
slides: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/slide/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'مورد با موفقیت حذف شد'
})
this.slides = this.slides.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const slides = await $axios.get(`/api/public/slides`)
return {
slides: slides.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>
+223
View File
@@ -0,0 +1,223 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{name: 'admin-team'}">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.team === 'new'" size="sm" color="success" class="mr-1" @click="post">افزودن</CButton>
<CButton v-else size="sm" color="success" class="mr-1" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
<CCol lg="6">
<CCard>
<CCardBody>
<CForm>
<h4>شماره ترتیب نمایش</h4>
<el-divider></el-divider>
<el-select v-model="team.index" filterable>
<el-option v-for="index in 10000" :key="index" :label="index" :value="index" v-if="checkIndexes(index)"/>
</el-select>
<p class="text-danger" v-if="validation.index">{{ validation.index.msg }}</p>
<h4 class="mt-5">فارسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.fa_first_name ? 'err' : null"
label="نام فارسی"
:description="validation.fa_first_name ? validation.fa_first_name.msg : null"
v-model="team.locale.fa.first_name"
/>
<CInput
:class="validation.fa_last_name ? 'err' : null"
label="نام خانوادگی فارسی"
:description="validation.fa_last_name ? validation.fa_last_name.msg : null"
v-model="team.locale.fa.last_name"
/>
<CInput
:class="validation.fa_position ? 'err' : null"
label="سمت فارسی"
:description="validation.fa_position ? validation.fa_position.msg : null"
v-model="team.locale.fa.position"
/>
<h4 class="mt-5">انگلیسی</h4>
<el-divider></el-divider>
<CInput
:class="validation.en_first_name ? 'err' : null"
label="نام انگلیسی"
:description="validation.en_first_name ? validation.en_first_name.msg : null"
v-model="team.locale.en.first_name"
/>
<CInput
:class="validation.en_last_name ? 'err' : null"
label="نام خانوادگی انگلیسی"
:description="validation.en_last_name ? validation.en_last_name.msg : null"
v-model="team.locale.en.last_name"
/>
<CInput
:class="validation.en_position ? 'err' : null"
label="سمت انگلیسی"
:description="validation.en_position ? validation.en_position.msg : null"
v-model="team.locale.en.position"
/>
</CForm>
</CCardBody>
</CCard>
</CCol>
<CCol lg="6">
<CCard>
<CCardBody>
<h2>تصویر</h2>
<el-divider></el-divider>
<img :src="team.image" alt="" style="width: 100%;max-width: 600px;">
<input type="file" ref="image" @change="preview">
<p class="text-danger" v-if="validation.image">{{ validation.image.msg }}</p>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
data() {
return {
teams: null,
team: null,
validation: {}
}
},
computed: {
title() {
return this.$route.params.team === 'new' ? 'افزودن عضو جدید' : 'مشاهده اطلاعات شخص'
}
},
methods: {
preview() {
this.team.image = URL.createObjectURL(event.target.files[0])
},
post() {
this.validation = {}
const data = new FormData()
data.append('index', this.team.index)
data.append('fa_first_name', this.team.locale.fa.first_name)
data.append('en_first_name', this.team.locale.en.first_name)
data.append('fa_last_name', this.team.locale.fa.last_name)
data.append('en_last_name', this.team.locale.en.last_name)
data.append('fa_position', this.team.locale.fa.position)
data.append('en_position', this.team.locale.en.position)
data.append('image', this.$refs.image.files[0])
this.$axios.post(`/api/admin/team`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'عضو با موفقیت ایجاد شد.'
})
this.$router.push({name: 'admin-team'})
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) {
this.validation = err.response.data.validation
return this.$message({
type: 'warning',
message: 'پارامتر ها رو بررسی و دوباره تلاش کنید'
})
} else console.log(err.response.data)
})
},
update() {
this.validation = {}
const data = new FormData()
data.append('index', this.team.index)
data.append('fa_first_name', this.team.locale.fa.first_name)
data.append('en_first_name', this.team.locale.en.first_name)
data.append('fa_last_name', this.team.locale.fa.last_name)
data.append('en_last_name', this.team.locale.en.last_name)
data.append('fa_position', this.team.locale.fa.position)
data.append('en_position', this.team.locale.en.position)
if (this.$refs.image.files[0]) data.append('image', this.$refs.image.files[0])
this.$axios.put(`/api/admin/team/${this.team._id}`, data, this.axiosConfig)
.then(response => {
this.$message({
type: 'success',
message: 'اطلاعات بروزرسانی شد.'
})
this.$refs.image.value = null
this.$nuxt.refresh()
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err.response.data)
})
},
checkIndexes(index) {
return Boolean(!this.teams.filter(item => item.index === index).length)
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, params, error}) {
try {
const teams = await $axios.get(`/api/public/teams`)
if (params.team !== 'new') {
const team = await $axios.get(`/api/public/team/${params.team}`)
return {
teams: teams.data,
team: team.data
}
} else {
return {
teams: teams.data,
team: {
locale: {
fa: {
first_name: '',
last_name: '',
position: ''
},
en: {
first_name: '',
last_name: '',
position: ''
}
},
image: '',
index: ''
}
}
}
} catch (e) {
error({status: 404, message: 'page not found'})
}
}
}
</script>
+130
View File
@@ -0,0 +1,130 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="success" :to="{name: 'admin-team-team',params:{team: 'new'}}" class="mr-auto">افزودن</CButton>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<i class="fal fa-bars"></i>
<span>{{ list_title }}</span>
</slot>
</CCardHeader>
<CCardBody>
<el-table
:data="team"
style="width: 100%">
<el-table-column
type="index"
label="#">
</el-table-column>
<el-table-column
label="عکس"
width="200">
<template slot-scope="scope">
<img :src="scope.row.image" alt="" style="width: 100%;">
</template>
</el-table-column>
<el-table-column
label="نام و نام خانوادگی"
width="">
<template slot-scope="scope">
<span>{{ scope.row.locale.fa.first_name + ' ' + scope.row.locale.fa.last_name }}</span>
</template>
</el-table-column>
<el-table-column
prop="locale.fa.position"
label="سمت"
width="">
</el-table-column>
<el-table-column
label="ویرایش"
width="110"
align="center">
<template slot-scope="scope">
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
<i class="far fa-trash-alt"></i>
</CButton>
<CButton color="success" variant="outline" :key="scope.row._id" :to="{name: 'admin-team-team',params: {team: scope.row._id}}">
<i class="far fa-eye"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
data() {
return {
title: 'لیست اعضای تیم',
list_title: 'لیست',
team: null
}
},
methods: {
remove(id) {
this.$confirm('این مورد حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
}).then(async () => {
this.$axios.delete(`/api/admin/team/${id}`)
.then(res => {
this.$message({
type: 'success',
message: 'مورد با موفقیت حذف شد'
})
this.team = this.team.filter(item => item._id !== id)
})
.catch(err => {
if (err.response.status === 401) {
return this.$message({
type: 'error',
message: 'لطفا دوباره وارد سیستم شوید.'
})
}
if (err.response.status === 403) {
return this.$message({
type: 'error',
message: err.response.data.message
})
} else console.log(err.response.data)
})
}).catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
},
head() {
return {
title: this.title
}
},
layout: 'admin',
async asyncData({$axios, error}) {
try {
const team = await $axios.get(`/api/public/teams`)
return {
team: team.data
}
} catch (e) {
error({status: 500, message: 'there is a problem here'})
}
}
}
</script>