@nixweb/nixloc-ui 0.0.97 → 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.97",
3
+ "version": "0.0.98",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -12,10 +12,12 @@
12
12
  "dependencies": {
13
13
  "@babel/polyfill": "^7.2.5",
14
14
  "bootstrap-vue": "^2.0.0-rc.11",
15
- "file-saver": "^2.0.5",
16
15
  "sass-loader": "^12.4.0",
17
16
  "vodal": "^2.4.0",
18
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",
19
21
  "vue-currency-filter": "^3.3.0",
20
22
  "vue-js-toggle-button": "^1.3.0",
21
23
  "vue-loading-template": "^1.3.0",
@@ -28,8 +30,7 @@
28
30
  "vue-toggles": "^1.1.4",
29
31
  "vue-upload-file": "^1.1.0",
30
32
  "vue2-datepicker": "^2.13.0",
31
- "vue2-editor": "^2.6.6",
32
- "xlsx": "^0.18.5"
33
+ "vue2-editor": "^2.6.6"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@vue/cli-plugin-babel": "~4.5.0",
@@ -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,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
  },
@@ -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") {
@@ -127,36 +127,40 @@
127
127
  <b-row>
128
128
  <b-col sm="6">
129
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"
130
+ <ExportarExcel
131
+ :botao="{ tipo: 'editar', titulo: 'Excel', tamanho: 'pequeno' }"
132
+ nomeArquivo="Auditoria"
133
+ :cabecalho="conteudo.cabecalhoTabela"
134
+ :dados="conteudo.dados"
137
135
  />
138
136
  </div>
139
137
  <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
- />
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>
148
149
  </div>
149
150
  </b-col>
150
151
  <b-col sm="6">
151
152
  <Registro :totalRegistro="conteudo.totalRegistros" />
152
153
  </b-col>
153
154
  </b-row>
154
- <BarraRolagem :alturaMinima="300" :alturaMaxima="500">
155
- <Tabela
156
- :cabecalhoTabela="conteudo.cabecalhoTabela"
157
- :dados="conteudo.dados"
158
- :mostrarChecks="modeloLista.mostrarChecks"
159
- />
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>
160
164
  </BarraRolagem>
161
165
  </div>
162
166
  <div class="div-sem-dados" v-if="nenhumDadoRetornado">
@@ -176,7 +180,9 @@
176
180
  import Alerta from "@nixweb/nixloc-ui/src/component/layout/Alerta";
177
181
  import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
178
182
  import Botao from "@nixweb/nixloc-ui/src/component/forms/Botao";
183
+ import ExportarExcel from "@nixweb/nixloc-ui/src/component/shared/ExportarExcel";
179
184
  import Tabela from "../shared/Tabela.vue";
185
+ import CabecalhoImpressao from "../shared/CabecalhoImpressao.vue";
180
186
  import Registro from "../shared/Registro.vue";
181
187
  import Painel from "@nixweb/nixloc-ui/src/component/layout/Painel.vue";
182
188
  import BarraRolagem from "@nixweb/nixloc-ui/src/component/layout/BarraRolagem.vue";
@@ -185,11 +191,15 @@ import Progresso from "@nixweb/nixloc-ui/src/component/shared/Progresso";
185
191
  import Rodape from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rodape.vue";
186
192
  import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
187
193
  import RelatorioAdicionarModificar from "@nixweb/nixloc-ui/src/component/template/RelatorioAdicionarModificar.vue";
194
+ import print from "vue-print-nb";
188
195
 
189
196
  import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
190
197
 
191
198
  export default {
192
199
  name: "ModeloRelatorioView",
200
+ directives: {
201
+ print,
202
+ },
193
203
  props: {
194
204
  modeloLista: Object,
195
205
  campo: Array,
@@ -208,6 +218,8 @@ export default {
208
218
  Progresso,
209
219
  Tags,
210
220
  RelatorioAdicionarModificar,
221
+ ExportarExcel,
222
+ CabecalhoImpressao,
211
223
  },
212
224
  data() {
213
225
  return {
@@ -223,6 +235,7 @@ export default {
223
235
  btnDesativado: true,
224
236
  carregando: false,
225
237
  nenhumDadoRetornado: false,
238
+ teste: this.router,
226
239
  };
227
240
  },
228
241
  mounted() {
@@ -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",
@@ -17,6 +17,7 @@ export default {
17
17
  opcoesValorInicial: [],
18
18
  consulta: [],
19
19
  resumo: [],
20
+ tags: []
20
21
  },
21
22
  getters: {
22
23
  cabecalhoTabela: (state) => {
@@ -49,9 +50,9 @@ export default {
49
50
  });
50
51
 
51
52
  // se não tiver salvo, reseta o filtro que estava armazenado
52
- /* if (tamanhoValorInicial == 0)
53
- state.filtroSelecionado.children = [];*/
54
-
53
+ /* if (tamanhoValorInicial == 0)
54
+ state.filtroSelecionado.children = [];*/
55
+
55
56
  return state.opcoes;
56
57
  },
57
58
  filtroObrigatorio: (state) => {
@@ -113,6 +114,37 @@ export default {
113
114
 
114
115
  return { consulta, resumo };
115
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
+ }
116
148
  },
117
149
  mutations: {
118
150
  insereRelatorio: (state, obj) => {