Skip to content

Commit 56267fa

Browse files
committed
Editar Areas y Editar Equipos Funciona
1 parent 08ee841 commit 56267fa

File tree

9 files changed

+425
-15
lines changed

9 files changed

+425
-15
lines changed

client/src/components/Areas/cardAreas.vue

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
<div>
1414
<span><b>Actividad:</b> {{actividad}}</span><br>
1515
<b>Descripción:</b> {{descripcion}} <br>
16+
<b>Metros Cuadrados:</b> {{areaMetrosCuadrados}} <br>
1617
<v-btn
1718
fab
1819
dark
1920
small
2021
color="blue"
21-
@click="visualizarEditar(puestos, areasId)"
22+
@click="visualizarEditar()"
2223
>
2324
<v-icon>edit</v-icon>
2425
</v-btn>
@@ -85,12 +86,16 @@
8586
:areaNombre="areaNombre"
8687
@close="visiblePuestos=false">
8788
</DialogPuestosFromAreas>
88-
<!--DialogEditarAreas
89+
<DialogEditarAreas
8990
:visible="visibleEdicion"
9091
:areaId="areaId"
9192
:areaNombre="areaNombre"
93+
:areaActividad="areaActividad"
94+
:areaDescripcion="areaDescripcion"
95+
:areaMetrosCuadrados="metrosCuadrados"
96+
:areaFotoUrl="areaFotoUrl"
9297
@close="visibleEdicion=false">
93-
</DialogEditarAreas-->
98+
</DialogEditarAreas>
9499
<DialogCapacitacionesFromAreas
95100
:visible="visibleCapacitaciones"
96101
:areaId="areaId"
@@ -107,12 +112,12 @@ import DialogNovedadesFromAreas from '../Novedades/DialogNovedadesFromAreas'
107112
import DialogEquiposFromAreas from '../Equipos/DialogEquiposFromAreas'
108113
import DialogRiesgosFromPuestos from '../Riesgos/DialogRiesgosFromPuestos'
109114
import DialogPuestosFromAreas from '../DialogPuestosFromAreas'
110-
// import DialogEditarAreas from '../Editar/DialogEditarAreas'
115+
import DialogEditarAreas from '../Editar/DialogEditarAreas'
111116
import DialogCapacitacionesFromAreas from '../DialogCapacitacionesFromAreas'
112117
export default{
113-
components: {DialogNovedadesFromAreas, DialogEquiposFromAreas, DialogRiesgosFromPuestos, DialogPuestosFromAreas, DialogCapacitacionesFromAreas},
118+
components: {DialogNovedadesFromAreas, DialogEquiposFromAreas, DialogRiesgosFromPuestos, DialogPuestosFromAreas, DialogCapacitacionesFromAreas, DialogEditarAreas},
114119
name: 'puestosPorArea',
115-
props: ['id', 'nombre', 'actividad', 'descripcion', 'numPuestos', 'numPersonas', 'numCapacitaciones', 'novedades', 'equipos'],
120+
props: ['id', 'nombre', 'actividad', 'descripcion', 'numPuestos', 'numPersonas', 'numCapacitaciones', 'novedades', 'equipos', 'areaMetrosCuadrados', 'fotoUrl'],
116121
data () {
117122
return {
118123
dumb: false,
@@ -123,13 +128,26 @@ export default{
123128
visibleCapacitaciones: false,
124129
areaId: '',
125130
areaNombre: '',
131+
areaActividad: '',
132+
metrosCuadrados: '',
133+
areaFotoUrl: '',
134+
areaDescripcion: '',
126135
mensajeSnackbar: '',
127136
color: '',
128137
snackbar: false,
129138
visibleEdicion: false
130139
}
131140
},
132141
methods: {
142+
visualizarEditar () {
143+
this.areaId = this.id
144+
this.areaActividad = this.actividad
145+
this.areaDescripcion = this.descripcion
146+
this.areaFotoUrl = this.fotoUrl
147+
this.metrosCuadrados = this.areaMetrosCuadrados
148+
this.areaNombre = this.nombre
149+
this.visibleEdicion = true
150+
},
133151
visualizarNovedades () {
134152
this.visibleNovedades = true
135153
},

client/src/components/Areas/verAreasDialog.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
:numCapacitaciones = "area.cantidadCapacitaciones"
2323
:novedades = "area.cantidadNovedades"
2424
:equipos = "area.cantidadEquipos"
25+
:areaMetrosCuadrados = "area.areaMetrosCuadrados"
26+
:fotoUrl = "area.areaFotoUrl"
2527
>
2628
</cardAreas>
2729
</v-flex>

client/src/components/Editar/DialogEditarAccidentes.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default {
161161
}
162162
}
163163
this.snackbar = true
164-
this.mensajeSnackbar = 'Capacitacion editada exitosamente.'
164+
this.mensajeSnackbar = 'Accidente editado exitosamente.'
165165
this.color = 'success'
166166
this.$emit('close')
167167
})
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<template>
2+
<main id="DialogEditarAreas">
3+
<v-dialog v-model="show" @keydown.esc="show=false" persistent max-width="600px">
4+
<v-card>
5+
<v-card-title>
6+
<span class="headline">Editar Área</span>
7+
</v-card-title>
8+
<v-card-text>
9+
<p>{{ this.equipoNombre }}</p>
10+
<v-form v-model="valid">
11+
<v-text-field
12+
v-model = "newNombre"
13+
label="Nombre" required
14+
:rules="[rules.required]"
15+
></v-text-field>
16+
<v-text-field
17+
v-model = "newActividad"
18+
label="Actividad" required
19+
:rules="[rules.required]"
20+
></v-text-field>
21+
<v-text-field
22+
v-model = "newDescripcion"
23+
label="Descripcion" required
24+
:rules="[rules.required]"
25+
></v-text-field>
26+
<v-text-field
27+
v-model = "newMetrosCuadrados"
28+
label="Metros Cuadrados" required
29+
:rules="[rules.required]"
30+
></v-text-field>
31+
</v-form>
32+
</v-card-text>
33+
<v-card-actions>
34+
<v-spacer></v-spacer>
35+
<v-btn color="blue darken-1" flat @click.native="show = false">Cerrar</v-btn>
36+
<v-btn color="blue darken-1" flat :disabled="!valid" @click = "edit ()">Editar</v-btn>
37+
</v-card-actions>
38+
</v-card>
39+
</v-dialog>
40+
<v-snackbar
41+
:timeout="3000"
42+
:multi-line="true"
43+
:color="color"
44+
:top="true"
45+
v-model="snackbar"
46+
>
47+
{{mensajeSnackbar}}
48+
</v-snackbar>
49+
</main>
50+
</template>
51+
<script>
52+
export default {
53+
data () {
54+
return {
55+
newDescripcion: '',
56+
newNombre: '',
57+
newActividad: '',
58+
newMetrosCuadrados: '',
59+
valid: false,
60+
mensajeSnackbar: '',
61+
color: '',
62+
snackbar: false,
63+
rules: {
64+
required: (value) => !!value || 'Campo Requerido.',
65+
RUC: (value) => value.length <= 13 || 'Deben ser 13 caracteres'
66+
}
67+
}
68+
},
69+
props: ['visible', 'areaNombre', 'areaDescripcion', 'areaActividad', 'areaMetrosCuadrados', 'areaFotoUrl', 'areaId'],
70+
watch: {
71+
nombre () {
72+
this.newNombre = this.nombre
73+
},
74+
descripcion () {
75+
this.newDescripcion = this.descripcion
76+
},
77+
actividad () {
78+
this.newActividad = this.actividad
79+
},
80+
metrosCuadrados () {
81+
this.newMetrosCuadrados = this.metrosCuadrados
82+
}
83+
},
84+
computed: {
85+
show: {
86+
get () {
87+
return this.visible
88+
},
89+
set (value) {
90+
if (!value) {
91+
this.$emit('close')
92+
}
93+
}
94+
},
95+
nombre: {
96+
get () {
97+
return this.areaNombre
98+
},
99+
set (value) {
100+
this.$data.newNombre = value
101+
}
102+
},
103+
descripcion: {
104+
get () {
105+
return this.areaDescripcion
106+
},
107+
set (vaule) {
108+
this.$data.newDescripcion = value
109+
}
110+
},
111+
actividad: {
112+
get () {
113+
return this.areaActividad
114+
},
115+
set (value) {
116+
this.$data.newActividad = value
117+
}
118+
},
119+
metrosCuadrados: {
120+
get () {
121+
return this.areaMetrosCuadrados
122+
},
123+
set () {
124+
this.$data.newMetrosCuadrados = value
125+
}
126+
}
127+
},
128+
methods: {
129+
edit () {
130+
let nombre = this.$data.newNombre
131+
let descripcionLugar = this.$data.newDescripcion
132+
let fotoUrl = this.areaFotoUrl
133+
let actividad = this.$data.newActividad
134+
let metrosCuadrados = this.$data.newMetrosCuadrados
135+
let areasId = this.areaId
136+
this.$store.dispatch('updateArea', {areasId, nombre, actividad, fotoUrl, metrosCuadrados, descripcionLugar })
137+
.then((resp) => {
138+
for (let i = 0; i < this.$store.getters.areas.length; i++) {
139+
let area = this.$store.getters.areas[i]
140+
if (area.id === areasId) {
141+
area.areaNombre = nombre
142+
area.areaActividad = actividad
143+
area.areaDescripcionLugar = descripcionLugar
144+
area.areaMetrosCuadrados = metrosCuadrados
145+
break
146+
}
147+
}
148+
this.snackbar = true
149+
this.mensajeSnackbar = 'Equipo editado exitosamente.'
150+
this.color = 'success'
151+
this.$emit('close')
152+
})
153+
.catch((err) => {
154+
this.color = 'error'
155+
this.snackbar = true
156+
this.mensajeSnackbar = err
157+
})
158+
}
159+
}
160+
}
161+
</script>
162+
<style>
163+
.izq {
164+
text-align: left;
165+
}
166+
</style>
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<template>
2+
<main id="DialogEditarEquipos">
3+
<v-dialog v-model="show" @keydown.esc="show=false" persistent max-width="600px">
4+
<v-card>
5+
<v-card-title>
6+
<span class="headline">Editar Equipo</span>
7+
</v-card-title>
8+
<v-card-text>
9+
<p>{{ this.equipoNombre }}</p>
10+
<v-form v-model="valid">
11+
<v-text-field
12+
v-model = "newDescripcion"
13+
label="Descripcion" required
14+
:rules="[rules.required]"
15+
></v-text-field>
16+
<v-text-field
17+
v-model = "newCantidad"
18+
label="Cantidad" required
19+
:rules="[rules.required]"
20+
></v-text-field>
21+
</v-form>
22+
</v-card-text>
23+
<v-card-actions>
24+
<v-spacer></v-spacer>
25+
<v-btn color="blue darken-1" flat @click.native="show = false">Cerrar</v-btn>
26+
<v-btn color="blue darken-1" flat :disabled="!valid" @click = "edit ()">Editar</v-btn>
27+
</v-card-actions>
28+
</v-card>
29+
</v-dialog>
30+
<v-snackbar
31+
:timeout="3000"
32+
:multi-line="true"
33+
:color="color"
34+
:top="true"
35+
v-model="snackbar"
36+
>
37+
{{mensajeSnackbar}}
38+
</v-snackbar>
39+
</main>
40+
</template>
41+
<script>
42+
export default {
43+
data () {
44+
return {
45+
newDescripcion: '',
46+
newCantidad: '',
47+
valid: false,
48+
mensajeSnackbar: '',
49+
color: '',
50+
snackbar: false,
51+
rules: {
52+
required: (value) => !!value || 'Campo Requerido.',
53+
RUC: (value) => value.length <= 13 || 'Deben ser 13 caracteres'
54+
}
55+
}
56+
},
57+
props: ['visible', 'equipoNombre', 'equipoCantidad', 'equipoId', 'equipoDescripcion', 'equipoFotoUrl'],
58+
watch: {
59+
cantidad () {
60+
this.newCantidad = this.cantidad
61+
},
62+
descripcion () {
63+
this.newDescripcion = this.descripcion
64+
}
65+
},
66+
computed: {
67+
show: {
68+
get () {
69+
return this.visible
70+
},
71+
set (value) {
72+
if (!value) {
73+
this.$emit('close')
74+
}
75+
}
76+
},
77+
cantidad: {
78+
get () {
79+
return this.equipoCantidad
80+
},
81+
set (value) {
82+
this.$data.newCantidad = value
83+
}
84+
},
85+
descripcion: {
86+
get () {
87+
return this.equipoDescripcion
88+
},
89+
set (vaule) {
90+
this.$data.newDescripcion = value
91+
}
92+
}
93+
},
94+
methods: {
95+
edit () {
96+
let nombre = this.equipoNombre
97+
let descripcion = this.$data.newDescripcion
98+
let fotoUrl = this.equipoFotoUrl
99+
let cantidad = Number(this.$data.newCantidad)
100+
let equiposId = this.equipoId
101+
this.$store.dispatch('updateEquipos', { nombre, descripcion, fotoUrl, cantidad, equiposId })
102+
.then((resp) => {
103+
for (let i = 0; i < this.$store.getters.equipoAreas.length; i++) {
104+
let equipo = this.$store.getters.equipoAreas[i]
105+
if (equipo.id === equiposId) {
106+
equipo.descripcion = descripcion
107+
equipo.cantidad = cantidad
108+
break
109+
}
110+
}
111+
this.snackbar = true
112+
this.mensajeSnackbar = 'Equipo editado exitosamente.'
113+
this.color = 'success'
114+
this.$emit('close')
115+
})
116+
.catch((err) => {
117+
this.color = 'error'
118+
this.snackbar = true
119+
this.mensajeSnackbar = err
120+
})
121+
}
122+
}
123+
}
124+
</script>
125+
<style>
126+
.izq {
127+
text-align: left;
128+
}
129+
</style>

0 commit comments

Comments
 (0)