@nixweb/nixloc-ui 0.0.138 → 0.0.140

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixweb/nixloc-ui",
3
- "version": "0.0.138",
3
+ "version": "0.0.140",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -16,7 +16,11 @@
16
16
  <thead>
17
17
  <tr>
18
18
  <th v-for="(obj, ind) in header" :key="ind">
19
- <div class="title-margem" :class="obj.classCssTitle">
19
+ <div
20
+ class="title-margem"
21
+ :class="obj.classCssTitle"
22
+ :style="obj.styleHeader"
23
+ >
20
24
  <i class="fas fa-search" v-if="obj.iconSearch"></i>
21
25
  <span class="title-header"> {{ obj.title }}</span>
22
26
  </div>
@@ -27,25 +31,37 @@
27
31
  <tr v-for="(row, index) in data" :key="index" :style="row.rowCss">
28
32
  <td v-for="(obj, ind) in header" :key="ind">
29
33
  <div
30
- :class="convertClass(row[obj.fieldComparison], obj.classCssBody)"
34
+ :style="obj.styleBody"
35
+ :class="
36
+ convertClass(row[obj.fieldComparison], obj.classCssBody)
37
+ "
31
38
  v-if="obj.type === 'text'"
32
39
  >
33
40
  {{ row[obj.field] }}
34
41
  </div>
35
42
  <div
36
- :class="convertClass(row[obj.fieldComparison], obj.classCssBody)"
43
+ :style="obj.styleBody"
44
+ :class="
45
+ convertClass(row[obj.fieldComparison], obj.classCssBody)
46
+ "
37
47
  v-if="obj.type === 'date'"
38
48
  >
39
49
  {{ row[obj.field] | moment("DD/MM/YYYY") }}
40
50
  </div>
41
51
  <div
42
- :class="convertClass(row[obj.fieldComparison], obj.classCssBody)"
52
+ :style="obj.styleBody"
53
+ :class="
54
+ convertClass(row[obj.fieldComparison], obj.classCssBody)
55
+ "
43
56
  v-if="obj.type === 'dateTime'"
44
57
  >
45
58
  {{ row[obj.field] | moment("DD/MM/YYYY HH:mm") }}
46
59
  </div>
47
60
  <div
48
- :class="convertClass(row[obj.fieldComparison], obj.classCssBody)"
61
+ :style="obj.styleBody"
62
+ :class="
63
+ convertClass(row[obj.fieldComparison], obj.classCssBody)
64
+ "
49
65
  v-if="obj.type === 'currency'"
50
66
  >
51
67
  {{ row[obj.field] | currency }}
@@ -62,7 +78,10 @@
62
78
  </tbody>
63
79
  </table>
64
80
  <div>
65
- <TotalizationReport :totalization="totalization" :totalRecords="data.length" />
81
+ <TotalizationReport
82
+ :totalization="totalization"
83
+ :totalRecords="data.length"
84
+ />
66
85
  </div>
67
86
  </div>
68
87
  </ScrollBar>
@@ -122,17 +141,18 @@ table tbody tr td {
122
141
  padding-right: 5px !important;
123
142
  border-bottom: 0px !important;
124
143
  border-top: 0px !important;
144
+ font-size: 13px !important;
125
145
  }
126
146
 
127
147
  .title-header {
128
- font-size: 13px;
148
+ font-size: 12px;
129
149
  color: #757d8c;
130
150
  font-weight: 400;
131
151
  text-transform: uppercase;
132
152
  }
133
153
 
134
154
  .table-number {
135
- font-size: 14px;
155
+ font-size: 12px;
136
156
  font-weight: bold;
137
157
  }
138
158
 
@@ -142,7 +162,7 @@ table tbody tr td {
142
162
  }
143
163
 
144
164
  .table-currency {
145
- font-size: 14px;
165
+ font-size: 12px;
146
166
  min-width: 100px;
147
167
  }
148
168
 
@@ -184,4 +204,21 @@ table tbody tr td {
184
204
  .icon-excel {
185
205
  color: green;
186
206
  }
207
+
208
+ .danger {
209
+ color: #f0134d;
210
+ }
211
+
212
+ .progress-rent {
213
+ color: #4bb4e2;
214
+ }
215
+
216
+ .accepted {
217
+ color: #38a169;
218
+ }
219
+
220
+ .rejected {
221
+ color: #f0134d;
222
+ }
223
+
187
224
  </style>
@@ -56,4 +56,8 @@ export default {
56
56
  background: black !important;
57
57
  height: 0px !important;
58
58
  }
59
+
60
+ .receipt {
61
+ color: darkblue;
62
+ }
59
63
  </style>
@@ -53,7 +53,7 @@ export default {
53
53
  data() {
54
54
  return {
55
55
  selectedRule: this.rules[0],
56
- andOr: "or",
56
+ andOr: "and",
57
57
  duplicate: [],
58
58
  };
59
59
  },
@@ -7,6 +7,7 @@
7
7
  </label>
8
8
  <div style="margin-right: 20px">
9
9
  <RadioGroup
10
+ v-if="index > 0"
10
11
  :options="[
11
12
  { text: 'e', value: 'and' },
12
13
  { text: 'ou', value: 'or' },
@@ -36,13 +37,36 @@
36
37
  :initialValue="rule.value"
37
38
  v-model="rule.value"
38
39
  />
39
- <DateTime
40
- v-if="rule.typeField == 'dateTime'"
41
- :format="rule.props.format"
42
- :type="rule.props.type"
43
- :range="rule.props.range"
44
- v-model="rule.value"
45
- />
40
+ <div v-if="rule.typeField == 'dateTime'">
41
+ <div class="side-by-side">
42
+ <DateTime
43
+ :format="rule.props.format"
44
+ :type="rule.props.type"
45
+ :range="rule.props.range"
46
+ v-model="rule.value"
47
+ />
48
+ </div>
49
+ <div class="side-by-side margin">ou</div>
50
+ <div class="side-by-side margin">
51
+ <select
52
+ @change="verifyCalculate"
53
+ v-model="rule.value[2]"
54
+ class="form-control mr-2"
55
+ >
56
+ <option v-for="period in optionsPeriodCustom" :key="period">
57
+ {{ period }}
58
+ </option>
59
+ </select>
60
+ </div>
61
+ <div v-if="rule.props.filterByField">
62
+ <RadioGroup
63
+ v-if="rule.props.filterByField"
64
+ :options="rule.props.filterByField"
65
+ v-model="rule.name"
66
+ />
67
+ </div>
68
+ </div>
69
+
46
70
  <Select
47
71
  v-if="rule.typeField == 'select'"
48
72
  :url="rule.props.url"
@@ -61,7 +85,7 @@ import Select from "@nixweb/nixloc-ui/src/component/forms/Select";
61
85
  import CheckboxGroup from "@nixweb/nixloc-ui/src/component/forms/CheckboxGroup";
62
86
  import RadioGroup from "@nixweb/nixloc-ui/src/component/forms/RadioGroup.vue";
63
87
 
64
- import { mapMutations } from "vuex";
88
+ import { mapMutations, mapActions } from "vuex";
65
89
 
66
90
  export default {
67
91
  name: "DynamicComponent",
@@ -71,10 +95,38 @@ export default {
71
95
  CheckboxGroup,
72
96
  RadioGroup,
73
97
  },
74
- props: ["rule"],
98
+ props: ["rule", "index"],
99
+ created() {
100
+ if (this.rule.typeField == "dateTime") {
101
+ if (this.rule.value == null) {
102
+ this.rule.value = ["", "", ""];
103
+ } else {
104
+ if (this.rule.value.length == 3) {
105
+ this.verifyCalculate();
106
+ }
107
+ }
108
+ }
109
+ },
110
+ data() {
111
+ return {
112
+ urlCalculate: "/api/v1/rental/period-rent/calculate-period-query-builder",
113
+ optionsPeriodCustom: [
114
+ "hoje",
115
+ "próximos 7 dias",
116
+ "próximos 15 dias",
117
+ "próximos 30 dias",
118
+ "próximos 45 dias",
119
+ "últimos 7 dias",
120
+ "últimos 15 dias",
121
+ "últimos 30 dias",
122
+ "últimos 45 dias",
123
+ ],
124
+ };
125
+ },
75
126
  methods: {
76
127
  ...mapMutations("generic", ["addEvent"]),
77
128
  ...mapMutations("report", ["removeSelectedRule"]),
129
+ ...mapActions("generic", ["postApi"]),
78
130
  removeRule() {
79
131
  this.removeSelectedRule(this.rule.id);
80
132
  this.addEvent({
@@ -82,6 +134,31 @@ export default {
82
134
  data: { id: this.rule.id },
83
135
  });
84
136
  },
137
+ verifyCalculate() {
138
+ let title = this.rule.value[2];
139
+ if (title == "hoje") this.calculate(0, title);
140
+ if (title == "próximos 7 dias") this.calculate(7, title);
141
+ if (title == "próximos 15 dias") this.calculate(15, title);
142
+ if (title == "próximos 30 dias") this.calculate(30, title);
143
+ if (title == "próximos 45 dias") this.calculate(45, title);
144
+ if (title == "últimos 7 dias") this.calculate(-7, title);
145
+ if (title == "últimos 15 dias") this.calculate(-15, title);
146
+ if (title == "últimos 30 dias") this.calculate(-30, title);
147
+ if (title == "últimos 45 dias") this.calculate(-45, title);
148
+ },
149
+ calculate(days, title) {
150
+ let params = {
151
+ url: this.urlCalculate,
152
+ obj: { days: days },
153
+ notNotifyToast: true,
154
+ };
155
+ this.postApi(params).then((response) => {
156
+ this.rule.value = [];
157
+ this.rule.value[0] = response.content.start;
158
+ this.rule.value[1] = response.content.end;
159
+ this.rule.value[2] = title;
160
+ });
161
+ },
85
162
  },
86
163
  computed: {
87
164
  options() {
@@ -109,4 +186,9 @@ export default {
109
186
  .div-select {
110
187
  width: 330px;
111
188
  }
189
+
190
+ .margin {
191
+ margin-left: 30px;
192
+ padding: 10px;
193
+ }
112
194
  </style>
@@ -10,11 +10,14 @@
10
10
  v-for="(rule, index) in selectedRules"
11
11
  :key="index"
12
12
  :rule="rule"
13
+ :index="index"
13
14
  />
14
15
  </draggable>
15
16
  <br />
16
17
  <div v-if="selectedRules.length == 0">
17
- <Alert type="info"> Selecione o filtro desejado e clique em +Adicionar</Alert>
18
+ <Alert type="info">
19
+ Selecione o filtro desejado e clique em +Adicionar</Alert
20
+ >
18
21
  </div>
19
22
  </div>
20
23
  </div>
@@ -41,7 +44,8 @@ export default {
41
44
  ...mapState("report", ["selectedRules"]),
42
45
  },
43
46
  mounted() {
44
- this.dynamicComponent = this.$parent.$options.components["DynamicComponent"];
47
+ this.dynamicComponent =
48
+ this.$parent.$options.components["DynamicComponent"];
45
49
  },
46
50
  methods: {
47
51
  ...mapMutations("report", ["mountFinalQueryFormatOData"]),
@@ -62,8 +66,8 @@ export default {
62
66
 
63
67
  <style scoped>
64
68
  .component {
65
- min-height: 380px;
66
- max-height: 380px;
69
+ min-height: 450px;
70
+ max-height: 450px;
67
71
  overflow-y: visible;
68
72
  overflow-x: hidden;
69
73
  padding-left: 10px;
@@ -9,7 +9,10 @@
9
9
  >
10
10
  <div slot="content-main">
11
11
  <br />
12
- <div class="div-progress" v-if="liveTotalRecords != baseParams.totalRecords">
12
+ <div
13
+ class="div-progress"
14
+ v-if="liveTotalRecords != baseParams.totalRecords"
15
+ >
13
16
  <ProgressBar
14
17
  :text="`Carregando ${liveTotalRecords} registro(s) de ${baseParams.totalRecords}`"
15
18
  :value="liveTotalRecords"
@@ -96,7 +99,10 @@
96
99
  :width="modalOptions.width"
97
100
  v-show="showModal('templateReport')"
98
101
  >
99
- <ReportCreateUpdate :module="panel.module" v-show="modalOptions.name == 'save'" />
102
+ <ReportCreateUpdate
103
+ :module="panel.module"
104
+ v-show="modalOptions.name == 'save'"
105
+ />
100
106
  <Fields v-if="modalOptions.name == 'fields'" />
101
107
  <Rules v-show="modalOptions.name == 'rules'" />
102
108
  <div
@@ -201,7 +207,12 @@ export default {
201
207
  "addInitialReportCustom",
202
208
  "removeInitialReportCustom",
203
209
  ]),
204
- ...mapMutations("generic", ["addEvent", "openModal", "hideModal", "removeLoading"]),
210
+ ...mapMutations("generic", [
211
+ "addEvent",
212
+ "openModal",
213
+ "hideModal",
214
+ "removeLoading",
215
+ ]),
205
216
  getById() {
206
217
  let params = { url: this.urlGetById, obj: { id: this.id } };
207
218
  this.getApi(params).then((response) => {
@@ -238,7 +249,8 @@ export default {
238
249
  totalRecords / this.baseParams.totalPerPage
239
250
  );
240
251
 
241
- if (this.baseParams.totalPage <= 1) this.loadingOnlyIfOnePage(response.value);
252
+ if (this.baseParams.totalPage <= 1)
253
+ this.loadingOnlyIfOnePage(response.value);
242
254
  if (this.baseParams.totalPage > 1) this.loadingOnlyIfManyPages();
243
255
 
244
256
  this.content.headerTable = this.headerTable;
@@ -105,7 +105,7 @@ export default {
105
105
  let isGrouped = th.innerText.includes("t.produtoAgrupado");
106
106
  let isMoviment = th.innerText.includes("t.produtoMovimentacao");
107
107
  let isCustumerAddress = th.innerText.includes("t.enderecoCliente");
108
- let isAddressRent = th.innerText.includes("t.enderecoLocacao");
108
+ let isAddressRent = th.innerText.includes("t.saidaRetornoLocacao");
109
109
 
110
110
 
111
111
  if (isProduct) {
@@ -162,7 +162,7 @@ export default {
162
162
 
163
163
  var retParse = ret.replaceAll("\"", "'");
164
164
  retParse = eval(`retParse${replace}`);
165
-
165
+
166
166
  var classImportant = retParse
167
167
  .replaceAll("t.pagamentoLocacao", "")
168
168
  .replaceAll("t.periodoLocacao", "")
@@ -170,7 +170,7 @@ export default {
170
170
  .replaceAll("t.produtoAgrupado", "")
171
171
  .replaceAll("t.produtoMovimentacao", "")
172
172
  .replaceAll("t.enderecoCliente", "")
173
- .replaceAll("t.enderecoLocacao", "")
173
+ .replaceAll("t.saidaRetornoLocacao", "")
174
174
  .replaceAll("<p>&nbsp!important;</p>", "<p>&nbsp</p>");
175
175
  }
176
176
 
@@ -540,7 +540,6 @@ export default {
540
540
  })
541
541
  },
542
542
  getDocumentApi: async function (context, params) {
543
- console.log(params.obj);
544
543
  context.commit('cleanMethodExecutedApi');
545
544
  return axios.get(params.url, {
546
545
  params: params.obj,
@@ -551,10 +550,8 @@ export default {
551
550
  })
552
551
  .then((response) => {
553
552
  if (response.data.success) {
554
-
555
553
  return response.data;
556
554
  } else {
557
-
558
555
  return response.data;
559
556
  }
560
557
  }, (err) => {
@@ -562,5 +559,19 @@ export default {
562
559
  return false;
563
560
  })
564
561
  },
562
+ getPdfApi: async function (context, params) {
563
+ context.commit('cleanMethodExecutedApi');
564
+ return axios.get(params.url, {
565
+ params: params.obj,
566
+ responseType: "arraybuffer",
567
+ })
568
+ .then((response) => {
569
+ let blob = new Blob([response.data], { type: "application/pdf" }),
570
+ url = window.URL.createObjectURL(blob);
571
+ window.open(url);
572
+ }, (err) => {
573
+ return false;
574
+ })
575
+ },
565
576
  }
566
577
  }
@@ -1,497 +0,0 @@
1
- <template>
2
- <div>
3
- <Panel
4
- :module="panel.module"
5
- :title="panel.title"
6
- :showVerticalFilter="panel.showVerticalFilter"
7
- :showSearch="panel.showSearch"
8
- :showButtons="panel.showButtons"
9
- >
10
- <div slot="content-main">
11
- <br />
12
- <!-- <div class="div-progress" v-if="loading && liveTotalRecords > 0">
13
- <ProgressBar
14
- :text="`Carregando ${liveTotalRecords} registro(s) de ${content.totalRecords}`"
15
- :value="liveTotalRecords"
16
- :max="content.totalRecords"
17
- size="medium"
18
- />
19
- </div>
20
- <Modal title="Salvar" :width="550" v-show="showModal('saveReport')">
21
- <ReportCreateUpdate :module="panel.module" />
22
- </Modal>
23
- <Molded>
24
- <div>
25
- <div slot="content-filter-horizontal">
26
- <b-row>
27
- <b-col sm="6">
28
- <div class="side-by-side">
29
- <Button
30
- _key="searchReport"
31
- type="primary"
32
- title="Buscar"
33
- classIcon="fas fa-file-search"
34
- size="medium"
35
- :disabled="invalid || btnDisabled"
36
- :clicked="getAll"
37
- />
38
- </div>
39
- <div class="side-by-side">
40
- <Button
41
- v-if="!invalid"
42
- _key="btnSaveReport"
43
- type="success"
44
- title="Salvar Modelo"
45
- classIcon="fas fa-save"
46
- :disabled="loading || invalid"
47
- size="small"
48
- :clicked="openSaveReport"
49
- />
50
- </div>
51
- </b-col>
52
- <b-col class="text-right" sm="6">
53
- <div class="side-by-side">
54
- <Button
55
- _key="btnOpenFields"
56
- type="info"
57
- title="Campos"
58
- classIcon="fas fa-database"
59
- size="small"
60
- :disabled="loading"
61
- :clicked="openFields"
62
- />
63
- </div>
64
- <div class="side-by-side">
65
- <Button
66
- _key="btnOpenFilters"
67
- type="info"
68
- title="Filtros"
69
- classIcon="fas fa-filter"
70
- size="small"
71
- :disabled="loading"
72
- :clicked="openFilters"
73
- />
74
- </div>
75
- </b-col>
76
- </b-row>
77
- <Modal title="Campos" :width="600" v-if="showModal('fields')">
78
- <Fields />
79
- <b-row>
80
- <b-col class="text-right" sm="12">
81
- <div class="side-by-side">
82
- <Button
83
- _key="btnApplyFilters"
84
- type="primary"
85
- title="Aplicar"
86
- classIcon="fas fa-filter"
87
- size="small"
88
- :disabled="fields.selected.length == 0"
89
- :clicked="applyFilters"
90
- />
91
- </div>
92
- </b-col>
93
- </b-row>
94
- </Modal>
95
- <Modal title="Filtros" :width="900" v-show="showModal('filters')">
96
- <Rules :rules="rules" />
97
- <br />
98
- <b-row>
99
- <b-col class="text-right" sm="12">
100
- <div class="side-by-side">
101
- <Button
102
- _key="btnApplyFilters"
103
- type="primary"
104
- title="Aplicar"
105
- classIcon="fas fa-filter"
106
- size="small"
107
- :clicked="applyFilters"
108
- />
109
- </div>
110
- </b-col>
111
- </b-row>
112
- </Modal>
113
- </div>
114
- </div>
115
- </Molded>
116
- <div class="div-required" v-show="invalid">
117
- <Alert type="info" v-for="item in requiredRules" :key="item.id">
118
- É necessário informar o filtro
119
- <span class="filter-required">{{ item.title }}</span
120
- >, clique no botão "Filtros" para adicionar.
121
- </Alert>
122
- </div>
123
- <div class="div-tags">
124
- <Tags eventName="tagReport" />
125
- </div>
126
- <div class="g-div-molded div-table" v-if="!loading && liveTotalRecords > 0">
127
- <b-row>
128
- <b-col sm="6">
129
- <div class="div-button">
130
- <div class="side-by-side">
131
- <ExportExcel
132
- :button="{ type: 'edit', title: 'Excel', size: 'small' }"
133
- fileName="Auditoria"
134
- :cabecalho="content.headerTable"
135
- :data="content.data"
136
- />
137
- </div>
138
- <div class="side-by-side">
139
- <div>
140
- <Button
141
- v-print="'#printMe'"
142
- _key="btnApplyFilters"
143
- type="edit"
144
- title="Imprimir"
145
- classIcon="fas fa-print"
146
- size="small"
147
- :clicked="applyFilters"
148
- />
149
- </div>
150
- </div>
151
- </div>
152
- </b-col>
153
- <b-col sm="6">
154
- <TableTotalRecords :totalRecords="content.totalRecords" />
155
- </b-col>
156
- </b-row>
157
- <ScrollBar :minHeight="400" :maxHeight="600">
158
- <div id="printMe">
159
- <HeaderPrint />
160
- {{ content.headerTable }}
161
- <Table
162
- :headerTable="content.headerTable"
163
- :data="content.data"
164
- :showChecks="templateList.showChecks"
165
- />
166
- </div>
167
- </ScrollBar>
168
- </div>
169
- <div class="div-sem-data" v-if="noDataReturned">
170
- <Alert type="info">
171
- <span> Nenhum registro foi encontrato!</span>
172
- </Alert>
173
- </div>
174
- <div class="div-Totalization" v-if="content.totalization.length > 0">
175
- <Totalization :data="content.totalization" />
176
- </div>
177
- </div> -->
178
- </div>
179
- </Panel>
180
- </div>
181
- </template>
182
-
183
- <script>
184
- import Alert from "@nixweb/nixloc-ui/src/component/layout/Alert";
185
- import Modal from "@nixweb/nixloc-ui/src/component/forms/Modal";
186
- import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
187
- import ExportExcel from "@nixweb/nixloc-ui/src/component/shared/ExportExcel";
188
- import Table from "../shared/Table.vue";
189
- import HeaderPrint from "../shared/HeaderPrint.vue";
190
- import TableTotalRecords from "../shared/TableTotalRecords.vue";
191
- import Panel from "@nixweb/nixloc-ui/src/component/layout/Panel.vue";
192
- import ScrollBar from "@nixweb/nixloc-ui/src/component/layout/ScrollBar.vue";
193
- import Molded from "@nixweb/nixloc-ui/src/component/layout/Molded";
194
- import ProgressBar from "@nixweb/nixloc-ui/src/component/shared/ProgressBar";
195
- import Totalization from "@nixweb/nixloc-ui/src/component/shared/query-builder/Totalization.vue";
196
- import Tags from "@nixweb/nixloc-ui/src/component/shared/query-builder/Tags.vue";
197
- import ReportCreateUpdate from "@nixweb/nixloc-ui/src/component/template/ReportCreateUpdate.vue";
198
- import Fields from "@nixweb/nixloc-ui/src/component/shared/query-builder/Fields.vue";
199
- import Rules from "@nixweb/nixloc-ui/src/component/shared/query-builder/Rules.vue";
200
- import print from "vue-print-nb";
201
-
202
- import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
203
-
204
- export default {
205
- name: "TemplateReportView",
206
- directives: {
207
- print,
208
- },
209
- props: {
210
- panel: Object,
211
- templateList: Object,
212
- templateReport: Object,
213
- },
214
- components: {
215
- Alert,
216
- Modal,
217
- Button,
218
- TableTotalRecords,
219
- Table,
220
- Panel,
221
- ScrollBar,
222
- Molded,
223
- Totalization,
224
- ProgressBar,
225
- Tags,
226
- ReportCreateUpdate,
227
- ExportExcel,
228
- HeaderPrint,
229
- Fields,
230
- Rules,
231
- },
232
- data() {
233
- return {
234
- content: {
235
- headerTable: [],
236
- data: [],
237
- totalization: [],
238
- pagination: 0,
239
- currentPage: 1,
240
- totalPerPage: 100,
241
- totalRecords: 0,
242
- },
243
- btnDisabled: true,
244
- loading: false,
245
- noDataReturned: false,
246
- };
247
- },
248
- mounted() {
249
- this.addReport(this.templateReport);
250
- this.removeLoading(["panel"]);
251
- },
252
- beforeDestroy() {
253
- /* this.updateOptionsInitValue({});
254
- this.atualizaCampoOrdenado({});
255
- this.atualizaFiltroSelecionado({ children: [] });*/
256
- },
257
- computed: {
258
- ...mapGetters("generic", ["showModal", "event"]),
259
- ...mapGetters("report", [
260
- "headerTable",
261
- "selectedRules",
262
- "requiredRules",
263
- "requiredRulesAlreadyAdded",
264
- "hasSelectedFields",
265
- "oDataSelect",
266
- "oDataFilter",
267
- "oDataOrderBy",
268
- ]),
269
- ...mapState("report", ["report", "fields", "totalization"]),
270
- urlQuery() {
271
- let baseUrl = `${this.templateList.urlGetApi}?${this.oDataSelect}&${this.oDataOrderBy}&${this.oDataFilter.query}&$skip=${this.skip}&$top=${this.content.totalPerPage}&$count=true`;
272
- return baseUrl.replace("&&", "&");
273
- },
274
- urlTotalization() {
275
- let query = this.oDataFilter.totalization
276
- ? `$apply=filter(${this.oDataFilter.query.replace("$filter=", "")})/`
277
- : "$apply=";
278
- let baseUrl = `${this.templateList.urlGetApi}?${query}aggregate(${this.oDataFilter.totalization})`;
279
- return baseUrl;
280
- },
281
- skip() {
282
- return (this.content.currentPage - 1) * this.content.totalPerPage;
283
- },
284
- invalid() {
285
- let ret = true;
286
- this.requiredRules.forEach((rule) => {
287
- ret = this.requiredRulesAlreadyAdded(rule);
288
- });
289
-
290
- if (this.requiredRules.length == 0) ret = false;
291
-
292
- return ret;
293
- },
294
- liveTotalRecords() {
295
- return this.content.data.length;
296
- },
297
- },
298
- methods: {
299
- ...mapActions("generic", ["getApiOdata"]),
300
- ...mapMutations("generic", ["addEvent", "openModal", "hideModal", "removeLoading"]),
301
- ...mapMutations("report", [
302
- "addReport",
303
- "atualizaFiltroSelecionado",
304
- "atualizaCampoOrdenado",
305
- "updateOptionsInitValue",
306
- "atualizaCabecalhoTabela",
307
- ]),
308
- getAll() {
309
- this.content.data = [];
310
- this.content.totalization = [];
311
- this.btnDisabled = true;
312
-
313
- if (!this.invalid) {
314
- this.showHideFields();
315
- this.pagination();
316
- this.removeLoading(["searchReport"]);
317
-
318
- if (this.oDataFilter.totalization) this.totalizationOData();
319
- if (!this.oDataFilter.totalization) this.content.totalization = [];
320
- }
321
- },
322
- pagination() {
323
- let paramsQuery = { url: this.urlQuery };
324
- this.resetData();
325
-
326
- this.getApiOdata(paramsQuery).then((response) => {
327
- let totalRecords = response["@odata.count"];
328
- if (totalRecords == 0) this.noDataReturned = true;
329
- this.content.totalRecords = totalRecords;
330
- this.content.pagination = Math.round(totalRecords / this.content.totalPerPage);
331
-
332
- if (totalRecords <= this.content.totalPerPage) {
333
- this.queryOData();
334
- this.content.headerTable = this.headerTable;
335
- }
336
- if (this.content.pagination == 0) this.loading = false;
337
- });
338
- },
339
- resetData() {
340
- this.loading = true;
341
- this.content.data = [];
342
- this.content.currentPage = 1;
343
- this.noDataReturned = false;
344
- },
345
- queryOData() {
346
- let paramsQuery = { url: this.urlQuery };
347
- this.getApiOdata(paramsQuery).then((response) => {
348
- let self = this;
349
- response.value.forEach(function (obj) {
350
- self.content.data.push(obj);
351
- });
352
- this.content.currentPage++;
353
- });
354
- this.content.headerTable = this.headerTable;
355
- },
356
- totalizationOData() {
357
- let paramsResumo = { url: this.urlTotalization };
358
- this.getApiOdata(paramsResumo).then((response) => {
359
- this.content.totalization = [];
360
- const result = Object.entries(response[0]);
361
- let self = this;
362
- result.forEach(function (value) {
363
- self.totalization.forEach(function (totalization) {
364
- let obj = {
365
- title: "",
366
- value: value[1],
367
- classCss: totalization.classCss,
368
- type: totalization.type,
369
- };
370
- if (totalization.value == value[0]) {
371
- obj.title = totalization.title;
372
- self.content.totalization.push(obj);
373
- }
374
- });
375
- });
376
- });
377
- },
378
- openSaveReport() {
379
- this.addEvent({ nome: "changeReport" });
380
- this.openModal("saveReport");
381
- this.removeLoading(["btnSaveReport"]);
382
- },
383
- openFields() {
384
- this.openModal("fields");
385
- this.removeLoading(["btnOpenFields"]);
386
- },
387
- openFilters() {
388
- this.openModal("filters");
389
- this.removeLoading(["btnOpenFilters"]);
390
- },
391
- applyFilters() {
392
- this.hideModal();
393
- this.removeLoading(["btnApplyFilters"]);
394
- },
395
- showHideFields() {
396
- let self = this;
397
- this.report.fields.forEach(function (field) {
398
- /* if (self.hasSelectedFields(field.field, self.selectedFields)) {
399
- field.show = true;
400
- } else {
401
- field.show = false;
402
- }*/
403
- });
404
- },
405
- },
406
- watch: {
407
- event: {
408
- handler(event) {
409
- if (event.nome == "tagReport") this.openModal("filters");
410
- },
411
- deep: true,
412
- },
413
- selectedFields: {
414
- handler() {
415
- this.showHideFields();
416
- },
417
- deep: true,
418
- },
419
- "content.currentPage": {
420
- handler(currentPage) {
421
- if (currentPage <= this.content.pagination - 1) {
422
- let self = this;
423
- setTimeout(function () {
424
- self.queryOData();
425
- }, 200);
426
- }
427
- if (currentPage == this.content.pagination && currentPage != 0)
428
- this.loading = false;
429
- },
430
- deep: true,
431
- },
432
- "content.pagination": {
433
- handler() {
434
- this.queryOData();
435
- },
436
- deep: true,
437
- },
438
- "oDataFilter.query": {
439
- handler() {
440
- this.btnDisabled = false;
441
- },
442
- deep: true,
443
- },
444
- oDataSelect: {
445
- handler() {
446
- this.btnDisabled = false;
447
- },
448
- deep: true,
449
- },
450
- oDataOrderBy: {
451
- handler() {
452
- this.btnDisabled = false;
453
- },
454
- deep: true,
455
- },
456
- },
457
- };
458
- </script>
459
-
460
- <style scoped>
461
- .div-button {
462
- padding-bottom: 15px;
463
- }
464
-
465
- .div-progress {
466
- margin-bottom: 10px;
467
- }
468
-
469
- .div-sem-data {
470
- margin-top: 20px;
471
- }
472
-
473
- .div-table {
474
- margin-top: 20px;
475
- }
476
-
477
- .div-separacao {
478
- margin-left: 10px;
479
- margin-right: 5px;
480
- }
481
-
482
- .div-Totalization {
483
- margin-top: 20px;
484
- }
485
-
486
- .div-tags {
487
- margin-top: 15px;
488
- }
489
-
490
- .div-required {
491
- margin-top: 20px;
492
- }
493
-
494
- .filter-required {
495
- font-weight: 500;
496
- }
497
- </style>