cuestionario completo, api en local

This commit is contained in:
eithan
2021-01-02 17:06:57 -06:00
parent b33e38de7a
commit 1a7c073eaf
2 changed files with 96 additions and 55 deletions
+2
View File
@@ -325,6 +325,8 @@ export default {
this.alumno.cuenta = localStorage.getItem('usuario')
window.localStorage.setItem('idCuestionarioAlumno', resp.data.idCuestionarioAlumno)
window.localStorage.setItem('idServicio', resp.data.idServicio)
})
.catch((error) => {
console.log(error.message)
+94 -55
View File
@@ -34,7 +34,17 @@
</b-field>
<div class="field is-flex is-flex-direction-column SINO">
<p>¿Cuentas con algún servicio médico?</p>
<b-radio
<div v-for="(Sm) in servicioMedicoOptions" :key="Sm" class="SINO">
<b-radio
v-model="answers.servicioMedicoAux"
:native-value="Sm"
type="is-info"
> {{Sm}} </b-radio>
</div>
<!-- <b-radio
@click="answers.servicioMedicoOtro= ''"
v-model="answers.servicioMedico"
native-value="IMSS"
type="is-info"
@@ -42,6 +52,7 @@
IMSS
</b-radio>
<b-radio
@click="answers.servicioMedicoOtro= ''"
v-model="answers.servicioMedico"
native-value="ISSSTE"
type="is-info"
@@ -49,6 +60,7 @@
ISSSTE
</b-radio>
<b-radio
@click="answers.servicioMedicoOtro= ''"
v-model="answers.servicioMedico"
native-value="Ninguno"
type="is-info"
@@ -56,16 +68,18 @@
Ninguno
</b-radio>
<b-radio
@click="answers.servicioMedicoOtro= ''"
v-model="answers.servicioMedico"
native-value="Otro"
type="is-info"
>
Otro
</b-radio>
</b-radio> -->
<b-field>
<b-input
placeholder="Otro servicio medico"
:disabled="answers.servicioMedico !== 'Otro'"
:disabled="answers.servicioMedicoAux !== 'Otro'"
v-model="answers.servicioMedicoOtro"
></b-input>
</b-field>
@@ -102,12 +116,14 @@
3.Señala los tres principales criterios que utilizaste para seleccionar
el programa de servicio social:
</p>
<div v-for="(b3) in b3Options" :key="b3" class="SINO">
<input class="checkb" type="checkbox" :value="b3" v-model="answers.p3" :disabled="maxCheckbox >=3" @change="max()">
<div v-for="(b3,index) in b3Options" :key="b3" class="SINO">
<input class="checkb" type="checkbox" :value="index" v-model="answers.p3" :disabled="maxCheckbox >=3 || (maxCheckbox >=2 && answers.p3Otro != '')" @change="max()">
{{ b3 }}
</div>
<b-field>
<b-input
@change="max()"
:disabled="maxCheckbox >=3"
placeholder="Otro (especificar)"
v-model="answers.p3Otro"
></b-input>
@@ -153,7 +169,7 @@
<td>
<b-radio
v-model="answers.p5[index]"
native-value="true"
native-value="s"
type="is-info"
>
</b-radio>
@@ -161,7 +177,7 @@
<td>
<b-radio
v-model="answers.p5[index]"
native-value="false"
native-value="n"
type="is-info"
>
</b-radio>
@@ -218,7 +234,7 @@
<td>
<b-radio
v-model="answers.p8[index]"
native-value="true"
native-value="s"
type="is-info"
>
</b-radio>
@@ -226,7 +242,7 @@
<td>
<b-radio
v-model="answers.p8[index]"
native-value="false"
native-value="n"
type="is-info"
>
</b-radio>
@@ -330,7 +346,7 @@
<td>
<b-radio
v-model="answers.p14[index]"
native-value="true"
native-value="s"
type="is-info"
>
</b-radio>
@@ -338,7 +354,7 @@
<td>
<b-radio
v-model="answers.p14[index]"
native-value="false"
native-value="n"
type="is-info"
>
</b-radio>
@@ -365,7 +381,7 @@
<td>
<b-radio
v-model="answers.p15[index]"
native-value="true"
native-value="s"
type="is-info"
>
</b-radio>
@@ -373,7 +389,7 @@
<td>
<b-radio
v-model="answers.p15[index]"
native-value="false"
native-value="n"
type="is-info"
>
</b-radio>
@@ -388,13 +404,13 @@
16.De acuerdo al desarrollo del programa en el que participaste en cual
de las siguientes áreas lo enmarcas (Elige solo una)
</p>
<div v-for="d16 in d16Options"
<div v-for="(d16,index) in d16Options"
:key="d16">
<input
type="radio"
v-model="answers.p16"
class="checkb"
:value="d16"
:value="index"
native-value="true"
>
{{ d16 }}
@@ -419,8 +435,8 @@
v-model="answers.p17[index]"
>
<option
v-for="frec in frecuencia"
:value="frec"
v-for="(frec,i) in frecuencia"
:value="i"
:key="frec"
>
{{ frec }}
@@ -490,7 +506,7 @@
<td>
<b-radio
v-model="answers.p21[index]"
native-value="true"
native-value="s"
type="is-info"
>
</b-radio>
@@ -498,7 +514,7 @@
<td>
<b-radio
v-model="answers.p21[index]"
native-value="false"
native-value="n"
type="is-info"
>
</b-radio>
@@ -633,7 +649,7 @@
<td >
<b-field>
<b-select placeholder="Seleccionar" v-model="answers.p28">
<option v-for="adj in adjetivos" :key="adj" :value="adj">{{
<option v-for="(adj,i) in adjetivos" :key="adj" :value="i">{{
adj
}}</option>
@@ -658,7 +674,7 @@
<td>
<b-field>
<b-select placeholder="Seleccionar" v-model="answers.p29">
<option v-for="adj in adjetivos" :key="adj" :value="adj">{{
<option v-for="(adj,i) in adjetivos" :key="adj" :value="i">{{
adj
}}</option>
</b-select>
@@ -690,24 +706,31 @@
</div>
<div class="buttons px-auto is-justify-content-center">
<button class="navPages button is-info" @click="current=1" > A</button>
<button class="navPages button is-info" @click="current=2" :disabled="navB()" > B</button>
<button class="navPages button is-info" @click="current=3" :disabled="navC()"> C</button>
<button class="navPages button is-info" @click="current=4" :disabled="navD()"> D</button>
<button class="navPages button is-info" @click="current=5" :disabled="navE()"> E</button>
<button class="navPages button is-info" @click="current=6" :disabled="navF()"> F</button>
<b-button class="navPages button is-info is-light" tag="router-link" to="/alumno">
<b-icon
icon="home"
type="is-info">
</b-icon></b-button>
<button class="navPages button is-info" :class="{ active: current==1 }" @click="current=1" > A</button>
<button class="navPages button is-info" :class="{ active: current==2 }" @click="current=2" :disabled="navB()" > B</button>
<button class="navPages button is-info" :class="{ active: current==3 }" @click="current=3" :disabled="navC()"> C</button>
<button class="navPages button is-info" :class="{ active: current==4 }" @click="current=4" :disabled="navD()"> D</button>
<button class="navPages button is-info" :class="{ active: current==5 }" @click="current=5" :disabled="navE()"> E</button>
<button class="navPages button is-info" :class="{ active: current==6 }" @click="current=6" :disabled="navF()"> F</button>
</div>
</div>
<div v-else class="vh ">
<h1>Ya has contestado tu cuestionario :)</h1>
</div>
<pre>{{$data}}</pre>
</section>
</template>
<script>
import 'buefy/dist/buefy.css'
import moment from 'moment'
import axios from 'axios'
export default {
data () {
@@ -720,6 +743,7 @@ export default {
edad: '',
servicioMedico: '',
servicioMedicoOtro: '',
servicioMedicoAux:'',
p1: '',
p2: '',
p3: [], // selecciona 3 opciones
@@ -752,6 +776,13 @@ export default {
p29: null,
p30: ''
},
servicioMedicoOptions:[
'IMSS',
'ISSSTE',
'Ninguno',
'Otro'
],
b3Options: [
'Actividades descritas en el programa',
'Apoyo económico',
@@ -857,11 +888,13 @@ export default {
this.maxCheckbox += 1
},
navB () {
if(this.answers.sexo !=='' && this.answers.edad !== '' && this.answers.servicioMedico !== '') return false
if(this.answers.sexo !=='' && this.answers.edad !== '' && this.answers.servicioMedico !== '')
if(this.answers.servicioMedico == 'Otro' && !this.answers.servicioMedicoOtro) return true
else return false
else return true
},
navC () {
if(this.answers.p1 !=='' && this.answers.p2 !=='' && this.maxCheckbox == 3) return false
if(this.answers.p1 !=='' && this.answers.p2 !=='' && (this.maxCheckbox == 3 || this.maxCheckbox == 2 && this.answers.p3Otro !=='')) return false
else return true
},
navD () {
@@ -876,36 +909,27 @@ export default {
if(this.answers.p19 && this.answers.p18 && this.answers.p20 && this.answers.p21[0] != null && this.answers.p21[1] != null && this.answers.p21[2] != null && this.answers.p21[3] != null && this.answers.p21[4] != null ) return false
else return true
},
available(){
console.log(this.answers.p5[0])
if( this.answers.p5[0] !== null){
console.log("se activa boton")
return false // activar boton
}
else
return true
if( this.answers.p22.length ==8 && this.answers.p23.length ==3 && this.answers.p24.length ==3 && this.answers.p25 && this.answers.p26 && this.answers.p27 && this.answers.p28 !== null && this.answers.p29 !== null && this.answers.p30) return false // activar boton
else return true
},
enviarCuestionario () {
const loadingComponent = this.$buefy.loading.open({
container: this.isFullPage ? null : this.$refs.element.$el
})
if (this.answers.p3Otro != '' && this.maxCheckbox < 3) {
console.log("agregarotro");
(this.answers.p3).push(this.answers.p3Otro);
}
const data = {
idServicio: this.alumno.idServicio,
direccion: this.direccion,
telefono: this.telefono,
fechaNacimiento: moment(this.nacimiento)
idServicio: localStorage.getItem('idServicio'),
asnwers: this.answers
}
console.log(data)
axios
.put(`${process.env.api}/servicio/registro_validado`, data)
.post(`${process.env.api}/cuestionario_alumno`, data)
.then((res) => {
loadingComponent.close()
this.$buefy.dialog.alert({
title: 'Success',
message: 'Se enviaron los datos correctamente',
@@ -918,10 +942,10 @@ export default {
})
//this.reset()
//this.getData()
this.$router.push('/alumno')
})
.catch((error) => {
loadingComponent.close()
this.$buefy.dialog.alert({
title: 'Error',
message: error.response.data.message,
@@ -937,8 +961,20 @@ export default {
},
mounted () {
this.idCuestionario = localStorage.getItem('idCuestionarioAlumno')
console.log(this.idCuestionario)
console.log("este es el id del cuestionario:" + this.idCuestionario)
},
watch:{
'answers.servicioMedicoAux' () {
this.answers.servicioMedicoOtro = ''
this.answers.servicioMedico = this.answers.servicioMedicoAux
},
'answers.servicioMedicoOtro' () {
this.answers.servicioMedico = this.answers.servicioMedicoOtro
},
}
}
</script>
<style scoped>
@@ -972,4 +1008,7 @@ export default {
.vh h1{
font-size: 60px;
}
.active, .active:hover{
background-color:#bb8800;
}
</style>