@nixweb/nixloc-ui 0.0.95 → 0.0.98

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.98",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -15,14 +15,17 @@
15
15
  "sass-loader": "^12.4.0",
16
16
  "vodal": "^2.4.0",
17
17
  "vue-color": "^2.7.0",
18
+ "vue-html2pdf": "^1.8.0",
19
+ "vue-json-excel": "^0.3.0",
20
+ "vue-print-nb": "^1.7.5",
18
21
  "vue-currency-filter": "^3.3.0",
19
22
  "vue-js-toggle-button": "^1.3.0",
20
23
  "vue-loading-template": "^1.3.0",
21
24
  "vue-moment": "^4.0.0",
22
25
  "vue-multiselect": "^2.1.0",
23
26
  "vue-numeric": "^2.4.1",
24
- "vue-the-mask": "^0.11.1",
25
27
  "vue-simple-progress": "^1.1.1",
28
+ "vue-the-mask": "^0.11.1",
26
29
  "vue-toasted": "^1.1.28",
27
30
  "vue-toggles": "^1.1.4",
28
31
  "vue-upload-file": "^1.1.0",
@@ -35,6 +38,7 @@
35
38
  "babel-eslint": "^10.1.0",
36
39
  "eslint": "^6.7.2",
37
40
  "eslint-plugin-vue": "^6.2.2",
41
+ "script-loader": "^0.7.2",
38
42
  "vue-template-compiler": "^2.6.11"
39
43
  },
40
44
  "eslintConfig": {
@@ -65,4 +69,4 @@
65
69
  "type": "git",
66
70
  "url": "git+https://github.com/nixweb-sistemas/nixloc-ui.git"
67
71
  }
68
- }
72
+ }
@@ -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,36 @@
1
+ <template>
2
+ <div class="div-cabecalho somente-impressao">
3
+ <div class="titulo">{{ nomeArquivo }}</div>
4
+ <div class="lado-a-lado div-tag" v-for="tag in tags" :key="tag.id">
5
+ <span>{{ tag.titulo }}</span> <span>{{ tag.valor }}</span>
6
+ <span>,</span>
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script>
12
+ import { mapGetters, mapMutations } from "vuex";
13
+
14
+ export default {
15
+ name: "CabecalhoImpressao",
16
+ computed: {
17
+ ...mapGetters("relatorio", ["tags"]),
18
+ nomeArquivo() {
19
+ return this.$route.matched[0].props.default.relatorio;
20
+ },
21
+ },
22
+ };
23
+ </script>
24
+ <style scoped>
25
+ .div-cabecalho {
26
+ margin: 20px;
27
+ }
28
+
29
+ .div-tag {
30
+ margin-right: 10px;
31
+ }
32
+
33
+ .titulo {
34
+ font-size: 18px;
35
+ }
36
+ </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>
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <div>
3
+ <download-excel
4
+ :fields="coluna"
5
+ :data="dados"
6
+ :before-finish="exportacaoFinalizada"
7
+ worksheet="Planilha"
8
+ :name="`${nomeArquivo}.xls`"
9
+ >
10
+ <Botao
11
+ chave="exportarExcel"
12
+ :tipo="botao.tipo"
13
+ :titulo="botao.titulo"
14
+ classeIcone="fas fa-file-excel"
15
+ :tamanho="botao.tamanho"
16
+ />
17
+ </download-excel>
18
+ </div>
19
+ </template>
20
+
21
+ <script>
22
+ import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
23
+
24
+ import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
25
+
26
+ export default {
27
+ name: "ExportarExcel",
28
+ props: {
29
+ botao: Object,
30
+ cabecalho: Array,
31
+ dados: Array,
32
+ },
33
+ components: {
34
+ Botao,
35
+ },
36
+ data() {
37
+ return {
38
+ json_meta: [
39
+ [
40
+ {
41
+ key: "charset",
42
+ value: "utf-8",
43
+ },
44
+ ],
45
+ ],
46
+ };
47
+ },
48
+ methods: {
49
+ ...mapMutations("generic", ["removeCarregando"]),
50
+ exportacaoFinalizada() {
51
+ this.removeCarregando(["exportarExcel"]);
52
+ },
53
+ },
54
+ computed: {
55
+ coluna() {
56
+ var object = this.cabecalho.reduce(
57
+ (obj, item) => Object.assign(obj, { [item.titulo]: item.campo }),
58
+ {}
59
+ );
60
+ return object;
61
+ },
62
+ nomeArquivo() {
63
+ return this.$route.matched[0].props.default.relatorio;
64
+ },
65
+ },
66
+ };
67
+ </script>
@@ -16,7 +16,7 @@
16
16
  :paginate-elements-by-height="1400"
17
17
  :filename="nomeArquivo"
18
18
  :pdf-quality="2"
19
- :manual-pagination="true"
19
+ :manual-pagination="false"
20
20
  :pdf-format="tamanhoPagina"
21
21
  :pdf-orientation="orientacao"
22
22
  pdf-content-width="100%"
@@ -51,7 +51,7 @@ import BarraRolagem from "../layout/BarraRolagem.vue";
51
51
  import VueHtml2pdf from "vue-html2pdf";
52
52
 
53
53
  export default {
54
- name: "Imprimir",
54
+ name: "ExportarPDF",
55
55
  components: { VueHtml2pdf, BarraRolagem, Carregando },
56
56
  props: {
57
57
  titulo: String,
@@ -76,7 +76,9 @@ export default {
76
76
  this.carregando = false;
77
77
  }
78
78
  },
79
- hasStartedGeneration() {},
79
+ hasStartedGeneration() {
80
+ console.log("começou");
81
+ },
80
82
  hasDownloaded() {
81
83
  console.log("finalizou");
82
84
  },
@@ -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;
@@ -22,51 +22,15 @@ export default {
22
22
  props: {
23
23
  nomeEvento: String,
24
24
  },
25
- data() {
26
- return {
27
- tags: [],
28
- };
29
- },
25
+
30
26
  computed: {
31
- ...mapGetters("relatorio", ["filtroSelecionado"]),
27
+ ...mapGetters("relatorio", ["tags"]),
32
28
  ...mapGetters("generic", ["mostrarModal", "evento"]),
33
29
  },
34
30
  methods: {
35
31
  ...mapMutations("relatorio", ["removeFiltroSelecionado"]),
36
32
  },
37
33
  watch: {
38
- filtroSelecionado: {
39
- handler(filtro) {
40
- let self = this;
41
- this.tags = [];
42
- filtro.children.forEach(function (value) {
43
- let valor = "";
44
- let type = value.query.type;
45
-
46
- if (type == "custom-component" && value.query.label == "Período") {
47
- valor = `${value.query.value[0]} - ${value.query.value[1]}`;
48
- }
49
-
50
- if (type == "text" || type == "numeric") {
51
- valor = `${value.query.operator} "${value.query.value}"`;
52
- }
53
-
54
- if (type == "checkbox") {
55
- value.query.choices.forEach(function (opcoes) {
56
- value.query.value.forEach(function (value) {
57
- if (opcoes.value == value) {
58
- valor += `${opcoes.label},`;
59
- }
60
- });
61
- });
62
- }
63
-
64
- let tag = { id: value.query.id, titulo: value.query.label, valor: valor };
65
- if (value.query.value != null) self.tags.push(tag);
66
- });
67
- },
68
- deep: true,
69
- },
70
34
  evento: {
71
35
  handler(evento) {
72
36
  if (evento.nome == "tagRemovida") {
@@ -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>
@@ -124,36 +127,40 @@
124
127
  <b-row>
125
128
  <b-col sm="6">
126
129
  <div class="lado-a-lado">
127
- <Botao
128
- chave="buscarRelatorio"
129
- tipo="editar"
130
- titulo="Excel"
131
- classeIcone="fas fa-file-excel"
132
- tamanho="pequeno"
133
- :clique="obterTodos"
130
+ <ExportarExcel
131
+ :botao="{ tipo: 'editar', titulo: 'Excel', tamanho: 'pequeno' }"
132
+ nomeArquivo="Auditoria"
133
+ :cabecalho="conteudo.cabecalhoTabela"
134
+ :dados="conteudo.dados"
134
135
  />
135
136
  </div>
136
137
  <div class="lado-a-lado">
137
- <Botao
138
- chave="buscarRelatorio"
139
- tipo="editar"
140
- titulo="PDF"
141
- classeIcone="fas fa-file-pdf"
142
- tamanho="pequeno"
143
- :clique="obterTodos"
144
- />
138
+ <div>
139
+ <Botao
140
+ v-print="'#printMe'"
141
+ chave="aplicaFiltro"
142
+ tipo="editar"
143
+ titulo="Imprimir"
144
+ classeIcone="fas fa-print"
145
+ tamanho="pequeno"
146
+ :clique="aplicarFiltro"
147
+ />
148
+ </div>
145
149
  </div>
146
150
  </b-col>
147
151
  <b-col sm="6">
148
152
  <Registro :totalRegistro="conteudo.totalRegistros" />
149
153
  </b-col>
150
154
  </b-row>
151
- <BarraRolagem :alturaMinima="300" :alturaMaxima="500">
152
- <Tabela
153
- :cabecalhoTabela="conteudo.cabecalhoTabela"
154
- :dados="conteudo.dados"
155
- :mostrarChecks="modeloLista.mostrarChecks"
156
- />
155
+ <BarraRolagem :alturaMinima="400" :alturaMaxima="600">
156
+ <div id="printMe">
157
+ <CabecalhoImpressao />
158
+ <Tabela
159
+ :cabecalhoTabela="conteudo.cabecalhoTabela"
160
+ :dados="conteudo.dados"
161
+ :mostrarChecks="modeloLista.mostrarChecks"
162
+ />
163
+ </div>
157
164
  </BarraRolagem>
158
165
  </div>
159
166
  <div class="div-sem-dados" v-if="nenhumDadoRetornado">
@@ -173,7 +180,9 @@
173
180
  import Alerta from "@nixweb/nixloc-ui/src/component/layout/Alerta";
174
181
  import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
175
182
  import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
183
+ import ExportarExcel from "@nixweb/nixloc-ui/src/component/shared/ExportarExcel";
176
184
  import Tabela from "../shared/Tabela.vue";
185
+ import CabecalhoImpressao from "../shared/CabecalhoImpressao.vue";
177
186
  import Registro from "../shared/Registro.vue";
178
187
  import Painel from "@nixweb/nixloc-ui/src/component/layout/Painel.vue";
179
188
  import BarraRolagem from "@nixweb/nixloc-ui/src/component/layout/BarraRolagem.vue";
@@ -181,11 +190,16 @@ import Moldura from "@nixweb/nixloc-ui/src/component/layout/Moldura";
181
190
  import Progresso from "@nixweb/nixloc-ui/src/component/shared/Progresso";
182
191
  import Rodape from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rodape.vue";
183
192
  import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
193
+ import RelatorioAdicionarModificar from "@nixweb/nixloc-ui/src/component/template/RelatorioAdicionarModificar.vue";
194
+ import print from "vue-print-nb";
184
195
 
185
196
  import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
186
197
 
187
198
  export default {
188
199
  name: "ModeloRelatorioView",
200
+ directives: {
201
+ print,
202
+ },
189
203
  props: {
190
204
  modeloLista: Object,
191
205
  campo: Array,
@@ -203,6 +217,9 @@ export default {
203
217
  Rodape,
204
218
  Progresso,
205
219
  Tags,
220
+ RelatorioAdicionarModificar,
221
+ ExportarExcel,
222
+ CabecalhoImpressao,
206
223
  },
207
224
  data() {
208
225
  return {
@@ -218,6 +235,7 @@ export default {
218
235
  btnDesativado: true,
219
236
  carregando: false,
220
237
  nenhumDadoRetornado: false,
238
+ teste: this.router,
221
239
  };
222
240
  },
223
241
  mounted() {
@@ -352,7 +370,10 @@ export default {
352
370
  this.fecharModal();
353
371
  this.removeCarregando(["aplicaFiltro", "aplicaCampo"]);
354
372
  },
355
- salvarRelatorio() {},
373
+ salvarRelatorio() {
374
+ this.abrirModal("salvar");
375
+ this.removeCarregando(["salvarRelatorio"]);
376
+ },
356
377
  mostraEscondeCampos() {
357
378
  let self = this;
358
379
  this.relatorio.campo.forEach(function (value) {
@@ -452,4 +473,8 @@ export default {
452
473
  .div-obrigatorio {
453
474
  margin-top: 20px;
454
475
  }
476
+
477
+ .filtro-obrigatorio {
478
+ font-weight: 500;
479
+ }
455
480
  </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>
@@ -312,7 +312,7 @@ export default {
312
312
  return false;
313
313
  })
314
314
  },
315
- getPdfApi: async function (context, params) {
315
+ getFileApi: async function (context, params) {
316
316
  context.commit('limpaMetodoExecutadoApi');
317
317
  return axios.post(params.url, params.obj, {
318
318
  headers: new Token().tokenHeaders(), responseType: "arraybuffer",
@@ -10,8 +10,14 @@ 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: [],
20
+ tags: []
15
21
  },
16
22
  getters: {
17
23
  cabecalhoTabela: (state) => {
@@ -22,17 +28,32 @@ export default {
22
28
  return lista;
23
29
  },
24
30
  opcoes: (state) => {
25
- let obj = {
31
+ // opcoesValorInicial é quando vem do relatório salvo
32
+
33
+ state.opcoes = {
26
34
  valorInicial: [],
27
35
  opcoes: []
28
- }
36
+ };
37
+
38
+ var tamanhoValorInicial = state.opcoesValorInicial.length;
39
+
29
40
  state.relatorio.campo.forEach(function (value) {
30
41
  let opcoes = { text: value.titulo, value: value.campo };
31
- obj.opcoes.push(opcoes);
42
+ state.opcoes.opcoes.push(opcoes);
43
+
44
+ if (value.mostrar && tamanhoValorInicial == 0)
45
+ state.opcoes.valorInicial.push(value.campo);
46
+
47
+ if (tamanhoValorInicial > 0)
48
+ state.opcoes.valorInicial = state.opcoesValorInicial;
32
49
 
33
- if (value.mostrar) obj.valorInicial.push(value.campo);
34
50
  });
35
- return obj;
51
+
52
+ // se não tiver salvo, reseta o filtro que estava armazenado
53
+ /* if (tamanhoValorInicial == 0)
54
+ state.filtroSelecionado.children = [];*/
55
+
56
+ return state.opcoes;
36
57
  },
37
58
  filtroObrigatorio: (state) => {
38
59
  var filtroObrigatorio = state.relatorio.filtro.filter(x => x.obrigatorio == true);
@@ -93,6 +114,37 @@ export default {
93
114
 
94
115
  return { consulta, resumo };
95
116
  },
117
+ tags: (state) => {
118
+ state.tags = [];
119
+ state.filtroSelecionado.children.forEach(function (value) {
120
+ let valor = "";
121
+ let type = value.query.type;
122
+
123
+ if (value.query.value) {
124
+ if (type == "custom-component" && value.query.label == "Período") {
125
+ valor = `${value.query.value[0]} - ${value.query.value[1]}`;
126
+ }
127
+
128
+ if (type == "text" || type == "numeric") {
129
+ valor = `${value.query.operator} "${value.query.value}"`;
130
+ }
131
+
132
+ if (type == "checkbox") {
133
+ value.query.choices.forEach(function (opcoes) {
134
+ value.query.value.forEach(function (value) {
135
+ if (opcoes.value == value) {
136
+ valor += `${opcoes.label},`;
137
+ }
138
+ });
139
+ });
140
+ }
141
+
142
+ let tag = { id: value.query.id, titulo: value.query.label, valor: valor };
143
+ if (value.query.value != null) state.tags.push(tag);
144
+ }
145
+ });
146
+ return state.tags;
147
+ }
96
148
  },
97
149
  mutations: {
98
150
  insereRelatorio: (state, obj) => {
@@ -101,6 +153,9 @@ export default {
101
153
  atualizaCampoSelecionado: (state, value) => {
102
154
  state.campoSelecionado = value;
103
155
  },
156
+ atualizaOpcoesValorInicial: (state, value) => {
157
+ state.opcoesValorInicial = value;
158
+ },
104
159
  atualizaFiltroSelecionado: (state, value) => {
105
160
  state.filtroSelecionado = value;
106
161
  },
@@ -143,7 +198,4 @@ export default {
143
198
  });
144
199
  }
145
200
  },
146
- actions: {
147
-
148
- }
149
201
  }