@nixweb/nixloc-ui 1.19.0 → 1.20.0

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 (110) hide show
  1. package/package.json +1 -1
  2. package/src/component/forms/ButtonFilter.vue +104 -104
  3. package/src/component/forms/ButtonGroup.vue +66 -66
  4. package/src/component/forms/ButtonGroupInline.vue +210 -210
  5. package/src/component/forms/ButtonSub.vue +97 -97
  6. package/src/component/forms/ButtonToggle.vue +76 -76
  7. package/src/component/forms/DateYearMonth.vue +192 -192
  8. package/src/component/forms/ImageUpload.vue +214 -214
  9. package/src/component/forms/IncrementDecrement.vue +151 -151
  10. package/src/component/forms/InputAddressGoogle.vue +171 -171
  11. package/src/component/forms/InputCallToAction.vue +135 -135
  12. package/src/component/forms/InputDecimalDiscount.vue +146 -146
  13. package/src/component/forms/InputTag.vue +124 -124
  14. package/src/component/forms/InputTextEdit.vue +69 -69
  15. package/src/component/forms/InputWhatsApp.vue +47 -47
  16. package/src/component/forms/SideBar.vue +99 -99
  17. package/src/component/forms/Toggle.vue +72 -72
  18. package/src/component/layout/Account.vue +131 -131
  19. package/src/component/layout/AnimatedPhrase.vue +68 -68
  20. package/src/component/layout/BarFloating.vue +67 -67
  21. package/src/component/layout/BottomActionsBar.vue +205 -205
  22. package/src/component/layout/ColorPicker.vue +175 -175
  23. package/src/component/layout/Gantt.vue +128 -128
  24. package/src/component/layout/HideShow.vue +61 -61
  25. package/src/component/layout/IconMolded.vue +58 -58
  26. package/src/component/layout/IconPicker.vue +161 -161
  27. package/src/component/layout/NewAccount.vue +136 -136
  28. package/src/component/layout/NewHeader.vue +59 -59
  29. package/src/component/layout/NewIconMolded.vue +70 -70
  30. package/src/component/layout/NewMenu.vue +472 -472
  31. package/src/component/layout/Tab.vue +259 -259
  32. package/src/component/layout/Tag.vue +97 -97
  33. package/src/component/layout/Tooltip.vue +155 -155
  34. package/src/component/layout/Zoom.vue +111 -111
  35. package/src/component/rental/DisplayCalculatePeriod.vue +48 -48
  36. package/src/component/rental/DisplayPeriodRent.vue +55 -55
  37. package/src/component/rental/DisplayTotalization.vue +86 -86
  38. package/src/component/report/Fields.vue +108 -108
  39. package/src/component/report/Report.vue +377 -377
  40. package/src/component/report/ReportTable.vue +111 -111
  41. package/src/component/report/Totalization.vue +33 -33
  42. package/src/component/shared/CodeEditor.vue +128 -128
  43. package/src/component/shared/Confirmation.vue +74 -74
  44. package/src/component/shared/DocumentEditor.vue +99 -99
  45. package/src/component/shared/DocumentPreview.vue +105 -105
  46. package/src/component/shared/DocumentPublic.vue +33 -33
  47. package/src/component/shared/ExportExcel.vue +56 -56
  48. package/src/component/shared/FullCalendar.vue +175 -175
  49. package/src/component/shared/HeaderReport.vue +47 -47
  50. package/src/component/shared/ListNotifications.vue +70 -70
  51. package/src/component/shared/Loading.vue +1 -4
  52. package/src/component/shared/LoadingCard.vue +64 -64
  53. package/src/component/shared/ParameterLegend.vue +169 -169
  54. package/src/component/shared/Report.vue +250 -250
  55. package/src/component/shared/SaveCancel.vue +99 -117
  56. package/src/component/shared/SelectOption.vue +162 -162
  57. package/src/component/shared/TableDraggable.vue +117 -117
  58. package/src/component/shared/TableImport.vue +93 -93
  59. package/src/component/shared/TableItem.vue +228 -228
  60. package/src/component/shared/TableTotalPerPage.vue +114 -114
  61. package/src/component/shared/TableTotalRecords.vue +44 -44
  62. package/src/component/shared/TimeLine.vue +41 -41
  63. package/src/component/shared/Timer.vue +77 -77
  64. package/src/component/shared/ToggleTheme.vue +127 -127
  65. package/src/component/shared/TotalizationReport.vue +86 -86
  66. package/src/component/shared/actions/ActionButtons.vue +53 -53
  67. package/src/component/shared/actions/ActionErrorContent.vue +103 -103
  68. package/src/component/shared/actions/ActionFooter.vue +93 -99
  69. package/src/component/shared/actions/ActionHeader.vue +110 -110
  70. package/src/component/shared/actions/ActionItemList.vue +143 -143
  71. package/src/component/shared/actions/ActionsOptions.vue +209 -209
  72. package/src/component/shared/actions/ActionsSelected.vue +262 -262
  73. package/src/component/shared/automation/ActivitiesList.vue +43 -43
  74. package/src/component/shared/automation/AddRule.vue +60 -60
  75. package/src/component/shared/automation/AutomationBuilder.vue +26 -26
  76. package/src/component/shared/automation/DynamicComponentList.vue +85 -85
  77. package/src/component/shared/automation/SelectRule.vue +97 -97
  78. package/src/component/shared/automation/components/BillingByRent.vue +97 -97
  79. package/src/component/shared/automation/components/SendEmail.vue +93 -93
  80. package/src/component/shared/file-manager/FileManager.vue +390 -390
  81. package/src/component/shared/filter-builder/FilterBuilder.vue +220 -220
  82. package/src/component/shared/filter-builder/FilterQuery.vue +95 -95
  83. package/src/component/shared/query-builder/ConvertToOdata.js +86 -86
  84. package/src/component/shared/query-builder/DynamicComponent.vue +161 -161
  85. package/src/component/shared/query-builder/Fields.vue +93 -93
  86. package/src/component/shared/query-builder/Rules.vue +68 -68
  87. package/src/component/shared/query-builder/SelectRule.vue +97 -97
  88. package/src/component/shared/query-builder/Tags.vue +59 -59
  89. package/src/component/signature/Payment.vue +160 -160
  90. package/src/component/signature/Warning.vue +75 -75
  91. package/src/component/template/ReportCreateUpdate.vue +110 -110
  92. package/src/component/template/ViewTemplateDocumentView.vue +213 -213
  93. package/src/component/template/ViewTemplateImportFile.vue +347 -347
  94. package/src/component/template/ViewTemplateReportList.vue +240 -240
  95. package/src/component/template/ViewTemplateReportPreview.vue +521 -521
  96. package/src/component/template/ViewTemplateSelectOption.vue +46 -46
  97. package/src/component/template/model/Report.js +5 -5
  98. package/src/component/training/Course.vue +343 -343
  99. package/src/component/training/CourseView.vue +198 -198
  100. package/src/component/value-objects/Address.js +10 -10
  101. package/src/component/value-objects/Address.vue +173 -173
  102. package/src/component/value-objects/Contact.js +6 -6
  103. package/src/component/value-objects/Contact.vue +106 -106
  104. package/src/component/value-objects/Person.js +10 -10
  105. package/src/component/value-objects/Person.vue +130 -130
  106. package/src/store/modules/automation.js +30 -30
  107. package/src/store/modules/generic.js +15 -1
  108. package/src/store/modules/report.js +277 -277
  109. package/src/store/modules/user.js +69 -69
  110. package/src/store/modules/util.js +25 -25
@@ -1,521 +1,521 @@
1
- <template>
2
- <div>
3
- <Panel
4
- :module="panel.module"
5
- layout="large"
6
- :title="panel.title"
7
- :showVerticalFilter="panel.showVerticalFilter"
8
- :showSearch="panel.showSearch"
9
- :showButtons="panel.showButtons"
10
- >
11
- <div slot="content-main">
12
- <br />
13
- <Loading
14
- type="line"
15
- :center="false"
16
- v-show="loadingSearch"
17
- />
18
- <div v-show="!showFilter">
19
- <div
20
- class="div-progress"
21
- v-if="liveTotalRecords != baseParams.totalRecords && !loadingSearch && !cancel"
22
- >
23
- <ProgressBar
24
- :text="`Carregando ${liveTotalRecords} registros de ${baseParams.totalRecords}`"
25
- :value="liveTotalRecords"
26
- :max="baseParams.totalRecords"
27
- size="medium"
28
- />
29
- <div
30
- class="text-center cancel"
31
- @click="stop"
32
- >
33
- <i class="fa-solid fa-ban"></i> Cancelar
34
- </div>
35
- </div>
36
- <Molded>
37
- <b-row>
38
- <b-col sm="6">
39
- <div class="side-by-side">
40
- <Button
41
- _key="btnSearchReport"
42
- type="primary"
43
- title="Buscar"
44
- classIcon="fas fa-file-search"
45
- :disabled="btnSearchDisabled || !rulesIsValid"
46
- size="medium"
47
- :clicked="getAll"
48
- />
49
- </div>
50
- <div class="side-by-side">
51
- <Button
52
- _key="btnSaveReport"
53
- type="success"
54
- title="Salvar"
55
- classIcon="fas fa-save"
56
- size="small"
57
- :disabled="isLoading || btnSaveDisabled || !rulesIsValid"
58
- :params="{ name: 'save', title: 'Salvar', width: 550 }"
59
- :clicked="executeOpenModal"
60
- />
61
- </div>
62
- </b-col>
63
- <b-col
64
- class="text-right"
65
- sm="6"
66
- >
67
- <div class="side-by-side">
68
- <Button
69
- _key="btnExecuteOpenModal"
70
- type="info"
71
- title="Campos"
72
- classIcon="fas fa-database"
73
- size="small"
74
- :disabled="isLoading"
75
- :params="{ name: 'fields', title: 'Campos', width: 550 }"
76
- :clicked="executeOpenModal"
77
- />
78
- </div>
79
- <div class="side-by-side">
80
- <Button
81
- _key="btnExecuteOpenModal"
82
- type="info"
83
- title="Filtros"
84
- classIcon="fas fa-filter"
85
- size="small"
86
- :disabled="isLoading"
87
- :params="{ name: 'rules', title: 'Filtros', width: 900 }"
88
- :clicked="executeShowFilter"
89
- />
90
- </div>
91
- </b-col>
92
- </b-row>
93
- </Molded>
94
- <div class="div-tags">
95
- <Tags eventName="tagReport" />
96
- </div>
97
- <div
98
- class="div-required"
99
- v-show="!rulesIsValid"
100
- >
101
- <Alert
102
- type="info"
103
- v-for="rule in rulesRequired"
104
- :key="rule.id"
105
- >
106
- É necessário informar o filtro
107
- <span class="filter-required">{{ rule.title }}</span>, clique no botão "Filtros" para adicionar.
108
- </Alert>
109
- </div>
110
- <div
111
- class="body-report"
112
- v-show="showBodyReport && rulesIsValid"
113
- >
114
- <Report
115
- :minHeight="700"
116
- :header="content.headerTable"
117
- :data="content.data"
118
- :totalization="content.totalization"
119
- />
120
- </div>
121
- </div>
122
- <div v-show="showFilter">
123
- <Rules />
124
- <br />
125
- <div class="text-center">
126
- <Button
127
- _key="btnCancelFilter"
128
- type="info"
129
- classIcon="fa-solid fa-arrow-left"
130
- size="small"
131
- :clicked="executeHideFilter"
132
- />
133
- <Button
134
- _key="btnApplyFilter"
135
- type="primary"
136
- title="Aplicar"
137
- classIcon="fas fa-filter"
138
- size="small"
139
- :clicked="executeHideFilter"
140
- />
141
- </div>
142
- </div>
143
- </div>
144
- </Panel>
145
-
146
- <Modal
147
- :title="modalOptions.title"
148
- :width="modalOptions.width"
149
- v-show="showModal('templateReport')"
150
- >
151
- <ReportCreateUpdate
152
- :module="panel.module"
153
- v-show="modalOptions.name == 'save'"
154
- />
155
- <Fields v-if="modalOptions.name == 'fields'" />
156
- <div
157
- class="text-right btn-apply"
158
- v-show="modalOptions.name == 'fields' || modalOptions.name == 'rules'"
159
- >
160
- <Button
161
- _key="btnApplyFieldsAndRules"
162
- type="primary"
163
- title="Aplicar"
164
- classIcon="fas fa-filter"
165
- size="small"
166
- :clicked="applyFieldsAndRules"
167
- />
168
- </div>
169
- </Modal>
170
- </div>
171
- </template>
172
-
173
- <script>
174
- import Panel from "@nixweb/nixloc-ui/src/component/layout/Panel.vue";
175
- import Molded from "@nixweb/nixloc-ui/src/component/layout/Molded";
176
- import ProgressBar from "@nixweb/nixloc-ui/src/component/shared/ProgressBar";
177
- import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
178
- import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
179
- import Alert from "@nixweb/nixloc-ui/src/component/layout/Alert";
180
- import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
181
- import Loading from "@nixweb/nixloc-ui/src/component/shared/Loading.vue";
182
- import Report from "../shared/Report.vue";
183
-
184
- import ReportCreateUpdate from "@nixweb/nixloc-ui/src/component/template/ReportCreateUpdate.vue";
185
- import Fields from "@nixweb/nixloc-ui/src/component/shared/query-builder/Fields.vue";
186
- import Rules from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rules.vue";
187
-
188
- import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
189
-
190
- export default {
191
- name: "TemplateReportView",
192
- props: {
193
- panel: Object,
194
- templateList: Object,
195
- templateReport: Object,
196
- },
197
- components: {
198
- Panel,
199
- Molded,
200
- ProgressBar,
201
- Button,
202
- Modal,
203
- Alert,
204
- Tags,
205
- Loading,
206
- Report,
207
- ReportCreateUpdate,
208
- Fields,
209
- Rules,
210
- },
211
- data() {
212
- return {
213
- id: this.$route.params.id,
214
- urlGetById: "api/v1/shared/report/get-by-id",
215
- content: {
216
- headerTable: [],
217
- data: [],
218
- totalPages: [],
219
- totalization: {},
220
- noDataReturned: false,
221
- },
222
- baseParams: {
223
- currentPage: 0,
224
- totalPerPage: 100,
225
- totalPage: 0,
226
- totalRecords: 0,
227
- },
228
- modalOptions: {
229
- name: "",
230
- title: "",
231
- width: 0,
232
- },
233
- btnSearchDisabled: false,
234
- loadingSearch: false,
235
- btnSaveDisabled: true,
236
- isLoading: false,
237
- showBodyReport: false,
238
- showFilter: false,
239
- cancel: false,
240
- };
241
- },
242
- mounted() {
243
- this.addReport({
244
- id: this.id,
245
- fields: this.templateReport.fields,
246
- rules: this.templateReport.rules,
247
- });
248
-
249
- this.clearTotalization();
250
-
251
- if (this.id) this.getById();
252
-
253
- if (!this.id) this.removeLoadingWithTime();
254
- },
255
- beforeDestroy() {
256
- this.removeInitialReportCustom();
257
- },
258
- methods: {
259
- ...mapActions("generic", ["getApi", "getApiOdata"]),
260
- ...mapActions("report", [
261
- "addReport",
262
- "addInitialReportCustom",
263
- "removeInitialReportCustom",
264
- ]),
265
- ...mapMutations("generic", [
266
- "addEvent",
267
- "openModal",
268
- "hideModal",
269
- "removeLoading",
270
- ]),
271
- ...mapMutations("report", ["clearTotalization"]),
272
- getById() {
273
- let params = { url: this.urlGetById, obj: { id: this.id } };
274
- this.getApi(params).then((response) => {
275
- const query = JSON.parse(response.content.query);
276
- let report = {
277
- selectedFields: query.selectedFields,
278
- selectedRules: query.selectedRules,
279
- };
280
- this.addInitialReportCustom(report);
281
- this.removeLoadingWithTime();
282
- });
283
- },
284
- getAll() {
285
- this.btnSearchDisabled = true;
286
- this.loadingSearch = true;
287
- this.cancel = false;
288
-
289
- if (this.rulesIsValid) {
290
- this.getTotalRecords();
291
- this.removeLoading(["btnSearchReport"]);
292
-
293
- if (this.oDataFilter.totalization) this.totalization();
294
- if (!this.oDataFilter.totalization) this.content.totalization = {};
295
- }
296
- },
297
- getTotalRecords() {
298
- let paramsQuery = { url: this.urlQuery };
299
- this.resetData();
300
- this.getApiOdata(paramsQuery).then((response) => {
301
- this.isLoading = true;
302
- let totalRecords = response["@odata.count"];
303
- this.loadingSearch = false;
304
-
305
- if (totalRecords == 0) this.noDataReturned = true;
306
-
307
- this.baseParams.totalRecords = totalRecords;
308
- this.baseParams.totalPage = Math.ceil(
309
- totalRecords / this.baseParams.totalPerPage
310
- );
311
-
312
- if (this.baseParams.totalPage <= 1)
313
- this.loadingOnlyIfOnePage(response.value);
314
- if (this.baseParams.totalPage > 1) this.loadingOnlyIfManyPages();
315
-
316
- this.content.headerTable = this.headerTable;
317
- this.showBodyReport = true;
318
- });
319
- },
320
- totalization() {
321
- let params = { url: this.urlTotalization };
322
- this.getApiOdata(params).then((response) => {
323
- const result = Object.entries(response[0]);
324
- this.content.totalization = result;
325
- });
326
- },
327
- loadingOnlyIfOnePage(data) {
328
- this.content.data = data;
329
- this.btnSearchDisabled = true;
330
- let self = this;
331
- setTimeout(function () {
332
- self.isLoading = false;
333
- }, 100);
334
- },
335
- loadingOnlyIfManyPages() {
336
- let seq = 0;
337
- while (seq <= this.baseParams.totalPage - 1) {
338
- this.content.totalPages.push(seq);
339
- seq++;
340
- }
341
- },
342
- getAllManyPages() {
343
- let paramsQuery = { url: this.urlQuery };
344
- this.getApiOdata(paramsQuery).then((response) => {
345
- let self = this;
346
- response.value.forEach(function (obj) {
347
- self.content.data.push(obj);
348
- });
349
- this.content.totalPages.pop();
350
- this.baseParams.currentPage++;
351
- });
352
- },
353
- resetData() {
354
- this.isLoading = false;
355
- this.content.data = [];
356
- this.content.totalPages = [];
357
- this.baseParams.currentPage = 0;
358
- this.baseParams.totalRecords = 0;
359
- this.noDataReturned = false;
360
- },
361
- executeOpenModal(params) {
362
- if (this.id && params.name == "save") {
363
- this.addEvent({ name: "saveReport" });
364
- } else {
365
- this.modalOptions = params;
366
- this.openModal("templateReport");
367
- this.removeLoading(["btnExecuteOpenModal", "btnSaveReport"]);
368
- }
369
- },
370
- executeShowFilter() {
371
- this.showFilter = true;
372
- this.removeLoading(["btnExecuteOpenModal", "btnSaveReport"]);
373
- },
374
- executeHideFilter() {
375
- this.showFilter = false;
376
- this.removeLoading(["btnCancelFilter", "btnApplyFilter"]);
377
- },
378
- applyFieldsAndRules() {
379
- this.hideModal("templateReport");
380
- this.removeLoading(["btnApplyFieldsAndRules"]);
381
- },
382
- removeLoadingWithTime() {
383
- let self = this;
384
- setTimeout(function () {
385
- self.btnSaveDisabled = true;
386
- self.removeLoading(["panel"]);
387
- }, 350);
388
- },
389
- stop() {
390
- this.cancel = true;
391
- this.btnSearchDisabled = false;
392
- this.btnSaveDisabled = false;
393
- this.isLoading = false;
394
- },
395
- },
396
- computed: {
397
- ...mapGetters("generic", ["showModal", "event"]),
398
- ...mapGetters("report", [
399
- "headerTable",
400
- "oDataFilter",
401
- "oDataSelect",
402
- "oDataOrderBy",
403
- "rulesIsValid",
404
- "rulesRequired",
405
- ]),
406
- ...mapState("report", ["report"]),
407
- urlQuery() {
408
- let skip = this.baseParams.currentPage * this.baseParams.totalPerPage;
409
- let baseUrl = `${this.templateList.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.query}&$skip=${skip}&$top=${this.baseParams.totalPerPage}&$count=true`;
410
- return baseUrl.replace("&&", "&");
411
- },
412
- urlTotalization() {
413
- let query = this.oDataFilter.query
414
- ? `$apply=filter(${this.oDataFilter.query.replace("$filter=", "")})/`
415
- : "$apply=";
416
- let baseUrl = `${
417
- this.templateList.urlGetApi
418
- }?${query}aggregate(${this.oDataFilter.totalization.replace(",", "")})`;
419
- return baseUrl;
420
- },
421
- liveTotalRecords() {
422
- return this.content.data.length;
423
- },
424
- },
425
- watch: {
426
- event: {
427
- handler(event) {
428
- if (event.name == "savedReport") this.btnSaveDisabled = true;
429
- },
430
- deep: true,
431
- },
432
- "content.totalPages": {
433
- handler(totalPages) {
434
- if (totalPages.length > 0 && !this.cancel) {
435
- let self = this;
436
- setTimeout(function () {
437
- self.getAllManyPages();
438
- }, 1000);
439
- }
440
- if (totalPages.length == 1) this.isLoading = false;
441
- },
442
- deep: true,
443
- },
444
- oDataFilter: {
445
- handler() {
446
- this.btnSearchDisabled = false;
447
- this.btnSaveDisabled = false;
448
- this.showBodyReport = false;
449
- this.resetData();
450
- },
451
- deep: true,
452
- },
453
- oDataSelect: {
454
- handler() {
455
- this.btnSearchDisabled = false;
456
- this.btnSaveDisabled = false;
457
- },
458
- deep: true,
459
- },
460
- oDataOrderBy: {
461
- handler() {
462
- this.btnSearchDisabled = false;
463
- this.btnSaveDisabled = false;
464
- },
465
- deep: true,
466
- },
467
- },
468
- };
469
- </script>
470
-
471
- <style scoped>
472
- .div-button {
473
- padding-bottom: 15px;
474
- }
475
-
476
- .div-progress {
477
- margin-bottom: 10px;
478
- }
479
-
480
- .div-sem-data {
481
- margin-top: 20px;
482
- }
483
-
484
- .div-table {
485
- margin-top: 20px;
486
- }
487
-
488
- .div-separacao {
489
- margin-left: 10px;
490
- margin-right: 5px;
491
- }
492
-
493
- .div-Totalization {
494
- margin-top: 20px;
495
- }
496
-
497
- .div-tags {
498
- margin-top: 15px;
499
- }
500
-
501
- .div-required {
502
- margin-top: 20px;
503
- }
504
-
505
- .filter-required {
506
- font-weight: 500;
507
- }
508
-
509
- .btn-apply {
510
- margin-top: 10px;
511
- }
512
-
513
- .body-report {
514
- margin-top: 30px;
515
- }
516
-
517
- .cancel {
518
- color: red;
519
- cursor: pointer;
520
- }
521
- </style>
1
+ <template>
2
+ <div>
3
+ <Panel
4
+ :module="panel.module"
5
+ layout="large"
6
+ :title="panel.title"
7
+ :showVerticalFilter="panel.showVerticalFilter"
8
+ :showSearch="panel.showSearch"
9
+ :showButtons="panel.showButtons"
10
+ >
11
+ <div slot="content-main">
12
+ <br />
13
+ <Loading
14
+ type="line"
15
+ :center="false"
16
+ v-show="loadingSearch"
17
+ />
18
+ <div v-show="!showFilter">
19
+ <div
20
+ class="div-progress"
21
+ v-if="liveTotalRecords != baseParams.totalRecords && !loadingSearch && !cancel"
22
+ >
23
+ <ProgressBar
24
+ :text="`Carregando ${liveTotalRecords} registros de ${baseParams.totalRecords}`"
25
+ :value="liveTotalRecords"
26
+ :max="baseParams.totalRecords"
27
+ size="medium"
28
+ />
29
+ <div
30
+ class="text-center cancel"
31
+ @click="stop"
32
+ >
33
+ <i class="fa-solid fa-ban"></i> Cancelar
34
+ </div>
35
+ </div>
36
+ <Molded>
37
+ <b-row>
38
+ <b-col sm="6">
39
+ <div class="side-by-side">
40
+ <Button
41
+ _key="btnSearchReport"
42
+ type="primary"
43
+ title="Buscar"
44
+ classIcon="fas fa-file-search"
45
+ :disabled="btnSearchDisabled || !rulesIsValid"
46
+ size="medium"
47
+ :clicked="getAll"
48
+ />
49
+ </div>
50
+ <div class="side-by-side">
51
+ <Button
52
+ _key="btnSaveReport"
53
+ type="success"
54
+ title="Salvar"
55
+ classIcon="fas fa-save"
56
+ size="small"
57
+ :disabled="isLoading || btnSaveDisabled || !rulesIsValid"
58
+ :params="{ name: 'save', title: 'Salvar', width: 550 }"
59
+ :clicked="executeOpenModal"
60
+ />
61
+ </div>
62
+ </b-col>
63
+ <b-col
64
+ class="text-right"
65
+ sm="6"
66
+ >
67
+ <div class="side-by-side">
68
+ <Button
69
+ _key="btnExecuteOpenModal"
70
+ type="info"
71
+ title="Campos"
72
+ classIcon="fas fa-database"
73
+ size="small"
74
+ :disabled="isLoading"
75
+ :params="{ name: 'fields', title: 'Campos', width: 550 }"
76
+ :clicked="executeOpenModal"
77
+ />
78
+ </div>
79
+ <div class="side-by-side">
80
+ <Button
81
+ _key="btnExecuteOpenModal"
82
+ type="info"
83
+ title="Filtros"
84
+ classIcon="fas fa-filter"
85
+ size="small"
86
+ :disabled="isLoading"
87
+ :params="{ name: 'rules', title: 'Filtros', width: 900 }"
88
+ :clicked="executeShowFilter"
89
+ />
90
+ </div>
91
+ </b-col>
92
+ </b-row>
93
+ </Molded>
94
+ <div class="div-tags">
95
+ <Tags eventName="tagReport" />
96
+ </div>
97
+ <div
98
+ class="div-required"
99
+ v-show="!rulesIsValid"
100
+ >
101
+ <Alert
102
+ type="info"
103
+ v-for="rule in rulesRequired"
104
+ :key="rule.id"
105
+ >
106
+ É necessário informar o filtro
107
+ <span class="filter-required">{{ rule.title }}</span>, clique no botão "Filtros" para adicionar.
108
+ </Alert>
109
+ </div>
110
+ <div
111
+ class="body-report"
112
+ v-show="showBodyReport && rulesIsValid"
113
+ >
114
+ <Report
115
+ :minHeight="700"
116
+ :header="content.headerTable"
117
+ :data="content.data"
118
+ :totalization="content.totalization"
119
+ />
120
+ </div>
121
+ </div>
122
+ <div v-show="showFilter">
123
+ <Rules />
124
+ <br />
125
+ <div class="text-center">
126
+ <Button
127
+ _key="btnCancelFilter"
128
+ type="info"
129
+ classIcon="fa-solid fa-arrow-left"
130
+ size="small"
131
+ :clicked="executeHideFilter"
132
+ />
133
+ <Button
134
+ _key="btnApplyFilter"
135
+ type="primary"
136
+ title="Aplicar"
137
+ classIcon="fas fa-filter"
138
+ size="small"
139
+ :clicked="executeHideFilter"
140
+ />
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </Panel>
145
+
146
+ <Modal
147
+ :title="modalOptions.title"
148
+ :width="modalOptions.width"
149
+ v-show="showModal('templateReport')"
150
+ >
151
+ <ReportCreateUpdate
152
+ :module="panel.module"
153
+ v-show="modalOptions.name == 'save'"
154
+ />
155
+ <Fields v-if="modalOptions.name == 'fields'" />
156
+ <div
157
+ class="text-right btn-apply"
158
+ v-show="modalOptions.name == 'fields' || modalOptions.name == 'rules'"
159
+ >
160
+ <Button
161
+ _key="btnApplyFieldsAndRules"
162
+ type="primary"
163
+ title="Aplicar"
164
+ classIcon="fas fa-filter"
165
+ size="small"
166
+ :clicked="applyFieldsAndRules"
167
+ />
168
+ </div>
169
+ </Modal>
170
+ </div>
171
+ </template>
172
+
173
+ <script>
174
+ import Panel from "@nixweb/nixloc-ui/src/component/layout/Panel.vue";
175
+ import Molded from "@nixweb/nixloc-ui/src/component/layout/Molded";
176
+ import ProgressBar from "@nixweb/nixloc-ui/src/component/shared/ProgressBar";
177
+ import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
178
+ import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
179
+ import Alert from "@nixweb/nixloc-ui/src/component/layout/Alert";
180
+ import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
181
+ import Loading from "@nixweb/nixloc-ui/src/component/shared/Loading.vue";
182
+ import Report from "../shared/Report.vue";
183
+
184
+ import ReportCreateUpdate from "@nixweb/nixloc-ui/src/component/template/ReportCreateUpdate.vue";
185
+ import Fields from "@nixweb/nixloc-ui/src/component/shared/query-builder/Fields.vue";
186
+ import Rules from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rules.vue";
187
+
188
+ import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
189
+
190
+ export default {
191
+ name: "TemplateReportView",
192
+ props: {
193
+ panel: Object,
194
+ templateList: Object,
195
+ templateReport: Object,
196
+ },
197
+ components: {
198
+ Panel,
199
+ Molded,
200
+ ProgressBar,
201
+ Button,
202
+ Modal,
203
+ Alert,
204
+ Tags,
205
+ Loading,
206
+ Report,
207
+ ReportCreateUpdate,
208
+ Fields,
209
+ Rules,
210
+ },
211
+ data() {
212
+ return {
213
+ id: this.$route.params.id,
214
+ urlGetById: "api/v1/shared/report/get-by-id",
215
+ content: {
216
+ headerTable: [],
217
+ data: [],
218
+ totalPages: [],
219
+ totalization: {},
220
+ noDataReturned: false,
221
+ },
222
+ baseParams: {
223
+ currentPage: 0,
224
+ totalPerPage: 100,
225
+ totalPage: 0,
226
+ totalRecords: 0,
227
+ },
228
+ modalOptions: {
229
+ name: "",
230
+ title: "",
231
+ width: 0,
232
+ },
233
+ btnSearchDisabled: false,
234
+ loadingSearch: false,
235
+ btnSaveDisabled: true,
236
+ isLoading: false,
237
+ showBodyReport: false,
238
+ showFilter: false,
239
+ cancel: false,
240
+ };
241
+ },
242
+ mounted() {
243
+ this.addReport({
244
+ id: this.id,
245
+ fields: this.templateReport.fields,
246
+ rules: this.templateReport.rules,
247
+ });
248
+
249
+ this.clearTotalization();
250
+
251
+ if (this.id) this.getById();
252
+
253
+ if (!this.id) this.removeLoadingWithTime();
254
+ },
255
+ beforeDestroy() {
256
+ this.removeInitialReportCustom();
257
+ },
258
+ methods: {
259
+ ...mapActions("generic", ["getApi", "getApiOdata"]),
260
+ ...mapActions("report", [
261
+ "addReport",
262
+ "addInitialReportCustom",
263
+ "removeInitialReportCustom",
264
+ ]),
265
+ ...mapMutations("generic", [
266
+ "addEvent",
267
+ "openModal",
268
+ "hideModal",
269
+ "removeLoading",
270
+ ]),
271
+ ...mapMutations("report", ["clearTotalization"]),
272
+ getById() {
273
+ let params = { url: this.urlGetById, obj: { id: this.id } };
274
+ this.getApi(params).then((response) => {
275
+ const query = JSON.parse(response.content.query);
276
+ let report = {
277
+ selectedFields: query.selectedFields,
278
+ selectedRules: query.selectedRules,
279
+ };
280
+ this.addInitialReportCustom(report);
281
+ this.removeLoadingWithTime();
282
+ });
283
+ },
284
+ getAll() {
285
+ this.btnSearchDisabled = true;
286
+ this.loadingSearch = true;
287
+ this.cancel = false;
288
+
289
+ if (this.rulesIsValid) {
290
+ this.getTotalRecords();
291
+ this.removeLoading(["btnSearchReport"]);
292
+
293
+ if (this.oDataFilter.totalization) this.totalization();
294
+ if (!this.oDataFilter.totalization) this.content.totalization = {};
295
+ }
296
+ },
297
+ getTotalRecords() {
298
+ let paramsQuery = { url: this.urlQuery };
299
+ this.resetData();
300
+ this.getApiOdata(paramsQuery).then((response) => {
301
+ this.isLoading = true;
302
+ let totalRecords = response["@odata.count"];
303
+ this.loadingSearch = false;
304
+
305
+ if (totalRecords == 0) this.noDataReturned = true;
306
+
307
+ this.baseParams.totalRecords = totalRecords;
308
+ this.baseParams.totalPage = Math.ceil(
309
+ totalRecords / this.baseParams.totalPerPage
310
+ );
311
+
312
+ if (this.baseParams.totalPage <= 1)
313
+ this.loadingOnlyIfOnePage(response.value);
314
+ if (this.baseParams.totalPage > 1) this.loadingOnlyIfManyPages();
315
+
316
+ this.content.headerTable = this.headerTable;
317
+ this.showBodyReport = true;
318
+ });
319
+ },
320
+ totalization() {
321
+ let params = { url: this.urlTotalization };
322
+ this.getApiOdata(params).then((response) => {
323
+ const result = Object.entries(response[0]);
324
+ this.content.totalization = result;
325
+ });
326
+ },
327
+ loadingOnlyIfOnePage(data) {
328
+ this.content.data = data;
329
+ this.btnSearchDisabled = true;
330
+ let self = this;
331
+ setTimeout(function () {
332
+ self.isLoading = false;
333
+ }, 100);
334
+ },
335
+ loadingOnlyIfManyPages() {
336
+ let seq = 0;
337
+ while (seq <= this.baseParams.totalPage - 1) {
338
+ this.content.totalPages.push(seq);
339
+ seq++;
340
+ }
341
+ },
342
+ getAllManyPages() {
343
+ let paramsQuery = { url: this.urlQuery };
344
+ this.getApiOdata(paramsQuery).then((response) => {
345
+ let self = this;
346
+ response.value.forEach(function (obj) {
347
+ self.content.data.push(obj);
348
+ });
349
+ this.content.totalPages.pop();
350
+ this.baseParams.currentPage++;
351
+ });
352
+ },
353
+ resetData() {
354
+ this.isLoading = false;
355
+ this.content.data = [];
356
+ this.content.totalPages = [];
357
+ this.baseParams.currentPage = 0;
358
+ this.baseParams.totalRecords = 0;
359
+ this.noDataReturned = false;
360
+ },
361
+ executeOpenModal(params) {
362
+ if (this.id && params.name == "save") {
363
+ this.addEvent({ name: "saveReport" });
364
+ } else {
365
+ this.modalOptions = params;
366
+ this.openModal("templateReport");
367
+ this.removeLoading(["btnExecuteOpenModal", "btnSaveReport"]);
368
+ }
369
+ },
370
+ executeShowFilter() {
371
+ this.showFilter = true;
372
+ this.removeLoading(["btnExecuteOpenModal", "btnSaveReport"]);
373
+ },
374
+ executeHideFilter() {
375
+ this.showFilter = false;
376
+ this.removeLoading(["btnCancelFilter", "btnApplyFilter"]);
377
+ },
378
+ applyFieldsAndRules() {
379
+ this.hideModal("templateReport");
380
+ this.removeLoading(["btnApplyFieldsAndRules"]);
381
+ },
382
+ removeLoadingWithTime() {
383
+ let self = this;
384
+ setTimeout(function () {
385
+ self.btnSaveDisabled = true;
386
+ self.removeLoading(["panel"]);
387
+ }, 350);
388
+ },
389
+ stop() {
390
+ this.cancel = true;
391
+ this.btnSearchDisabled = false;
392
+ this.btnSaveDisabled = false;
393
+ this.isLoading = false;
394
+ },
395
+ },
396
+ computed: {
397
+ ...mapGetters("generic", ["showModal", "event"]),
398
+ ...mapGetters("report", [
399
+ "headerTable",
400
+ "oDataFilter",
401
+ "oDataSelect",
402
+ "oDataOrderBy",
403
+ "rulesIsValid",
404
+ "rulesRequired",
405
+ ]),
406
+ ...mapState("report", ["report"]),
407
+ urlQuery() {
408
+ let skip = this.baseParams.currentPage * this.baseParams.totalPerPage;
409
+ let baseUrl = `${this.templateList.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.query}&$skip=${skip}&$top=${this.baseParams.totalPerPage}&$count=true`;
410
+ return baseUrl.replace("&&", "&");
411
+ },
412
+ urlTotalization() {
413
+ let query = this.oDataFilter.query
414
+ ? `$apply=filter(${this.oDataFilter.query.replace("$filter=", "")})/`
415
+ : "$apply=";
416
+ let baseUrl = `${
417
+ this.templateList.urlGetApi
418
+ }?${query}aggregate(${this.oDataFilter.totalization.replace(",", "")})`;
419
+ return baseUrl;
420
+ },
421
+ liveTotalRecords() {
422
+ return this.content.data.length;
423
+ },
424
+ },
425
+ watch: {
426
+ event: {
427
+ handler(event) {
428
+ if (event.name == "savedReport") this.btnSaveDisabled = true;
429
+ },
430
+ deep: true,
431
+ },
432
+ "content.totalPages": {
433
+ handler(totalPages) {
434
+ if (totalPages.length > 0 && !this.cancel) {
435
+ let self = this;
436
+ setTimeout(function () {
437
+ self.getAllManyPages();
438
+ }, 1000);
439
+ }
440
+ if (totalPages.length == 1) this.isLoading = false;
441
+ },
442
+ deep: true,
443
+ },
444
+ oDataFilter: {
445
+ handler() {
446
+ this.btnSearchDisabled = false;
447
+ this.btnSaveDisabled = false;
448
+ this.showBodyReport = false;
449
+ this.resetData();
450
+ },
451
+ deep: true,
452
+ },
453
+ oDataSelect: {
454
+ handler() {
455
+ this.btnSearchDisabled = false;
456
+ this.btnSaveDisabled = false;
457
+ },
458
+ deep: true,
459
+ },
460
+ oDataOrderBy: {
461
+ handler() {
462
+ this.btnSearchDisabled = false;
463
+ this.btnSaveDisabled = false;
464
+ },
465
+ deep: true,
466
+ },
467
+ },
468
+ };
469
+ </script>
470
+
471
+ <style scoped>
472
+ .div-button {
473
+ padding-bottom: 15px;
474
+ }
475
+
476
+ .div-progress {
477
+ margin-bottom: 10px;
478
+ }
479
+
480
+ .div-sem-data {
481
+ margin-top: 20px;
482
+ }
483
+
484
+ .div-table {
485
+ margin-top: 20px;
486
+ }
487
+
488
+ .div-separacao {
489
+ margin-left: 10px;
490
+ margin-right: 5px;
491
+ }
492
+
493
+ .div-Totalization {
494
+ margin-top: 20px;
495
+ }
496
+
497
+ .div-tags {
498
+ margin-top: 15px;
499
+ }
500
+
501
+ .div-required {
502
+ margin-top: 20px;
503
+ }
504
+
505
+ .filter-required {
506
+ font-weight: 500;
507
+ }
508
+
509
+ .btn-apply {
510
+ margin-top: 10px;
511
+ }
512
+
513
+ .body-report {
514
+ margin-top: 30px;
515
+ }
516
+
517
+ .cancel {
518
+ color: red;
519
+ cursor: pointer;
520
+ }
521
+ </style>