@nixweb/nixloc-ui 0.0.125 → 0.0.128

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 (111) hide show
  1. package/docs/src/component/template/ViewTemplateReportPreview.drawio +210 -0
  2. package/package.json +79 -77
  3. package/src/App.vue +13 -13
  4. package/src/component/forms/Button.vue +170 -169
  5. package/src/component/forms/CheckboxGroup.vue +72 -63
  6. package/src/component/forms/CheckboxSimple.vue +46 -27
  7. package/src/component/forms/Color.vue +38 -38
  8. package/src/component/forms/DateTime.vue +167 -177
  9. package/src/component/forms/Dropdown.vue +218 -224
  10. package/src/component/forms/EditorHtml.vue +126 -123
  11. package/src/component/forms/FileUpload.vue +185 -189
  12. package/src/component/forms/ImageUpload.vue +230 -0
  13. package/src/component/forms/IncrementDecrement.vue +101 -0
  14. package/src/component/forms/InputDecimal.vue +142 -137
  15. package/src/component/forms/InputNumber.vue +154 -149
  16. package/src/component/forms/InputPassword.vue +135 -135
  17. package/src/component/forms/InputText.vue +162 -157
  18. package/src/component/forms/Modal.vue +65 -60
  19. package/src/component/forms/RadioGroup.vue +50 -50
  20. package/src/component/forms/Select.vue +349 -337
  21. package/src/component/forms/SelectStatic.vue +127 -120
  22. package/src/component/forms/Slider.vue +18 -18
  23. package/src/component/forms/TextArea.vue +126 -126
  24. package/src/component/layout/Alert.vue +92 -92
  25. package/src/component/layout/Badge.vue +103 -103
  26. package/src/component/layout/FixedBar.vue +100 -68
  27. package/src/component/layout/Header.vue +38 -35
  28. package/src/component/layout/LoadingFullPage.vue +27 -27
  29. package/src/component/layout/Menu.vue +210 -214
  30. package/src/component/layout/Molded.vue +28 -27
  31. package/src/component/layout/Panel.vue +140 -142
  32. package/src/component/layout/Popover.vue +126 -126
  33. package/src/component/layout/ScrollBar.vue +42 -43
  34. package/src/component/layout/Tab.vue +135 -0
  35. package/src/component/layout/Tag.vue +3 -3
  36. package/src/component/layout/Wizard.vue +211 -213
  37. package/src/component/rental/DisplayPeriodRent.vue +81 -0
  38. package/src/component/rental/DisplayTotalization.vue +47 -0
  39. package/src/component/shared/Collapse.vue +131 -131
  40. package/src/component/shared/Confirmation.vue +2 -2
  41. package/src/component/shared/DocumentEditor.vue +1 -1
  42. package/src/component/shared/DocumentPreview.vue +1 -1
  43. package/src/component/shared/DocumentPublic.vue +34 -0
  44. package/src/component/shared/ExportExcel.vue +1 -8
  45. package/src/component/shared/ExportPDF.vue +116 -116
  46. package/src/component/shared/{HeaderPrint.vue → HeaderReport.vue} +4 -4
  47. package/src/component/shared/HorizontalFilter.vue +59 -59
  48. package/src/component/shared/Loading.vue +107 -107
  49. package/src/component/shared/LoadingMoreButton.vue +23 -23
  50. package/src/component/shared/Messages.vue +81 -83
  51. package/src/component/shared/PDFViewer.vue +22 -22
  52. package/src/component/shared/Pagination.vue +52 -53
  53. package/src/component/shared/{LegendaParametro.vue → ParameterLegend.vue} +22 -26
  54. package/src/component/shared/ProgressBar.vue +22 -21
  55. package/src/component/shared/QueryButton.vue +66 -66
  56. package/src/component/shared/Report.vue +187 -0
  57. package/src/component/shared/SaveCancel.vue +26 -5
  58. package/src/component/shared/Search.vue +154 -154
  59. package/src/component/shared/SelectOption.vue +146 -0
  60. package/src/component/shared/Table.vue +163 -243
  61. package/src/component/shared/TableButton.vue +36 -36
  62. package/src/component/shared/TableDraggable.vue +127 -0
  63. package/src/component/shared/TableItem.vue +177 -0
  64. package/src/component/shared/TableTotalRecords.vue +9 -10
  65. package/src/component/shared/TableTotalization.vue +47 -47
  66. package/src/component/shared/Tip.vue +42 -42
  67. package/src/component/shared/Toast.vue +54 -54
  68. package/src/component/shared/TotalizationReport.vue +59 -0
  69. package/src/component/shared/VerticalFilter.vue +97 -145
  70. package/src/component/shared/query-builder/AddRule.vue +181 -187
  71. package/src/component/shared/query-builder/ConvertToOdata.js +34 -43
  72. package/src/component/shared/query-builder/DynamicComponent.vue +21 -16
  73. package/src/component/shared/query-builder/DynamicComponentList.vue +73 -0
  74. package/src/component/shared/query-builder/Fields.vue +29 -63
  75. package/src/component/shared/query-builder/QueryBuilder.vue +69 -69
  76. package/src/component/shared/query-builder/Rules.vue +2 -14
  77. package/src/component/shared/query-builder/SelectRule.vue +15 -15
  78. package/src/component/shared/query-builder/Tags.vue +24 -8
  79. package/src/component/shared/query-builder/utilities.js +21 -21
  80. package/src/component/template/{ListViewWithHandlerData.vue → ListViewWithDataHandler.vue} +260 -231
  81. package/src/component/template/{AddEditReport.vue → ReportCreateUpdate.vue} +40 -22
  82. package/src/component/template/ViewTemplateConfiguration.vue +64 -69
  83. package/src/component/template/ViewTemplateDocumentView.vue +22 -25
  84. package/src/component/template/ViewTemplateReportList.vue +39 -57
  85. package/src/component/template/ViewTemplateReportPreview.vue +270 -341
  86. package/src/component/template/ViewTemplateReportPreviewCOPIASEGURANCA.vue +497 -0
  87. package/src/component/template/ViewTemplateSelectOption.vue +60 -0
  88. package/src/component/template/ViewTemplateWithSalveCancel.vue +32 -32
  89. package/src/component/template/ViewTemplateWithTable.vue +56 -49
  90. package/src/component/template/model/Report.js +2 -2
  91. package/src/component/value-objects/Address.js +11 -0
  92. package/src/component/value-objects/{Endereco.vue → Address.vue} +39 -40
  93. package/src/component/value-objects/{DadosContato.js → Contact.js} +2 -2
  94. package/src/component/value-objects/{DadosContato.vue → Contact.vue} +24 -17
  95. package/src/component/value-objects/Person.js +10 -0
  96. package/src/component/value-objects/{DadosPessoa.vue → Person.vue} +50 -35
  97. package/src/config/axios.js +9 -9
  98. package/src/config/dicas.js +14 -14
  99. package/src/config/router.js +13 -13
  100. package/src/config/token.js +14 -14
  101. package/src/main.js +23 -23
  102. package/src/store/modules/generic.js +512 -488
  103. package/src/store/modules/report.js +156 -127
  104. package/src/store/modules/user.js +6 -0
  105. package/src/store/modules/validation.js +38 -38
  106. package/src/store/store.js +13 -13
  107. package/docs/src/component/template/ModeloRelatorioView.drawio +0 -160
  108. package/src/component/shared/query-builder/ListDynamicComponent.vue +0 -42
  109. package/src/component/shared/query-builder/Totalization.vue +0 -38
  110. package/src/component/value-objects/DadosPessoa.js +0 -10
  111. package/src/component/value-objects/Endereco.js +0 -11
@@ -9,449 +9,370 @@
9
9
  >
10
10
  <div slot="content-main">
11
11
  <br />
12
- {{ urlConsulta }}
13
- <div class="div-progresso" v-if="carregando && tamanhoDados > 0">
12
+ <div class="div-progress" v-if="liveTotalRecords != baseParams.totalRecords">
14
13
  <ProgressBar
15
- :texto="`Loading ${tamanhoDados} registro(s) de ${content.totalRecords}`"
16
- :valor="tamanhoDados"
17
- :maximo="content.totalRecords"
14
+ :text="`Carregando ${liveTotalRecords} registro(s) de ${baseParams.totalRecords}`"
15
+ :value="liveTotalRecords"
16
+ :max="baseParams.totalRecords"
18
17
  size="medium"
19
18
  />
20
19
  </div>
21
- <Modal title="Salvar" :width="550" v-show="showModal('salvar')">
22
- <AddEditReport :module="panel.module" />
23
- </Modal>
24
20
  <Molded>
25
- <div>
26
- <div slot="content-filter-horizontal">
27
- <b-row>
28
- <b-col sm="6">
29
- <div class="side-by-side">
30
- {{ invalid }}
31
- <Button
32
- key="buscarRelatorio"
33
- type="primary"
34
- title="Buscar"
35
- classIcon="fas fa-file-search"
36
- size="medium"
37
- :disabled="invalid || btnDesativado"
38
- :clicked="getAll"
39
- />
40
- </div>
41
- <div class="side-by-side">
42
- <Button
43
- v-if="!invalid"
44
- key="saveReport"
45
- type="success"
46
- title="Salvar Modelo"
47
- classIcon="fas fa-save"
48
- :disabled="carregando || invalid"
49
- size="small"
50
- :clicked="saveReport"
51
- />
52
- </div>
53
- </b-col>
54
- <b-col class="text-right" sm="6">
55
- <div class="side-by-side">
56
- <Button
57
- key="abrirCampo"
58
- type="info"
59
- title="fields"
60
- classIcon="fas fa-database"
61
- size="small"
62
- :disabled="carregando"
63
- :clicked="abrirCampo"
64
- />
65
- </div>
66
- <div class="side-by-side">
67
- <Button
68
- key="abrirFiltro"
69
- type="info"
70
- title="Filtros"
71
- classIcon="fas fa-filter"
72
- size="small"
73
- :disabled="carregando"
74
- :clicked="abrirFiltro"
75
- />
76
- </div>
77
- </b-col>
78
- </b-row>
79
- <Modal title="Filtros" :width="900" v-show="showModal('filter')">
80
- <Rules :rules="rules" />
81
- <br />
82
- <b-row>
83
- <b-col class="text-right" sm="12">
84
- <div class="side-by-side">
85
- <Button
86
- key="aplicaFiltro"
87
- type="primary"
88
- title="Aplicar"
89
- classIcon="fas fa-filter"
90
- size="small"
91
- :clicked="aplicarFiltro"
92
- />
93
- </div>
94
- </b-col>
95
- </b-row>
96
- </Modal>
97
- <Modal title="fields" :width="600" v-show="showModal('field')">
98
- <Fields :fields="fields" />
99
- <b-row>
100
- <b-col class="text-right" sm="12">
101
- <div class="side-by-side">
102
- <Button
103
- key="aplicaFiltro"
104
- type="primary"
105
- title="Aplicar"
106
- classIcon="fas fa-filter"
107
- size="small"
108
- :disabled="selectedField.length == 0"
109
- :clicked="aplicarFiltro"
110
- />
111
- </div>
112
- </b-col>
113
- </b-row>
114
- </Modal>
115
- </div>
116
- </div>
117
- </Molded>
118
- <div class="div-obrigatorio" v-show="invalid">
119
- <Alert type="info" v-for="item in requiredRules" :key="item.id">
120
- É necessário informar o filter
121
- <span class="filter-obrigatorio">{{ item.title }}</span
122
- >, clicked no botão "Filtros" para adicionar.
123
- </Alert>
124
- </div>
125
- <div class="div-tags">
126
- <Tags eventName="tagRelatorio" />
127
- </div>
128
- <div class="g-div-molded div-tabela" v-if="!carregando && tamanhoDados > 0">
129
21
  <b-row>
130
22
  <b-col sm="6">
131
- <div class="div-button">
132
- <div class="side-by-side">
133
- <ExportExcel
134
- :button="{ type: 'edit', title: 'Excel', size: 'small' }"
135
- fileName="Auditoria"
136
- :cabecalho="content.headerTable"
137
- :data="content.data"
138
- />
139
- </div>
140
- <div class="side-by-side">
141
- <div>
142
- <Button
143
- v-print="'#printMe'"
144
- key="aplicaFiltro"
145
- type="edit"
146
- title="Imprimir"
147
- classIcon="fas fa-print"
148
- size="small"
149
- :clicked="aplicarFiltro"
150
- />
151
- </div>
152
- </div>
23
+ <div class="side-by-side">
24
+ <Button
25
+ _key="btnSearchReport"
26
+ type="primary"
27
+ title="Buscar"
28
+ classIcon="fas fa-file-search"
29
+ :disabled="btnSearchDisabled || !rulesIsValid"
30
+ size="medium"
31
+ :clicked="getAll"
32
+ />
33
+ </div>
34
+ <div class="side-by-side">
35
+ <Button
36
+ _key="btnSaveReport"
37
+ type="success"
38
+ title="Salvar"
39
+ classIcon="fas fa-save"
40
+ size="small"
41
+ :disabled="isLoading || btnSaveDisabled || !rulesIsValid"
42
+ :params="{ name: 'save', title: 'Salvar', width: 550 }"
43
+ :clicked="executeOpenModal"
44
+ />
153
45
  </div>
154
46
  </b-col>
155
- <b-col sm="6">
156
- <TableTotalRecords :totalRecords="content.totalRecords" />
47
+ <b-col class="text-right" sm="6">
48
+ <div class="side-by-side">
49
+ <Button
50
+ _key="btnExecuteOpenModal"
51
+ type="info"
52
+ title="Campos"
53
+ classIcon="fas fa-database"
54
+ size="small"
55
+ :disabled="isLoading"
56
+ :params="{ name: 'fields', title: 'Campos', width: 550 }"
57
+ :clicked="executeOpenModal"
58
+ />
59
+ </div>
60
+ <div class="side-by-side">
61
+ <Button
62
+ _key="btnExecuteOpenModal"
63
+ type="info"
64
+ title="Filtros"
65
+ classIcon="fas fa-filter"
66
+ size="small"
67
+ :disabled="isLoading"
68
+ :params="{ name: 'rules', title: 'Filtros', width: 900 }"
69
+ :clicked="executeOpenModal"
70
+ />
71
+ </div>
157
72
  </b-col>
158
73
  </b-row>
159
- <ScrollBar :minHeight="400" :maxHeight="600">
160
- <div id="printMe">
161
- <HeaderPrint />
162
- {{ content.headerTable }}
163
- <Table
164
- :headerTable="content.headerTable"
165
- :data="content.data"
166
- :showChecks="templateList.showChecks"
167
- />
168
- </div>
169
- </ScrollBar>
74
+ </Molded>
75
+ <div class="div-tags">
76
+ <Tags eventName="tagReport" />
170
77
  </div>
171
- <div class="div-sem-data" v-if="nenhumDadoRetornado">
172
- <Alert type="info">
173
- <span> Nenhum registro foi encontrato!</span>
78
+ <div class="div-required" v-show="!rulesIsValid">
79
+ <Alert type="warning" v-for="rule in rulesRequired" :key="rule.id">
80
+ É necessário informar o filtro
81
+ <span class="filter-required">{{ rule.title }}</span
82
+ >, clique no botão "Filtros" para adicionar.
174
83
  </Alert>
175
84
  </div>
176
- <div class="div-Totalization" v-if="content.totalization.length > 0">
177
- <Totalization :data="content.totalization" />
85
+ <div class="body-report" v-show="showBodyReport && rulesIsValid">
86
+ <Report
87
+ :header="content.headerTable"
88
+ :data="content.data"
89
+ :totalization="content.totalization"
90
+ />
178
91
  </div>
179
92
  </div>
180
93
  </Panel>
94
+ <Modal
95
+ :title="modalOptions.title"
96
+ :width="modalOptions.width"
97
+ v-show="showModal('templateReport')"
98
+ >
99
+ <ReportCreateUpdate :module="panel.module" v-show="modalOptions.name == 'save'" />
100
+ <Fields v-if="modalOptions.name == 'fields'" />
101
+ <Rules v-show="modalOptions.name == 'rules'" />
102
+ <div
103
+ class="text-right btn-apply"
104
+ v-show="modalOptions.name == 'fields' || modalOptions.name == 'rules'"
105
+ >
106
+ <Button
107
+ _key="btnApplyFieldsAndRules"
108
+ type="primary"
109
+ title="Aplicar"
110
+ classIcon="fas fa-filter"
111
+ size="small"
112
+ :clicked="applyFieldsAndRules"
113
+ />
114
+ </div>
115
+ </Modal>
181
116
  </div>
182
117
  </template>
183
118
 
184
119
  <script>
185
- import Alert from "@nixweb/nixloc-ui/src/component/layout/Alert";
186
- import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
187
- import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
188
- import ExportExcel from "@nixweb/nixloc-ui/src/component/shared/ExportExcel";
189
- import Table from "../shared/Table.vue";
190
- import HeaderPrint from "../shared/HeaderPrint.vue";
191
- import TableTotalRecords from "../shared/TableTotalRecords.vue";
192
120
  import Panel from "@nixweb/nixloc-ui/src/component/layout/Panel.vue";
193
- import ScrollBar from "@nixweb/nixloc-ui/src/component/layout/ScrollBar.vue";
194
121
  import Molded from "@nixweb/nixloc-ui/src/component/layout/Molded";
195
122
  import ProgressBar from "@nixweb/nixloc-ui/src/component/shared/ProgressBar";
196
- import Totalization from "@nixweb/nixloc-ui/src/component/shared/query-builder/Totalization.vue";
123
+ import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
124
+ import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
125
+ import Alert from "@nixweb/nixloc-ui/src/component/layout/Alert";
197
126
  import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
198
- import AddEditReport from "@nixweb/nixloc-ui/src/component/template/AddEditReport.vue";
127
+ import Report from "../shared/Report.vue";
128
+
129
+ import ReportCreateUpdate from "@nixweb/nixloc-ui/src/component/template/ReportCreateUpdate.vue";
199
130
  import Fields from "@nixweb/nixloc-ui/src/component/shared/query-builder/Fields.vue";
200
131
  import Rules from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rules.vue";
201
- import print from "vue-print-nb";
202
132
 
203
133
  import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
204
134
 
205
135
  export default {
206
136
  name: "TemplateReportView",
207
- directives: {
208
- print,
209
- },
210
137
  props: {
211
138
  panel: Object,
212
139
  templateList: Object,
213
- rules: Array,
214
- fields: Array,
215
- field: Array,
140
+ templateReport: Object,
216
141
  },
217
142
  components: {
218
- Alert,
219
- Modal,
220
- Button,
221
- TableTotalRecords,
222
- Table,
223
143
  Panel,
224
- ScrollBar,
225
144
  Molded,
226
- Totalization,
227
145
  ProgressBar,
146
+ Button,
147
+ Modal,
148
+ Alert,
228
149
  Tags,
229
- AddEditReport,
230
- ExportExcel,
231
- HeaderPrint,
150
+ Report,
151
+ ReportCreateUpdate,
232
152
  Fields,
233
153
  Rules,
234
154
  },
235
155
  data() {
236
156
  return {
157
+ id: this.$route.params.id,
158
+ urlGetById: "api/v1/shared/report/get-by-id",
237
159
  content: {
238
160
  headerTable: [],
239
161
  data: [],
240
- totalization: [],
241
- pagination: 0,
242
- currentPage: 1,
162
+ totalPages: [],
163
+ totalization: {},
164
+ noDataReturned: false,
165
+ },
166
+ baseParams: {
167
+ currentPage: 0,
243
168
  totalPerPage: 100,
169
+ totalPage: 0,
244
170
  totalRecords: 0,
245
171
  },
246
- btnDesativado: true,
247
- carregando: false,
248
- nenhumDadoRetornado: false,
249
- teste: this.router,
172
+ modalOptions: {
173
+ name: "",
174
+ title: "",
175
+ width: 0,
176
+ },
177
+ btnSearchDisabled: false,
178
+ btnSaveDisabled: true,
179
+ isLoading: false,
180
+ showBodyReport: false,
250
181
  };
251
182
  },
252
183
  mounted() {
253
- this.removeLoading(["panel"]);
184
+ this.addReport({
185
+ id: this.id,
186
+ fields: this.templateReport.fields,
187
+ rules: this.templateReport.rules,
188
+ });
189
+
190
+ if (this.id) this.getById();
191
+
192
+ if (!this.id) this.removeLoadingWithTime();
254
193
  },
255
194
  beforeDestroy() {
256
- this.updateOptionsInitValue({});
257
- this.atualizaCampoOrdenado({});
258
- this.atualizaFiltroSelecionado({ children: [] });
195
+ this.removeInitialReportCustom();
259
196
  },
260
- computed: {
261
- ...mapGetters("generic", ["showModal", "event"]),
262
- ...mapGetters("report", [
263
- "headerTable",
264
- "selectedRules",
265
- "requiredRules",
266
- "regraObrigatoriaJaAdicionada",
267
- "hasSelectedField",
268
- "oDataSelect",
269
- "oDataFilter",
270
- "oDataOrderBy",
197
+ methods: {
198
+ ...mapActions("generic", ["getApi", "getApiOdata"]),
199
+ ...mapActions("report", [
200
+ "addReport",
201
+ "addInitialReportCustom",
202
+ "removeInitialReportCustom",
271
203
  ]),
272
- ...mapState("report", ["report", "selectedField", "totalization"]),
273
- urlConsulta() {
274
- let baseUrl = `${this.templateList.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.query}&$skip=${this.skip}&$top=${this.content.totalPerPage}&$count=true`;
275
- return baseUrl.replace("&&", "&");
276
- },
277
- urlResumo() {
278
- let query = this.oDataFilter.totalization
279
- ? `$apply=filter(${this.oDataFilter.query.replace("$filter=", "")})/`
280
- : "$apply=";
281
- let baseUrl = `${this.templateList.urlGetApi}?${query}aggregate(${this.oDataFilter.totalization})`;
282
- return baseUrl;
283
- },
284
- skip() {
285
- return (this.content.currentPage - 1) * this.content.totalPerPage;
286
- },
287
- invalid() {
288
- let retorno = true;
289
- this.requiredRules.forEach((rule) => {
290
- retorno = this.regraObrigatoriaJaAdicionada(rule);
204
+ ...mapMutations("generic", ["addEvent", "openModal", "hideModal", "removeLoading"]),
205
+ getById() {
206
+ let params = { url: this.urlGetById, obj: { id: this.id } };
207
+ this.getApi(params).then((response) => {
208
+ const query = JSON.parse(response.content.query);
209
+ let report = {
210
+ selectedFields: query.selectedFields,
211
+ selectedRules: query.selectedRules,
212
+ };
213
+ this.addInitialReportCustom(report);
214
+ this.removeLoadingWithTime();
291
215
  });
292
-
293
- if (this.requiredRules.length == 0) retorno = false;
294
-
295
- return retorno;
296
- },
297
- tamanhoDados() {
298
- return this.content.data.length;
299
216
  },
300
- },
301
- methods: {
302
- ...mapActions("generic", ["getApiOdata"]),
303
- ...mapMutations("generic", ["addEvent", "showModal", "hideModal", "removeLoading"]),
304
- ...mapMutations("report", [
305
- "atualizaFiltroSelecionado",
306
- "atualizaCampoOrdenado",
307
- "updateOptionsInitValue",
308
- "atualizaCabecalhoTabela",
309
- ]),
310
217
  getAll() {
311
- this.content.data = [];
312
- this.content.totalization = [];
313
- this.btnDesativado = true;
218
+ this.btnSearchDisabled = true;
314
219
 
315
- if (!this.invalid) {
316
- this.mostraEscondeCampos();
317
- this.pagination();
318
- this.removeLoading(["buscarRelatorio"]);
220
+ if (this.rulesIsValid) {
221
+ this.getTotalRecords();
222
+ this.removeLoading(["btnSearchReport"]);
319
223
 
320
- if (this.oDataFilter.totalization) this.resumoOData();
321
- if (!this.oDataFilter.totalization) this.content.totalization = [];
224
+ if (this.oDataFilter.totalization) this.totalization();
225
+ if (!this.oDataFilter.totalization) this.content.totalization = {};
322
226
  }
323
227
  },
324
- pagination() {
325
- let paramsConsulta = { url: this.urlConsulta };
326
- this.reiniciaDados();
228
+ getTotalRecords() {
229
+ let paramsQuery = { url: this.urlQuery };
230
+ this.resetData();
327
231
 
328
- this.getApiOdata(paramsConsulta).then((response) => {
232
+ this.getApiOdata(paramsQuery).then((response) => {
329
233
  let totalRecords = response["@odata.count"];
330
- if (totalRecords == 0) this.nenhumDadoRetornado = true;
331
- this.content.totalRecords = totalRecords;
332
- this.content.pagination = Math.round(totalRecords / this.content.totalPerPage);
234
+ if (totalRecords == 0) this.noDataReturned = true;
333
235
 
334
- if (totalRecords <= this.content.totalPerPage) {
335
- this.consultaOdata();
336
- this.content.headerTable = this.headerTable;
337
- }
338
- if (this.content.pagination == 0) this.carregando = false;
236
+ this.baseParams.totalRecords = totalRecords;
237
+ this.baseParams.totalPage = Math.ceil(
238
+ totalRecords / this.baseParams.totalPerPage
239
+ );
240
+
241
+ if (this.baseParams.totalPage <= 1) this.loadingOnlyIfOnePage(response.value);
242
+ if (this.baseParams.totalPage > 1) this.loadingOnlyIfManyPages();
243
+
244
+ this.content.headerTable = this.headerTable;
245
+ this.showBodyReport = true;
339
246
  });
340
247
  },
341
- reiniciaDados() {
342
- this.carregando = true;
343
- this.content.data = [];
344
- this.content.currentPage = 1;
345
- this.nenhumDadoRetornado = false;
248
+ totalization() {
249
+ let params = { url: this.urlTotalization };
250
+ this.getApiOdata(params).then((response) => {
251
+ const result = Object.entries(response[0]);
252
+ this.content.totalization = result;
253
+ });
254
+ },
255
+ loadingOnlyIfOnePage(data) {
256
+ this.content.data = data;
257
+ this.btnSearchDisabled = true;
258
+ let self = this;
259
+ setTimeout(function () {
260
+ self.isLoading = false;
261
+ }, 350);
346
262
  },
347
- consultaOdata() {
348
- let paramsConsulta = { url: this.urlConsulta };
349
- this.getApiOdata(paramsConsulta).then((response) => {
263
+ loadingOnlyIfManyPages() {
264
+ let seq = 0;
265
+ while (seq <= this.baseParams.totalPage - 1) {
266
+ this.content.totalPages.push(seq);
267
+ seq++;
268
+ }
269
+ },
270
+ getAllManyPages() {
271
+ let paramsQuery = { url: this.urlQuery };
272
+ this.getApiOdata(paramsQuery).then((response) => {
350
273
  let self = this;
351
274
  response.value.forEach(function (obj) {
352
275
  self.content.data.push(obj);
353
276
  });
354
- this.content.currentPage++;
355
277
  });
356
- this.content.headerTable = this.headerTable;
278
+ this.content.totalPages.pop();
279
+ this.baseParams.currentPage++;
357
280
  },
358
- resumoOData() {
359
- let paramsResumo = { url: this.urlResumo };
360
- this.getApiOdata(paramsResumo).then((response) => {
361
- this.content.totalization = [];
362
- const result = Object.entries(response[0]);
363
- let self = this;
364
- result.forEach(function (value) {
365
- self.totalization.forEach(function (legenda) {
366
- let obj = {
367
- title: "",
368
- valor: value[1],
369
- classCss: legenda.classCss,
370
- type: legenda.type,
371
- };
372
- if (legenda.valor == value[0]) {
373
- obj.title = legenda.title;
374
- self.content.totalization.push(obj);
375
- }
376
- });
377
- });
378
- });
281
+ resetData() {
282
+ this.isLoading = true;
283
+ this.content.data = [];
284
+ this.content.totalPages = [];
285
+ this.baseParams.currentPage = 0;
286
+ this.noDataReturned = false;
287
+ },
288
+ executeOpenModal(params) {
289
+ if (this.id && params.name == "save") {
290
+ this.addEvent({ name: "saveReport" });
291
+ } else {
292
+ this.modalOptions = params;
293
+ this.openModal("templateReport");
294
+ this.removeLoading(["btnExecuteOpenModal", "btnSaveReport"]);
295
+ }
379
296
  },
380
- abrirCampo() {
381
- this.showModal("field");
382
- this.removeLoading(["abrirCampo"]);
297
+ applyFieldsAndRules() {
298
+ this.hideModal("templateReport");
299
+ this.removeLoading(["btnApplyFieldsAndRules"]);
383
300
  },
384
- abrirFiltro() {
385
- this.showModal("filter");
386
- this.removeLoading(["abrirFiltro"]);
301
+ removeLoadingWithTime() {
302
+ let self = this;
303
+ setTimeout(function () {
304
+ self.btnSaveDisabled = true;
305
+ self.removeLoading(["panel"]);
306
+ }, 350);
387
307
  },
388
- aplicarFiltro() {
389
- this.hideModal();
390
- this.removeLoading(["aplicaFiltro", "aplicaCampo"]);
308
+ },
309
+ computed: {
310
+ ...mapGetters("generic", ["showModal", "event"]),
311
+ ...mapGetters("report", [
312
+ "headerTable",
313
+ "oDataFilter",
314
+ "oDataSelect",
315
+ "oDataOrderBy",
316
+ "rulesIsValid",
317
+ "rulesRequired",
318
+ ]),
319
+ ...mapState("report", ["report"]),
320
+ urlQuery() {
321
+ let skip = this.baseParams.currentPage * this.baseParams.totalPerPage;
322
+ let baseUrl = `${this.templateList.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.query}&$skip=${skip}&$top=${this.baseParams.totalPerPage}&$count=true`;
323
+ return baseUrl.replace("&&", "&");
391
324
  },
392
- saveReport() {
393
- this.addEvent({ nome: "changeReport" });
394
- this.showModal("salvar");
395
- this.removeLoading(["saveReport"]);
325
+ urlTotalization() {
326
+ let query = this.oDataFilter.query
327
+ ? `$apply=filter(${this.oDataFilter.query.replace("$filter=", "")})/`
328
+ : "$apply=";
329
+ let baseUrl = `${
330
+ this.templateList.urlGetApi
331
+ }?${query}aggregate(${this.oDataFilter.totalization.replace(",", "")})`;
332
+ return baseUrl;
396
333
  },
397
- mostraEscondeCampos() {
398
- let self = this;
399
- this.report.fields.forEach(function (field) {
400
- if (self.hasSelectedField(field.field, self.selectedField)) {
401
- value.show = true;
402
- } else {
403
- value.show = false;
404
- }
405
- });
334
+ liveTotalRecords() {
335
+ return this.content.data.length;
406
336
  },
407
337
  },
408
338
  watch: {
409
339
  event: {
410
340
  handler(event) {
411
- if (event.nome == "tagRelatorio") this.showModal("filter");
412
- },
413
- deep: true,
414
- },
415
- selectedField: {
416
- handler() {
417
- this.mostraEscondeCampos();
341
+ console.log(event);
342
+ if (event.name == "savedReport") this.btnSaveDisabled = true;
418
343
  },
419
344
  deep: true,
420
345
  },
421
- "content.currentPage": {
422
- handler(currentPage) {
423
- if (currentPage <= this.content.pagination - 1) {
346
+ "content.totalPages": {
347
+ handler(totalPages) {
348
+ if (totalPages.length > 0) {
424
349
  let self = this;
425
350
  setTimeout(function () {
426
- self.consultaOdata();
351
+ self.getAllManyPages();
427
352
  }, 200);
428
353
  }
429
- if (currentPage == this.content.pagination && currentPage != 0)
430
- this.carregando = false;
431
- },
432
- deep: true,
433
- },
434
- "content.pagination": {
435
- handler() {
436
- this.consultaOdata();
354
+ if (totalPages.length == 1) this.isLoading = false;
437
355
  },
438
356
  deep: true,
439
357
  },
440
- "oDataFilter.query": {
441
- handler() {
442
- this.btnDesativado = false;
358
+ oDataFilter: {
359
+ handler(totalPages) {
360
+ this.btnSearchDisabled = false;
361
+ this.btnSaveDisabled = false;
443
362
  },
444
363
  deep: true,
445
364
  },
446
365
  oDataSelect: {
447
- handler() {
448
- this.btnDesativado = false;
366
+ handler(totalPages) {
367
+ this.btnSearchDisabled = false;
368
+ this.btnSaveDisabled = false;
449
369
  },
450
370
  deep: true,
451
371
  },
452
372
  oDataOrderBy: {
453
- handler() {
454
- this.btnDesativado = false;
373
+ handler(totalPages) {
374
+ this.btnSearchDisabled = false;
375
+ this.btnSaveDisabled = false;
455
376
  },
456
377
  deep: true,
457
378
  },
@@ -464,7 +385,7 @@ export default {
464
385
  padding-bottom: 15px;
465
386
  }
466
387
 
467
- .div-progresso {
388
+ .div-progress {
468
389
  margin-bottom: 10px;
469
390
  }
470
391
 
@@ -472,7 +393,7 @@ export default {
472
393
  margin-top: 20px;
473
394
  }
474
395
 
475
- .div-tabela {
396
+ .div-table {
476
397
  margin-top: 20px;
477
398
  }
478
399
 
@@ -489,11 +410,19 @@ export default {
489
410
  margin-top: 15px;
490
411
  }
491
412
 
492
- .div-obrigatorio {
413
+ .div-required {
493
414
  margin-top: 20px;
494
415
  }
495
416
 
496
- .filter-obrigatorio {
417
+ .filter-required {
497
418
  font-weight: 500;
498
419
  }
420
+
421
+ .btn-apply {
422
+ margin-top: 10px;
423
+ }
424
+
425
+ .body-report {
426
+ margin-top: 30px;
427
+ }
499
428
  </style>