@nixweb/nixloc-ui 1.4.0 → 1.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixweb/nixloc-ui",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Componentes UI",
5
5
  "author": "Fábio Ávila <fabio@nixweb.com.br>",
6
6
  "private": false,
@@ -26,7 +26,6 @@
26
26
  </template>
27
27
 
28
28
  <script>
29
-
30
29
  import { mapMutations } from "vuex";
31
30
 
32
31
  export default {
@@ -39,11 +38,17 @@ export default {
39
38
  return Array.isArray(this.selected) && this.selected.length > 0;
40
39
  }
41
40
  },
41
+ watch: {
42
+ isOpen(val) {
43
+ document.body.classList.toggle("bab-open", val);
44
+ }
45
+ },
42
46
  mounted() {
43
47
  document.addEventListener("keydown", this.onKeydown);
44
48
  },
45
49
  beforeDestroy() {
46
50
  document.removeEventListener("keydown", this.onKeydown);
51
+ document.body.classList.remove("bab-open");
47
52
  },
48
53
  methods: {
49
54
  ...mapMutations("generic", ["addEvent"]),
@@ -59,19 +64,24 @@ export default {
59
64
  </script>
60
65
 
61
66
  <style>
67
+ body.bab-open {
68
+ margin-bottom: 150px;
69
+ transition: margin-bottom 0.25s ease;
70
+ }
71
+
62
72
  .bab-container {
63
73
  position: fixed;
64
74
  left: 0;
65
75
  right: 0;
66
76
  bottom: 0;
67
77
  height: 200px;
68
-
69
78
  border-top-left-radius: 18px;
70
79
  border-top-right-radius: 18px;
71
80
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
72
81
  z-index: 9999;
73
82
  display: flex;
74
83
  flex-direction: column;
84
+ background: #fff;
75
85
  animation: elevate 0.2s ease-in-out;
76
86
  }
77
87
 
@@ -156,6 +166,7 @@ export default {
156
166
  gap: 12px;
157
167
  }
158
168
 
169
+ /* --- Animações e transições --- */
159
170
  .slide-up-enter-active,
160
171
  .slide-up-leave-active {
161
172
  transition: transform 200ms ease-in-out, opacity 200ms ease-in-out;
@@ -179,6 +190,7 @@ export default {
179
190
  }
180
191
  }
181
192
 
193
+ /* --- Responsivo --- */
182
194
  @media (max-width: 640px) {
183
195
  .bab-container {
184
196
  height: 220px;
@@ -50,6 +50,15 @@ export default {
50
50
  });
51
51
  return sum.reduce((a, b) => a + b, 0);
52
52
  },
53
+ somaGrupoMaster(grupoMaster) {
54
+ let sum = [];
55
+ this.d.itensLocacao.forEach((item) => {
56
+ if (item.grupoMaster === grupoMaster) {
57
+ sum.push(item.totalValue);
58
+ }
59
+ });
60
+ return sum.reduce((a, b) => a + b, 0);
61
+ },
53
62
  convertToNumber(value) {
54
63
  return parseFloat(value.replace("R$", "").replace(",", "."));
55
64
  },
@@ -64,6 +73,21 @@ export default {
64
73
  var group = this.groupBy({ array: this.d.itensLocacao, key: "grupo" });
65
74
  return group;
66
75
  },
76
+ produtoGrupoSubgrupo() {
77
+ const resultado = {};
78
+
79
+ this.d.itensLocacao.forEach(item => {
80
+ const nomeGrupoMaster = item.grupoMaster;
81
+ const nomeGrupo = item.grupo;
82
+
83
+ if (!resultado[nomeGrupoMaster]) { resultado[nomeGrupoMaster] = {}; }
84
+ if (!resultado[nomeGrupoMaster][nomeGrupo]) { resultado[nomeGrupoMaster][nomeGrupo] = []; }
85
+
86
+ resultado[nomeGrupoMaster][nomeGrupo].push(item);
87
+ });
88
+
89
+ return resultado;
90
+ }
67
91
  },
68
92
  watch: {
69
93
  event: {
@@ -2,11 +2,22 @@
2
2
  <div>
3
3
  <div class="side-by-side" v-for="item in actions" :key="item.type">
4
4
 
5
- <Button v-if="item.type === 'delete'" key="remove" classIcon="fa-solid fa-trash" :title="item.title"
5
+ <Button v-if="item.type === 'delete'" tooltip="Gerar Retorno" key="remove" classIcon="fa-solid fa-trash" :title="item.title"
6
6
  type="danger" size="small" :params="item" :clicked="() => $emit('confirm', item)" />
7
7
 
8
+ <Button v-if="item.type === 'component'" key="component" :title="item.title" :classIcon="item.classIcon"
9
+ :type="item.backgroundColor ? '' : 'primary'" size="small" :params="item" color="white"
10
+ :backGroundColor="item.backgroundColor ? item.backgroundColor : ''"
11
+ :clicked="() => $emit('confirm', item)" />
12
+
8
13
  <Button v-if="item.type === 'options'" key="options" :title="item.title" :classIcon="item.classIcon"
9
- type="primary" size="small" :params="item" :clicked="() => $emit('confirm', item)" />
14
+ :type="item.backgroundColor ? '' : 'primary'" size="small" :params="item" color="white"
15
+ :backGroundColor="item.backgroundColor ? item.backgroundColor : ''"
16
+ :clicked="() => $emit('confirm', item)" />
17
+
18
+ <Button v-if="item.type === 'event'" :eventName="item.eventName" key="event" :title="item.title"
19
+ :classIcon="item.classIcon" :type="item.backgroundColor ? '' : 'primary'" size="small" :params="item"
20
+ color="white" :backGroundColor="item.backgroundColor ? item.backgroundColor : ''" />
10
21
 
11
22
  </div>
12
23
  </div>
@@ -15,15 +26,18 @@
15
26
  <script>
16
27
  import Button from "@nixweb/nixloc-ui/src/component/forms/Button";
17
28
 
29
+ import { mapMutations } from "vuex";
30
+
18
31
  export default {
19
32
  name: "ActionButtons",
20
33
  components: { Button },
21
34
  props: {
22
35
  actions: { type: Array, default: () => [] },
23
36
  },
37
+ methods: {
38
+ ...mapMutations("generic", ["addEvent"]),
39
+ }
24
40
  };
25
41
  </script>
26
42
 
27
- <style scoped>
28
-
29
- </style>
43
+ <style scoped></style>
@@ -2,6 +2,14 @@
2
2
  <div class="actions-options">
3
3
  <div class="ao-body">
4
4
  <ScrollBar :minHeight="minHeight" :maxHeight="maxHeight" class="ao-scroll">
5
+ <span class="ao-description title">
6
+ {{ actionSelected.description }}
7
+ </span>
8
+
9
+ <div v-if="actionSelected.type == 'component'">
10
+ <component :is="actionSelected.component" v-model="optionSelected"></component>
11
+ </div>
12
+
5
13
  <div v-if="actionSelected.type == 'options'" class="ao-radios" role="group"
6
14
  :aria-labelledby="'ao-title'">
7
15
  <RadioGroup :field="fieldName" :options="filteredOptions" v-model="optionSelected" />
@@ -148,6 +156,12 @@ export default {
148
156
  bottom: 0;
149
157
  }
150
158
 
159
+ .ao-description {
160
+ color: #475569;
161
+ font-weight: 500;
162
+ font-size: 13px;
163
+ }
164
+
151
165
  .ao-footer-right {
152
166
  display: flex;
153
167
  gap: 8px;
@@ -30,7 +30,7 @@
30
30
  </Modal>
31
31
 
32
32
  <Modal title="Selecione a opção desejada" :showValidation="false" :closeOnEsc="true" :closeButton="true"
33
- :width="600" :height="750" v-if="showModal('options')">
33
+ :width="600" :height="750" v-if="showModal('actionsOptions')">
34
34
  <ActionsOptions :actionSelected="actionSelected" v-model="optionSelected" />
35
35
  </Modal>
36
36
  </div>
@@ -106,7 +106,7 @@ export default {
106
106
  this.selected.forEach((id) => this.$set(this.status, id, "waiting"));
107
107
 
108
108
  if (params.type != "delete") {
109
- this.openModal("options");
109
+ this.openModal("actionsOptions");
110
110
  } else {
111
111
  this.openModal("confirm");
112
112
  }
@@ -120,6 +120,7 @@ export default {
120
120
  notNotifyToast: true
121
121
  }
122
122
  );
123
+ this.addEvent({ name: "actionsUpdated" });
123
124
  return response;
124
125
  },
125
126
  async remove(id) {
@@ -130,6 +131,7 @@ export default {
130
131
  notNotifyToast: true
131
132
  }
132
133
  );
134
+ this.addEvent({ name: "actionsUpdated" });
133
135
  return response;
134
136
  },
135
137
  async ok() {
@@ -148,10 +150,6 @@ export default {
148
150
  if (this.actionSelected.method == "put")
149
151
  result = await this.put(id);
150
152
 
151
- console.log(this.actionSelected);
152
- console.log(result);
153
-
154
-
155
153
  if (result?.success) {
156
154
  this.$set(this.status, id, "done");
157
155
  this.selectedDone.push(id);
@@ -106,9 +106,24 @@ export default {
106
106
  },
107
107
  documentPreview: (state) => (env) => {
108
108
  let documentHtml = state.documentHtml
109
- let ret = documentHtml;
110
-
111
109
  var template = null;
110
+ let tableStart = 0;
111
+ let tableEnd = 0;
112
+ let removedTableHtml = ""
113
+
114
+ const tabelaGrupoSubGrupo = "t.produtoGrupoSubgrupo";
115
+ const idxMarker = documentHtml.indexOf(tabelaGrupoSubGrupo);
116
+ const marcadorDiv = `<tabela-grupo-subgrupo></tabela-grupo-subgrupo>`;
117
+
118
+ if (idxMarker !== -1) {
119
+ tableStart = documentHtml.lastIndexOf("<table", idxMarker);
120
+ tableEnd = documentHtml.indexOf("</table>", idxMarker) + "</table>".length;
121
+
122
+ removedTableHtml = documentHtml.substring(tableStart, tableEnd); // armazena
123
+ documentHtml = documentHtml.substring(0, tableStart) + marcadorDiv + documentHtml.substring(tableEnd);
124
+ }
125
+
126
+ let ret = documentHtml;
112
127
 
113
128
  if (env == 'dev')
114
129
  template = document.getElementById("template-dev");
@@ -131,7 +146,7 @@ export default {
131
146
  vForGrouped: "",
132
147
  vForSimple: "",
133
148
  nameGroup: "",
134
- nameGroupReplace: ""
149
+ nameGroupReplace: "",
135
150
  };
136
151
 
137
152
  if (th) {
@@ -141,6 +156,7 @@ export default {
141
156
  let isProduct = th.innerText.includes("t.produtoLocacao");
142
157
  let isInvoice = th.innerText.includes("t.produtoFatura");
143
158
  let isGrouped = th.innerText.includes("t.produtoAgrupado");
159
+ let isGroupedSubgroup = th.innerText.includes("t.produtoGrupoSubgrupo");
144
160
  let isMoviment = th.innerText.includes("t.produtoMovimentacao");
145
161
  let isCustumerAddress = th.innerText.includes("t.enderecoCliente");
146
162
  let isAddressRent = th.innerText.includes("t.saidaRetornoLocacao");
@@ -179,7 +195,6 @@ export default {
179
195
  obj.vForSimple = "v-for='produto in itensLocacao'";
180
196
 
181
197
  // neste cenário basicamente temos que montar o <tbody> no array de agrupamento
182
-
183
198
  var initIndex = documentHtml.split("<tbody>", index + 1).join("<tbody>").length;
184
199
  var lastIndex = documentHtml.split("</tbody>", index + 1).join("</tbody>").length;
185
200
 
@@ -194,7 +209,10 @@ export default {
194
209
 
195
210
  config.push(obj);
196
211
 
197
- } else if (isMoviment) {
212
+ } else if (isGroupedSubgroup) {
213
+ // não faz nda, quem altera essa tabela é a após retParse
214
+ }
215
+ else if (isMoviment) {
198
216
  obj.vForSimple = "v-for='produto in d.itensMovimentacao'";
199
217
  config.push(obj);
200
218
  } else if (isCustumerAddress) {
@@ -223,12 +241,55 @@ export default {
223
241
  var retParse = ret.replaceAll("\"", "'");
224
242
  retParse = eval(`retParse${replace}`);
225
243
 
244
+ if (removedTableHtml) {
245
+
246
+ removedTableHtml = removedTableHtml.replace("<tbody>", `<tbody v-for="(grupos, grupoMaster) in produtoGrupoSubgrupo">`);
247
+
248
+ const inicio = removedTableHtml.indexOf("<tbody");
249
+ const fim = removedTableHtml.indexOf("</tbody>", inicio) + "</tbody>".length;
250
+ let tbodyHtml = removedTableHtml.substring(inicio, fim);
251
+ const trs = [...tbodyHtml.matchAll(/<tr[^>]*>/g)];
252
+ if (trs.length >= 3) {
253
+ const grupoStart = trs[1].index;
254
+ const produtoStart = trs[2].index;
255
+ const produtoEnd = tbodyHtml.indexOf("</tr>", produtoStart) + "</tr>".length;
256
+
257
+ const wrapStart = grupoStart;
258
+ const wrapEnd = produtoEnd;
259
+
260
+ let templateContent = tbodyHtml.substring(wrapStart, wrapEnd);
261
+
262
+ const innerTrs = [...templateContent.matchAll(/<tr[^>]*>/g)];
263
+ if (innerTrs.length >= 2) {
264
+ const prodTag = innerTrs[1];
265
+ const pStart = prodTag.index;
266
+ const pEnd = pStart + prodTag[0].length;
267
+
268
+ templateContent =
269
+ templateContent.substring(0, pStart) +
270
+ `<tr v-for="produto in itensLocacao">` +
271
+ templateContent.substring(pEnd);
272
+ }
273
+
274
+ tbodyHtml = tbodyHtml.substring(0, wrapStart) +
275
+ `<template v-for="(itensLocacao, grupo) in grupos">` +
276
+ templateContent +
277
+ `</template>` +
278
+ tbodyHtml.substring(wrapEnd);
279
+
280
+ removedTableHtml = removedTableHtml.substring(0, inicio) + tbodyHtml + removedTableHtml.substring(fim);
281
+ }
282
+
283
+ retParse = retParse.replace(marcadorDiv, `<div>${removedTableHtml}</div>`);
284
+ }
285
+
226
286
  var classImportant = retParse
227
287
  .replaceAll("t.pagamentoLocacao", "")
228
288
  .replaceAll("t.periodoLocacao", "")
229
289
  .replaceAll("t.produtoLocacao", "")
230
290
  .replaceAll("t.produtoFatura", "")
231
291
  .replaceAll("t.produtoAgrupado", "")
292
+ .replaceAll("t.produtoGrupoSubgrupo", "")
232
293
  .replaceAll("t.produtoMovimentacao", "")
233
294
  .replaceAll("t.enderecoCliente", "")
234
295
  .replaceAll("t.saidaRetornoLocacao", "")