@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
@@ -1,489 +1,513 @@
1
- import axios from "@/config/axios";
2
- import tips from "@/config/dicas";
3
- import Token from "@nixweb/nixloc-ui/src/config/token";
4
-
5
- export default {
6
- namespaced: true,
7
- state: {
8
- modal: {
9
- name: undefined,
10
- open: false
11
- },
12
- vodal: {
13
- name: undefined,
14
- open: false
15
- },
16
- notifications: [],
17
- pagination: [],
18
- selected: [],
19
- loading: [],
20
- event: {
21
- dateTime: undefined,
22
- name: undefined,
23
- data: {}
24
- },
25
- toast: {
26
- dateTime: undefined,
27
- type: undefined,
28
- },
29
- ids: undefined,
30
- search: { content: "", filter: { text: "Contém", value: "contem" } },
31
- documentHtml: "",
32
- selectStatic: { dateTime: undefined, targetField: undefined, value: undefined },
33
- executedSearch: false,
34
- clearedSearch: false,
35
- methodExecutedApi: undefined,
36
- },
37
- getters: {
38
- showModal: (state) => (name) => {
39
- if (name == state.modal.name) return true;
40
- return false;
41
- },
42
- showVodal: (state) => (name) => {
43
- if (name == state.vodal.name) return true;
44
- return false;
45
- },
46
- isLoading: (state) => (key) => {
47
- var loading = state.loading.find(value => {
48
- return value === key
49
- })
50
- if (loading) return true;
51
- return false;
52
- },
53
- pagination: (state) => (key) => {
54
- return state.pagination.find(obj => {
55
- return obj.key === key
56
- })
57
- },
58
- tip: (state) => (obj) => {
59
- return tips.find(value => {
60
- if (value.formName == obj.formName && value.field == obj.field)
61
- return value
62
- })
63
- },
64
- event: (state) => {
65
- return state.event;
66
- },
67
- documentPreview: (state) => {
68
- let documentHtml = state.documentHtml
69
- let ret = documentHtml;
70
-
71
- var tables = document.getElementsByTagName("table");
72
- let total = tables.length;
73
-
74
- let config = [];
75
-
76
- let index = 0;
77
- while (index <= total - 1) {
78
-
79
- let table = document.getElementsByTagName("table")[index];
80
- let th = table.getElementsByTagName("th")[0];
81
-
82
- let obj = {
83
- vForGrouped: "",
84
- vForSimple: "",
85
- nameGroup: "",
86
- nameGroupReplace: ""
87
- };
88
-
89
- if (th) {
90
- let isGrouped = th.innerText.includes("n.grupo");
91
- let isProduct = th.innerText.includes("n.produto");
92
- let isPeriod = th.innerText.includes("n.periodo");
93
- let isPayment = th.innerText.includes("n.pagamento");
94
-
95
- if (isProduct) {
96
- obj.vForSimple = "v-for='p in d.produto'";
97
- config.push(obj);
98
- } else if (isPeriod) {
99
- obj.vForSimple = "v-for='pe in d.periodo'";
100
- config.push(obj);
101
- } else if (isPayment) {
102
- obj.vForSimple = "v-for='pg in d.pagamento'";
103
- config.push(obj);
104
- } else if (isGrouped) {
105
- obj.vForGrouped = "v-for='(produto, grN) in produtoAgrupado'";
106
- obj.vForSimple = "v-for='p in d.produto'";
107
-
108
- var initIndex = documentHtml.split("<tbody>", index + 1).join("<tbody>").length;
109
- var lastIndex = documentHtml.split("</tbody>", index + 1).join("</tbody>").length;
110
-
111
- let tbody = documentHtml.substring(documentHtml.indexOf("<tbody>", initIndex), documentHtml.lastIndexOf("</tbody>", lastIndex));
112
-
113
- let tr = tbody.substring(tbody.indexOf("<tr>"), tbody.lastIndexOf("</tr>"));
114
-
115
- obj.nameGroup = tr.substring(0, tr.indexOf('</tr>')) + "</tr>";
116
- obj.nameGroup = obj.nameGroup.replaceAll("\"", "'");
117
- obj.nameGroupReplace = obj.nameGroup.replace("<tr>", "").replace("</tr>", "");
118
- config.push(obj);
119
-
120
- } else {
121
- config.push(obj);
122
- }
123
- } else {
124
- config.push(obj);
125
- }
126
- index++;
127
- }
128
-
129
- let replace = "";
130
- config.forEach(x => {
131
- replace += `.replace("<tbody>${x.nameGroup}<tr>", "<tbody ${x.vForGrouped}>${x.nameGroupReplace}<tr ${x.vForSimple}>")`;
132
- });
133
-
134
- var retParse = ret.replaceAll("\"", "'");
135
- retParse = eval(`ret${replace}`);
136
-
137
- var classImportant = retParse
138
- .replaceAll("n.grupo", "")
139
- .replaceAll("n.produto", "")
140
- .replaceAll("n.periodo", "")
141
- .replaceAll("n.pagamento", "")
142
- .replaceAll("<p>&nbsp!important;</p>", "<p>&nbsp</p>");
143
-
144
- return classImportant;
145
- },
146
- groupBy: () => (obj) => {
147
- const result = {};
148
- obj.array.forEach((item) => {
149
- if (!result[item[obj.key]]) {
150
- result[item[obj.key]] = [];
151
- }
152
- result[item[obj.key]].push(item);
153
- });
154
- return result;
155
- },
156
- },
157
- mutations: {
158
- openModal: (state, name) => {
159
- state.modal.name = name;
160
- state.modal.open = true;
161
- },
162
- hideModal: (state) => {
163
- state.modal.open = false;
164
- },
165
- openVodal: (state, name) => {
166
- state.vodal.name = name;
167
- state.vodal.open = true;
168
- },
169
- hideVodal: (state) => {
170
- state.vodal.name = "";
171
- state.vodal.open = false;
172
- },
173
- updateSearch: (state, value) => {
174
- state.search = value;
175
- },
176
- executedSearch: (state) => {
177
- state.executedSearch = state.executedSearch = !state.executedSearch
178
- },
179
- clearedSearch: (state) => {
180
- state.clearedSearch = state.clearedSearch = !state.clearedSearch
181
- },
182
- addSelected: (state, selected) => {
183
- state.selected = selected;
184
- },
185
- addToast: (state, action) => {
186
- state.toast.dateTime = new Date();
187
- state.toast.type = action;
188
- },
189
- addMethodExecutedApi: (state, action) => {
190
- state.methodExecutedApi = action;
191
- },
192
- cleanMethodExecutedApi: (state) => {
193
- state.methodExecutedApi = "";
194
- },
195
- addLoading: (state, key) => {
196
- state.loading.push(key);
197
- },
198
- removeLoading: (state, listKey) => {
199
- listKey.forEach(function (key) {
200
- let filter = state.loading.filter(function (item) {
201
- return item != key;
202
- });
203
- state.loading = filter;
204
- });
205
- },
206
- addPagination: (state, pagination) => {
207
- state.pagination.push(pagination);
208
- },
209
- updatePagination: (state, pagination) => {
210
- state.pagination.forEach(function (obj) {
211
- if (obj.key == pagination.key)
212
- obj.totalPerPage = pagination.totalPerPage;
213
- });
214
- },
215
- updateDocumentHtml: (state, value) => {
216
- state.documentHtml = value;
217
- },
218
- addEvent: (state, obj) => {
219
- state.event.dateTime = new Date();
220
- state.event.name = obj.name;
221
- state.event.data = obj.data;
222
- },
223
- removeEvent: (state) => {
224
- state.event = {};
225
- },
226
- addNotifications: (state, notifications) => {
227
- state.notifications = notifications;
228
- },
229
- removeNotificarions: (state) => {
230
- state.notifications = [];
231
- },
232
- addNotificationErrorApi: (state) => {
233
- var erro = { property: "ERRO API", message: "Falha de Comunicação!" };
234
- state.notifications = [erro];
235
- },
236
- listIdToString: (state, listId) => {
237
- state.ids = "";
238
- listId.forEach(function (id) {
239
- state.ids += `${id},`;
240
- });
241
- },
242
- addFilter: (state, obj) => {
243
- state.selectStatic.dateTime = new Date();
244
- state.selectStatic.targetField = obj.targetField;
245
- state.selectStatic.value = obj.value;
246
- },
247
-
248
- },
249
- actions: {
250
- postApi: async function (context, params) {
251
- context.commit('cleanMethodExecutedApi');
252
- return axios.post(params.url, params.obj, {
253
- headers: new Token().tokenHeaders(),
254
- })
255
- .then((response) => {
256
- if (response.data.success) {
257
- context.commit('addMethodExecutedApi', 'postApi');
258
-
259
- if (!params.notNotifyToast)
260
- context.commit('addToast', 'postApi');
261
-
262
- context.commit('removeNotificarions');
263
- context.commit('validation/removeFormDirty', null, { root: true });
264
- return response.data;
265
- } else {
266
-
267
- context.commit('addNotifications', response.data.notifications)
268
- context.commit('addToast', 'postApiError');
269
- return response.data;
270
- }
271
- }, (err) => {
272
- if (err.response)
273
- if (err.response.status === 403)
274
- context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
275
-
276
- if (!err.response)
277
- context.commit('addNotificationErrorApi');
278
- return false;
279
- })
280
- },
281
- putApi: async function (context, params) {
282
- context.commit('cleanMethodExecutedApi');
283
- return axios.put(params.url, params.obj, {
284
- headers: new Token().tokenHeaders(),
285
- })
286
- .then((response) => {
287
- if (response.data.success) {
288
- context.commit('addMethodExecutedApi', 'putApi');
289
-
290
- if (!params.notNotifyToast)
291
- context.commit('addToast', 'putApi');
292
-
293
- context.commit('removeNotificarions');
294
- context.commit('validation/removeFormDirty', null, { root: true });
295
- return response.data;
296
- } else {
297
- context.commit('addToast', 'putApiErro');
298
- context.commit('addNotifications', response.data.notifications)
299
- return response.data;
300
- }
301
- }, (err) => {
302
- if (err.response)
303
- if (err.response.status === 403)
304
- context.commit('addNotifications', [{ message: "Usuário sem permissão para modificar!" }])
305
-
306
- if (!err.response)
307
- context.commit('addNotificationErrorApi');
308
-
309
- return false;
310
- })
311
- },
312
- getApi: async function (context, params) {
313
- context.commit('cleanMethodExecutedApi');
314
- return axios.get(params.url, {
315
- params: params.obj,
316
- headers: new Token().tokenHeaders(),
317
- })
318
- .then((response) => {
319
- if (response.data.success) {
320
- context.commit('addMethodExecutedApi', params.methodExecutedApi);
321
- context.commit('removeNotificarions');
322
- return response.data;
323
- } else {
324
- context.commit('addNotifications', response.data.notifications)
325
- context.commit('addToast', 'falhaGenerica');
326
- return response.data;
327
- }
328
- }, (err) => {
329
- context.commit('addNotificationErrorApi');
330
- return false;
331
- })
332
- },
333
- getApiOdata: async function (context, params) {
334
- return axios.get(params.url, {
335
- headers: new Token().tokenHeaders(),
336
- })
337
- .then((response) => {
338
- return response.data;
339
- }, (err) => {
340
- context.commit('addNotificationErrorApi');
341
- return false;
342
- })
343
- },
344
- deleteAllApi: async function (context, params) {
345
-
346
- context.commit('cleanMethodExecutedApi');
347
- context.commit('listIdToString', params.selected);
348
-
349
- let url = params.url;
350
- let ids = context.state.ids;
351
-
352
- return axios.delete(`${url}?ids=${ids}`, {
353
- headers: new Token().tokenHeaders(),
354
- })
355
- .then((response) => {
356
- if (response.data.success) {
357
- context.commit('addMethodExecutedApi', 'deleteAllApi');
358
- context.commit('addToast', 'deleteApiSucesso');
359
- context.commit('removeNotificarions');
360
- return response.data;
361
- } else {
362
- context.commit('addNotifications', response.data.notifications)
363
- context.commit('addMethodExecutedApi', 'deleteAllApiErro');
364
- context.commit('addToast', 'deleteApiErro');
365
- return response.data;
366
- }
367
-
368
- }, (err) => {
369
- if (err.response)
370
- if (err.response.status === 403)
371
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
372
-
373
- if (!err.response)
374
- context.commit('addNotificationErrorApi');
375
- return false;
376
- })
377
- },
378
- deleteApi: async function (context, params) {
379
-
380
- context.commit('cleanMethodExecutedApi');
381
- let url = params.url;
382
-
383
- return axios.delete(`${url}`, {
384
- headers: new Token().tokenHeaders(),
385
- })
386
- .then((response) => {
387
- if (response.data.success) {
388
- context.commit('addMethodExecutedApi', 'deleteApi')
389
- context.commit('addToast', 'deleteApiSucesso');
390
- context.commit('removeNotificarions');
391
- return response.data;
392
- } else {
393
- context.commit('addNotifications', response.data.notifications)
394
- context.commit('addToast', 'deleteApiErro');
395
- return response.data;
396
- }
397
-
398
- }, (err) => {
399
- if (err.response)
400
- if (err.response.status === 403)
401
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
402
-
403
- if (!err.response)
404
- context.commit('addNotificationErrorApi');
405
- return false;
406
- })
407
- },
408
- getFileApi: async function (context, params) {
409
- context.commit('cleanMethodExecutedApi');
410
- return axios.post(params.url, params.obj, {
411
- headers: new Token().tokenHeaders(), responseType: "arraybuffer",
412
- })
413
- .then((response) => {
414
- let blob = new Blob([response.data], { type: "application/pdf" }),
415
- url = window.URL.createObjectURL(blob);
416
- window.open(url);
417
- context.commit('addMethodExecutedApi', 'getPdfApi');
418
- context.commit('removeNotificarions');
419
-
420
- }, (err) => {
421
- context.commit('addNotificationErrorApi');
422
- return false;
423
- })
424
- },
425
- postFileApi: async function (context, params) {
426
- context.commit('cleanMethodExecutedApi');
427
-
428
- let formData = new FormData();
429
- formData.append("file", params.file);
430
- formData.append(params.container, params.container);
431
- formData.append(params.name, params.name);
432
- formData.append(params.accepted, params.accepted);
433
-
434
- return axios.post(params.url, formData, {
435
- headers: new Token().tokenHeaders(),
436
- })
437
- .then((response) => {
438
- if (response.data.success) {
439
- context.commit('addMethodExecutedApi', 'postFileApi');
440
- context.commit('removeNotificarions');
441
- return response.data;
442
- } else {
443
- context.commit('addToast', 'addApiError');
444
- context.commit('addNotifications', response.data.notifications)
445
-
446
- return response.data;
447
- }
448
- }, (err) => {
449
- if (err.response)
450
- if (err.response.status === 403)
451
- context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
452
-
453
- if (!err.response)
454
- context.commit('addNotificationErrorApi');
455
- return false;
456
- })
457
- },
458
- deleteFileApi: async function (context, params) {
459
- context.commit('cleanMethodExecutedApi');
460
-
461
- let url = params.url;
462
- let name = params.obj.name;
463
- let container = params.obj.container;
464
-
465
- return axios.delete(`${url}?name=${name}&container=${container}`, {
466
- headers: new Token().tokenHeaders(),
467
- })
468
- .then((response) => {
469
- if (response.data.success) {
470
- context.commit('addMethodExecutedApi', 'deleteFileApi');
471
- context.commit('removeNotificarions');
472
- return response.data;
473
- } else {
474
- context.commit('addNotifications', response.data.notifications)
475
- context.commit('addToast', 'addApiError');
476
- return response.data;
477
- }
478
- }, (err) => {
479
- if (err.response)
480
- if (err.response.status === 403)
481
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
482
-
483
- if (!err.response)
484
- context.commit('addNotificationErrorApi');
485
- return false;
486
- })
487
- },
488
- }
1
+ import axios from "@/config/axios";
2
+ import Tips from "@/config/tips";
3
+ import Token from "@nixweb/nixloc-ui/src/config/token";
4
+
5
+ export default {
6
+ namespaced: true,
7
+ state: {
8
+ modal: {
9
+ name: undefined,
10
+ open: false
11
+ },
12
+ vodal: {
13
+ name: undefined,
14
+ open: false
15
+ },
16
+ notifications: [],
17
+ pagination: [],
18
+ selected: [],
19
+ loading: [],
20
+ event: {
21
+ dateTime: undefined,
22
+ name: undefined,
23
+ data: {}
24
+ },
25
+ toast: {
26
+ dateTime: undefined,
27
+ type: undefined,
28
+ },
29
+ ids: undefined,
30
+ search: { content: "", filter: { content: "Contém", id: "contains" } },
31
+ documentHtml: "",
32
+ selectStatic: { dateTime: undefined, fieldTarget: undefined, value: undefined },
33
+ executedSearch: false,
34
+ clearedSearch: false,
35
+ methodExecutedApi: undefined,
36
+ },
37
+ getters: {
38
+ tip: (state) => (tipId) => {
39
+ var tips = new Tips();
40
+ let message = "";
41
+ tips.help.find(value => {
42
+ if (value.tipId == tipId)
43
+ message = value.message;
44
+ })
45
+ return message;
46
+ },
47
+ showModal: (state) => (name) => {
48
+ if (name == state.modal.name) return true;
49
+ return false;
50
+ },
51
+ showVodal: (state) => (name) => {
52
+ if (name == state.vodal.name) return true;
53
+ return false;
54
+ },
55
+ isLoading: (state) => (key) => {
56
+ var loading = state.loading.find(value => {
57
+ return value === key
58
+ })
59
+ if (loading) return true;
60
+ return false;
61
+ },
62
+ pagination: (state) => (key) => {
63
+ return state.pagination.find(obj => {
64
+ return obj.key === key
65
+ })
66
+ },
67
+ event: (state) => {
68
+ return state.event;
69
+ },
70
+ documentPreview: (state) => {
71
+ let documentHtml = state.documentHtml
72
+ let ret = documentHtml;
73
+
74
+ var tables = document.getElementsByTagName("table");
75
+ let total = tables.length;
76
+
77
+ let config = [];
78
+
79
+ let index = 0;
80
+ while (index <= total - 1) {
81
+
82
+ let table = document.getElementsByTagName("table")[index];
83
+ let th = table.getElementsByTagName("th")[0];
84
+
85
+ let obj = {
86
+ vForGrouped: "",
87
+ vForSimple: "",
88
+ nameGroup: "",
89
+ nameGroupReplace: ""
90
+ };
91
+
92
+ if (th) {
93
+ let isGrouped = th.innerText.includes("n.grupo");
94
+ let isProduct = th.innerText.includes("n.produto");
95
+ let isPeriod = th.innerText.includes("n.periodo");
96
+ let isPayment = th.innerText.includes("n.pagamento");
97
+
98
+ if (isProduct) {
99
+ obj.vForSimple = "v-for='p in d.produto'";
100
+ config.push(obj);
101
+ } else if (isPeriod) {
102
+ obj.vForSimple = "v-for='pe in d.periodo'";
103
+ config.push(obj);
104
+ } else if (isPayment) {
105
+ obj.vForSimple = "v-for='pg in d.pagamento'";
106
+ config.push(obj);
107
+ } else if (isGrouped) {
108
+ obj.vForGrouped = "v-for='(produto, grN) in produtoAgrupado'";
109
+ obj.vForSimple = "v-for='p in d.produto'";
110
+
111
+ var initIndex = documentHtml.split("<tbody>", index + 1).join("<tbody>").length;
112
+ var lastIndex = documentHtml.split("</tbody>", index + 1).join("</tbody>").length;
113
+
114
+ let tbody = documentHtml.substring(documentHtml.indexOf("<tbody>", initIndex), documentHtml.lastIndexOf("</tbody>", lastIndex));
115
+
116
+ let tr = tbody.substring(tbody.indexOf("<tr>"), tbody.lastIndexOf("</tr>"));
117
+
118
+ obj.nameGroup = tr.substring(0, tr.indexOf('</tr>')) + "</tr>";
119
+ obj.nameGroup = obj.nameGroup.replaceAll("\"", "'");
120
+ obj.nameGroupReplace = obj.nameGroup.replace("<tr>", "").replace("</tr>", "");
121
+ config.push(obj);
122
+
123
+ } else {
124
+ config.push(obj);
125
+ }
126
+ } else {
127
+ config.push(obj);
128
+ }
129
+ index++;
130
+ }
131
+
132
+ let replace = "";
133
+ config.forEach(x => {
134
+ replace += `.replace("<tbody>${x.nameGroup}<tr>", "<tbody ${x.vForGrouped}>${x.nameGroupReplace}<tr ${x.vForSimple}>")`;
135
+ });
136
+
137
+ var retParse = ret.replaceAll("\"", "'");
138
+ retParse = eval(`ret${replace}`);
139
+
140
+ var classImportant = retParse
141
+ .replaceAll("n.grupo", "")
142
+ .replaceAll("n.produto", "")
143
+ .replaceAll("n.periodo", "")
144
+ .replaceAll("n.pagamento", "")
145
+ .replaceAll("<p>&nbsp!important;</p>", "<p>&nbsp</p>");
146
+
147
+ return classImportant;
148
+ },
149
+ groupBy: () => (obj) => {
150
+ const result = {};
151
+ obj.array.forEach((item) => {
152
+ if (!result[item[obj.key]]) {
153
+ result[item[obj.key]] = [];
154
+ }
155
+ result[item[obj.key]].push(item);
156
+ });
157
+ return result;
158
+ },
159
+ },
160
+ mutations: {
161
+ openModal: (state, name) => {
162
+ state.modal.name = name;
163
+ state.modal.open = true;
164
+ },
165
+ hideModal: (state) => {
166
+ state.modal.open = false;
167
+ },
168
+ openVodal: (state, name) => {
169
+ state.vodal.name = name;
170
+ state.vodal.open = true;
171
+ },
172
+ hideVodal: (state) => {
173
+ state.vodal.name = "";
174
+ state.vodal.open = false;
175
+ },
176
+ updateSearch: (state, value) => {
177
+ state.search = value;
178
+ },
179
+ executedSearch: (state) => {
180
+ state.executedSearch = state.executedSearch = !state.executedSearch
181
+ },
182
+ clearedSearch: (state) => {
183
+ state.clearedSearch = state.clearedSearch = !state.clearedSearch
184
+ },
185
+ addSelected: (state, selected) => {
186
+ state.selected = selected;
187
+ },
188
+ addToast: (state, action) => {
189
+ state.toast.dateTime = new Date();
190
+ state.toast.type = action;
191
+ },
192
+ addMethodExecutedApi: (state, action) => {
193
+ setTimeout(function () {
194
+ state.methodExecutedApi = action;
195
+ }, 100);
196
+ },
197
+ cleanMethodExecutedApi: (state) => {
198
+ setTimeout(function () {
199
+ state.methodExecutedApi = "";
200
+ }, 100);
201
+ },
202
+ addLoading: (state, key) => {
203
+ state.loading.push(key);
204
+ },
205
+ removeLoading: (state, listKey) => {
206
+ listKey.forEach(function (key) {
207
+ let filter = state.loading.filter(function (item) {
208
+ return item != key;
209
+ });
210
+ state.loading = filter;
211
+ });
212
+ },
213
+ addPagination: (state, pagination) => {
214
+ state.pagination.push(pagination);
215
+ },
216
+ updatePagination: (state, pagination) => {
217
+ state.pagination.forEach(function (obj) {
218
+ if (obj.key == pagination.key)
219
+ obj.totalPerPage = pagination.totalPerPage;
220
+ });
221
+ },
222
+ updateDocumentHtml: (state, value) => {
223
+ state.documentHtml = value;
224
+ },
225
+ addEvent: (state, obj) => {
226
+ setTimeout(function () {
227
+ state.event.dateTime = new Date();
228
+ state.event.name = obj.name;
229
+ state.event.data = obj.data;
230
+ }, 100);
231
+ },
232
+ removeEvent: (state) => {
233
+ state.event = {};
234
+ },
235
+ addNotifications: (state, notifications) => {
236
+ state.notifications = notifications;
237
+ },
238
+ removeNotificarions: (state) => {
239
+ state.notifications = [];
240
+ },
241
+ addNotificationErrorApi: (state) => {
242
+ var erro = { property: "ERRO API", message: "Falha de Comunicação!" };
243
+ state.notifications = [erro];
244
+ },
245
+ listIdToString: (state, listId) => {
246
+ state.ids = "";
247
+ listId.forEach(function (id) {
248
+ state.ids += `${id},`;
249
+ });
250
+ },
251
+ addFilter: (state, obj) => {
252
+ state.selectStatic.dateTime = new Date();
253
+ state.selectStatic.fieldTarget = obj.fieldTarget;
254
+ state.selectStatic.value = obj.value;
255
+ },
256
+ },
257
+ actions: {
258
+ postApi: async function (context, params) {
259
+ context.commit('cleanMethodExecutedApi');
260
+ return axios.post(params.url, params.obj, {
261
+ headers: new Token().tokenHeaders(),
262
+ })
263
+ .then((response) => {
264
+
265
+ if (response.data.success) {
266
+ context.commit('addMethodExecutedApi', 'postApi');
267
+
268
+ if (!params.notNotifyToast)
269
+ context.commit('addToast', 'postApi');
270
+
271
+ context.commit('removeNotificarions');
272
+
273
+ if (!params.notRemoveFormDirty)
274
+ context.commit('validation/removeFormDirty', null, { root: true });
275
+
276
+ return response.data;
277
+ } else {
278
+
279
+ context.commit('addNotifications', response.data.notifications)
280
+ context.commit('addToast', 'postApiError');
281
+ return response.data;
282
+ }
283
+ }, (err) => {
284
+
285
+ if (err.response)
286
+ if (err.response.status === 403)
287
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
288
+
289
+ if (!err.response)
290
+ context.commit('addNotificationErrorApi');
291
+ return false;
292
+ })
293
+ },
294
+ putApi: async function (context, params) {
295
+ context.commit('cleanMethodExecutedApi');
296
+ return axios.put(params.url, params.obj, {
297
+ headers: new Token().tokenHeaders(),
298
+ })
299
+ .then((response) => {
300
+ if (response.data.success) {
301
+ context.commit('addMethodExecutedApi', 'putApi');
302
+
303
+ if (!params.notNotifyToast)
304
+ context.commit('addToast', 'putApi');
305
+
306
+ context.commit('removeNotificarions');
307
+ context.commit('validation/removeFormDirty', null, { root: true });
308
+ return response.data;
309
+ } else {
310
+ context.commit('addToast', 'putApiErro');
311
+ context.commit('addNotifications', response.data.notifications)
312
+ return response.data;
313
+ }
314
+ }, (err) => {
315
+ if (err.response)
316
+ if (err.response.status === 403)
317
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para modificar!" }])
318
+
319
+ if (!err.response)
320
+ context.commit('addNotificationErrorApi');
321
+
322
+ return false;
323
+ })
324
+ },
325
+ getApi: async function (context, params) {
326
+ context.commit('cleanMethodExecutedApi');
327
+ return axios.get(params.url, {
328
+ params: params.obj,
329
+ headers: new Token().tokenHeaders(),
330
+ })
331
+ .then((response) => {
332
+ if (response.data.success) {
333
+ context.commit('addMethodExecutedApi', params.methodExecutedApi);
334
+ context.commit('removeNotificarions');
335
+ return response.data;
336
+ } else {
337
+ context.commit('addNotifications', response.data.notifications)
338
+ context.commit('addToast', 'falhaGenerica');
339
+ return response.data;
340
+ }
341
+ }, (err) => {
342
+ context.commit('addNotificationErrorApi');
343
+ return false;
344
+ })
345
+ },
346
+ orderAllApi: async function (context, params) {
347
+ return axios.put(params.url, params.obj, {
348
+ headers: new Token().tokenHeaders(),
349
+ })
350
+ .then((response) => {
351
+ return response.data;
352
+ }, (err) => {
353
+ context.commit('addNotificationErrorApi');
354
+ return false;
355
+ })
356
+ },
357
+ getApiOdata: async function (context, params) {
358
+ return axios.get(params.url, {
359
+ headers: new Token().tokenHeaders(),
360
+ })
361
+ .then((response) => {
362
+ return response.data;
363
+ }, (err) => {
364
+ context.commit('addNotificationErrorApi');
365
+ return false;
366
+ })
367
+ },
368
+ deleteAllApi: async function (context, params) {
369
+
370
+ context.commit('cleanMethodExecutedApi');
371
+ context.commit('listIdToString', params.selected);
372
+
373
+ let url = params.url;
374
+ let ids = context.state.ids;
375
+
376
+ return axios.delete(`${url}?ids=${ids}`, {
377
+ headers: new Token().tokenHeaders(),
378
+ })
379
+ .then((response) => {
380
+ if (response.data.success) {
381
+ context.commit('addMethodExecutedApi', 'deleteAllApi');
382
+ context.commit('addToast', 'deleteApiSucesso');
383
+ context.commit('removeNotificarions');
384
+ return response.data;
385
+ } else {
386
+ context.commit('addNotifications', response.data.notifications)
387
+ context.commit('addMethodExecutedApi', 'deleteAllApiErro');
388
+ context.commit('addToast', 'deleteApiErro');
389
+ return response.data;
390
+ }
391
+
392
+ }, (err) => {
393
+ if (err.response)
394
+ if (err.response.status === 403)
395
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
396
+
397
+ if (!err.response)
398
+ context.commit('addNotificationErrorApi');
399
+ return false;
400
+ })
401
+ },
402
+ deleteApi: async function (context, params) {
403
+
404
+ context.commit('cleanMethodExecutedApi');
405
+ let url = params.url;
406
+
407
+ return axios.delete(`${url}`, {
408
+ headers: new Token().tokenHeaders(),
409
+ })
410
+ .then((response) => {
411
+ if (response.data.success) {
412
+ context.commit('addMethodExecutedApi', 'deleteApi')
413
+ context.commit('addToast', 'deleteApiSucesso');
414
+ context.commit('removeNotificarions');
415
+ return response.data;
416
+ } else {
417
+ context.commit('addNotifications', response.data.notifications)
418
+ context.commit('addToast', 'deleteApiErro');
419
+ return response.data;
420
+ }
421
+
422
+ }, (err) => {
423
+ if (err.response)
424
+ if (err.response.status === 403)
425
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
426
+
427
+ if (!err.response)
428
+ context.commit('addNotificationErrorApi');
429
+ return false;
430
+ })
431
+ },
432
+ getFileApi: async function (context, params) {
433
+ context.commit('cleanMethodExecutedApi');
434
+ return axios.post(params.url, params.obj, {
435
+ headers: new Token().tokenHeaders(), responseType: "arraybuffer",
436
+ })
437
+ .then((response) => {
438
+ let blob = new Blob([response.data], { type: "application/pdf" }),
439
+ url = window.URL.createObjectURL(blob);
440
+ window.open(url);
441
+ context.commit('addMethodExecutedApi', 'getPdfApi');
442
+ context.commit('removeNotificarions');
443
+
444
+ }, (err) => {
445
+ context.commit('addNotificationErrorApi');
446
+ return false;
447
+ })
448
+ },
449
+ postFileApi: async function (context, params) {
450
+ context.commit('cleanMethodExecutedApi');
451
+
452
+ let formData = new FormData();
453
+ formData.append("file", params.file);
454
+ formData.append(params.container, params.container);
455
+ formData.append(params.name, params.name);
456
+ formData.append(params.accepted, params.accepted);
457
+
458
+ return axios.post(params.url, formData, {
459
+ headers: new Token().tokenHeaders(),
460
+ })
461
+ .then((response) => {
462
+ if (response.data.success) {
463
+ context.commit('addMethodExecutedApi', 'postFileApi');
464
+ context.commit('removeNotificarions');
465
+ return response.data;
466
+ } else {
467
+ context.commit('addToast', 'addApiError');
468
+ context.commit('addNotifications', response.data.notifications)
469
+
470
+ return response.data;
471
+ }
472
+ }, (err) => {
473
+ if (err.response)
474
+ if (err.response.status === 403)
475
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
476
+
477
+ if (!err.response)
478
+ context.commit('addNotificationErrorApi');
479
+ return false;
480
+ })
481
+ },
482
+ deleteFileApi: async function (context, params) {
483
+ context.commit('cleanMethodExecutedApi');
484
+
485
+ let url = params.url;
486
+ let name = params.obj.name;
487
+ let container = params.obj.container;
488
+
489
+ return axios.delete(`${url}?name=${name}&container=${container}`, {
490
+ headers: new Token().tokenHeaders(),
491
+ })
492
+ .then((response) => {
493
+ if (response.data.success) {
494
+ context.commit('addMethodExecutedApi', 'deleteFileApi');
495
+ context.commit('removeNotificarions');
496
+ return response.data;
497
+ } else {
498
+ context.commit('addNotifications', response.data.notifications)
499
+ context.commit('addToast', 'addApiError');
500
+ return response.data;
501
+ }
502
+ }, (err) => {
503
+ if (err.response)
504
+ if (err.response.status === 403)
505
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
506
+
507
+ if (!err.response)
508
+ context.commit('addNotificationErrorApi');
509
+ return false;
510
+ })
511
+ },
512
+ }
489
513
  }