@nixweb/nixloc-ui 0.0.127 → 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 (88) hide show
  1. package/package.json +79 -79
  2. package/src/App.vue +13 -13
  3. package/src/component/forms/Button.vue +170 -170
  4. package/src/component/forms/CheckboxGroup.vue +72 -66
  5. package/src/component/forms/CheckboxSimple.vue +46 -42
  6. package/src/component/forms/Color.vue +38 -38
  7. package/src/component/forms/DateTime.vue +167 -163
  8. package/src/component/forms/Dropdown.vue +218 -224
  9. package/src/component/forms/EditorHtml.vue +126 -126
  10. package/src/component/forms/FileUpload.vue +185 -185
  11. package/src/component/forms/ImageUpload.vue +12 -4
  12. package/src/component/forms/IncrementDecrement.vue +101 -0
  13. package/src/component/forms/InputDecimal.vue +142 -138
  14. package/src/component/forms/InputNumber.vue +154 -154
  15. package/src/component/forms/InputPassword.vue +135 -135
  16. package/src/component/forms/InputText.vue +162 -157
  17. package/src/component/forms/Modal.vue +65 -65
  18. package/src/component/forms/RadioGroup.vue +50 -50
  19. package/src/component/forms/Select.vue +349 -340
  20. package/src/component/forms/SelectStatic.vue +127 -127
  21. package/src/component/forms/Slider.vue +18 -18
  22. package/src/component/forms/TextArea.vue +126 -126
  23. package/src/component/layout/Alert.vue +92 -92
  24. package/src/component/layout/Badge.vue +103 -103
  25. package/src/component/layout/FixedBar.vue +100 -68
  26. package/src/component/layout/Header.vue +38 -35
  27. package/src/component/layout/LoadingFullPage.vue +27 -27
  28. package/src/component/layout/Menu.vue +210 -215
  29. package/src/component/layout/Molded.vue +28 -27
  30. package/src/component/layout/Panel.vue +140 -140
  31. package/src/component/layout/Popover.vue +126 -126
  32. package/src/component/layout/ScrollBar.vue +42 -42
  33. package/src/component/layout/Tab.vue +135 -0
  34. package/src/component/layout/Wizard.vue +211 -211
  35. package/src/component/rental/DisplayPeriodRent.vue +81 -0
  36. package/src/component/rental/DisplayTotalization.vue +47 -0
  37. package/src/component/shared/Collapse.vue +131 -131
  38. package/src/component/shared/DocumentPreview.vue +1 -1
  39. package/src/component/shared/DocumentPublic.vue +34 -0
  40. package/src/component/shared/ExportPDF.vue +116 -116
  41. package/src/component/shared/HeaderReport.vue +1 -1
  42. package/src/component/shared/HorizontalFilter.vue +59 -59
  43. package/src/component/shared/Loading.vue +107 -107
  44. package/src/component/shared/LoadingMoreButton.vue +23 -23
  45. package/src/component/shared/Messages.vue +81 -81
  46. package/src/component/shared/PDFViewer.vue +22 -22
  47. package/src/component/shared/Pagination.vue +52 -52
  48. package/src/component/shared/ProgressBar.vue +22 -22
  49. package/src/component/shared/QueryButton.vue +66 -66
  50. package/src/component/shared/{BodyReport.vue → Report.vue} +8 -7
  51. package/src/component/shared/SaveCancel.vue +6 -1
  52. package/src/component/shared/Search.vue +154 -154
  53. package/src/component/shared/SelectOption.vue +18 -9
  54. package/src/component/shared/Table.vue +163 -254
  55. package/src/component/shared/TableButton.vue +36 -36
  56. package/src/component/shared/TableDraggable.vue +127 -0
  57. package/src/component/shared/TableItem.vue +177 -0
  58. package/src/component/shared/TableTotalization.vue +47 -47
  59. package/src/component/shared/Tip.vue +42 -42
  60. package/src/component/shared/Toast.vue +54 -54
  61. package/src/component/shared/TotalizationReport.vue +59 -0
  62. package/src/component/shared/VerticalFilter.vue +97 -97
  63. package/src/component/shared/query-builder/AddRule.vue +181 -181
  64. package/src/component/shared/query-builder/ConvertToOdata.js +3 -9
  65. package/src/component/shared/query-builder/DynamicComponent.vue +5 -1
  66. package/src/component/shared/query-builder/DynamicComponentList.vue +73 -62
  67. package/src/component/shared/query-builder/QueryBuilder.vue +69 -69
  68. package/src/component/shared/query-builder/utilities.js +21 -21
  69. package/src/component/template/ListViewWithDataHandler.vue +260 -238
  70. package/src/component/template/ReportCreateUpdate.vue +9 -2
  71. package/src/component/template/ViewTemplateConfiguration.vue +64 -63
  72. package/src/component/template/ViewTemplateDocumentView.vue +1 -0
  73. package/src/component/template/ViewTemplateReportPreview.vue +56 -12
  74. package/src/component/template/ViewTemplateWithSalveCancel.vue +32 -32
  75. package/src/component/template/ViewTemplateWithTable.vue +56 -56
  76. package/src/component/value-objects/Contact.vue +7 -0
  77. package/src/component/value-objects/Person.vue +15 -0
  78. package/src/config/axios.js +9 -9
  79. package/src/config/dicas.js +14 -14
  80. package/src/config/router.js +13 -13
  81. package/src/config/token.js +14 -14
  82. package/src/main.js +23 -23
  83. package/src/store/modules/generic.js +512 -494
  84. package/src/store/modules/report.js +37 -19
  85. package/src/store/modules/user.js +3 -0
  86. package/src/store/modules/validation.js +38 -38
  87. package/src/store/store.js +13 -13
  88. package/src/component/shared/query-builder/Totalization.vue +0 -38
@@ -1,495 +1,513 @@
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
- state.methodExecutedApi = action;
194
- },
195
- cleanMethodExecutedApi: (state) => {
196
- state.methodExecutedApi = "";
197
- },
198
- addLoading: (state, key) => {
199
- state.loading.push(key);
200
- },
201
- removeLoading: (state, listKey) => {
202
- listKey.forEach(function (key) {
203
- let filter = state.loading.filter(function (item) {
204
- return item != key;
205
- });
206
- state.loading = filter;
207
- });
208
- },
209
- addPagination: (state, pagination) => {
210
- state.pagination.push(pagination);
211
- },
212
- updatePagination: (state, pagination) => {
213
- state.pagination.forEach(function (obj) {
214
- if (obj.key == pagination.key)
215
- obj.totalPerPage = pagination.totalPerPage;
216
- });
217
- },
218
- updateDocumentHtml: (state, value) => {
219
- state.documentHtml = value;
220
- },
221
- addEvent: (state, obj) => {
222
- state.event.dateTime = new Date();
223
- state.event.name = obj.name;
224
- state.event.data = obj.data;
225
- },
226
- removeEvent: (state) => {
227
- state.event = {};
228
- },
229
- addNotifications: (state, notifications) => {
230
- state.notifications = notifications;
231
- },
232
- removeNotificarions: (state) => {
233
- state.notifications = [];
234
- },
235
- addNotificationErrorApi: (state) => {
236
- var erro = { property: "ERRO API", message: "Falha de Comunicação!" };
237
- state.notifications = [erro];
238
- },
239
- listIdToString: (state, listId) => {
240
- state.ids = "";
241
- listId.forEach(function (id) {
242
- state.ids += `${id},`;
243
- });
244
- },
245
- addFilter: (state, obj) => {
246
- state.selectStatic.dateTime = new Date();
247
- state.selectStatic.fieldTarget = obj.fieldTarget;
248
- state.selectStatic.value = obj.value;
249
- },
250
- },
251
- actions: {
252
- postApi: async function (context, params) {
253
- context.commit('cleanMethodExecutedApi');
254
- return axios.post(params.url, params.obj, {
255
- headers: new Token().tokenHeaders(),
256
- })
257
- .then((response) => {
258
-
259
- if (response.data.success) {
260
- context.commit('addMethodExecutedApi', 'postApi');
261
-
262
- if (!params.notNotifyToast)
263
- context.commit('addToast', 'postApi');
264
-
265
- context.commit('removeNotificarions');
266
- context.commit('validation/removeFormDirty', null, { root: true });
267
- return response.data;
268
- } else {
269
-
270
- context.commit('addNotifications', response.data.notifications)
271
- context.commit('addToast', 'postApiError');
272
- return response.data;
273
- }
274
- }, (err) => {
275
-
276
- console.log(err);
277
-
278
- if (err.response)
279
- if (err.response.status === 403)
280
- context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
281
-
282
- if (!err.response)
283
- context.commit('addNotificationErrorApi');
284
- return false;
285
- })
286
- },
287
- putApi: async function (context, params) {
288
- context.commit('cleanMethodExecutedApi');
289
- return axios.put(params.url, params.obj, {
290
- headers: new Token().tokenHeaders(),
291
- })
292
- .then((response) => {
293
- if (response.data.success) {
294
- context.commit('addMethodExecutedApi', 'putApi');
295
-
296
- if (!params.notNotifyToast)
297
- context.commit('addToast', 'putApi');
298
-
299
- context.commit('removeNotificarions');
300
- context.commit('validation/removeFormDirty', null, { root: true });
301
- return response.data;
302
- } else {
303
- context.commit('addToast', 'putApiErro');
304
- context.commit('addNotifications', response.data.notifications)
305
- return response.data;
306
- }
307
- }, (err) => {
308
- if (err.response)
309
- if (err.response.status === 403)
310
- context.commit('addNotifications', [{ message: "Usuário sem permissão para modificar!" }])
311
-
312
- if (!err.response)
313
- context.commit('addNotificationErrorApi');
314
-
315
- return false;
316
- })
317
- },
318
- getApi: async function (context, params) {
319
- context.commit('cleanMethodExecutedApi');
320
- return axios.get(params.url, {
321
- params: params.obj,
322
- headers: new Token().tokenHeaders(),
323
- })
324
- .then((response) => {
325
- if (response.data.success) {
326
- context.commit('addMethodExecutedApi', params.methodExecutedApi);
327
- context.commit('removeNotificarions');
328
- return response.data;
329
- } else {
330
- context.commit('addNotifications', response.data.notifications)
331
- context.commit('addToast', 'falhaGenerica');
332
- return response.data;
333
- }
334
- }, (err) => {
335
- context.commit('addNotificationErrorApi');
336
- return false;
337
- })
338
- },
339
- getApiOdata: async function (context, params) {
340
- return axios.get(params.url, {
341
- headers: new Token().tokenHeaders(),
342
- })
343
- .then((response) => {
344
- return response.data;
345
- }, (err) => {
346
- context.commit('addNotificationErrorApi');
347
- return false;
348
- })
349
- },
350
- deleteAllApi: async function (context, params) {
351
-
352
- context.commit('cleanMethodExecutedApi');
353
- context.commit('listIdToString', params.selected);
354
-
355
- let url = params.url;
356
- let ids = context.state.ids;
357
-
358
- return axios.delete(`${url}?ids=${ids}`, {
359
- headers: new Token().tokenHeaders(),
360
- })
361
- .then((response) => {
362
- if (response.data.success) {
363
- context.commit('addMethodExecutedApi', 'deleteAllApi');
364
- context.commit('addToast', 'deleteApiSucesso');
365
- context.commit('removeNotificarions');
366
- return response.data;
367
- } else {
368
- context.commit('addNotifications', response.data.notifications)
369
- context.commit('addMethodExecutedApi', 'deleteAllApiErro');
370
- context.commit('addToast', 'deleteApiErro');
371
- return response.data;
372
- }
373
-
374
- }, (err) => {
375
- if (err.response)
376
- if (err.response.status === 403)
377
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
378
-
379
- if (!err.response)
380
- context.commit('addNotificationErrorApi');
381
- return false;
382
- })
383
- },
384
- deleteApi: async function (context, params) {
385
-
386
- context.commit('cleanMethodExecutedApi');
387
- let url = params.url;
388
-
389
- return axios.delete(`${url}`, {
390
- headers: new Token().tokenHeaders(),
391
- })
392
- .then((response) => {
393
- if (response.data.success) {
394
- context.commit('addMethodExecutedApi', 'deleteApi')
395
- context.commit('addToast', 'deleteApiSucesso');
396
- context.commit('removeNotificarions');
397
- return response.data;
398
- } else {
399
- context.commit('addNotifications', response.data.notifications)
400
- context.commit('addToast', 'deleteApiErro');
401
- return response.data;
402
- }
403
-
404
- }, (err) => {
405
- if (err.response)
406
- if (err.response.status === 403)
407
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
408
-
409
- if (!err.response)
410
- context.commit('addNotificationErrorApi');
411
- return false;
412
- })
413
- },
414
- getFileApi: async function (context, params) {
415
- context.commit('cleanMethodExecutedApi');
416
- return axios.post(params.url, params.obj, {
417
- headers: new Token().tokenHeaders(), responseType: "arraybuffer",
418
- })
419
- .then((response) => {
420
- let blob = new Blob([response.data], { type: "application/pdf" }),
421
- url = window.URL.createObjectURL(blob);
422
- window.open(url);
423
- context.commit('addMethodExecutedApi', 'getPdfApi');
424
- context.commit('removeNotificarions');
425
-
426
- }, (err) => {
427
- context.commit('addNotificationErrorApi');
428
- return false;
429
- })
430
- },
431
- postFileApi: async function (context, params) {
432
- context.commit('cleanMethodExecutedApi');
433
-
434
- let formData = new FormData();
435
- formData.append("file", params.file);
436
- formData.append(params.container, params.container);
437
- formData.append(params.name, params.name);
438
- formData.append(params.accepted, params.accepted);
439
-
440
- return axios.post(params.url, formData, {
441
- headers: new Token().tokenHeaders(),
442
- })
443
- .then((response) => {
444
- if (response.data.success) {
445
- context.commit('addMethodExecutedApi', 'postFileApi');
446
- context.commit('removeNotificarions');
447
- return response.data;
448
- } else {
449
- context.commit('addToast', 'addApiError');
450
- context.commit('addNotifications', response.data.notifications)
451
-
452
- return response.data;
453
- }
454
- }, (err) => {
455
- if (err.response)
456
- if (err.response.status === 403)
457
- context.commit('addNotifications', [{ message: "Usuário sem permissão para adicionar!" }])
458
-
459
- if (!err.response)
460
- context.commit('addNotificationErrorApi');
461
- return false;
462
- })
463
- },
464
- deleteFileApi: async function (context, params) {
465
- context.commit('cleanMethodExecutedApi');
466
-
467
- let url = params.url;
468
- let name = params.obj.name;
469
- let container = params.obj.container;
470
-
471
- return axios.delete(`${url}?name=${name}&container=${container}`, {
472
- headers: new Token().tokenHeaders(),
473
- })
474
- .then((response) => {
475
- if (response.data.success) {
476
- context.commit('addMethodExecutedApi', 'deleteFileApi');
477
- context.commit('removeNotificarions');
478
- return response.data;
479
- } else {
480
- context.commit('addNotifications', response.data.notifications)
481
- context.commit('addToast', 'addApiError');
482
- return response.data;
483
- }
484
- }, (err) => {
485
- if (err.response)
486
- if (err.response.status === 403)
487
- context.commit('addNotifications', [{ message: "Usuário sem permissão para remove!" }])
488
-
489
- if (!err.response)
490
- context.commit('addNotificationErrorApi');
491
- return false;
492
- })
493
- },
494
- }
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
+ }
495
513
  }