update:add ci cd files ==> do not edit those file
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user