@nixweb/nixloc-ui 1.19.0 → 1.21.0
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.
- package/package.json +1 -1
- package/src/component/forms/ButtonFilter.vue +104 -104
- package/src/component/forms/ButtonGroup.vue +66 -66
- package/src/component/forms/ButtonGroupInline.vue +210 -210
- package/src/component/forms/ButtonSub.vue +97 -97
- package/src/component/forms/ButtonToggle.vue +76 -76
- package/src/component/forms/DateYearMonth.vue +192 -192
- package/src/component/forms/ImageUpload.vue +214 -214
- package/src/component/forms/IncrementDecrement.vue +151 -151
- package/src/component/forms/InputAddressGoogle.vue +171 -171
- package/src/component/forms/InputCallToAction.vue +135 -135
- package/src/component/forms/InputDecimalDiscount.vue +146 -146
- package/src/component/forms/InputTag.vue +124 -124
- package/src/component/forms/InputTextEdit.vue +69 -69
- package/src/component/forms/InputWhatsApp.vue +47 -47
- package/src/component/forms/SideBar.vue +99 -99
- package/src/component/forms/Toggle.vue +72 -72
- package/src/component/layout/Account.vue +131 -131
- package/src/component/layout/AnimatedPhrase.vue +68 -68
- package/src/component/layout/BarFloating.vue +67 -67
- package/src/component/layout/BottomActionsBar.vue +205 -205
- package/src/component/layout/ColorPicker.vue +175 -175
- package/src/component/layout/Gantt.vue +128 -128
- package/src/component/layout/HideShow.vue +61 -61
- package/src/component/layout/IconMolded.vue +58 -58
- package/src/component/layout/IconPicker.vue +161 -161
- package/src/component/layout/NewAccount.vue +136 -136
- package/src/component/layout/NewHeader.vue +59 -59
- package/src/component/layout/NewIconMolded.vue +70 -70
- package/src/component/layout/NewMenu.vue +472 -472
- package/src/component/layout/Tab.vue +259 -259
- package/src/component/layout/Tag.vue +97 -97
- package/src/component/layout/Tooltip.vue +155 -155
- package/src/component/layout/Zoom.vue +111 -111
- package/src/component/rental/DisplayCalculatePeriod.vue +48 -48
- package/src/component/rental/DisplayPeriodRent.vue +55 -55
- package/src/component/rental/DisplayTotalization.vue +86 -86
- package/src/component/report/Fields.vue +108 -108
- package/src/component/report/Report.vue +377 -377
- package/src/component/report/ReportTable.vue +111 -111
- package/src/component/report/Totalization.vue +33 -33
- package/src/component/shared/CodeEditor.vue +128 -128
- package/src/component/shared/Confirmation.vue +74 -74
- package/src/component/shared/DocumentEditor.vue +99 -99
- package/src/component/shared/DocumentPreview.vue +117 -105
- package/src/component/shared/DocumentPublic.vue +33 -33
- package/src/component/shared/ExportExcel.vue +56 -56
- package/src/component/shared/FullCalendar.vue +175 -175
- package/src/component/shared/HeaderReport.vue +47 -47
- package/src/component/shared/ListNotifications.vue +70 -70
- package/src/component/shared/Loading.vue +1 -4
- package/src/component/shared/LoadingCard.vue +64 -64
- package/src/component/shared/ParameterLegend.vue +169 -169
- package/src/component/shared/Report.vue +250 -250
- package/src/component/shared/SaveCancel.vue +99 -117
- package/src/component/shared/SelectOption.vue +162 -162
- package/src/component/shared/TableDraggable.vue +117 -117
- package/src/component/shared/TableImport.vue +93 -93
- package/src/component/shared/TableItem.vue +228 -228
- package/src/component/shared/TableTotalPerPage.vue +114 -114
- package/src/component/shared/TableTotalRecords.vue +44 -44
- package/src/component/shared/TimeLine.vue +41 -41
- package/src/component/shared/Timer.vue +77 -77
- package/src/component/shared/ToggleTheme.vue +127 -127
- package/src/component/shared/TotalizationReport.vue +86 -86
- package/src/component/shared/actions/ActionButtons.vue +53 -53
- package/src/component/shared/actions/ActionErrorContent.vue +103 -103
- package/src/component/shared/actions/ActionFooter.vue +93 -99
- package/src/component/shared/actions/ActionHeader.vue +110 -110
- package/src/component/shared/actions/ActionItemList.vue +143 -143
- package/src/component/shared/actions/ActionsOptions.vue +209 -209
- package/src/component/shared/actions/ActionsSelected.vue +262 -262
- package/src/component/shared/automation/ActivitiesList.vue +43 -43
- package/src/component/shared/automation/AddRule.vue +60 -60
- package/src/component/shared/automation/AutomationBuilder.vue +26 -26
- package/src/component/shared/automation/DynamicComponentList.vue +85 -85
- package/src/component/shared/automation/SelectRule.vue +97 -97
- package/src/component/shared/automation/components/BillingByRent.vue +97 -97
- package/src/component/shared/automation/components/SendEmail.vue +93 -93
- package/src/component/shared/file-manager/FileManager.vue +390 -390
- package/src/component/shared/filter-builder/FilterBuilder.vue +220 -220
- package/src/component/shared/filter-builder/FilterQuery.vue +95 -95
- package/src/component/shared/query-builder/ConvertToOdata.js +86 -86
- package/src/component/shared/query-builder/DynamicComponent.vue +161 -161
- package/src/component/shared/query-builder/Fields.vue +93 -93
- package/src/component/shared/query-builder/Rules.vue +68 -68
- package/src/component/shared/query-builder/SelectRule.vue +97 -97
- package/src/component/shared/query-builder/Tags.vue +59 -59
- package/src/component/signature/Payment.vue +160 -160
- package/src/component/signature/Warning.vue +75 -75
- package/src/component/template/ReportCreateUpdate.vue +110 -110
- package/src/component/template/ViewTemplateDocumentView.vue +213 -213
- package/src/component/template/ViewTemplateImportFile.vue +347 -347
- package/src/component/template/ViewTemplateReportList.vue +240 -240
- package/src/component/template/ViewTemplateReportPreview.vue +521 -521
- package/src/component/template/ViewTemplateSelectOption.vue +46 -46
- package/src/component/template/model/Report.js +5 -5
- package/src/component/training/Course.vue +343 -343
- package/src/component/training/CourseView.vue +198 -198
- package/src/component/value-objects/Address.js +10 -10
- package/src/component/value-objects/Address.vue +173 -173
- package/src/component/value-objects/Contact.js +6 -6
- package/src/component/value-objects/Contact.vue +106 -106
- package/src/component/value-objects/Person.js +10 -10
- package/src/component/value-objects/Person.vue +130 -130
- package/src/store/modules/automation.js +30 -30
- package/src/store/modules/generic.js +16 -6
- package/src/store/modules/report.js +277 -277
- package/src/store/modules/user.js +69 -69
- package/src/store/modules/util.js +25 -25
|
@@ -1,278 +1,278 @@
|
|
|
1
|
-
import ConvertToOdata from "@nixweb/nixloc-ui/src/component/shared/query-builder/ConvertToOdata.js";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
namespaced: true,
|
|
5
|
-
state: {
|
|
6
|
-
report: { id: "", fields: [], rules: [], },
|
|
7
|
-
selectedFields: {},
|
|
8
|
-
selectedRules: [],
|
|
9
|
-
finalQueryFormatOData: {
|
|
10
|
-
fields: [], totalization: [],
|
|
11
|
-
},
|
|
12
|
-
tags: []
|
|
13
|
-
},
|
|
14
|
-
getters: {
|
|
15
|
-
headerTable: (state) => {
|
|
16
|
-
let list = [];
|
|
17
|
-
state.report.fields.forEach(function (field) {
|
|
18
|
-
if (field.selected) list.push(field);
|
|
19
|
-
});
|
|
20
|
-
return list;
|
|
21
|
-
},
|
|
22
|
-
fields: (state) => {
|
|
23
|
-
// esse getter serve somente para carregar informações no component Fields
|
|
24
|
-
var fields = { selected: [], options: [], sort: { content: "", id: "asc" }, orderBy: "" };
|
|
25
|
-
|
|
26
|
-
state.report.fields.forEach(function (value) {
|
|
27
|
-
let option = { text: value.title, value: value.field };
|
|
28
|
-
fields.options.push(option);
|
|
29
|
-
|
|
30
|
-
// se o relatório for o padrão, carrega as info default
|
|
31
|
-
if (state.report.id == undefined) {
|
|
32
|
-
if (value.selected)
|
|
33
|
-
fields.selected.push(value.field);
|
|
34
|
-
|
|
35
|
-
if (value.orderBy) {
|
|
36
|
-
fields.sort = { content: value.title, id: value.field };
|
|
37
|
-
fields.orderBy = value.orderBy;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
fields.selected = state.selectedFields.selected;
|
|
42
|
-
fields.sort = state.selectedFields.sort;
|
|
43
|
-
fields.orderBy = state.selectedFields.orderBy;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
return fields;
|
|
48
|
-
},
|
|
49
|
-
oDataOrderBy: (state) => {
|
|
50
|
-
let orderBy = "";
|
|
51
|
-
if (state.selectedFields.sort != undefined)
|
|
52
|
-
orderBy = `$orderby=${state.selectedFields.sort.id} ${state.selectedFields.orderBy}`;
|
|
53
|
-
return orderBy;
|
|
54
|
-
},
|
|
55
|
-
oDataSelect: (state) => {
|
|
56
|
-
let selectedFields = [];
|
|
57
|
-
|
|
58
|
-
// verifica os campos obrigatórios por default "requiredOData"
|
|
59
|
-
state.report.fields.forEach(value => {
|
|
60
|
-
if (value.requiredOData)
|
|
61
|
-
selectedFields.push(value.field);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// verifica os campos selecionados pelo usuário
|
|
65
|
-
if (state.selectedFields.selected != undefined) {
|
|
66
|
-
state.selectedFields.selected.forEach(function (field) {
|
|
67
|
-
selectedFields.push(field);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let query = "";
|
|
72
|
-
let indexQuery = 0;
|
|
73
|
-
|
|
74
|
-
// remove itens duplicados e monta a query select
|
|
75
|
-
[...new Set(selectedFields)].forEach(field => {
|
|
76
|
-
if (indexQuery == 0) query += `$select=${field}`;
|
|
77
|
-
if (indexQuery > 0) query += `,${field}`;
|
|
78
|
-
indexQuery++;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return query;
|
|
82
|
-
},
|
|
83
|
-
oDataFilter: (state) => {
|
|
84
|
-
let query = "";
|
|
85
|
-
let totalization = "";
|
|
86
|
-
let indexQuery = 0;
|
|
87
|
-
let indexTotalization = 0;
|
|
88
|
-
var sizeFields = state.finalQueryFormatOData.fields.length;
|
|
89
|
-
var sizeTotalization = state.finalQueryFormatOData.totalization.length;
|
|
90
|
-
var andOr = [];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
state.finalQueryFormatOData.fields.forEach(function (rule) {
|
|
94
|
-
|
|
95
|
-
if (rule.type == "field") {
|
|
96
|
-
if (indexQuery == 0 && sizeFields > 0) query += `$filter=${rule.formatOdata}`;
|
|
97
|
-
|
|
98
|
-
if (indexQuery > 0 && sizeFields > 0) {
|
|
99
|
-
query += ` ${rule.andOr} ${rule.formatOdata}`;
|
|
100
|
-
andOr.push(rule.andOr);
|
|
101
|
-
}
|
|
102
|
-
indexQuery++;
|
|
103
|
-
|
|
104
|
-
// verifica no array se o último item é o "and", se sim será necessário inserir "(" depois do filter = e ")" antes do "and"
|
|
105
|
-
// para que o oData consiga efetuar a query corretamente
|
|
106
|
-
if (andOr[andOr.length - 1] == "and") {
|
|
107
|
-
|
|
108
|
-
let initIndex = query.indexOf("=");
|
|
109
|
-
let lastIndex = query.indexOf("and");
|
|
110
|
-
|
|
111
|
-
var query1 = [query.slice(0, initIndex + 1), "(", query.slice(initIndex)].join('').replace("=(=", "=(");
|
|
112
|
-
var query2 = [query1.slice(0, lastIndex + 1), ")", query1.slice(lastIndex)].join('');
|
|
113
|
-
query = query2;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
} else {
|
|
117
|
-
if (indexTotalization == 0 && size > 0) totalization += `${rule.formatOdata}`;
|
|
118
|
-
if (indexTotalization > 0 && size > 0) totalization += `,${rule.formatOdata}`;
|
|
119
|
-
indexTotalization++;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
state.finalQueryFormatOData.totalization.forEach(function (rule) {
|
|
124
|
-
|
|
125
|
-
if (indexTotalization == 0 && sizeTotalization > 0) totalization = `${rule.formatOdata}`;
|
|
126
|
-
if (indexTotalization > 0 && sizeTotalization > 0) totalization = `,${rule.formatOdata}`;
|
|
127
|
-
indexTotalization++;
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return { query, totalization };
|
|
131
|
-
},
|
|
132
|
-
tags: (state) => {
|
|
133
|
-
state.tags = [];
|
|
134
|
-
let description = "";
|
|
135
|
-
|
|
136
|
-
state.finalQueryFormatOData.fields.forEach(function (rule) {
|
|
137
|
-
description = "";
|
|
138
|
-
|
|
139
|
-
if (rule.typeField == "dateTime") {
|
|
140
|
-
description = `${rule.value[0]} - ${rule.value[1]}`;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (rule.typeField == "select") {
|
|
144
|
-
description = rule.value.content;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (rule.typeField == "text" || rule.typeField == "numeric") {
|
|
148
|
-
description = `${rule.operator} "${rule.value}"`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (rule.typeField == "checkbox") {
|
|
152
|
-
rule.options.forEach(function (option) {
|
|
153
|
-
rule.value.forEach(function (value) {
|
|
154
|
-
if (option.value == value) {
|
|
155
|
-
description += `${option.title},`;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let tag = { id: rule.id, title: rule.title, value: description };
|
|
162
|
-
state.tags.push(tag);
|
|
163
|
-
|
|
164
|
-
});
|
|
165
|
-
return state.tags;
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
rulesIsValid: (state) => {
|
|
169
|
-
let isValid = false;
|
|
170
|
-
let rulesRequired = state.report.rules.filter(x => x.isRequired);
|
|
171
|
-
let rulesRequiredSelected = state.selectedRules.filter(x => x.isRequired);
|
|
172
|
-
|
|
173
|
-
if (rulesRequired.length == rulesRequiredSelected.length)
|
|
174
|
-
isValid = true;
|
|
175
|
-
|
|
176
|
-
return isValid;
|
|
177
|
-
},
|
|
178
|
-
rulesRequired: (state) => {
|
|
179
|
-
return state.report.rules.filter(x => x.isRequired);
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
mutations: {
|
|
183
|
-
updateSelectedFields: (state, selectedFields) => {
|
|
184
|
-
state.selectedFields = selectedFields;
|
|
185
|
-
// após selecionar o campo, atualiza tambem quais campos deverão aparecer no report
|
|
186
|
-
// se foi selecionado é marcado como selected = true
|
|
187
|
-
state.report.fields.forEach(function (value) {
|
|
188
|
-
var hasSelected = selectedFields.selected.find((selected) => {
|
|
189
|
-
if (value.field == selected) return true;
|
|
190
|
-
});
|
|
191
|
-
if (value.field === hasSelected) {
|
|
192
|
-
value.selected = true;
|
|
193
|
-
} else {
|
|
194
|
-
value.selected = false;
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
},
|
|
198
|
-
addSelectedRules: (state, selectedRule) => {
|
|
199
|
-
state.selectedRules.push(selectedRule);
|
|
200
|
-
},
|
|
201
|
-
removeSelectedRule: (state, id) => {
|
|
202
|
-
var filter = state.selectedRules.filter((item) => {
|
|
203
|
-
return id != item.id;
|
|
204
|
-
})
|
|
205
|
-
state.selectedRules = filter;
|
|
206
|
-
},
|
|
207
|
-
mountFinalQueryFormatOData: (state, selectedRules) => {
|
|
208
|
-
// aqui faz a conversão das regras selecionadas no padrão do query-builder para o formato oData carregando no objeto finalQueryFormatOData
|
|
209
|
-
// para ser consumido nos getters oDataSelect e oDataFilter
|
|
210
|
-
|
|
211
|
-
state.finalQueryFormatOData = { fields: [], totalization: [] };
|
|
212
|
-
var convertToOdata = new ConvertToOdata();
|
|
213
|
-
|
|
214
|
-
selectedRules.forEach(function (rule) {
|
|
215
|
-
|
|
216
|
-
if (rule.value != null && rule.value != "" && rule.value != undefined && rule.type == "totalization") {
|
|
217
|
-
let formatOdata = convertToOdata.convertRule(rule);
|
|
218
|
-
|
|
219
|
-
rule.value.forEach(value => {
|
|
220
|
-
// adiciona no array somente a opção da regra selecionada
|
|
221
|
-
var ruleSelected = rule.options.filter(x => x.value == value);
|
|
222
|
-
|
|
223
|
-
let ruleOdata = {
|
|
224
|
-
title: ruleSelected[0].aggregate.title,
|
|
225
|
-
value: ruleSelected[0].aggregate.value,
|
|
226
|
-
classCss: ruleSelected[0].aggregate.classCss,
|
|
227
|
-
type: ruleSelected[0].aggregate.type,
|
|
228
|
-
formatOdata: formatOdata,
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
state.finalQueryFormatOData.totalization.push(ruleOdata);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (rule.value != null && rule.value != "" && rule.value != undefined && rule.type == "field") {
|
|
236
|
-
|
|
237
|
-
let formatOdata = convertToOdata.convertRule(rule);
|
|
238
|
-
|
|
239
|
-
let ruleOdata = {
|
|
240
|
-
id: rule.id,
|
|
241
|
-
title: rule.title,
|
|
242
|
-
type: rule.type,
|
|
243
|
-
typeField: rule.typeField,
|
|
244
|
-
options: rule.options,
|
|
245
|
-
operator: rule.operator,
|
|
246
|
-
selected: rule.selected,
|
|
247
|
-
isRequired: rule.isRequired,
|
|
248
|
-
formatOdata: formatOdata,
|
|
249
|
-
andOr: rule.andOr,
|
|
250
|
-
value: rule.value,
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
state.finalQueryFormatOData.fields.push(ruleOdata);
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
clearTotalization: (state) => {
|
|
258
|
-
state.finalQueryFormatOData.totalization = [];
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
actions: {
|
|
262
|
-
addReport: async function (context, report) {
|
|
263
|
-
context.state.report = report;
|
|
264
|
-
context.state.selectedFields = context.getters.fields;
|
|
265
|
-
},
|
|
266
|
-
addInitialReportCustom: async function (context, report) {
|
|
267
|
-
context.state.selectedFields = report.selectedFields;
|
|
268
|
-
context.state.selectedRules = report.selectedRules;
|
|
269
|
-
context.commit('mountFinalQueryFormatOData', report.selectedRules);
|
|
270
|
-
context.commit('updateSelectedFields', report.selectedFields);
|
|
271
|
-
},
|
|
272
|
-
removeInitialReportCustom: async function (context) {
|
|
273
|
-
context.state.selectedFields = {};
|
|
274
|
-
context.state.selectedRules = [];
|
|
275
|
-
context.state.finalQueryFormatOData.fields = [];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
1
|
+
import ConvertToOdata from "@nixweb/nixloc-ui/src/component/shared/query-builder/ConvertToOdata.js";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
namespaced: true,
|
|
5
|
+
state: {
|
|
6
|
+
report: { id: "", fields: [], rules: [], },
|
|
7
|
+
selectedFields: {},
|
|
8
|
+
selectedRules: [],
|
|
9
|
+
finalQueryFormatOData: {
|
|
10
|
+
fields: [], totalization: [],
|
|
11
|
+
},
|
|
12
|
+
tags: []
|
|
13
|
+
},
|
|
14
|
+
getters: {
|
|
15
|
+
headerTable: (state) => {
|
|
16
|
+
let list = [];
|
|
17
|
+
state.report.fields.forEach(function (field) {
|
|
18
|
+
if (field.selected) list.push(field);
|
|
19
|
+
});
|
|
20
|
+
return list;
|
|
21
|
+
},
|
|
22
|
+
fields: (state) => {
|
|
23
|
+
// esse getter serve somente para carregar informações no component Fields
|
|
24
|
+
var fields = { selected: [], options: [], sort: { content: "", id: "asc" }, orderBy: "" };
|
|
25
|
+
|
|
26
|
+
state.report.fields.forEach(function (value) {
|
|
27
|
+
let option = { text: value.title, value: value.field };
|
|
28
|
+
fields.options.push(option);
|
|
29
|
+
|
|
30
|
+
// se o relatório for o padrão, carrega as info default
|
|
31
|
+
if (state.report.id == undefined) {
|
|
32
|
+
if (value.selected)
|
|
33
|
+
fields.selected.push(value.field);
|
|
34
|
+
|
|
35
|
+
if (value.orderBy) {
|
|
36
|
+
fields.sort = { content: value.title, id: value.field };
|
|
37
|
+
fields.orderBy = value.orderBy;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
fields.selected = state.selectedFields.selected;
|
|
42
|
+
fields.sort = state.selectedFields.sort;
|
|
43
|
+
fields.orderBy = state.selectedFields.orderBy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
return fields;
|
|
48
|
+
},
|
|
49
|
+
oDataOrderBy: (state) => {
|
|
50
|
+
let orderBy = "";
|
|
51
|
+
if (state.selectedFields.sort != undefined)
|
|
52
|
+
orderBy = `$orderby=${state.selectedFields.sort.id} ${state.selectedFields.orderBy}`;
|
|
53
|
+
return orderBy;
|
|
54
|
+
},
|
|
55
|
+
oDataSelect: (state) => {
|
|
56
|
+
let selectedFields = [];
|
|
57
|
+
|
|
58
|
+
// verifica os campos obrigatórios por default "requiredOData"
|
|
59
|
+
state.report.fields.forEach(value => {
|
|
60
|
+
if (value.requiredOData)
|
|
61
|
+
selectedFields.push(value.field);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// verifica os campos selecionados pelo usuário
|
|
65
|
+
if (state.selectedFields.selected != undefined) {
|
|
66
|
+
state.selectedFields.selected.forEach(function (field) {
|
|
67
|
+
selectedFields.push(field);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let query = "";
|
|
72
|
+
let indexQuery = 0;
|
|
73
|
+
|
|
74
|
+
// remove itens duplicados e monta a query select
|
|
75
|
+
[...new Set(selectedFields)].forEach(field => {
|
|
76
|
+
if (indexQuery == 0) query += `$select=${field}`;
|
|
77
|
+
if (indexQuery > 0) query += `,${field}`;
|
|
78
|
+
indexQuery++;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return query;
|
|
82
|
+
},
|
|
83
|
+
oDataFilter: (state) => {
|
|
84
|
+
let query = "";
|
|
85
|
+
let totalization = "";
|
|
86
|
+
let indexQuery = 0;
|
|
87
|
+
let indexTotalization = 0;
|
|
88
|
+
var sizeFields = state.finalQueryFormatOData.fields.length;
|
|
89
|
+
var sizeTotalization = state.finalQueryFormatOData.totalization.length;
|
|
90
|
+
var andOr = [];
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
state.finalQueryFormatOData.fields.forEach(function (rule) {
|
|
94
|
+
|
|
95
|
+
if (rule.type == "field") {
|
|
96
|
+
if (indexQuery == 0 && sizeFields > 0) query += `$filter=${rule.formatOdata}`;
|
|
97
|
+
|
|
98
|
+
if (indexQuery > 0 && sizeFields > 0) {
|
|
99
|
+
query += ` ${rule.andOr} ${rule.formatOdata}`;
|
|
100
|
+
andOr.push(rule.andOr);
|
|
101
|
+
}
|
|
102
|
+
indexQuery++;
|
|
103
|
+
|
|
104
|
+
// verifica no array se o último item é o "and", se sim será necessário inserir "(" depois do filter = e ")" antes do "and"
|
|
105
|
+
// para que o oData consiga efetuar a query corretamente
|
|
106
|
+
if (andOr[andOr.length - 1] == "and") {
|
|
107
|
+
|
|
108
|
+
let initIndex = query.indexOf("=");
|
|
109
|
+
let lastIndex = query.indexOf("and");
|
|
110
|
+
|
|
111
|
+
var query1 = [query.slice(0, initIndex + 1), "(", query.slice(initIndex)].join('').replace("=(=", "=(");
|
|
112
|
+
var query2 = [query1.slice(0, lastIndex + 1), ")", query1.slice(lastIndex)].join('');
|
|
113
|
+
query = query2;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
} else {
|
|
117
|
+
if (indexTotalization == 0 && size > 0) totalization += `${rule.formatOdata}`;
|
|
118
|
+
if (indexTotalization > 0 && size > 0) totalization += `,${rule.formatOdata}`;
|
|
119
|
+
indexTotalization++;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
state.finalQueryFormatOData.totalization.forEach(function (rule) {
|
|
124
|
+
|
|
125
|
+
if (indexTotalization == 0 && sizeTotalization > 0) totalization = `${rule.formatOdata}`;
|
|
126
|
+
if (indexTotalization > 0 && sizeTotalization > 0) totalization = `,${rule.formatOdata}`;
|
|
127
|
+
indexTotalization++;
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return { query, totalization };
|
|
131
|
+
},
|
|
132
|
+
tags: (state) => {
|
|
133
|
+
state.tags = [];
|
|
134
|
+
let description = "";
|
|
135
|
+
|
|
136
|
+
state.finalQueryFormatOData.fields.forEach(function (rule) {
|
|
137
|
+
description = "";
|
|
138
|
+
|
|
139
|
+
if (rule.typeField == "dateTime") {
|
|
140
|
+
description = `${rule.value[0]} - ${rule.value[1]}`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (rule.typeField == "select") {
|
|
144
|
+
description = rule.value.content;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (rule.typeField == "text" || rule.typeField == "numeric") {
|
|
148
|
+
description = `${rule.operator} "${rule.value}"`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (rule.typeField == "checkbox") {
|
|
152
|
+
rule.options.forEach(function (option) {
|
|
153
|
+
rule.value.forEach(function (value) {
|
|
154
|
+
if (option.value == value) {
|
|
155
|
+
description += `${option.title},`;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
let tag = { id: rule.id, title: rule.title, value: description };
|
|
162
|
+
state.tags.push(tag);
|
|
163
|
+
|
|
164
|
+
});
|
|
165
|
+
return state.tags;
|
|
166
|
+
|
|
167
|
+
},
|
|
168
|
+
rulesIsValid: (state) => {
|
|
169
|
+
let isValid = false;
|
|
170
|
+
let rulesRequired = state.report.rules.filter(x => x.isRequired);
|
|
171
|
+
let rulesRequiredSelected = state.selectedRules.filter(x => x.isRequired);
|
|
172
|
+
|
|
173
|
+
if (rulesRequired.length == rulesRequiredSelected.length)
|
|
174
|
+
isValid = true;
|
|
175
|
+
|
|
176
|
+
return isValid;
|
|
177
|
+
},
|
|
178
|
+
rulesRequired: (state) => {
|
|
179
|
+
return state.report.rules.filter(x => x.isRequired);
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
mutations: {
|
|
183
|
+
updateSelectedFields: (state, selectedFields) => {
|
|
184
|
+
state.selectedFields = selectedFields;
|
|
185
|
+
// após selecionar o campo, atualiza tambem quais campos deverão aparecer no report
|
|
186
|
+
// se foi selecionado é marcado como selected = true
|
|
187
|
+
state.report.fields.forEach(function (value) {
|
|
188
|
+
var hasSelected = selectedFields.selected.find((selected) => {
|
|
189
|
+
if (value.field == selected) return true;
|
|
190
|
+
});
|
|
191
|
+
if (value.field === hasSelected) {
|
|
192
|
+
value.selected = true;
|
|
193
|
+
} else {
|
|
194
|
+
value.selected = false;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
addSelectedRules: (state, selectedRule) => {
|
|
199
|
+
state.selectedRules.push(selectedRule);
|
|
200
|
+
},
|
|
201
|
+
removeSelectedRule: (state, id) => {
|
|
202
|
+
var filter = state.selectedRules.filter((item) => {
|
|
203
|
+
return id != item.id;
|
|
204
|
+
})
|
|
205
|
+
state.selectedRules = filter;
|
|
206
|
+
},
|
|
207
|
+
mountFinalQueryFormatOData: (state, selectedRules) => {
|
|
208
|
+
// aqui faz a conversão das regras selecionadas no padrão do query-builder para o formato oData carregando no objeto finalQueryFormatOData
|
|
209
|
+
// para ser consumido nos getters oDataSelect e oDataFilter
|
|
210
|
+
|
|
211
|
+
state.finalQueryFormatOData = { fields: [], totalization: [] };
|
|
212
|
+
var convertToOdata = new ConvertToOdata();
|
|
213
|
+
|
|
214
|
+
selectedRules.forEach(function (rule) {
|
|
215
|
+
|
|
216
|
+
if (rule.value != null && rule.value != "" && rule.value != undefined && rule.type == "totalization") {
|
|
217
|
+
let formatOdata = convertToOdata.convertRule(rule);
|
|
218
|
+
|
|
219
|
+
rule.value.forEach(value => {
|
|
220
|
+
// adiciona no array somente a opção da regra selecionada
|
|
221
|
+
var ruleSelected = rule.options.filter(x => x.value == value);
|
|
222
|
+
|
|
223
|
+
let ruleOdata = {
|
|
224
|
+
title: ruleSelected[0].aggregate.title,
|
|
225
|
+
value: ruleSelected[0].aggregate.value,
|
|
226
|
+
classCss: ruleSelected[0].aggregate.classCss,
|
|
227
|
+
type: ruleSelected[0].aggregate.type,
|
|
228
|
+
formatOdata: formatOdata,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
state.finalQueryFormatOData.totalization.push(ruleOdata);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (rule.value != null && rule.value != "" && rule.value != undefined && rule.type == "field") {
|
|
236
|
+
|
|
237
|
+
let formatOdata = convertToOdata.convertRule(rule);
|
|
238
|
+
|
|
239
|
+
let ruleOdata = {
|
|
240
|
+
id: rule.id,
|
|
241
|
+
title: rule.title,
|
|
242
|
+
type: rule.type,
|
|
243
|
+
typeField: rule.typeField,
|
|
244
|
+
options: rule.options,
|
|
245
|
+
operator: rule.operator,
|
|
246
|
+
selected: rule.selected,
|
|
247
|
+
isRequired: rule.isRequired,
|
|
248
|
+
formatOdata: formatOdata,
|
|
249
|
+
andOr: rule.andOr,
|
|
250
|
+
value: rule.value,
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
state.finalQueryFormatOData.fields.push(ruleOdata);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
clearTotalization: (state) => {
|
|
258
|
+
state.finalQueryFormatOData.totalization = [];
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
actions: {
|
|
262
|
+
addReport: async function (context, report) {
|
|
263
|
+
context.state.report = report;
|
|
264
|
+
context.state.selectedFields = context.getters.fields;
|
|
265
|
+
},
|
|
266
|
+
addInitialReportCustom: async function (context, report) {
|
|
267
|
+
context.state.selectedFields = report.selectedFields;
|
|
268
|
+
context.state.selectedRules = report.selectedRules;
|
|
269
|
+
context.commit('mountFinalQueryFormatOData', report.selectedRules);
|
|
270
|
+
context.commit('updateSelectedFields', report.selectedFields);
|
|
271
|
+
},
|
|
272
|
+
removeInitialReportCustom: async function (context) {
|
|
273
|
+
context.state.selectedFields = {};
|
|
274
|
+
context.state.selectedRules = [];
|
|
275
|
+
context.state.finalQueryFormatOData.fields = [];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
278
|
}
|