Fix bug and update
This commit is contained in:
@@ -14,23 +14,28 @@
|
||||
<h6>متن اعلان:</h6>
|
||||
<el-divider></el-divider>
|
||||
<CForm>
|
||||
<CInput
|
||||
v-model="announcement.title"
|
||||
label="عنوان"
|
||||
horizontal
|
||||
:class="validation.title && 'err'"
|
||||
:disabled="!isNew"
|
||||
:description="validation.title && validation.title.msg"
|
||||
/>
|
||||
<CTextarea
|
||||
v-model="announcement.caption"
|
||||
label="متن"
|
||||
horizontal
|
||||
rows="5"
|
||||
:class="validation.caption && 'err'"
|
||||
:disabled="!isNew"
|
||||
:description="validation.caption && validation.caption.msg"
|
||||
/>
|
||||
<CInput v-model="announcement.title" label="عنوان" horizontal :class="validation.title && 'err'"
|
||||
:disabled="!isNew" :description="validation.title && validation.title.msg" />
|
||||
<CTextarea v-model="announcement.caption" label="متن" horizontal rows="5"
|
||||
:class="validation.caption && 'err'" :disabled="!isNew"
|
||||
:description="validation.caption && validation.caption.msg" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<label class="fl-r"> تصویر : </label>
|
||||
<label for="file" class="btn-upload">آپلود تصویر</label>
|
||||
<input id="file" ref="myFiles" style="display: none;" type="file" @change="setData" />
|
||||
</div>
|
||||
<div v-if="type === 'user'" class="col-12 mt-4 mr-3">
|
||||
<input id="flexCheckDefault" v-model="announcement.publicx" class="form-check-input" type="checkbox" />
|
||||
<label class="form-check-label" for="flexCheckDefault">
|
||||
عمومی
|
||||
</label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</CForm>
|
||||
<el-divider></el-divider>
|
||||
<h6>تاریخ منقضی شدن اعلان:</h6>
|
||||
@@ -40,15 +45,8 @@
|
||||
<p v-if="type === 'agent'" class="mb-4" style="font-size: 12px; color: gray">
|
||||
*زمانی که اعلان منقضی شود از لیست حذف نخواهد شد و فقط در پنل نمایندگان قابل مشاهده نخواهد بود.
|
||||
</p>
|
||||
<persian-date-picker
|
||||
v-model="expireDate"
|
||||
display-format="jYYYY/jMM/jDD"
|
||||
:min="today"
|
||||
format="x"
|
||||
:disabled="!isNew"
|
||||
placeholder="تاریخ را انتخاب کنید"
|
||||
color="#065495"
|
||||
/>
|
||||
<persian-date-picker v-model="expireDate" display-format="jYYYY/jMM/jDD" :min="today" format="x"
|
||||
:disabled="!isNew" placeholder="تاریخ را انتخاب کنید" color="#065495" />
|
||||
|
||||
<p v-if="validation.expireDate" style="color: red">{{ validation.expireDate.msg }}</p>
|
||||
</CCardBody>
|
||||
@@ -61,12 +59,8 @@
|
||||
<h6>وضعیت بازدید اعلان:</h6>
|
||||
<el-divider></el-divider>
|
||||
<div class="progressBar">
|
||||
<el-progress
|
||||
:text-inside="true"
|
||||
:stroke-width="26"
|
||||
:color="customColors"
|
||||
:percentage="seenPercentage"
|
||||
></el-progress>
|
||||
<el-progress :text-inside="true" :stroke-width="26" :color="customColors"
|
||||
:percentage="seenPercentage"></el-progress>
|
||||
</div>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
@@ -76,9 +70,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axiosUploadProcess from '@/mixins/axiosUploadProcess'
|
||||
|
||||
export default {
|
||||
name: 'AdminAnnouncementDetails',
|
||||
mixins: [axiosUploadProcess],
|
||||
|
||||
layout: 'admin',
|
||||
|
||||
async asyncData({ $axios, params, query, error }) {
|
||||
try {
|
||||
if (params.item !== 'new') {
|
||||
@@ -93,6 +92,8 @@ export default {
|
||||
} else {
|
||||
return {
|
||||
announcement: {
|
||||
publicx: false,
|
||||
image: '',
|
||||
title: '',
|
||||
caption: '',
|
||||
expireDate: '',
|
||||
@@ -160,10 +161,22 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setData(event) {
|
||||
|
||||
this.announcement.image = this.$refs.myFiles.files[0];
|
||||
console.log(event)
|
||||
},
|
||||
post() {
|
||||
this.validation = {}
|
||||
const data = new FormData()
|
||||
data.append('title', this.announcement.title)
|
||||
data.append('caption', this.announcement.caption)
|
||||
data.append('isForAgents', this.announcement.isForAgents)
|
||||
data.append('publicx', this.announcement.publicx)
|
||||
data.append('expireDate', this.announcement.expireDate)
|
||||
data.append('image', this.$refs.myFiles.files[0])
|
||||
this.$axios
|
||||
.post('/api/admin/announcements', this.announcement)
|
||||
.post('/api/admin/announcements', data, this.axiosConfig)
|
||||
.then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
@@ -223,4 +236,17 @@ export default {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-upload {
|
||||
background-color: cornflowerblue;
|
||||
padding: .5rem 1rem;
|
||||
border-radius: .5rem;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.space {
|
||||
margin: 5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -120,37 +120,31 @@
|
||||
</CCard>
|
||||
</CCol>
|
||||
|
||||
<CCol lg="6">
|
||||
<CCol lg="12">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<h6>اطلاعات مشتری:</h6>
|
||||
<el-divider></el-divider>
|
||||
<CForm>
|
||||
<CInput label="نام مشتری" horizontal disabled :value="user.first_name + ' ' + user.last_name" />
|
||||
<CInput label="کد ملی" horizontal disabled :value="user.national_code" />
|
||||
<CInput label="شماره تلفن" horizontal disabled :value="user.tel_number" />
|
||||
<CInput label="شماره موبایل" horizontal disabled :value="user.mobile_number" />
|
||||
<CInput label="ایمیل" horizontal disabled :value="user.email" />
|
||||
<CInput label="نام فروشگاه" horizontal disabled :value="user.store_name" />
|
||||
<CForm class="row" style="justify-content: center;">
|
||||
<CInput v-model="user.first_name" class="col-6 col-sm-12" label="نام" horizontal :value="user.first_name" />
|
||||
<CInput v-model="user.last_name" class="col-6 col-sm-12" label="نام خانوادگی" horizontal :value=" user.last_name" />
|
||||
<CInput v-model="user.national_code" class="col-6 col-sm-12" label="کد ملی" horizontal :value="user.national_code" />
|
||||
<CInput v-model="user.tel_number" class="col-6 col-sm-12" label="شماره تلفن" horizontal :value="user.tel_number" />
|
||||
<CInput v-model="user.mobile_number" class="col-6 col-sm-12" label="شماره موبایل" horizontal :value="user.mobile_number" />
|
||||
<CInput v-model="user.email" class="col-6 col-sm-12" label="ایمیل" horizontal :value="user.email" />
|
||||
<CInput v-model="user.store_name" class="col-6 col-sm-12" label="نام فروشگاه" horizontal :value="user.store_name" />
|
||||
<CInput v-model="user.province_name" class="col-6 col-sm-12" label="استان" horizontal :value="user.province_name" />
|
||||
<CInput v-model="user.city_name" class="col-6 col-sm-12" label="شهر" horizontal :value="user.city_name" />
|
||||
<CTextarea v-model="user.address" class="col-6 col-sm-12" label="آدرس" horizontal rows="5" :value="user.address" />
|
||||
<CInput v-model="user.postal_code" class="col-6 col-sm-12" label="کد پستی" horizontal :value="user.postal_code" />
|
||||
|
||||
<CButton color="success" style="width: 10%; " @click="update" >بروزرسانی</CButton>
|
||||
|
||||
</CForm>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
|
||||
<CCol lg="6">
|
||||
<CCard>
|
||||
<CCardBody>
|
||||
<h6>آدرس مشتری</h6>
|
||||
<el-divider></el-divider>
|
||||
<CForm>
|
||||
<CInput label="استان" horizontal disabled :value="user.province_name" />
|
||||
<CInput label="شهر" horizontal disabled :value="user.city_name" />
|
||||
<CTextarea label="آدرس" horizontal disabled rows="5" :value="user.address" />
|
||||
<CInput label="کد پستی" horizontal disabled :value="user.postal_code" />
|
||||
</CForm>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
</CRow>
|
||||
</div>
|
||||
</template>
|
||||
@@ -190,6 +184,20 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
update(){
|
||||
this.$axios.put(`/api/admin/user/update/${this.user._id}`,this.user).then((res)=>{
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'اطالاعات جدید در سیستم ثبت شد'
|
||||
})
|
||||
this.$nuxt.refresh()
|
||||
|
||||
}).catch((err) =>{
|
||||
|
||||
if (err.response.status === 422) this.validation = err.response.data.validation
|
||||
else console.log(err)
|
||||
})
|
||||
},
|
||||
updateVerityInfo() {
|
||||
this.validation = {}
|
||||
this.$confirm(
|
||||
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
tickets: tickets.data
|
||||
}
|
||||
} catch (err) {
|
||||
error({ status: 404, message: 'There is a problem here' })
|
||||
error({ status: 404, message: 'There is a problem here', log: err })
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
Reference in New Issue
Block a user