-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
196 lines (175 loc) · 6.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui" />
</head>
<body>
<div id="app">
<v-app>
<v-main>
<v-container>
<v-dialog v-model="dialogEditar" max-width="1000">
<v-card>
<v-card-title class="headline">Editar Pessoa</v-card-title>
<v-card-text> </v-card-text>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.nome" label="Nome"></v-text-field>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.idade" label="Idade"></v-text-field>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.peso" label="Peso"></v-text-field>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="salvarEdicao()">
Salvar
</v-btn>
<v-btn color="blue darken-1" text @click="dialogEditar = false">
Fechar
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogAdicionar" max-width="1000">
<v-card>
<v-card-title class="headline">Adicionar nova pessoa
</v-card-title>
<v-card-text> </v-card-text>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.nome" label="Nome"></v-text-field>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.idade" label="Idade"></v-text-field>
<v-text-field name="name" class="ma-2" outlined dense v-model="pessoa.peso" label="Peso"></v-text-field>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="adicionar">
Salvar
</v-btn>
<v-btn color="blue darken-1" text @click="dialogAdicionar = false">
Fechar
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogApagar" max-width="1000">
<v-card>
<v-card-title class="headline">Apagar Pessoa "{{pessoa.nome}}"?
</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="red darken-1" dark @click="removerPessoa">
Apagar
</v-btn>
<v-btn color="blue darken-1" text @click="dialogApagar = false">
Fechar
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-card class="pa-4">
<v-row class="my-0 mx-0">
<v-col>
<h2>Lista de Pessoas</h2>
</v-col>
<v-col align="right" justify="center">
<v-btn color="success" @click="adicionarNovo()">Adicionar Novo
</v-btn>
</v-col>
</v-row>
<v-data-table :headers="headers" :items="pessoas" item-key="name" class="elevation-1">
<template v-slot:item.action="{ item }">
<v-icon small class="mr-2" @click="editarPessoa(item)">
mdi-pencil
</v-icon>
<v-icon small class="mr-2" @click="dialogApagar = true; pessoa = item">
mdi-delete
</v-icon>
</template>
</v-data-table>
</v-card>
</v-container>
</v-main>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
<script>
new Vue({
el: "#app",
vuetify: new Vuetify(),
data() {
return {
headers: [
{
text: "Nome",
align: "start",
value: "nome",
},
{
text: "Idade",
align: "start",
value: "idade",
},
{
text: "Peso",
align: "start",
value: "peso",
},
{
text: "",
align: "start",
value: "action",
},
],
pessoas: [
{
nome: "João",
idade: "80",
peso: "75KG",
},
{
nome: "Maria",
idade: "50",
peso: "55KG",
},
{
nome: "Joana",
idade: "55",
peso: "54KG",
},
],
pessoa: {},
index: 0,
dialogEditar: false,
dialogAdicionar: false,
dialogApagar: false,
};
},
methods: {
editarPessoa(pessoa) {
this.index = this.pessoas.findIndex((x) => x === pessoa);
this.pessoa = Object.assign({}, pessoa);
this.dialogEditar = true;
},
salvarEdicao() {
this.$set(this.pessoas, this.index, this.pessoa);
this.dialogEditar = false;
},
adicionarNovo() {
this.dialogAdicionar = true;
this.pessoa = {};
},
adicionar() {
this.pessoas.push(this.pessoa);
this.dialogAdicionar = false;
this.pessoa = {};
},
removerPessoa() {
this.index = this.pessoas.findIndex(
(x) => x === this.pessoa
);
this.$delete(this.pessoas, this.index);
this.dialogApagar = false;
},
},
});
</script>
</body>
</html>