@freteclick/quasar-financial-ui 1.0.106 → 1.0.108

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": "@freteclick/quasar-financial-ui",
3
- "version": "1.0.106",
3
+ "version": "1.0.108",
4
4
  "author": "FreteClick",
5
5
  "description": "FreteClick financial Quasar UI Component",
6
6
  "license": "MIT",
@@ -39,6 +39,7 @@
39
39
 
40
40
  <script>
41
41
  import { mapActions, mapGetters } from 'vuex';
42
+ import axios from 'axios';
42
43
  import { ENTRYPOINT } from '@freteclick/../../src/config/entrypoint';
43
44
 
44
45
  export default {
@@ -140,7 +141,7 @@ export default {
140
141
  getBankPerInvoiceId: 'receiveInvoice/getBankPerInvoiceId',
141
142
  }),
142
143
 
143
- // Ver boleto ou baixar
144
+ // Ver boleto via blob (busca PDF autenticado do backend)
144
145
  clickDownloadBilletSicred() {
145
146
  if (this.isLoadingDownload) {
146
147
  return null;
@@ -148,11 +149,26 @@ export default {
148
149
 
149
150
  this.isLoadingDownload = true;
150
151
 
151
- const viewerUrl = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/bank/sicred/download?timestamp=${new Date().getTime()}`;
152
- this.invoiceUrlSicred = viewerUrl;
153
- this.showBilletSicred = true;
154
-
155
- this.isLoadingDownload = false;
152
+ const url = ENTRYPOINT + `finance/${this.invoiceId}/bank/sicred/download?timestamp=${new Date().getTime()}`;
153
+
154
+ axios.get(url, { responseType: 'blob' })
155
+ .then(response => {
156
+ const blob = new Blob([response.data], { type: 'application/pdf' });
157
+ const blobUrl = URL.createObjectURL(blob);
158
+ this.invoiceUrlSicred = blobUrl;
159
+ this.showBilletSicred = true;
160
+ })
161
+ .catch(error => {
162
+ console.error('Erro ao baixar boleto:', error);
163
+ this.$q.notify({
164
+ message: 'Erro ao carregar o boleto',
165
+ type: 'negative',
166
+ position: 'bottom',
167
+ });
168
+ })
169
+ .finally(() => {
170
+ this.isLoadingDownload = false;
171
+ });
156
172
  },
157
173
 
158
174
  // Consulta informações do banco
@@ -176,6 +192,11 @@ export default {
176
192
  return null;
177
193
  }
178
194
 
195
+ // Se já temos nosso_numero, não gerar novamente
196
+ if (this.invoiceBankId !== null) {
197
+ return;
198
+ }
199
+
179
200
  let params = {};
180
201
 
181
202
  this.isLoading = true;
@@ -158,7 +158,7 @@ export default {
158
158
  getBankPerInvoiceId: 'receiveInvoice/getBankPerInvoiceId',
159
159
  }),
160
160
 
161
- // Ver boleto ou baixar
161
+ // Ver boleto via blob (busca PDF autenticado do backend)
162
162
  clickDownloadBilletSicred() {
163
163
  if (this.isLoadingDownload) {
164
164
  return null;
@@ -166,11 +166,26 @@ export default {
166
166
 
167
167
  this.isLoadingDownload = true;
168
168
 
169
- const viewerUrl = ENTRYPOINT + `/vendor/pdf.js/web/viewer.html?file=/finance/${this.invoiceId}/bank/sicred/download?timestamp=${new Date().getTime()}`;
170
- this.invoiceUrlSicred = viewerUrl;
171
- this.showBilletSicred = true;
172
-
173
- this.isLoadingDownload = false;
169
+ const url = ENTRYPOINT + `finance/${this.invoiceId}/bank/sicred/download?timestamp=${new Date().getTime()}`;
170
+
171
+ axios.get(url, { responseType: 'blob' })
172
+ .then(response => {
173
+ const blob = new Blob([response.data], { type: 'application/pdf' });
174
+ const blobUrl = URL.createObjectURL(blob);
175
+ this.invoiceUrlSicred = blobUrl;
176
+ this.showBilletSicred = true;
177
+ })
178
+ .catch(error => {
179
+ console.error('Erro ao baixar boleto:', error);
180
+ this.$q.notify({
181
+ message: 'Erro ao carregar o boleto',
182
+ type: 'negative',
183
+ position: 'bottom',
184
+ });
185
+ })
186
+ .finally(() => {
187
+ this.isLoadingDownload = false;
188
+ });
174
189
  },
175
190
 
176
191
  // Consulta informações do banco
@@ -194,6 +209,12 @@ export default {
194
209
  return null;
195
210
  }
196
211
 
212
+ // Se já temos nosso_numero, não gerar novamente — apenas exibir o existente
213
+ if (this.invoiceBankId !== null) {
214
+ this.clickDownloadBilletSicred();
215
+ return;
216
+ }
217
+
197
218
  let params = {};
198
219
 
199
220
  this.isLoading = true;