@nixweb/nixloc-ui 0.0.128 → 0.0.129

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