fix surveys
This commit is contained in:
@@ -71,7 +71,7 @@ export default {
|
|||||||
layout: 'admin',
|
layout: 'admin',
|
||||||
async asyncData({ $axios, error }) {
|
async asyncData({ $axios, error }) {
|
||||||
try {
|
try {
|
||||||
const surveys = await $axios.$get(`/api/admin/surveys?type=0`)
|
const surveys = await $axios.$get(`/api/admin/surveys?type=1`)
|
||||||
return {
|
return {
|
||||||
surveys
|
surveys
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@
|
|||||||
<el-input v-model="form.deviceNumber" :class="validation.deviceNumber ? 'err' : null" placeholder="شماره سریال دستگاه"></el-input>
|
<el-input v-model="form.deviceNumber" :class="validation.deviceNumber ? 'err' : null" placeholder="شماره سریال دستگاه"></el-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-sm-12 mt-4">
|
<div class="col-lg-4 col-sm-12 mt-4">
|
||||||
<el-input v-model="form.receptionCode" :class="validation.receptionCode ? 'err' : null" placeholder="کد پذیرش"></el-input>
|
<el-input v-model="form.receptionCode" :class="validation.receptionCode ? 'err' : null" placeholder="کد پذیرش (اختیاری)"></el-input>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-12 col-sm-12 mt-4">
|
<div class="col-lg-12 col-sm-12 mt-4">
|
||||||
|
|||||||
+51
-19
@@ -150,7 +150,43 @@
|
|||||||
<p>{{ config.survey }}</p>
|
<p>{{ config.survey }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form class="form form_3" @submit.prevent="post">
|
<form class="form form_3" @submit.prevent="post">
|
||||||
|
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-lg-6 col-sm-12 mt-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label> نام و نام خانوادگی</label>
|
||||||
|
</div>
|
||||||
|
<el-input v-model="survey.fullName" :class="validation.fullName ? 'err' : null" placeholder="نام و نام خانوادگی"></el-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-sm-12 mt-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>کد ملی </label>
|
||||||
|
</div>
|
||||||
|
<el-input v-model="survey.national" :class="validation.national ? 'err' : null" placeholder="کد ملی"></el-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-sm-12 mt-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>شماره تلفن </label>
|
||||||
|
</div>
|
||||||
|
<el-input v-model="survey.phoneNumber" :class="validation.phoneNumber ? 'err' : null" placeholder="شماره تلفن"></el-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-sm-12 mt-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>ایمیل </label>
|
||||||
|
</div>
|
||||||
|
<el-input v-model="survey.email" :class="validation.email ? 'err' : null" placeholder="ایمیل"></el-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-sm-12 mt-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label> کد پذیرش (اختیاری)</label>
|
||||||
|
</div>
|
||||||
|
<el-input v-model="survey.code" :class="validation.code ? 'err' : null" placeholder="کد پذیرش (اختیاری)"></el-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-for="item in surveyOptions" :key="item.fieldName" class="mb-5" style="width: 100%">
|
<div v-for="item in surveyOptions" :key="item.fieldName" class="mb-5" style="width: 100%">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label>{{ item.title }}</label>
|
<label>{{ item.title }}</label>
|
||||||
@@ -198,7 +234,21 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
survey: this.initForm(),
|
survey: {
|
||||||
|
purchasedProduct: 0,
|
||||||
|
guaranteeWorkFlow: 0,
|
||||||
|
employeeResponsibility: 0,
|
||||||
|
serviceQuality: 0,
|
||||||
|
serviceTime: 0,
|
||||||
|
repairQuality: 0,
|
||||||
|
coast: 0,
|
||||||
|
code: '',
|
||||||
|
fullName: '',
|
||||||
|
national: '',
|
||||||
|
phoneNumber: '',
|
||||||
|
email: '',
|
||||||
|
description: ''
|
||||||
|
},
|
||||||
validation: {},
|
validation: {},
|
||||||
hasValidationError: false,
|
hasValidationError: false,
|
||||||
waiting: true
|
waiting: true
|
||||||
@@ -227,24 +277,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
initForm() {
|
|
||||||
const survey = {
|
|
||||||
purchasedProduct: 0,
|
|
||||||
guaranteeWorkFlow: 0,
|
|
||||||
employeeResponsibility: 0,
|
|
||||||
serviceQuality: 0,
|
|
||||||
serviceTime: 0,
|
|
||||||
repairQuality: 0,
|
|
||||||
coast: 0,
|
|
||||||
code: '',
|
|
||||||
fullName: '',
|
|
||||||
national: '',
|
|
||||||
phoneNumber: '',
|
|
||||||
email: '',
|
|
||||||
description: ''
|
|
||||||
}
|
|
||||||
return survey
|
|
||||||
},
|
|
||||||
post() {
|
post() {
|
||||||
if (this.disabledBtn) return
|
if (this.disabledBtn) return
|
||||||
this.$axios.$post('/api/public/survey', { ...this.survey }).then(res => {
|
this.$axios.$post('/api/public/survey', { ...this.survey }).then(res => {
|
||||||
|
|||||||
@@ -104,12 +104,22 @@ module.exports.getAllForUser = [
|
|||||||
|
|
||||||
module.exports.getAllForAdmin = [
|
module.exports.getAllForAdmin = [
|
||||||
(req, res) => {
|
(req, res) => {
|
||||||
Survey.find({type:req.query.type || 0})
|
|
||||||
.populate('user', 'first_name last_name')
|
// eslint-disable-next-line eqeqeq
|
||||||
.exec((err, data) => {
|
if(req.query.type == 1){
|
||||||
if (err) return res500(res, err)
|
Survey.find({type: 1 })
|
||||||
return res.json(data)
|
.exec((err, data) => {
|
||||||
})
|
if (err) return res500(res, err)
|
||||||
|
return res.json(data)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
Survey.find({type: 0 })
|
||||||
|
.populate('user', 'first_name last_name')
|
||||||
|
.exec((err, data) => {
|
||||||
|
if (err) return res500(res, err)
|
||||||
|
return res.json(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user