@nixweb/nixloc-ui 0.0.95 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixweb/nixloc-ui",
3
- "version": "0.0.95",
3
+ "version": "0.0.96",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -52,7 +52,21 @@ export default {
52
52
  components: { Dica, DatePicker },
53
53
  name: "Data",
54
54
  mixins: [],
55
- props: {
55
+ props: [
56
+ "titulo",
57
+ "campo",
58
+ "campoAlvo",
59
+ "placeholder",
60
+ "formNome",
61
+ "requerido",
62
+ "format",
63
+ "type",
64
+ "value",
65
+ "range",
66
+ "confirm",
67
+ "confirmText",
68
+ ],
69
+ /* props: {
56
70
  titulo: String,
57
71
  campo: String,
58
72
  campoAlvo: String,
@@ -65,7 +79,7 @@ export default {
65
79
  range: Boolean,
66
80
  confirm: Boolean,
67
81
  confirmText: String,
68
- },
82
+ },*/
69
83
  data() {
70
84
  return {
71
85
  notificacoes: [],
@@ -152,7 +166,6 @@ export default {
152
166
  </script>
153
167
 
154
168
  <style scoped>
155
-
156
169
  .sucesso {
157
170
  color: #94aa2a;
158
171
  font-size: 14px;
@@ -37,11 +37,11 @@
37
37
  <span
38
38
  :class="{
39
39
  'icone-ativo': menuAtivo == item.modulo,
40
- 'icone-normal': menuAtivo != item.modulo
40
+ 'icone-normal': menuAtivo != item.modulo,
41
41
  }"
42
- > <i :class="item.icone"></i>
42
+ >
43
+ <i :class="item.icone"></i>
43
44
  </span>
44
-
45
45
  </div>
46
46
  <div class="titulo">{{ item.titulo }}</div>
47
47
  </a>
@@ -171,8 +171,8 @@ export default {
171
171
  }
172
172
 
173
173
  .div-logo {
174
- padding-top: 5px;
175
- padding-bottom: 15px;
174
+ padding-top: 2px;
175
+ padding-bottom: 16px;
176
176
  }
177
177
 
178
178
  .div-icone {
@@ -208,7 +208,7 @@ export default {
208
208
  }
209
209
 
210
210
  img {
211
- height: 27px;
211
+ height: 22px;
212
212
  margin-top: 10px;
213
213
  }
214
214
  </style>
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <div>
3
+ <div @click="executar()">
4
+ <slot></slot>
5
+ </div>
6
+ <Modal
7
+ :titulo="titulo"
8
+ :largura="450"
9
+ :altura="250"
10
+ v-show="mostrarModal(`confirmacao${dados.id}`)"
11
+ >
12
+ <b-col sm="12">
13
+ <div class="div-botao text-center">
14
+ <Botao
15
+ chave="confirmacaoNao"
16
+ tipo="editar"
17
+ titulo="cancelar"
18
+ tamanho="pequeno"
19
+ :clique="cancelar"
20
+ />
21
+ <Botao
22
+ chave="confirmacaoSim"
23
+ :tipo="tipo"
24
+ titulo="Sim, confirmar"
25
+ tamanho="medio"
26
+ :clique="confirmar"
27
+ />
28
+ </div>
29
+ </b-col>
30
+ </Modal>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
36
+ import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
37
+
38
+ import { mapGetters, mapMutations } from "vuex";
39
+
40
+ export default {
41
+ name: "Confirmacao",
42
+ components: {
43
+ Botao,
44
+ Modal,
45
+ },
46
+ props: {
47
+ titulo: String,
48
+ tipo: String,
49
+ dados: Object,
50
+ confirmado: Function,
51
+ },
52
+ methods: {
53
+ ...mapMutations("generic", ["abrirModal", "fecharModal", "removeCarregando"]),
54
+ executar() {
55
+ this.abrirModal(`confirmacao${this.dados.id}`);
56
+ },
57
+ confirmar() {
58
+ let self = this;
59
+ setTimeout(function () {
60
+ if (self.confirmado) self.confirmado(self.dados);
61
+ self.removeCarregando(["confirmacaoSim"]);
62
+ self.fecharModal();
63
+ }, 200);
64
+ },
65
+ cancelar() {
66
+ this.removeCarregando(["confirmacaoNao"]);
67
+ this.fecharModal();
68
+ },
69
+ },
70
+ computed: {
71
+ ...mapGetters("generic", ["mostrarModal", "evento"]),
72
+ },
73
+ };
74
+ </script>
75
+ <style scoped>
76
+ .div-botao {
77
+ padding-top: 20px;
78
+ height: 100px;
79
+ }
80
+ </style>
@@ -258,7 +258,7 @@ tr:hover {
258
258
  }
259
259
 
260
260
  .link {
261
- color: #0c63c0;
261
+ color: darkblue;
262
262
  font-size: 15px;
263
263
  font-weight: 400;
264
264
  cursor: pointer;
@@ -9,44 +9,49 @@
9
9
  >
10
10
  <div slot="conteudo-principal">
11
11
  <b-row>
12
- <!-- <b-col xs="12" sm="12" md="12" lg="5" xl="5">
13
- <div><i class="fas fa-star icone-favorito"></i> Favoritos</div>
12
+ <b-col xs="12" sm="12" md="12" lg="6" xl="6" v-if="todos.salvo.length > 0">
13
+ <div><i class="fas fa-file-alt icone-salvo"></i></i> Personalizado</div>
14
14
  <hr />
15
- <div class="div-moldura" v-for="relatorio in favoritos">
15
+ <div class="div-moldura" v-for="relatorio in todos.salvo">
16
16
  <div>
17
17
  <Moldura :bordaArredondada="12">
18
18
  <b-row>
19
- <b-col sm="10" @click="navegarPara(relatorio.nomeRota)">
19
+ <b-col sm="1">
20
+ <i class="fas fa-file-alt icone-report"></i>
21
+ </b-col>
22
+ <b-col sm="10" @click="navegarPara(relatorio)">
20
23
  <div>{{ relatorio.nome }}</div>
21
24
  </b-col>
22
- <b-col sm="2">
23
- <div class="text-right">
24
- <i class="fas fa-times-circle icone-remover"></i>
25
- </div>
25
+ <b-col sm="1">
26
+ <Confirmacao
27
+ titulo="Deseja excluir?"
28
+ tipo="perigo"
29
+ :dados="relatorio"
30
+ :confirmado="excluir"
31
+ >
32
+ <div class="text-right">
33
+ <i class="fas fa-times-circle icone-remover"></i>
34
+ </div>
35
+ </Confirmacao>
26
36
  </b-col>
27
37
  </b-row>
28
38
  </Moldura>
29
39
  </div>
30
40
  </div>
31
- </b-col> -->
32
- <b-col xs="12" sm="12" md="12" lg="5" xl="5">
33
- <div><i class="fas fa-list-ul"></i> Todos</div>
41
+ </b-col>
42
+ <b-col xs="12" sm="12" md="12" lg="6" xl="6">
43
+ <div><i class="fas fa-file-chart-line"></i> Padrão</div>
34
44
  <hr />
35
- <div class="div-moldura" v-for="relatorio in todos">
45
+ <div class="div-moldura" v-for="relatorio in todos.padrao">
36
46
  <div>
37
47
  <Moldura :bordaArredondada="12">
38
48
  <b-row>
39
49
  <b-col sm="1">
40
50
  <i class="fas fa-file-alt icone-report"></i>
41
51
  </b-col>
42
- <b-col sm="10" @click="navegarPara(relatorio.nomeRota)">
52
+ <b-col sm="11" @click="navegarPara(relatorio)">
43
53
  <div class="lado-a-lado">{{ relatorio.nome }}</div>
44
54
  </b-col>
45
- <!-- <b-col sm="2">
46
- <div class="text-right">
47
- <i class="fas fa-plus-circle icone-favorito"></i>
48
- </div>
49
- </b-col>-->
50
55
  </b-row>
51
56
  </Moldura>
52
57
  </div>
@@ -61,52 +66,115 @@
61
66
  <script>
62
67
  import Painel from "@nixweb/nixloc-ui/src/component/layout/Painel.vue";
63
68
  import Moldura from "@nixweb/nixloc-ui/src/component/layout/Moldura";
69
+ import Confirmacao from "@nixweb/nixloc-ui/src/component/shared/Confirmacao";
64
70
 
65
71
  import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
66
72
 
67
73
  export default {
68
74
  name: "ModeloRelatorioListaView",
69
- components: { Painel, Moldura },
75
+ components: { Painel, Moldura, Confirmacao },
70
76
  props: {
71
77
  painel: Object,
72
78
  relatorios: Object,
73
79
  },
74
80
  data() {
75
81
  return {
76
- todos: [],
82
+ todos: {},
83
+ urlObterTodos: "/api/v1/shared/relatorio/obter-todos",
84
+ urlRemover: "/api/v1/shared/relatorio/remover",
77
85
  };
78
86
  },
79
87
  computed: {
80
88
  ...mapState("generic", ["pesquisa", "buscouPesquisa", "limpouPesquisa"]),
81
89
  },
82
90
  mounted() {
83
- this.removeCarregando(["painel"]);
84
- this.todos = this.relatorios;
91
+ this.obterTodos();
92
+ this.todos = JSON.parse(JSON.stringify(this.relatorios)); // remove observable
85
93
  },
86
94
  methods: {
87
95
  ...mapMutations("generic", ["removeCarregando"]),
88
- navegarPara(nomeRota) {
96
+ ...mapMutations("relatorio", [
97
+ "atualizaFiltroSelecionado",
98
+ "atualizaCampoOrdenado",
99
+ "atualizaOpcoesValorInicial",
100
+ ]),
101
+ ...mapActions("generic", ["getApi", "deleteAllApi"]),
102
+ obterTodos() {
103
+ let obj = { modulo: this.painel.modulo };
104
+ let params = { url: this.urlObterTodos, obj: obj };
105
+ this.getApi(params).then((response) => {
106
+ this.todos.salvo = [];
107
+ let self = this;
108
+ response.conteudo.dados.forEach((item) => {
109
+ const consulta = JSON.parse(item.consulta);
110
+ let obj = {
111
+ id: item.id,
112
+ nome: item.nome,
113
+ nomeRota: consulta.nomeRota,
114
+ filtro: consulta.filtro,
115
+ campo: consulta.campo,
116
+ ordenacao: consulta.ordenacao,
117
+ };
118
+ self.todos.salvo.push(obj);
119
+ });
120
+ this.removeCarregando(["painel"]);
121
+ });
122
+ },
123
+ navegarPara(relatorio) {
124
+ if (relatorio.filtro) {
125
+ let filtroSelecionado = { logicalOperator: "all", children: relatorio.filtro };
126
+ this.atualizaOpcoesValorInicial(relatorio.campo);
127
+ this.atualizaCampoOrdenado(relatorio.ordenacao);
128
+ this.atualizaFiltroSelecionado(filtroSelecionado);
129
+ } else {
130
+ this.atualizaOpcoesValorInicial([]);
131
+ }
89
132
  this.$router.push({
90
- name: nomeRota,
133
+ name: relatorio.nomeRota,
134
+ });
135
+ },
136
+ excluir(dados) {
137
+ let selecionados = [];
138
+ selecionados.push(dados.id);
139
+
140
+ let params = {
141
+ url: this.urlRemover,
142
+ selecionados: selecionados,
143
+ };
144
+
145
+ this.deleteAllApi(params).then((reponse) => {
146
+ if (reponse.sucesso) this.obterTodos();
91
147
  });
92
148
  },
93
149
  },
94
150
  watch: {
95
151
  buscouPesquisa: function () {
96
- let filtro = [];
152
+ let padrao = [];
153
+ let salvo = [];
97
154
  let self = this;
98
155
  setTimeout(function () {
99
- self.todos.forEach(function (item) {
156
+ self.todos.padrao.forEach(function (item) {
157
+ if (self.pesquisa.filtro.conteudo == "igual") {
158
+ if (item.nome == self.pesquisa.conteudo) padrao.push(item);
159
+ }
160
+
161
+ if (self.pesquisa.filtro.conteudo == "contem") {
162
+ if (item.nome.includes(self.pesquisa.conteudo)) padrao.push(item);
163
+ }
164
+ });
165
+
166
+ self.todos.salvo.forEach(function (item) {
100
167
  if (self.pesquisa.filtro.conteudo == "igual") {
101
- if (item.nome == self.pesquisa.conteudo) filtro.push(item);
168
+ if (item.nome == self.pesquisa.conteudo) salvo.push(item);
102
169
  }
103
170
 
104
171
  if (self.pesquisa.filtro.conteudo == "contem") {
105
- if (item.nome.includes(self.pesquisa.conteudo)) filtro.push(item);
172
+ if (item.nome.includes(self.pesquisa.conteudo)) salvo.push(item);
106
173
  }
107
174
  });
108
175
 
109
- self.todos = filtro;
176
+ self.todos.salvo = salvo;
177
+ self.todos.padrao = padrao;
110
178
 
111
179
  self.removeCarregando(["pesquisar", "limpar"]);
112
180
  }, 300);
@@ -115,6 +183,7 @@ export default {
115
183
  let self = this;
116
184
  setTimeout(function () {
117
185
  self.todos = self.relatorios;
186
+ self.obterTodos();
118
187
  self.removeCarregando(["pesquisar", "limpar"]);
119
188
  }, 300);
120
189
  },
@@ -123,8 +192,8 @@ export default {
123
192
  </script>
124
193
 
125
194
  <style scoped>
126
- .icone-favorito {
127
- color: orange;
195
+ .icone-salvo {
196
+ color: #94aa2a;
128
197
  }
129
198
 
130
199
  .icone-remover {
@@ -132,7 +201,7 @@ export default {
132
201
  }
133
202
 
134
203
  .icone-report {
135
- font-size: 30px;
204
+ font-size: 25px;
136
205
  opacity: 0.2;
137
206
  color: #577696;
138
207
  }
@@ -17,6 +17,9 @@
17
17
  tamanho="medium"
18
18
  />
19
19
  </div>
20
+ <Modal titulo="Salvar" :largura="550" v-show="mostrarModal('salvar')">
21
+ <RelatorioAdicionarModificar :modulo="painel.modulo" />
22
+ </Modal>
20
23
  <Moldura>
21
24
  <div>
22
25
  <div slot="conteudo-filtro-horizontal">
@@ -112,11 +115,11 @@
112
115
  </Moldura>
113
116
  <div class="div-obrigatorio" v-show="invalido">
114
117
  <Alerta tipo="info" v-for="item in filtroObrigatorio" :key="item.id">
115
- É necessário informar o filtro <b>{{ item.label }}</b
118
+ É necessário informar o filtro
119
+ <span class="filtro-obrigatorio">{{ item.label }}</span
116
120
  >, clique no botão "Filtros" para adicionar.
117
121
  </Alerta>
118
122
  </div>
119
-
120
123
  <div class="div-tags">
121
124
  <Tags nomeEvento="tagRelatorio" />
122
125
  </div>
@@ -181,6 +184,7 @@ import Moldura from "@nixweb/nixloc-ui/src/component/layout/Moldura";
181
184
  import Progresso from "@nixweb/nixloc-ui/src/component/shared/Progresso";
182
185
  import Rodape from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rodape.vue";
183
186
  import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
187
+ import RelatorioAdicionarModificar from "@nixweb/nixloc-ui/src/component/template/RelatorioAdicionarModificar.vue";
184
188
 
185
189
  import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
186
190
 
@@ -203,6 +207,7 @@ export default {
203
207
  Rodape,
204
208
  Progresso,
205
209
  Tags,
210
+ RelatorioAdicionarModificar,
206
211
  },
207
212
  data() {
208
213
  return {
@@ -352,7 +357,10 @@ export default {
352
357
  this.fecharModal();
353
358
  this.removeCarregando(["aplicaFiltro", "aplicaCampo"]);
354
359
  },
355
- salvarRelatorio() {},
360
+ salvarRelatorio() {
361
+ this.abrirModal("salvar");
362
+ this.removeCarregando(["salvarRelatorio"]);
363
+ },
356
364
  mostraEscondeCampos() {
357
365
  let self = this;
358
366
  this.relatorio.campo.forEach(function (value) {
@@ -452,4 +460,8 @@ export default {
452
460
  .div-obrigatorio {
453
461
  margin-top: 20px;
454
462
  }
463
+
464
+ .filtro-obrigatorio {
465
+ font-weight: 500;
466
+ }
455
467
  </style>
@@ -0,0 +1,10 @@
1
+ export default class Relatorio {
2
+ constructor() {
3
+ this.id = "";
4
+ this.nome = "";
5
+ }
6
+ modificar(dados) {
7
+ this.id = dados.id;
8
+ this.nome = dados.nome;
9
+ }
10
+ }
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <div>
3
+ <b-row>
4
+ <b-col sm="12"
5
+ ><Texto
6
+ titulo="Nome"
7
+ campo="nome"
8
+ :formNome="formNome"
9
+ :requerido="true"
10
+ :tamanhoMaximo="40"
11
+ v-model="relatorio.nome"
12
+ :marcarFormSujo="false"
13
+ />
14
+ </b-col>
15
+ </b-row>
16
+ <b-row>
17
+ <b-col sm="12">
18
+ <div class="text-right">
19
+ <Botao
20
+ chave="salvar"
21
+ tipo="sucesso"
22
+ titulo="Salvar"
23
+ :desabilitado="!formValido(formNome)"
24
+ classeIcone="fas fa-save"
25
+ tamanho="medio"
26
+ :clique="salvarRelatorio"
27
+ />
28
+ </div>
29
+ </b-col>
30
+ </b-row>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ import Texto from "@nixweb/nixloc-ui/src/component/forms/Texto";
36
+ import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
37
+ import Relatorio from "@nixweb/nixloc-ui/src/component/template/Relatorio.js";
38
+
39
+ import { mapGetters, mapState, mapActions, mapMutations } from "vuex";
40
+
41
+ export default {
42
+ name: "RelatorioAdicionarModificar",
43
+ components: { Botao, Texto },
44
+ props: {
45
+ modulo: String,
46
+ },
47
+ data() {
48
+ return {
49
+ formNome: "relatorioAdicionarModificar",
50
+ relatorio: new Relatorio(),
51
+ urlAdicionar: "/api/v1/shared/relatorio/adicionar",
52
+ urlModificar: "/api/v1/shared/relatorio/modificar",
53
+ };
54
+ },
55
+ computed: {
56
+ ...mapGetters("validation", ["formValido"]),
57
+ ...mapGetters("generic", ["evento"]),
58
+ ...mapGetters("relatorio", ["cabecalhoTabela", "filtroSelecionado"]),
59
+ ...mapState("relatorio", ["campoSelecionado", "campoOrdenado"]),
60
+ },
61
+ methods: {
62
+ ...mapActions("generic", ["postApi", "putApi"]),
63
+ ...mapMutations("generic", ["removeCarregando", "removeEvento", "fecharModal"]),
64
+ ...mapMutations("validation", ["reiniciaValidacao"]),
65
+ salvarRelatorio() {
66
+ const consulta = {
67
+ nomeRota: this.$route.name,
68
+ campo: this.campoSelecionado,
69
+ ordenacao: this.campoOrdenado,
70
+ filtro: this.filtroSelecionado.children,
71
+ };
72
+ let obj = {
73
+ nome: this.relatorio.nome,
74
+ modulo: this.modulo,
75
+ consulta: JSON.stringify(consulta),
76
+ };
77
+ if (this.relatorio.id) {
78
+ let params = { url: this.urlModificar, obj: obj };
79
+ this.putApi(params).then((response) => {
80
+ if (response.sucesso) this.fecharModal();
81
+ this.removeCarregando(["salvar"]);
82
+ });
83
+ } else {
84
+ let params = { url: this.urlAdicionar, obj: obj };
85
+ this.postApi(params).then((response) => {
86
+ if (response.sucesso) this.fecharModal();
87
+ this.removeCarregando(["salvar"]);
88
+ });
89
+ }
90
+ },
91
+ modificar(dados) {
92
+ this.relatorio = new Relatorio();
93
+ this.relatorio.modificar(dados);
94
+ this.removeCarregando([dados.id]);
95
+ },
96
+ },
97
+ watch: {
98
+ evento: {
99
+ handler(evento) {
100
+ if (evento.nome == "modificarRelatorio") this.modificar(evento.dados);
101
+ },
102
+ deep: true,
103
+ },
104
+ },
105
+ };
106
+ </script>
@@ -10,6 +10,11 @@ export default {
10
10
  campoSelecionado: [],
11
11
  campoOrdenado: {},
12
12
  filtroSelecionado: { children: [] },
13
+ opcoes: {
14
+ valorInicial: [],
15
+ opcoes: []
16
+ },
17
+ opcoesValorInicial: [],
13
18
  consulta: [],
14
19
  resumo: [],
15
20
  },
@@ -22,17 +27,32 @@ export default {
22
27
  return lista;
23
28
  },
24
29
  opcoes: (state) => {
25
- let obj = {
30
+ // opcoesValorInicial é quando vem do relatório salvo
31
+
32
+ state.opcoes = {
26
33
  valorInicial: [],
27
34
  opcoes: []
28
- }
35
+ };
36
+
37
+ var tamanhoValorInicial = state.opcoesValorInicial.length;
38
+
29
39
  state.relatorio.campo.forEach(function (value) {
30
40
  let opcoes = { text: value.titulo, value: value.campo };
31
- obj.opcoes.push(opcoes);
41
+ state.opcoes.opcoes.push(opcoes);
42
+
43
+ if (value.mostrar && tamanhoValorInicial == 0)
44
+ state.opcoes.valorInicial.push(value.campo);
45
+
46
+ if (tamanhoValorInicial > 0)
47
+ state.opcoes.valorInicial = state.opcoesValorInicial;
32
48
 
33
- if (value.mostrar) obj.valorInicial.push(value.campo);
34
49
  });
35
- return obj;
50
+
51
+ // se não tiver salvo, reseta o filtro que estava armazenado
52
+ /* if (tamanhoValorInicial == 0)
53
+ state.filtroSelecionado.children = [];*/
54
+
55
+ return state.opcoes;
36
56
  },
37
57
  filtroObrigatorio: (state) => {
38
58
  var filtroObrigatorio = state.relatorio.filtro.filter(x => x.obrigatorio == true);
@@ -101,6 +121,9 @@ export default {
101
121
  atualizaCampoSelecionado: (state, value) => {
102
122
  state.campoSelecionado = value;
103
123
  },
124
+ atualizaOpcoesValorInicial: (state, value) => {
125
+ state.opcoesValorInicial = value;
126
+ },
104
127
  atualizaFiltroSelecionado: (state, value) => {
105
128
  state.filtroSelecionado = value;
106
129
  },
@@ -143,7 +166,4 @@ export default {
143
166
  });
144
167
  }
145
168
  },
146
- actions: {
147
-
148
- }
149
169
  }