@nixweb/nixloc-ui 0.0.300 → 0.0.301

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 (158) hide show
  1. package/package.json +1 -1
  2. package/src/App.vue +13 -0
  3. package/src/component/forms/Button.vue +163 -0
  4. package/src/component/forms/ButtonFilter.vue +75 -0
  5. package/src/component/forms/ButtonGroup.vue +67 -0
  6. package/src/component/forms/ButtonSub.vue +98 -0
  7. package/src/component/forms/ButtonToggle.vue +77 -0
  8. package/src/component/forms/CheckboxGroup.vue +69 -0
  9. package/src/component/forms/CheckboxServer.vue +192 -0
  10. package/src/component/forms/CheckboxSimple.vue +60 -0
  11. package/src/component/forms/Color.vue +38 -0
  12. package/src/component/forms/DateTime.vue +170 -0
  13. package/src/component/forms/DateYearMonth.vue +193 -0
  14. package/src/component/forms/Dropdown.vue +236 -0
  15. package/src/component/forms/EditorHtml.vue +132 -0
  16. package/src/component/forms/FileUpload.vue +170 -0
  17. package/src/component/forms/ImageUpload.vue +214 -0
  18. package/src/component/forms/IncrementDecrement.vue +148 -0
  19. package/src/component/forms/InputAddressGoogle.vue +171 -0
  20. package/src/component/forms/InputCallToAction.vue +135 -0
  21. package/src/component/forms/InputDecimal.vue +153 -0
  22. package/src/component/forms/InputDecimalDiscount.vue +78 -0
  23. package/src/component/forms/InputNumber.vue +160 -0
  24. package/src/component/forms/InputPassword.vue +148 -0
  25. package/src/component/forms/InputTag.vue +125 -0
  26. package/src/component/forms/InputText.vue +174 -0
  27. package/src/component/forms/InputTextEdit.vue +69 -0
  28. package/src/component/forms/InputWhatsApp.vue +48 -0
  29. package/src/component/forms/Modal.vue +57 -0
  30. package/src/component/forms/RadioGroup.vue +91 -0
  31. package/src/component/forms/Select.vue +378 -0
  32. package/src/component/forms/SelectStatic.vue +198 -0
  33. package/src/component/forms/SideBar.vue +100 -0
  34. package/src/component/forms/Slider.vue +18 -0
  35. package/src/component/forms/TextArea.vue +138 -0
  36. package/src/component/forms/Toggle.vue +72 -0
  37. package/src/component/layout/Account.vue +131 -0
  38. package/src/component/layout/Alert.vue +88 -0
  39. package/src/component/layout/Badge.vue +111 -0
  40. package/src/component/layout/BarFloating.vue +68 -0
  41. package/src/component/layout/FixedBar.vue +103 -0
  42. package/src/component/layout/Gantt.vue +128 -0
  43. package/src/component/layout/Header.vue +56 -0
  44. package/src/component/layout/HideShow.vue +62 -0
  45. package/src/component/layout/IconMolded.vue +59 -0
  46. package/src/component/layout/LoadingFullPage.vue +27 -0
  47. package/src/component/layout/Menu.vue +287 -0
  48. package/src/component/layout/Molded.vue +30 -0
  49. package/src/component/layout/NewAccount.vue +136 -0
  50. package/src/component/layout/NewHeader.vue +60 -0
  51. package/src/component/layout/NewIconMolded.vue +71 -0
  52. package/src/component/layout/NewMenu.vue +456 -0
  53. package/src/component/layout/Panel.vue +185 -0
  54. package/src/component/layout/Popover.vue +126 -0
  55. package/src/component/layout/ScrollBar.vue +57 -0
  56. package/src/component/layout/Tab.vue +135 -0
  57. package/src/component/layout/Tag.vue +97 -0
  58. package/src/component/layout/Wizard.vue +211 -0
  59. package/src/component/rental/DisplayCalculatePeriod.vue +49 -0
  60. package/src/component/rental/DisplayPeriodRent.vue +55 -0
  61. package/src/component/rental/DisplayTotalization.vue +86 -0
  62. package/src/component/report/Fields.vue +109 -0
  63. package/src/component/report/Report.vue +314 -0
  64. package/src/component/report/ReportTable.vue +112 -0
  65. package/src/component/report/Totalization.vue +34 -0
  66. package/src/component/shared/CodeEditor.vue +128 -0
  67. package/src/component/shared/Collapse.vue +131 -0
  68. package/src/component/shared/Confirmation.vue +74 -0
  69. package/src/component/shared/DocumentEditor.vue +99 -0
  70. package/src/component/shared/DocumentPreview.vue +81 -0
  71. package/src/component/shared/DocumentPublic.vue +33 -0
  72. package/src/component/shared/ExportExcel.vue +56 -0
  73. package/src/component/shared/ExportPDF.vue +116 -0
  74. package/src/component/shared/FullCalendar.vue +174 -0
  75. package/src/component/shared/HeaderReport.vue +47 -0
  76. package/src/component/shared/HorizontalFilter.vue +64 -0
  77. package/src/component/shared/ListNotifications.vue +70 -0
  78. package/src/component/shared/Loading.vue +107 -0
  79. package/src/component/shared/LoadingCard.vue +65 -0
  80. package/src/component/shared/LoadingMoreButton.vue +23 -0
  81. package/src/component/shared/Messages.vue +109 -0
  82. package/src/component/shared/PDFViewer.vue +24 -0
  83. package/src/component/shared/Pagination.vue +108 -0
  84. package/src/component/shared/ParameterLegend.vue +169 -0
  85. package/src/component/shared/ProgressBar.vue +25 -0
  86. package/src/component/shared/QueryButton.vue +66 -0
  87. package/src/component/shared/Report.vue +200 -0
  88. package/src/component/shared/SaveCancel.vue +99 -0
  89. package/src/component/shared/Search.vue +174 -0
  90. package/src/component/shared/SelectOption.vue +162 -0
  91. package/src/component/shared/Table.vue +174 -0
  92. package/src/component/shared/TableButton.vue +36 -0
  93. package/src/component/shared/TableDraggable.vue +117 -0
  94. package/src/component/shared/TableImport.vue +93 -0
  95. package/src/component/shared/TableItem.vue +214 -0
  96. package/src/component/shared/TableTotalPerPage.vue +78 -0
  97. package/src/component/shared/TableTotalRecords.vue +44 -0
  98. package/src/component/shared/TableTotalization.vue +47 -0
  99. package/src/component/shared/TimeLine.vue +42 -0
  100. package/src/component/shared/Timer.vue +78 -0
  101. package/src/component/shared/Tip.vue +42 -0
  102. package/src/component/shared/Toast.vue +69 -0
  103. package/src/component/shared/ToggleTheme.vue +128 -0
  104. package/src/component/shared/TotalizationReport.vue +86 -0
  105. package/src/component/shared/VerticalFilter.vue +97 -0
  106. package/src/component/shared/automation/ActivitiesList.vue +44 -0
  107. package/src/component/shared/automation/AddRule.vue +61 -0
  108. package/src/component/shared/automation/AutomationBuilder.vue +27 -0
  109. package/src/component/shared/automation/DynamicComponentList.vue +86 -0
  110. package/src/component/shared/automation/SelectRule.vue +98 -0
  111. package/src/component/shared/automation/components/BillingByRent.vue +98 -0
  112. package/src/component/shared/automation/components/SendEmail.vue +94 -0
  113. package/src/component/shared/file-manager/FileManager.vue +391 -0
  114. package/src/component/shared/filter-builder/FilterBuilder.vue +221 -0
  115. package/src/component/shared/filter-builder/FilterQuery.vue +94 -0
  116. package/src/component/shared/query-builder/AddRule.vue +203 -0
  117. package/src/component/shared/query-builder/ConvertToOdata.js +86 -0
  118. package/src/component/shared/query-builder/DynamicComponent.vue +161 -0
  119. package/src/component/shared/query-builder/DynamicComponentList.vue +70 -0
  120. package/src/component/shared/query-builder/Fields.vue +93 -0
  121. package/src/component/shared/query-builder/QueryBuilder.vue +69 -0
  122. package/src/component/shared/query-builder/Rules.vue +68 -0
  123. package/src/component/shared/query-builder/SelectRule.vue +97 -0
  124. package/src/component/shared/query-builder/Tags.vue +59 -0
  125. package/src/component/shared/query-builder/utilities.js +22 -0
  126. package/src/component/signature/Payment.vue +161 -0
  127. package/src/component/signature/Warning.vue +76 -0
  128. package/src/component/template/ListViewWithDataHandler.vue +429 -0
  129. package/src/component/template/ReportCreateUpdate.vue +110 -0
  130. package/src/component/template/ViewTemplateConfiguration.vue +64 -0
  131. package/src/component/template/ViewTemplateDocumentView.vue +213 -0
  132. package/src/component/template/ViewTemplateImportFile.vue +347 -0
  133. package/src/component/template/ViewTemplateReportList.vue +217 -0
  134. package/src/component/template/ViewTemplateReportPreview.vue +432 -0
  135. package/src/component/template/ViewTemplateSelectOption.vue +46 -0
  136. package/src/component/template/ViewTemplateWithSalveCancel.vue +32 -0
  137. package/src/component/template/ViewTemplateWithTable.vue +62 -0
  138. package/src/component/template/model/Report.js +6 -0
  139. package/src/component/training/Course.vue +344 -0
  140. package/src/component/training/CourseView.vue +190 -0
  141. package/src/component/value-objects/Address.js +11 -0
  142. package/src/component/value-objects/Address.vue +157 -0
  143. package/src/component/value-objects/Contact.js +7 -0
  144. package/src/component/value-objects/Contact.vue +106 -0
  145. package/src/component/value-objects/Person.js +10 -0
  146. package/src/component/value-objects/Person.vue +129 -0
  147. package/src/config/axios.js +9 -0
  148. package/src/config/dicas.js +15 -0
  149. package/src/config/router.js +14 -0
  150. package/src/config/token.js +15 -0
  151. package/src/main.js +23 -0
  152. package/src/store/modules/automation.js +31 -0
  153. package/src/store/modules/generic.js +816 -0
  154. package/src/store/modules/report.js +278 -0
  155. package/src/store/modules/user.js +67 -0
  156. package/src/store/modules/util.js +26 -0
  157. package/src/store/modules/validation.js +39 -0
  158. package/src/store/store.js +14 -0
@@ -0,0 +1,816 @@
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: [],
14
+ open: false
15
+ },
16
+ sideBar: {
17
+ name: undefined,
18
+ open: false
19
+ },
20
+ menuCollapsed: true,
21
+ notifications: [],
22
+ pagination: [],
23
+ paginations: { currentPage: 1, totalPerPage: 10 },
24
+ totalPerPage: { "content": "10", "id": 10 },
25
+ selected: [],
26
+ loading: [],
27
+ event: {
28
+ dateTime: undefined,
29
+ name: undefined,
30
+ data: {}
31
+ },
32
+ toast: {
33
+ dateTime: undefined,
34
+ type: undefined,
35
+ },
36
+ ids: undefined,
37
+ search: { content: "", filter: { content: "Contém", id: "contains" } },
38
+ documentHtml: "",
39
+ documentHtmlFinal: "",
40
+ selectStatic: { dateTime: undefined, tag: undefined, fieldTarget: undefined, value: undefined },
41
+ tags: [],
42
+ executedSearch: false,
43
+ clearedSearch: false,
44
+ methodExecutedApi: undefined,
45
+ filterStorage: [],
46
+ filterQuery: [],
47
+ filterFinal: [],
48
+ queryTags: [],
49
+ _filterStorage: [],
50
+ },
51
+ getters: {
52
+ tip: (state) => (tipId) => {
53
+ var tips = new Tips();
54
+ let message = "";
55
+ tips.help.find(value => {
56
+ if (value.tipId == tipId)
57
+ message = value.message;
58
+ })
59
+ return message;
60
+ },
61
+ showModal: (state) => (name) => {
62
+ if (name == state.modal.name) return true;
63
+ return false;
64
+ },
65
+ showVodal: (state) => (name) => {
66
+ return state.vodal.name.includes(name);
67
+ },
68
+ isLoading: (state) => (key) => {
69
+ var loading = state.loading.find(value => {
70
+ return value === key
71
+ })
72
+ if (loading) return true;
73
+ return false;
74
+ },
75
+ getFilterStorage: (state) => (key) => {
76
+ return state.filterStorage.find(x => x.key === key);
77
+ },
78
+ getQueryFilter: (state) => (routeName) => {
79
+ return state.filterQuery.find(x => x.routeName === routeName);
80
+ },
81
+ get_FilterStorage: (state) => (routeName) => {
82
+ return state._filterStorage.find(x => x.routeName === routeName);
83
+ },
84
+ isExistFilterQuery: (state) => (routeName, field) => {
85
+ var arr = state.filterFinal.find(x => x.routeName === routeName && x.field == field);
86
+ if (arr) return true;
87
+ return false;
88
+ },
89
+ paramsFilterStorage: (state) => (route, key, returnIfNull) => {
90
+ var filter = state.filterStorage.find(x => x.key === route);
91
+
92
+ if (filter) {
93
+ var obj = filter.paramsFilter.find(x => x.key === key);
94
+ if (obj) return obj.value;
95
+ return returnIfNull;
96
+ }
97
+ return returnIfNull;
98
+ },
99
+ pagination: (state) => (key) => {
100
+ return state.pagination.find(obj => {
101
+ return obj.key === key
102
+ })
103
+ },
104
+ event: (state) => {
105
+ return state.event;
106
+ },
107
+ documentPreview: (state) => (env) => {
108
+ let documentHtml = state.documentHtml
109
+ let ret = documentHtml;
110
+
111
+ var template = null;
112
+
113
+ if (env == 'dev')
114
+ template = document.getElementById("template-dev");
115
+
116
+ if (env == 'prod')
117
+ template = document.getElementById("template-prod");
118
+
119
+ if (template != null) {
120
+ var tables = template.getElementsByTagName("table");
121
+ let total = tables.length;
122
+ let config = [];
123
+
124
+ let index = 0;
125
+ while (index <= total - 1) {
126
+
127
+ let table = template.getElementsByTagName("table")[index];
128
+ let th = table.getElementsByTagName("th")[0];
129
+
130
+ let obj = {
131
+ vForGrouped: "",
132
+ vForSimple: "",
133
+ nameGroup: "",
134
+ nameGroupReplace: ""
135
+ };
136
+
137
+ if (th) {
138
+
139
+ let isPayment = th.innerText.includes("t.pagamentoLocacao");
140
+ let isPeriod = th.innerText.includes("t.periodoLocacao");
141
+ let isProduct = th.innerText.includes("t.produtoLocacao");
142
+ let isInvoice = th.innerText.includes("t.produtoFatura");
143
+ let isGrouped = th.innerText.includes("t.produtoAgrupado");
144
+ let isMoviment = th.innerText.includes("t.produtoMovimentacao");
145
+ let isCustumerAddress = th.innerText.includes("t.enderecoCliente");
146
+ let isAddressRent = th.innerText.includes("t.saidaRetornoLocacao");
147
+ let isTeamRent = th.innerText.includes("t.equipeLocacao");
148
+ let isOrderService = th.innerText.includes("t.produtoOs");
149
+ let isPaymentOsCustomer = th.innerText.includes("t.pagamentoCliente");
150
+ let isPaymentOsSupplier = th.innerText.includes("t.pagamentoFornecedor");
151
+ let isAttachment = th.innerText.includes("t.anexo");
152
+
153
+ if (isProduct) {
154
+ obj.vForSimple = "v-for='produto in d.itensLocacao'";
155
+ config.push(obj);
156
+ } else if (isInvoice) {
157
+ obj.vForSimple = "v-for='produto in d.itensFatura'";
158
+ config.push(obj);
159
+ } else if (isPeriod) {
160
+ obj.vForSimple = "v-for='periodo in d.periodoLocacao'";
161
+ config.push(obj);
162
+ } else if (isPayment) {
163
+ obj.vForSimple = "v-for='pagamento in d.pagamentoLocacao'";
164
+ config.push(obj);
165
+ } else if (isTeamRent) {
166
+ obj.vForSimple = "v-for='equipe in d.equipeLocacao'";
167
+ config.push(obj);
168
+ } else if (isOrderService) {
169
+ obj.vForSimple = "v-for='produto in d.itensOs'";
170
+ config.push(obj);
171
+ } else if (isPaymentOsCustomer) {
172
+ obj.vForSimple = "v-for='pagamento in d.pagamentoOsCliente'";
173
+ config.push(obj);
174
+ } else if (isPaymentOsSupplier) {
175
+ obj.vForSimple = "v-for='pagamento in d.pagamentoOsFornecedor'";
176
+ config.push(obj);
177
+ } else if (isGrouped) {
178
+ obj.vForGrouped = "v-for='(itensLocacao, grupo) in produtoAgrupado'";
179
+ obj.vForSimple = "v-for='produto in itensLocacao'";
180
+
181
+ // neste cenário basicamente temos que montar o <tbody> no array de agrupamento
182
+
183
+ var initIndex = documentHtml.split("<tbody>", index + 1).join("<tbody>").length;
184
+ var lastIndex = documentHtml.split("</tbody>", index + 1).join("</tbody>").length;
185
+
186
+ let tbody = documentHtml.substring(documentHtml.indexOf("<tbody>", initIndex), documentHtml.lastIndexOf("</tbody>", lastIndex));
187
+
188
+ let tr = tbody.substring(tbody.indexOf("<tr>"), tbody.lastIndexOf("</tr>"));
189
+
190
+ // faz o replace nameGroup para tirar o <tr/>
191
+ obj.nameGroup = tr.substring(0, tr.indexOf('</tr>')) + "</tr>";
192
+ obj.nameGroup = obj.nameGroup.replaceAll("\"", "'");
193
+ obj.nameGroupReplace = obj.nameGroup.replace("<tr>", "").replace("</tr>", "");
194
+
195
+ config.push(obj);
196
+
197
+ } else if (isMoviment) {
198
+ obj.vForSimple = "v-for='produto in d.itensMovimentacao'";
199
+ config.push(obj);
200
+ } else if (isCustumerAddress) {
201
+ obj.vForSimple = "v-for='endereco in d.locacao.cliente.endereco'";
202
+ config.push(obj);
203
+ } else if (isAddressRent) {
204
+ obj.vForSimple = "v-for='endereco in d.saidaRetorno'";
205
+ config.push(obj);
206
+ } else if (isAttachment) {
207
+ obj.vForSimple = "v-for='anexo in d.anexo'";
208
+ config.push(obj);
209
+ } else {
210
+ config.push(obj);
211
+ }
212
+ } else {
213
+ config.push(obj);
214
+ }
215
+ index++;
216
+ }
217
+
218
+ let replace = "";
219
+ config.forEach(x => {
220
+ replace += `.replace("<tbody>${x.nameGroup}<tr>", "<tbody ${x.vForGrouped}>${x.nameGroupReplace}<tr ${x.vForSimple}>")`;
221
+ });
222
+
223
+ var retParse = ret.replaceAll("\"", "'");
224
+ retParse = eval(`retParse${replace}`);
225
+
226
+ var classImportant = retParse
227
+ .replaceAll("t.pagamentoLocacao", "")
228
+ .replaceAll("t.periodoLocacao", "")
229
+ .replaceAll("t.produtoLocacao", "")
230
+ .replaceAll("t.produtoFatura", "")
231
+ .replaceAll("t.produtoAgrupado", "")
232
+ .replaceAll("t.produtoMovimentacao", "")
233
+ .replaceAll("t.enderecoCliente", "")
234
+ .replaceAll("t.saidaRetornoLocacao", "")
235
+ .replaceAll("t.equipeLocacao", "")
236
+ .replaceAll("t.produtoOs", "")
237
+ .replaceAll("t.pagamentoCliente", "")
238
+ .replaceAll("t.pagamentoFornecedor", "")
239
+ .replaceAll("t.anexo", "")
240
+ .replaceAll("<p>&nbsp!important;</p>", "<p>&nbsp</p>");
241
+ }
242
+
243
+ return classImportant;
244
+ },
245
+ groupBy: () => (obj) => {
246
+ const result = {};
247
+ obj.array.forEach((item) => {
248
+ if (!result[item[obj.key]]) {
249
+ result[item[obj.key]] = [];
250
+ }
251
+ result[item[obj.key]].push(item);
252
+ });
253
+ return result;
254
+ },
255
+ listIdToString: () => (listId) => {
256
+ var ids = "";
257
+ listId.forEach(function (id) {
258
+ ids += `${id},`;
259
+ });
260
+ return ids;
261
+ },
262
+ },
263
+ mutations: {
264
+ openModal: (state, name) => {
265
+ state.modal.name = name;
266
+ state.modal.open = true;
267
+ },
268
+ toggleMenu: (state, data) => {
269
+ state.menuCollapsed = data;
270
+ },
271
+ hideModal: (state) => {
272
+ state.modal.open = false;
273
+ },
274
+ openSideBar: (state, name) => {
275
+ state.sideBar.name = name;
276
+ state.sideBar.open = true;
277
+ },
278
+ hideSideBar: (state) => {
279
+ state.sideBar.open = false;
280
+ },
281
+ openVodal: (state, name) => {
282
+ state.vodal.name.push(name);
283
+ state.vodal.open = true;
284
+ },
285
+ hideVodal: (state, name) => {
286
+ let filter = state.vodal.name.filter(x => x != name);
287
+ state.vodal.name = filter;
288
+ state.vodal.open = false;
289
+ },
290
+ updateSearch: (state, value) => {
291
+ state.search = value;
292
+ },
293
+ executedSearch: (state) => {
294
+ state.executedSearch = state.executedSearch = !state.executedSearch
295
+ },
296
+ clearedSearch: (state) => {
297
+ state.clearedSearch = state.clearedSearch = !state.clearedSearch
298
+ },
299
+ updateCurrentPage: (state, value) => {
300
+ state.paginations.currentPage = value;
301
+ },
302
+ updateTotalPerPage: (state, value) => {
303
+ state.paginations.totalPerPage = value.id;
304
+ },
305
+ updateDocumentHtmlFinal: (state, html) => {
306
+ state.documentHtmlFinal = html;
307
+ },
308
+ addSelected: (state, selected) => {
309
+ state.selected = selected;
310
+ },
311
+ cleanSelected: (state) => {
312
+ setTimeout(function () {
313
+ state.selected = [];
314
+ }, 100);
315
+ },
316
+ addToast: (state, action) => {
317
+ state.toast.dateTime = new Date();
318
+ state.toast.type = action;
319
+ },
320
+ addMethodExecutedApi: (state, action) => {
321
+ setTimeout(function () {
322
+ state.methodExecutedApi = action;
323
+ }, 100);
324
+ },
325
+ cleanMethodExecutedApi: (state) => {
326
+ setTimeout(function () {
327
+ state.methodExecutedApi = "";
328
+ }, 100);
329
+ },
330
+ addLoading: (state, key) => {
331
+ state.loading.push(key);
332
+ },
333
+ removeLoading: (state, listKey) => {
334
+ listKey.forEach(function (key) {
335
+ let filter = state.loading.filter(function (item) {
336
+ return item != key;
337
+ });
338
+ state.loading = filter;
339
+ });
340
+ },
341
+ updateDocumentHtml: (state, value) => {
342
+ state.documentHtml = value;
343
+ },
344
+ addEvent: (state, obj) => {
345
+ setTimeout(function () {
346
+ state.event.dateTime = new Date();
347
+ state.event.name = obj.name;
348
+ state.event.data = obj.data;
349
+ }, 100);
350
+ },
351
+ removeEvent: (state) => {
352
+ state.event = {};
353
+ },
354
+ addNotifications: (state, notifications) => {
355
+ state.notifications = notifications;
356
+ },
357
+ removeNotificarions: (state) => {
358
+ state.notifications = [];
359
+ },
360
+ addNotificationErrorApi: (state) => {
361
+ var erro = { property: "ERRO API", message: "Falha de Comunicação!" };
362
+ state.notifications = [erro];
363
+ },
364
+ listIdToString: (state, listId) => {
365
+ state.ids = "";
366
+ listId.forEach(function (id) {
367
+ state.ids += `${id},`;
368
+ });
369
+ },
370
+ addFilter: (state, obj) => {
371
+ setTimeout(function () {
372
+ state.selectStatic.dateTime = new Date();
373
+ state.selectStatic.tag = obj.tag;
374
+ state.selectStatic.fieldTarget = obj.fieldTarget;
375
+ state.selectStatic.value = obj.value;
376
+ }, 100);
377
+ },
378
+ addTag: (state, tag) => {
379
+ state.tags.push(tag);
380
+ },
381
+ removeTag: (state, key) => {
382
+ let filter = state.tags.filter(x => x.key != key);
383
+ state.tags = filter;
384
+ },
385
+ cleanTags: (state) => {
386
+ state.tags = []
387
+ },
388
+ openModal: (state, name) => {
389
+ state.modal.name = name;
390
+ state.modal.open = true;
391
+ },
392
+ addFilterStorage: (state, obj) => {
393
+ const index = state.filterStorage.findIndex(x => x.key === obj.key);
394
+ if (index !== -1) {
395
+ state.filterStorage[index] = obj;
396
+
397
+ } else {
398
+ state.filterStorage.push(obj);
399
+ }
400
+ },
401
+ removeFilterStorage: (state, key) => {
402
+ let filter = state.filterStorage.filter(x => x.key != key);
403
+ state.filterStorage = filter;
404
+ },
405
+ addFilterQuery: (state, obj) => {
406
+ // função abaixo é para não deixar duplicidade
407
+ const index = state.filterQuery.findIndex(x => x.routeName === obj.routeName);
408
+ if (index !== -1) {
409
+ state.filterQuery[index] = obj;
410
+
411
+ } else {
412
+ state.filterQuery.push(obj);
413
+ }
414
+ },
415
+ updateFilterFinal: (state, filterFinal) => {
416
+ state.filterFinal = filterFinal;
417
+ },
418
+ updateQueryTags: (state, tags) => {
419
+ state.queryTags = tags;
420
+ },
421
+ _addFilterStorage: (state, obj) => { // está com _addFilterStorage para não ter duplicidade
422
+ // função abaixo é para não deixar duplicidade
423
+ const index = state._filterStorage.findIndex(x => x.routeName === obj.routeName);
424
+ if (index !== -1) {
425
+ state._filterStorage[index] = obj;
426
+
427
+ } else {
428
+ state._filterStorage.push(obj);
429
+ }
430
+ },
431
+ },
432
+ actions: {
433
+ postApi: async function (context, params) {
434
+ context.commit('cleanMethodExecutedApi');
435
+ return axios.post(params.url, params.obj, {
436
+ headers: new Token().tokenHeaders(),
437
+ })
438
+ .then((response) => {
439
+
440
+ if (response.data.success) {
441
+ context.commit('addMethodExecutedApi', 'postApi');
442
+
443
+ if (!params.notNotifyToast)
444
+ context.commit('addToast', 'postApi');
445
+
446
+ context.commit('removeNotificarions');
447
+
448
+ if (!params.notRemoveFormDirty)
449
+ context.commit('validation/removeFormDirty', null, { root: true });
450
+
451
+ return response.data;
452
+ } else {
453
+
454
+ context.commit('addNotifications', response.data.notifications)
455
+ context.commit('addToast', 'messageError');
456
+
457
+ return response.data;
458
+ }
459
+ }, (err) => {
460
+
461
+ if (err.response)
462
+ if (err.response.status === 403) {
463
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
464
+ context.commit('addToast', 'noPermission');
465
+ }
466
+
467
+ if (!err.response)
468
+ context.commit('addNotificationErrorApi');
469
+ return false;
470
+ })
471
+ },
472
+ putApi: async function (context, params) {
473
+ context.commit('cleanMethodExecutedApi');
474
+ return axios.put(params.url, params.obj, {
475
+ headers: new Token().tokenHeaders(),
476
+ })
477
+ .then((response) => {
478
+ if (response.data.success) {
479
+ context.commit('addMethodExecutedApi', 'putApi');
480
+
481
+ if (!params.notNotifyToast)
482
+ context.commit('addToast', 'putApi');
483
+
484
+ context.commit('removeNotificarions');
485
+ context.commit('validation/removeFormDirty', null, { root: true });
486
+ return response.data;
487
+ } else {
488
+ context.commit('addNotifications', response.data.notifications)
489
+ context.commit('addToast', 'messageError');
490
+ return response.data;
491
+ }
492
+ }, (err) => {
493
+ if (err.response)
494
+ if (err.response.status === 403) {
495
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
496
+ context.commit('addToast', 'noPermission');
497
+ }
498
+
499
+ if (!err.response)
500
+ context.commit('addNotificationErrorApi');
501
+
502
+ return false;
503
+ })
504
+ },
505
+ getApi: async function (context, params) {
506
+
507
+ context.commit('cleanMethodExecutedApi');
508
+ return axios.get(params.url, {
509
+ params: params.obj,
510
+ headers: new Token().tokenHeaders(),
511
+ })
512
+ .then((response) => {
513
+
514
+ if (response.data.success) {
515
+ context.commit('addMethodExecutedApi', params.methodExecutedApi);
516
+ context.commit('removeNotificarions');
517
+ return response.data;
518
+ } else {
519
+
520
+ context.commit('addNotifications', response.data.notifications)
521
+ context.commit('addToast', 'falhaGenerica');
522
+ return response.data;
523
+ }
524
+ }, (err) => {
525
+ context.commit('addNotificationErrorApi');
526
+ return false;
527
+ })
528
+ },
529
+ orderAllApi: async function (context, params) {
530
+ return axios.put(params.url, params.obj, {
531
+ headers: new Token().tokenHeaders(),
532
+ })
533
+ .then((response) => {
534
+ return response.data;
535
+ }, (err) => {
536
+ context.commit('addNotificationErrorApi');
537
+ return false;
538
+ })
539
+ },
540
+ getApiOdata: async function (context, params) {
541
+ return axios.get(params.url, {
542
+ headers: new Token().tokenHeaders(),
543
+ })
544
+ .then((response) => {
545
+ return response.data;
546
+ }, (err) => {
547
+ context.commit('addNotificationErrorApi');
548
+ return false;
549
+ })
550
+ },
551
+ putAllApi: async function (context, params) {
552
+
553
+ context.commit('cleanMethodExecutedApi');
554
+ context.commit('listIdToString', params.selected);
555
+
556
+ let ids = context.state.ids;
557
+
558
+ return axios.put(params.url, { ids: ids }, {
559
+ headers: new Token().tokenHeaders(),
560
+ })
561
+ .then((response) => {
562
+ if (response.data.success) {
563
+ context.commit('addMethodExecutedApi', 'putApi');
564
+ context.commit('addToast', 'putAllApi');
565
+ context.commit('removeNotificarions');
566
+ context.commit('cleanSelected', 'putApi');
567
+
568
+ return response.data;
569
+ } else {
570
+ context.commit('addNotifications', response.data.notifications)
571
+ context.commit('addMethodExecutedApi', 'putApiErro');
572
+ context.commit('addToast', 'messageError');
573
+ return response.data;
574
+ }
575
+
576
+ }, (err) => {
577
+ if (err.response)
578
+ if (err.response.status === 403) {
579
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
580
+ context.commit('addToast', 'noPermission');
581
+ }
582
+
583
+ if (!err.response)
584
+ context.commit('addNotificationErrorApi');
585
+ return false;
586
+ })
587
+ },
588
+ deleteAllApi: async function (context, params) {
589
+
590
+ context.commit('cleanMethodExecutedApi');
591
+ context.commit('listIdToString', params.selected);
592
+
593
+ let url = params.url;
594
+ let ids = context.state.ids;
595
+
596
+ return axios.delete(`${url}?ids=${ids}`, {
597
+ headers: new Token().tokenHeaders(),
598
+ })
599
+ .then((response) => {
600
+ if (response.data.success) {
601
+ context.commit('addMethodExecutedApi', 'deleteAllApi');
602
+ context.commit('addToast', 'deleteApiSucesso');
603
+ context.commit('removeNotificarions');
604
+ return response.data;
605
+ } else {
606
+ context.commit('addNotifications', response.data.notifications)
607
+ context.commit('addMethodExecutedApi', 'deleteAllApiErro');
608
+ context.commit('addToast', 'messageError');
609
+ return response.data;
610
+ }
611
+
612
+ }, (err) => {
613
+ if (err.response)
614
+ if (err.response.status === 403) {
615
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
616
+ context.commit('addToast', 'noPermission');
617
+ }
618
+
619
+ if (!err.response)
620
+ context.commit('addNotificationErrorApi');
621
+ return false;
622
+ })
623
+ },
624
+ deleteApi: async function (context, params) {
625
+
626
+ context.commit('cleanMethodExecutedApi');
627
+ let url = params.url;
628
+
629
+ return axios.delete(`${url}`, {
630
+ headers: new Token().tokenHeaders(),
631
+ })
632
+ .then((response) => {
633
+ if (response.data.success) {
634
+ context.commit('addMethodExecutedApi', 'deleteApi')
635
+ context.commit('addToast', 'deleteApiSucesso');
636
+ context.commit('removeNotificarions');
637
+ return response.data;
638
+ } else {
639
+ context.commit('addNotifications', response.data.notifications)
640
+ context.commit('addToast', 'messageError');
641
+ return response.data;
642
+ }
643
+
644
+ }, (err) => {
645
+ if (err.response)
646
+ if (err.response.status === 403) {
647
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
648
+ context.commit('addToast', 'noPermission');
649
+ }
650
+
651
+ if (!err.response)
652
+ context.commit('addNotificationErrorApi');
653
+ return false;
654
+ })
655
+ },
656
+ getFileApi: async function (context, params) {
657
+ context.commit('cleanMethodExecutedApi');
658
+ return axios.get(params.url, {
659
+ params: params.obj,
660
+ headers: new Token().tokenHeaders(),
661
+ responseType: "arraybuffer",
662
+ })
663
+ .then((response) => {
664
+
665
+
666
+ let blob = new Blob([response.data], { type: `application/${params.obj.fileType}` });
667
+ let url = window.URL.createObjectURL(blob);
668
+
669
+ let downloadLink = document.createElement("a");
670
+ downloadLink.href = url;
671
+ downloadLink.download = `${params.obj.fileName}`;
672
+
673
+ document.body.appendChild(downloadLink);
674
+ downloadLink.click();
675
+
676
+ document.body.removeChild(downloadLink);
677
+
678
+ context.commit('addMethodExecutedApi', 'getPdfApi');
679
+ context.commit('removeNotificarions');
680
+
681
+ }, (err) => {
682
+ context.commit('addNotificationErrorApi');
683
+ return false;
684
+ })
685
+ },
686
+ getFileApiWithParameterBody: async function (context, params) {
687
+ context.commit('cleanMethodExecutedApi');
688
+ return axios.post(params.url, params.obj, {
689
+ headers: new Token().tokenHeaders(),
690
+ responseType: "arraybuffer",
691
+ })
692
+ .then((response) => {
693
+
694
+ let blob = new Blob([response.data], { type: "application/pdf" });
695
+ let url = window.URL.createObjectURL(blob);
696
+
697
+ let downloadLink = document.createElement("a");
698
+ downloadLink.href = url;
699
+ downloadLink.download = `${params.obj.fileName}`;
700
+
701
+ document.body.appendChild(downloadLink);
702
+ downloadLink.click();
703
+
704
+ document.body.removeChild(downloadLink);
705
+
706
+ }, (err) => {
707
+ return false;
708
+ })
709
+ },
710
+ postFileApi: async function (context, params) {
711
+ context.commit('cleanMethodExecutedApi');
712
+
713
+ let formData = new FormData();
714
+ formData.append("file", params.file);
715
+ formData.append(params.container, params.container);
716
+ formData.append(params.name, params.name);
717
+ formData.append(params.accepted, params.accepted);
718
+
719
+ return axios.post(params.url, formData, {
720
+ headers: new Token().tokenHeaders(),
721
+ })
722
+ .then((response) => {
723
+ if (response.data.success) {
724
+ context.commit('addMethodExecutedApi', 'postFileApi');
725
+ context.commit('removeNotificarions');
726
+ return response.data;
727
+ } else {
728
+
729
+ context.commit('addNotifications', response.data.notifications)
730
+ context.commit('addToast', 'messageError');
731
+
732
+ return response.data;
733
+ }
734
+ }, (err) => {
735
+ if (err.response)
736
+ if (err.response.status === 403) {
737
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
738
+ context.commit('addToast', 'noPermission');
739
+ }
740
+
741
+ if (!err.response)
742
+ context.commit('addNotificationErrorApi');
743
+ return false;
744
+ })
745
+ },
746
+ deleteFileApi: async function (context, params) {
747
+ context.commit('cleanMethodExecutedApi');
748
+
749
+ let url = params.url;
750
+ let name = params.obj.name;
751
+ let container = params.obj.container;
752
+
753
+ return axios.delete(`${url}?name=${name}&container=${container}`, {
754
+ headers: new Token().tokenHeaders(),
755
+ })
756
+ .then((response) => {
757
+ if (response.data.success) {
758
+ context.commit('addMethodExecutedApi', 'deleteFileApi');
759
+ context.commit('removeNotificarions');
760
+ return response.data;
761
+ } else {
762
+ context.commit('addNotifications', response.data.notifications)
763
+ context.commit('addToast', 'addApiError');
764
+ return response.data;
765
+ }
766
+ }, (err) => {
767
+ if (err.response)
768
+ if (err.response.status === 403) {
769
+ context.commit('addNotifications', [{ message: "Usuário sem permissão para executar esta ação!" }])
770
+ context.commit('addToast', 'noPermission');
771
+ }
772
+
773
+ if (!err.response)
774
+ context.commit('addNotificationErrorApi');
775
+ return false;
776
+ })
777
+ },
778
+ getDocumentApi: async function (context, params) {
779
+ context.commit('cleanMethodExecutedApi');
780
+ return axios.get(params.url, {
781
+ params: params.obj,
782
+ headers: {
783
+ "Content-Type": "application/json",
784
+ Authorization: "Bearer " + params.obj.token
785
+ },
786
+ })
787
+ .then((response) => {
788
+ if (response.data.success) {
789
+ return response.data;
790
+ } else {
791
+ return response.data;
792
+ }
793
+ }, (err) => {
794
+
795
+ return false;
796
+ })
797
+ },
798
+ getPdfApi: async function (context, params) {
799
+ context.commit('cleanMethodExecutedApi');
800
+ return axios.get(params.url, {
801
+ params: params.obj,
802
+ responseType: "arraybuffer",
803
+ headers: new Token().tokenHeaders(),
804
+ })
805
+ .then((response) => {
806
+
807
+ let blob = new Blob([response.data], { type: "application/pdf" }),
808
+ url = window.URL.createObjectURL(blob);
809
+ window.open(url);
810
+ }, (err) => {
811
+ return false;
812
+ })
813
+ },
814
+
815
+ }
816
+ }