@nixweb/nixloc-ui 0.0.128 → 0.0.130

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