@nixweb/nixloc-ui 0.0.93 → 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.
Files changed (30) hide show
  1. package/package.json +3 -2
  2. package/src/component/forms/DateTime.vue +16 -3
  3. package/src/component/forms/EscolherEstatico.vue +0 -3
  4. package/src/component/layout/BarraRolagem.vue +9 -2
  5. package/src/component/layout/Menu.vue +19 -12
  6. package/src/component/layout/Tag.vue +66 -0
  7. package/src/component/shared/Confirmacao.vue +80 -0
  8. package/src/component/shared/FiltroHorizontal.vue +8 -2
  9. package/src/component/shared/Progresso.vue +14 -1
  10. package/src/component/shared/Tabela.vue +3 -13
  11. package/src/component/shared/query-builder/Campo.vue +116 -0
  12. package/src/component/shared/query-builder/ConverteParaOdata.js +73 -0
  13. package/src/component/shared/query-builder/Filtro.vue +85 -0
  14. package/src/component/shared/query-builder/QueryBuilder.vue +164 -0
  15. package/src/component/shared/query-builder/Rodape.vue +38 -0
  16. package/src/component/shared/query-builder/Tags.vue +84 -0
  17. package/src/component/shared/query-builder/components/CustomSelect.vue +115 -0
  18. package/src/component/shared/query-builder/components/QueryBuilderChildren.vue +46 -0
  19. package/src/component/shared/query-builder/components/QueryBuilderGroup.vue +151 -0
  20. package/src/component/shared/query-builder/components/QueryBuilderRule.vue +81 -0
  21. package/src/component/shared/query-builder/layouts/Bootstrap/BootstrapGroup.vue +120 -0
  22. package/src/component/shared/query-builder/layouts/Bootstrap/BootstrapRule.vue +171 -0
  23. package/src/component/shared/query-builder/main.js +81 -0
  24. package/src/component/shared/query-builder/utilities.js +22 -0
  25. package/src/component/template/ModeloRelatorioListaView.vue +101 -32
  26. package/src/component/template/ModeloRelatorioView.vue +467 -0
  27. package/src/component/template/Relatorio.js +10 -0
  28. package/src/component/template/RelatorioAdicionarModificar.vue +106 -0
  29. package/src/store/modulos/generic.js +11 -0
  30. package/src/store/modulos/relatorio.js +169 -0
@@ -0,0 +1,467 @@
1
+ <template>
2
+ <div>
3
+ <Painel
4
+ :modulo="painel.modulo"
5
+ :titulo="painel.titulo"
6
+ :mostrarFiltroVertical="painel.mostrarFiltroVertical"
7
+ :mostrarPesquisa="painel.mostrarPesquisa"
8
+ :mostrarBotoes="painel.mostrarBotoes"
9
+ >
10
+ <div slot="conteudo-principal">
11
+ <br />
12
+ <div class="div-progresso" v-if="carregando && tamanhoDados > 0">
13
+ <Progresso
14
+ :texto="`Carregando ${tamanhoDados} registro(s) de ${conteudo.totalRegistros}`"
15
+ :valor="tamanhoDados"
16
+ :maximo="conteudo.totalRegistros"
17
+ tamanho="medium"
18
+ />
19
+ </div>
20
+ <Modal titulo="Salvar" :largura="550" v-show="mostrarModal('salvar')">
21
+ <RelatorioAdicionarModificar :modulo="painel.modulo" />
22
+ </Modal>
23
+ <Moldura>
24
+ <div>
25
+ <div slot="conteudo-filtro-horizontal">
26
+ <b-row>
27
+ <b-col sm="6">
28
+ <div class="lado-a-lado">
29
+ <Botao
30
+ chave="buscarRelatorio"
31
+ tipo="primario"
32
+ titulo="Buscar"
33
+ classeIcone="fas fa-file-search"
34
+ tamanho="medio"
35
+ :desabilitado="invalido || btnDesativado"
36
+ :clique="obterTodos"
37
+ />
38
+ </div>
39
+ <div class="lado-a-lado">
40
+ <Botao
41
+ v-if="!invalido"
42
+ chave="salvarRelatorio"
43
+ tipo="sucesso"
44
+ titulo="Salvar"
45
+ classeIcone="fas fa-save"
46
+ :desabilitado="carregando || invalido"
47
+ tamanho="pequeno"
48
+ :clique="salvarRelatorio"
49
+ />
50
+ </div>
51
+ </b-col>
52
+ <b-col class="text-right" sm="6">
53
+ <div class="lado-a-lado">
54
+ <Botao
55
+ chave="abrirCampo"
56
+ tipo="info"
57
+ titulo="Campos"
58
+ classeIcone="fas fa-database"
59
+ tamanho="pequeno"
60
+ :desabilitado="carregando"
61
+ :clique="abrirCampo"
62
+ />
63
+ </div>
64
+ <div class="lado-a-lado">
65
+ <Botao
66
+ chave="abrirFiltro"
67
+ tipo="info"
68
+ titulo="Filtros"
69
+ classeIcone="fas fa-filter"
70
+ tamanho="pequeno"
71
+ :desabilitado="carregando"
72
+ :clique="abrirFiltro"
73
+ />
74
+ </div>
75
+ </b-col>
76
+ </b-row>
77
+ <Modal titulo="Filtros" :largura="900" v-show="mostrarModal('filtro')">
78
+ <slot name="filtro"></slot>
79
+ <br />
80
+ <b-row>
81
+ <b-col class="text-right" sm="12">
82
+ <div class="lado-a-lado">
83
+ <Botao
84
+ chave="aplicaFiltro"
85
+ tipo="primario"
86
+ titulo="Aplicar"
87
+ classeIcone="fas fa-filter"
88
+ tamanho="pequeno"
89
+ :clique="aplicarFiltro"
90
+ />
91
+ </div>
92
+ </b-col>
93
+ </b-row>
94
+ </Modal>
95
+ <Modal titulo="Campos" :largura="600" v-show="mostrarModal('campo')">
96
+ <slot name="campo"></slot>
97
+ <b-row>
98
+ <b-col class="text-right" sm="12">
99
+ <div class="lado-a-lado">
100
+ <Botao
101
+ chave="aplicaFiltro"
102
+ tipo="primario"
103
+ titulo="Aplicar"
104
+ classeIcone="fas fa-filter"
105
+ tamanho="pequeno"
106
+ :desabilitado="campoSelecionado.length == 0"
107
+ :clique="aplicarFiltro"
108
+ />
109
+ </div>
110
+ </b-col>
111
+ </b-row>
112
+ </Modal>
113
+ </div>
114
+ </div>
115
+ </Moldura>
116
+ <div class="div-obrigatorio" v-show="invalido">
117
+ <Alerta tipo="info" v-for="item in filtroObrigatorio" :key="item.id">
118
+ É necessário informar o filtro
119
+ <span class="filtro-obrigatorio">{{ item.label }}</span
120
+ >, clique no botão "Filtros" para adicionar.
121
+ </Alerta>
122
+ </div>
123
+ <div class="div-tags">
124
+ <Tags nomeEvento="tagRelatorio" />
125
+ </div>
126
+ <div class="g-div-moldura div-tabela" v-if="!carregando && tamanhoDados > 0">
127
+ <b-row>
128
+ <b-col sm="6">
129
+ <div class="lado-a-lado">
130
+ <Botao
131
+ chave="buscarRelatorio"
132
+ tipo="editar"
133
+ titulo="Excel"
134
+ classeIcone="fas fa-file-excel"
135
+ tamanho="pequeno"
136
+ :clique="obterTodos"
137
+ />
138
+ </div>
139
+ <div class="lado-a-lado">
140
+ <Botao
141
+ chave="buscarRelatorio"
142
+ tipo="editar"
143
+ titulo="PDF"
144
+ classeIcone="fas fa-file-pdf"
145
+ tamanho="pequeno"
146
+ :clique="obterTodos"
147
+ />
148
+ </div>
149
+ </b-col>
150
+ <b-col sm="6">
151
+ <Registro :totalRegistro="conteudo.totalRegistros" />
152
+ </b-col>
153
+ </b-row>
154
+ <BarraRolagem :alturaMinima="300" :alturaMaxima="500">
155
+ <Tabela
156
+ :cabecalhoTabela="conteudo.cabecalhoTabela"
157
+ :dados="conteudo.dados"
158
+ :mostrarChecks="modeloLista.mostrarChecks"
159
+ />
160
+ </BarraRolagem>
161
+ </div>
162
+ <div class="div-sem-dados" v-if="nenhumDadoRetornado">
163
+ <Alerta tipo="info">
164
+ <span> Nenhum registro foi encontrato!</span>
165
+ </Alerta>
166
+ </div>
167
+ <div class="div-rodape" v-if="conteudo.resumo.length > 0">
168
+ <Rodape :dados="conteudo.resumo" />
169
+ </div>
170
+ </div>
171
+ </Painel>
172
+ </div>
173
+ </template>
174
+
175
+ <script>
176
+ import Alerta from "@nixweb/nixloc-ui/src/component/layout/Alerta";
177
+ import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
178
+ import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
179
+ import Tabela from "../shared/Tabela.vue";
180
+ import Registro from "../shared/Registro.vue";
181
+ import Painel from "@nixweb/nixloc-ui/src/component/layout/Painel.vue";
182
+ import BarraRolagem from "@nixweb/nixloc-ui/src/component/layout/BarraRolagem.vue";
183
+ import Moldura from "@nixweb/nixloc-ui/src/component/layout/Moldura";
184
+ import Progresso from "@nixweb/nixloc-ui/src/component/shared/Progresso";
185
+ import Rodape from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rodape.vue";
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";
188
+
189
+ import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
190
+
191
+ export default {
192
+ name: "ModeloRelatorioView",
193
+ props: {
194
+ modeloLista: Object,
195
+ campo: Array,
196
+ painel: Object,
197
+ },
198
+ components: {
199
+ Alerta,
200
+ Modal,
201
+ Botao,
202
+ Registro,
203
+ Tabela,
204
+ Painel,
205
+ BarraRolagem,
206
+ Moldura,
207
+ Rodape,
208
+ Progresso,
209
+ Tags,
210
+ RelatorioAdicionarModificar,
211
+ },
212
+ data() {
213
+ return {
214
+ conteudo: {
215
+ cabecalhoTabela: [],
216
+ dados: [],
217
+ resumo: [],
218
+ paginacao: 0,
219
+ paginaAtual: 1,
220
+ totalPorPagina: 100,
221
+ totalRegistros: 0,
222
+ },
223
+ btnDesativado: true,
224
+ carregando: false,
225
+ nenhumDadoRetornado: false,
226
+ };
227
+ },
228
+ mounted() {
229
+ this.removeCarregando(["painel"]);
230
+ },
231
+ computed: {
232
+ ...mapGetters("generic", ["mostrarModal", "evento"]),
233
+ ...mapGetters("relatorio", [
234
+ "cabecalhoTabela",
235
+ "filtroSelecionado",
236
+ "filtroObrigatorio",
237
+ "temCampoSelecionado",
238
+ "oDataSelect",
239
+ "oDataFilter",
240
+ "oDataOrderBy",
241
+ ]),
242
+ ...mapState("relatorio", ["relatorio", "campoSelecionado", "resumo"]),
243
+ urlConsulta() {
244
+ let baseUrl = `${this.modeloLista.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.consulta}&$skip=${this.skip}&$top=${this.conteudo.totalPorPagina}&$count=true`;
245
+ return baseUrl.replace("&&", "&");
246
+ },
247
+ urlResumo() {
248
+ let consulta = this.oDataFilter.resumo
249
+ ? `$apply=filter(${this.oDataFilter.consulta.replace("$filter=", "")})/`
250
+ : "$apply=";
251
+ let baseUrl = `${this.modeloLista.urlGetApi}?${consulta}aggregate(${this.oDataFilter.resumo})`;
252
+ return baseUrl;
253
+ },
254
+ skip() {
255
+ return (this.conteudo.paginaAtual - 1) * this.conteudo.totalPorPagina;
256
+ },
257
+ invalido() {
258
+ let retorno = true;
259
+ this.filtroObrigatorio.forEach((filtro) => {
260
+ var existe = this.filtroSelecionado.children.find((value) => {
261
+ if (filtro.label == value.query.label) retorno = false;
262
+ });
263
+ });
264
+
265
+ return retorno;
266
+ },
267
+ tamanhoDados() {
268
+ return this.conteudo.dados.length;
269
+ },
270
+ },
271
+ methods: {
272
+ ...mapActions("generic", ["getApiOdata"]),
273
+ ...mapMutations("generic", ["abrirModal", "fecharModal", "removeCarregando"]),
274
+ ...mapMutations("relatorio", ["atualizaCabecalhoTabela", "atualizaConsultaFiltro"]),
275
+
276
+ obterTodos() {
277
+ this.conteudo.dados = [];
278
+ this.conteudo.resumo = [];
279
+ this.btnDesativado = true;
280
+
281
+ if (!this.invalido) {
282
+ this.mostraEscondeCampos();
283
+ this.paginacao();
284
+ this.removeCarregando(["buscarRelatorio"]);
285
+
286
+ if (this.oDataFilter.resumo) this.resumoOData();
287
+ if (!this.oDataFilter.resumo) this.conteudo.resumo = [];
288
+ }
289
+ },
290
+ paginacao() {
291
+ let paramsConsulta = { url: this.urlConsulta };
292
+ this.reiniciaDados();
293
+
294
+ this.getApiOdata(paramsConsulta).then((response) => {
295
+ let totalRegistros = response["@odata.count"];
296
+ if (totalRegistros == 0) this.nenhumDadoRetornado = true;
297
+ this.conteudo.totalRegistros = totalRegistros;
298
+ this.conteudo.paginacao = Math.round(
299
+ totalRegistros / this.conteudo.totalPorPagina
300
+ );
301
+
302
+ if (totalRegistros <= this.conteudo.totalPorPagina) {
303
+ this.consultaOdata();
304
+ this.conteudo.cabecalhoTabela = this.cabecalhoTabela;
305
+ }
306
+ if (this.conteudo.paginacao == 0) this.carregando = false;
307
+ });
308
+ },
309
+ reiniciaDados() {
310
+ this.carregando = true;
311
+ this.conteudo.dados = [];
312
+ this.conteudo.paginaAtual = 1;
313
+ this.nenhumDadoRetornado = false;
314
+ },
315
+ consultaOdata() {
316
+ let paramsConsulta = { url: this.urlConsulta };
317
+ this.getApiOdata(paramsConsulta).then((response) => {
318
+ let self = this;
319
+ response.value.forEach(function (obj) {
320
+ self.conteudo.dados.push(obj);
321
+ });
322
+ this.conteudo.paginaAtual++;
323
+ });
324
+ this.conteudo.cabecalhoTabela = this.cabecalhoTabela;
325
+ },
326
+ resumoOData() {
327
+ let paramsResumo = { url: this.urlResumo };
328
+ this.getApiOdata(paramsResumo).then((response) => {
329
+ this.conteudo.resumo = [];
330
+ const result = Object.entries(response[0]);
331
+ let self = this;
332
+ result.forEach(function (value) {
333
+ self.resumo.forEach(function (legenda) {
334
+ let obj = {
335
+ titulo: "",
336
+ valor: value[1],
337
+ classeCss: legenda.classeCss,
338
+ tipo: legenda.tipo,
339
+ };
340
+ if (legenda.valor == value[0]) {
341
+ obj.titulo = legenda.titulo;
342
+ self.conteudo.resumo.push(obj);
343
+ }
344
+ });
345
+ });
346
+ });
347
+ },
348
+ abrirCampo() {
349
+ this.abrirModal("campo");
350
+ this.removeCarregando(["abrirCampo"]);
351
+ },
352
+ abrirFiltro() {
353
+ this.abrirModal("filtro");
354
+ this.removeCarregando(["abrirFiltro"]);
355
+ },
356
+ aplicarFiltro() {
357
+ this.fecharModal();
358
+ this.removeCarregando(["aplicaFiltro", "aplicaCampo"]);
359
+ },
360
+ salvarRelatorio() {
361
+ this.abrirModal("salvar");
362
+ this.removeCarregando(["salvarRelatorio"]);
363
+ },
364
+ mostraEscondeCampos() {
365
+ let self = this;
366
+ this.relatorio.campo.forEach(function (value) {
367
+ if (self.temCampoSelecionado(value.campo, self.campoSelecionado)) {
368
+ value.mostrar = true;
369
+ } else {
370
+ value.mostrar = false;
371
+ }
372
+ });
373
+ },
374
+ },
375
+ watch: {
376
+ evento: {
377
+ handler(evento) {
378
+ if (evento.nome == "tagRelatorio") this.abrirModal("filtro");
379
+ },
380
+ deep: true,
381
+ },
382
+ campoSelecionado: {
383
+ handler() {
384
+ this.mostraEscondeCampos();
385
+ },
386
+ deep: true,
387
+ },
388
+ filtroSelecionado: {
389
+ handler(filtro) {
390
+ this.atualizaConsultaFiltro(filtro);
391
+ },
392
+ deep: true,
393
+ },
394
+ "conteudo.paginaAtual": {
395
+ handler(value) {
396
+ if (value <= this.conteudo.paginacao - 1) {
397
+ let self = this;
398
+ setTimeout(function () {
399
+ self.consultaOdata();
400
+ }, 200);
401
+ }
402
+ if (value == this.conteudo.paginacao && value != 0) this.carregando = false;
403
+ },
404
+ deep: true,
405
+ },
406
+ "conteudo.paginacao": {
407
+ handler(value) {
408
+ this.consultaOdata();
409
+ },
410
+ deep: true,
411
+ },
412
+ "oDataFilter.consulta": {
413
+ handler(value) {
414
+ this.btnDesativado = false;
415
+ },
416
+ deep: true,
417
+ },
418
+ oDataSelect: {
419
+ handler(value) {
420
+ this.btnDesativado = false;
421
+ },
422
+ deep: true,
423
+ },
424
+ oDataOrderBy: {
425
+ handler(value) {
426
+ this.btnDesativado = false;
427
+ },
428
+ deep: true,
429
+ },
430
+ },
431
+ };
432
+ </script>
433
+
434
+ <style scoped>
435
+ .div-progresso {
436
+ margin-bottom: 10px;
437
+ }
438
+
439
+ .div-sem-dados {
440
+ margin-top: 20px;
441
+ }
442
+
443
+ .div-tabela {
444
+ margin-top: 20px;
445
+ }
446
+
447
+ .div-separacao {
448
+ margin-left: 10px;
449
+ margin-right: 5px;
450
+ }
451
+
452
+ .div-rodape {
453
+ margin-top: 20px;
454
+ }
455
+
456
+ .div-tags {
457
+ margin-top: 15px;
458
+ }
459
+
460
+ .div-obrigatorio {
461
+ margin-top: 20px;
462
+ }
463
+
464
+ .filtro-obrigatorio {
465
+ font-weight: 500;
466
+ }
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>
@@ -237,6 +237,17 @@ export default {
237
237
  return false;
238
238
  })
239
239
  },
240
+ getApiOdata: async function (context, params) {
241
+ return axios.get(params.url, {
242
+ headers: new Token().tokenHeaders(),
243
+ })
244
+ .then((response) => {
245
+ return response.data;
246
+ }, (err) => {
247
+ context.commit('insereNotificacaoErroApi');
248
+ return false;
249
+ })
250
+ },
240
251
  deleteAllApi: async function (context, params) {
241
252
 
242
253
  context.commit('limpaMetodoExecutadoApi');