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