vue-intergrall-plugins 0.0.208 → 0.0.211

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": "vue-intergrall-plugins",
3
- "version": "0.0.208",
3
+ "version": "0.0.211",
4
4
  "description": "",
5
5
  "main": "dist/vue-intergrall-plugins.ssr.js",
6
6
  "browser": "dist/vue-intergrall-plugins.esm.js",
@@ -1,24 +1,24 @@
1
1
  <template>
2
2
  <span class="file-item">
3
3
  <transition-group name="fade" mode="out-in" class="file-item-transition">
4
- <div v-if="loading" :small="true" key="card-file-loader" class="req-loader slow"></div>
4
+ <div v-if="isLoading" :small="true" key="card-file-loader" class="req-loader slow"></div>
5
5
  <template v-else>
6
- <span v-if="imageUrl" class="file-img box-shadow" @click="openFile(imageUrl, true)" key="card-file-img" :title="fileName">
7
- <img :src="`${imageUrl}`" :alt="fileName" />
6
+ <span v-if="imageURL" class="file-img box-shadow" @click="openWindowFromURL(imageURL, true)" key="card-file-img" :title="filename">
7
+ <img :src="`${imageURL}`" :alt="filename" />
8
8
  </span>
9
9
  <span
10
10
  v-else
11
11
  class="file-icon"
12
12
  key="card-file-doc"
13
- :class="[currentClass]"
14
- @click="openFile(docUrl, false)"
15
- :title="fileName"
13
+ :class="[iconClass]"
14
+ @click="openWindowFromURL(docURL, false)"
15
+ :title="filename"
16
16
  target="_blank"
17
17
  rel="noreferrer noopener"
18
18
  >
19
19
  <fa-icon :icon="icon" />
20
20
  </span>
21
- <a :href="imageUrl ? imageUrl : docUrl" :download="`${fileName}`" target="_blank" rel="noreferrer noopener" key="card-file-download-icon" :title="`Download ${fileName}`">
21
+ <a :href="imageURL ? imageURL : docURL" :download="`${filename}`" target="_blank" rel="noreferrer noopener" key="card-file-download-icon" :title="`Download ${filename}`">
22
22
  <fa-icon :icon="['fas', 'download']" />
23
23
  </a>
24
24
  </template>
@@ -36,9 +36,10 @@
36
36
  </style>
37
37
 
38
38
  <script>
39
- import { gerarVariaveisAnexo } from "../../services/formatMessage"
39
+ import { fileHandler } from "../../mixins/fileHandler"
40
40
 
41
41
  export default {
42
+ mixins: [fileHandler],
42
43
  props: {
43
44
  file: {
44
45
  type: Object,
@@ -53,65 +54,8 @@ export default {
53
54
  required: true
54
55
  }
55
56
  },
56
- computed: {
57
- currentClass() {
58
- return this.fileExt === "pdf" ? "pdf" : "doc"
59
- }
60
- },
61
- data() {
62
- return {
63
- loading: true,
64
- isAnexo: false,
65
- imageUrl: "",
66
- fileExt: "",
67
- docUrl: "",
68
- fileName: "",
69
- audio: false,
70
- video: false,
71
- icon: []
72
- }
73
- },
74
- mounted() {
75
- this.setFileVars()
76
- },
77
- methods: {
78
- setFileVars() {
79
- try {
80
- const {
81
- anexo,
82
- imgAnexo,
83
- tipoDoc,
84
- docAnexo,
85
- nomeArquivo,
86
- audio,
87
- video
88
- } = gerarVariaveisAnexo(this.file, { dominio: this.domain });
89
-
90
- this.isAnexo = anexo;
91
- this.imageUrl = imgAnexo;
92
- this.fileExt = tipoDoc;
93
- this.docUrl = docAnexo;
94
- this.fileName = nomeArquivo;
95
- this.audio = audio;
96
- this.video = video;
97
-
98
- this.generateIcon();
99
-
100
- this.loading = false;
101
- }catch(e) {
102
- console.error("Erro ao gerar as variaveis dos anexos")
103
- console.error(e)
104
- }
105
- },
106
- generateIcon() {
107
- this.icon = this.fileExt === "pdf" ? ['fas', 'file-pdf'] : ['fas', 'file-alt']
108
- },
109
- openFile(link, isImg) {
110
- const width = window.innerWidth
111
- const height = window.innerHeight
112
- const options = !isImg ? `width=${width},height=${height}` : "width=auto,height=auto"
113
- window.open(link, "card-file", options)
114
- }
57
+ mounted(){
58
+ this.setFileVars(this.file, { dominio: this.domain })
115
59
  }
116
60
  }
117
61
  </script>
@@ -176,9 +176,13 @@ export default {
176
176
  if(!fileInput) if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError()
177
177
  },
178
178
  isFileValid(type, fileName) {
179
+ if((type == "img" && !this.fileSettings.imagesExtensions) || (type == "doc" && !this.fileSettings.docsExtensions)) {
180
+ this.$toasted.global.defaultInfo({ msg: this.dictionary.sem_extensoes_parametrizadas })
181
+ this.hasAnyFile = false
182
+ return false
183
+ }
179
184
  const extensions = type === "img" ? this.fileSettings.imagesExtensions : this.fileSettings.docsExtensions
180
185
  const regex = new RegExp("("+extensions+")", "i")
181
-
182
186
  if(regex.test(fileName)) return true
183
187
  this.hasAnyFile = false
184
188
  this.showToastedValidFormats()
@@ -197,10 +201,15 @@ export default {
197
201
  this.fileSize = 0
198
202
  if(this.fileFormatError) this.file = []
199
203
  this.openFiles = false
200
- let filesAux = !externalCall ? event.target.files ? event.target.files : event.dataTransfer.files : event
204
+ const filesAux = !externalCall ? event.target.files ? event.target.files : event.dataTransfer.files : event
201
205
  this.file = filesAux.length ? filesAux : this.file
202
206
 
203
207
  if(!this.file.length) return
208
+ if(this.file.length > this.fileSettings.max) {
209
+ this.file = []
210
+ return this.$toasted.global.defaultInfo({ msg: `Limite de ${this.fileSettings.max} arquivos` })
211
+ }
212
+
204
213
  this.hasAnyFile = true
205
214
  this.fileSize = this.file.length
206
215
  if(!this.fileSettings.multiple) {
@@ -215,6 +224,8 @@ export default {
215
224
  }
216
225
  },
217
226
  returnFileType(file) {
227
+ if(!this.fileSettings.imagesExtensions && !this.fileSettings.docsExtensions) return ""
228
+
218
229
  const imgRegex = new RegExp("\.("+this.fileSettings.imagesExtensions+")", "i")
219
230
  if(imgRegex.test(file.name)) return "img"
220
231
 
@@ -224,50 +235,66 @@ export default {
224
235
  return ""
225
236
  },
226
237
  multipleFileUpload() {
238
+ const hasImgExt = this.fileSettings.imagesExtensions ? true : false
239
+ const hasDocExt = this.fileSettings.docsExtensions ? true : false
240
+ if(!hasImgExt && !hasDocExt) {
241
+ this.file = []
242
+ this.fileSize = 0
243
+ return this.$toasted.global.defaultInfo({ msg: this.dictionary.sem_extensoes_parametrizadas })
244
+ }
227
245
  let waitForImageLoad = false
246
+ let hasAnyInvalidFile = false
228
247
  this.file = Array.from(this.file)
229
248
  this.file.forEach(file => {
230
- const fileReader = new FileReader();
231
-
232
249
  const singleFileType = this.returnFileType(file)
233
250
  if(!singleFileType) file.invalid = true
234
251
  file.imgOrDoc = singleFileType ? singleFileType : ""
235
-
236
- if(file.imgOrDoc === "doc") this.isDoc = true
237
- if(file.imgOrDoc === "img") {
238
- waitForImageLoad = true
239
- fileReader.onload = () => file.src = fileReader.result
240
- fileReader.onloadend = () => this.emitFileVars(true)
241
- }
242
-
243
252
  if(this.isFileValid(file.imgOrDoc, file.name)) {
244
- if(file.imgOrDoc === "img") fileReader.readAsDataURL(file)
253
+ if(file.imgOrDoc == "img") {
254
+ const fileReader = new FileReader();
255
+ waitForImageLoad = true
256
+ fileReader.onload = () => file.src = fileReader.result
257
+ fileReader.onloadend = () => this.emitFileVars(true)
258
+ fileReader.readAsDataURL(file)
259
+ }
260
+ if(file.imgOrDoc === "doc") this.isDoc = true
245
261
  file.invalid = false
246
- this.fileFormatError = false
262
+ this.fileFormatError = !hasAnyInvalidFile ? false : true
247
263
  }else{
264
+ hasAnyInvalidFile = true
248
265
  file.invalid = true
249
266
  this.fileFormatError = true
250
- this.validFileFormats = `Imgs: ${this.fileSettings.imagesExtensions.split("|").join(", ")} <br> Docs: ${this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
267
+ if(hasImgExt && !hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions.split("|").join(", ")}`
268
+ if(hasDocExt && hasImgExt) this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions.split("|").join(", ")}`
269
+ if(hasImgExt && hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions.split("|").join(", ")} - Documentos: ${this.fileSettings.docsExtensions.split("|").join(", ")}`
251
270
  }
252
271
  })
253
272
 
273
+ if(this.fileFormatError) {
274
+ this.file = []
275
+ this.fileSize = 0
276
+ }
277
+
254
278
  if(this.isDoc && !waitForImageLoad) this.emitFileVars()
255
279
  },
256
280
  singleFileUpload(type, fileName) {
257
- const fileReader = new FileReader()
258
- if(type === "img") {
259
- fileReader.onload = () => this.imagePreview = fileReader.result
260
- fileReader.onloadend = () => this.emitFileVars()
261
- }
262
-
263
281
  if(this.isFileValid(type, fileName)) {
264
- if(type === "img") fileReader.readAsDataURL(this.file)
282
+ const fileReader = new FileReader()
283
+ if(type === "img") {
284
+ fileReader.onload = () => this.imagePreview = fileReader.result
285
+ fileReader.onloadend = () => this.emitFileVars()
286
+ fileReader.readAsDataURL(this.file)
287
+ }
265
288
  if(type === "doc") this.isDoc = true
266
289
 
267
290
  this.fileFormatError = false
268
291
  }else {
269
292
  this.fileFormatError = true
270
- this.validFileFormats = `Imgs: ${this.fileSettings.imagesExtensions.split("|").join(", ")} <br> Docs: ${this.fileSettings.docsExtensions.split("|").join(", ")} ${this.dictionary.msg_extensoes_aceitas}`
293
+ const hasImgExt = this.fileSettings.imagesExtensions ? true : false
294
+ const hasDocExt = this.fileSettings.docsExtensions ? true : false
295
+ if(hasImgExt && !hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions}`
296
+ if(hasDocExt && hasImgExt) this.validFileFormats = `Documentos: ${this.fileSettings.docsExtensions}`
297
+ if(hasImgExt && hasDocExt) this.validFileFormats = `Imagens: ${this.fileSettings.imagesExtensions} - Documentos: ${this.fileSettings.docsExtensions}`
271
298
  }
272
299
 
273
300
  if(this.isDoc) this.emitFileVars()
@@ -9,17 +9,14 @@
9
9
  </span>
10
10
  <div class="text-footer-invalid-format" v-if="fileFormatError" key="mfp-invalid-format">
11
11
  <h3 v-text="dictionary.titulo_msg_formato_invalido"></h3>
12
- <h4 v-html="validFileFormats"></h4>
12
+ <h4 v-html="validFileFormats" :title="validFileFormats"></h4>
13
13
  </div>
14
14
  </template>
15
15
  <template v-else>
16
16
  <div class="file-preview" v-for="(singleFile, index) in file" :key="index">
17
- <p class="file-title">
17
+ <p class="file-title" :title="!singleFile.invalid ? singleFile.name : `${dictionary.titulo_msg_formato_invalido ? dictionary.titulo_msg_formato_invalido : 'Arquivo invalido'} - ${singleFile.name}`" :class="{'red' : singleFile.invalid}">
18
18
  <fa-icon :icon="icon(singleFile.imgOrDoc)" />
19
- {{ singleFile.name }}
20
- </p>
21
- <p v-if="singleFile.invalid" class="file-title red">
22
- {{ dictionary.titulo_msg_formato_invalido ? dictionary.titulo_msg_formato_invalido : "Arquivo invalido" }}
19
+ {{ !singleFile.invalid ? singleFile.name : `${dictionary.titulo_msg_formato_invalido ? dictionary.titulo_msg_formato_invalido : "Arquivo invalido"} - ${singleFile.name}` }}
23
20
  </p>
24
21
  <div class="small-img">
25
22
  <span class="img-container" v-if="singleFile.imgOrDoc === 'img' && !isPdf(singleFile.type)">
@@ -33,8 +30,11 @@
33
30
  <span class="pdf" v-else-if="isPdf(singleFile.type)">
34
31
  <fa-icon :icon="['fas', 'file-pdf']" />
35
32
  </span>
33
+ <span class="doc" v-else>
34
+ <fa-icon :icon="['fas', 'file-alt']" />
35
+ </span>
36
36
  </div>
37
- <span @click="deleteSpecificFile(singleFile.name, index)" :title="dictionary.msg_excluir_anexo" class="delete-file">
37
+ <span @click="deleteSpecificFile(singleFile.name, index)" v-tippy="{placement: 'left'}" :content="dictionary.msg_excluir_anexo" :title="dictionary.msg_excluir_anexo" class="delete-file">
38
38
  <fa-icon :icon="['fas', 'trash-alt']" />
39
39
  </span>
40
40
  </div>
@@ -145,9 +145,13 @@ export default {
145
145
  padding: 10px;
146
146
  }
147
147
  .text-footer-invalid-format h3 {
148
+ text-overflow: ellipsis;
149
+ overflow: hidden;
148
150
  font-weight: 500;
149
151
  }
150
152
  .text-footer-invalid-format h4 {
153
+ text-overflow: ellipsis;
154
+ overflow: hidden;
151
155
  font-size: .9rem;
152
156
  }
153
157
 
@@ -197,10 +201,11 @@ export default {
197
201
  }
198
202
  .file-title.red {
199
203
  color: #E74C3C;
200
- margin-left:5px;
204
+ margin-right: 5px;
201
205
  }
202
206
  .file-title > svg {
203
- margin-right: 5px
207
+ margin-right: 5px;
208
+ color: #333;
204
209
  }
205
210
 
206
211
  .small-img {
@@ -215,17 +220,22 @@ export default {
215
220
  height: 40px;
216
221
  cursor: pointer;
217
222
  }
218
- .small-img .pdf {
223
+ .small-img .pdf, .small-img .doc {
219
224
  display: flex;
220
225
  justify-content: center;
221
226
  align-items: center;
222
227
  font-size: 30px;
228
+ }
229
+ .small-img .pdf {
223
230
  color: #E74C3C;
224
231
  }
225
- .small-img .pdf svg{
232
+ .small-img .doc {
233
+ color: #006bc9;
234
+ }
235
+ .small-img .pdf svg, .small-img .doc svg{
226
236
  z-index: 1;
227
237
  }
228
- .small-img .pdf::after {
238
+ .small-img .pdf::after, .small-img .doc::after {
229
239
  content: "";
230
240
  position: absolute;
231
241
  bottom: 2px;
@@ -6,10 +6,10 @@
6
6
  </span>
7
7
  <div class="text-footer-invalid-format" v-if="fileFormatError">
8
8
  <h3 v-text="dictionary.titulo_msg_formato_invalido"></h3>
9
- <h4 v-text="validFileFormats"></h4>
9
+ <h4 v-text="validFileFormats" :title="validFileFormats"></h4>
10
10
  </div>
11
11
  <template v-else>
12
- <h3 v-if="file.name" class="text-footer-preview-title">
12
+ <h3 v-if="file.name" class="text-footer-preview-title" :title="file.name">
13
13
  <fa-icon :icon="['fas', 'file-alt']" v-if="isDoc" />
14
14
  <fa-icon :icon="['fas', 'image']" v-else />
15
15
  {{ file.name }}
@@ -139,7 +139,7 @@ export default {
139
139
  this.loadingReq = true
140
140
  this.getStandardMessages(cod, this.token_cliente).then((data) => {
141
141
  this.loadingReq = false
142
- if(data.msg_ret) return this.$toasted.global.emConstrucao({ msg: data.msg_ret })
142
+ if(data.msg_ret) return this.$toasted.global.defaultInfo({ msg: data.msg_ret })
143
143
  if(data) return this.showFormattedMessage(data, selectionIndex)
144
144
  this.$toasted.global.defaultError()
145
145
  }).catch(e => {
@@ -157,7 +157,7 @@ export default {
157
157
  try {
158
158
  let success = false
159
159
  if(Array.isArray(messageData)) success = true
160
- if(!success && selectionIndex != 4) this.$toasted.global.emConstrucao({ msg: messageData ? messageData.msg : "Nao foi possível obter mensagens" })
160
+ if(!success && selectionIndex != 4) this.$toasted.global.defaultInfo({ msg: messageData ? messageData.msg : "Nao foi possível obter mensagens" })
161
161
 
162
162
  switch (selectionIndex) {
163
163
  case 2:
@@ -177,7 +177,7 @@ export default {
177
177
  case 3:
178
178
  if(!success) {
179
179
  this.formatted_messages_3.push(messageData)
180
- this.$toasted.global.emConstrucao({msg: this.dictionary.msg_erro_sem_msg_formatada})
180
+ this.$toasted.global.defaultInfo({msg: this.dictionary.msg_erro_sem_msg_formatada})
181
181
  this.$emit("close-blocker-standard-message")
182
182
  }else{
183
183
  if(messageData.length){
@@ -143,7 +143,7 @@ export default {
143
143
  },
144
144
  fileSettings: {
145
145
  type: Object,
146
- default: () => { return { docsExtensions: "", imagesExtensions: "", multiple: false, systemButton: false } },
146
+ default: () => { return { docsExtensions: "", imagesExtensions: "", multiple: false, systemButton: false, max: 3 } },
147
147
  required: false
148
148
  },
149
149
  textId: {
@@ -211,7 +211,7 @@ export default {
211
211
  if(event.data == '' && this.showStandardMessages){
212
212
  this.closeBlockerStandardMessage()
213
213
  this.toggleStandardMessages()
214
- this.$toasted.global.emConstrucao({msg: this.dictionary.msg_erro_sem_msg_formatada})
214
+ this.$toasted.global.defaultInfo({msg: this.dictionary.msg_erro_sem_msg_formatada})
215
215
  }else if(typeof event.data === "string" && this.showStandardMessages){
216
216
  this.message = event.data
217
217
  this.focusTextarea()
@@ -271,7 +271,7 @@ export default {
271
271
 
272
272
  if(this.textareaSettings.disabled) return false
273
273
 
274
- if(this.fileFormatError) {
274
+ if(this.fileFormatError && this.hasAnyFile) {
275
275
  if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
276
276
  const str = {
277
277
  img: this.fileSettings.imagesExtensions.split("|").join(", "),
@@ -383,13 +383,14 @@ export default {
383
383
  this.audioSource = ""
384
384
  },
385
385
  returnFileType(file, stopAlert) {
386
+ if(!this.fileSettings.imagesExtensions && !this.fileSettings.docsExtensions) return false
386
387
  const imgRegex = new RegExp("\.("+this.fileSettings.imagesExtensions+")", "i")
387
388
  if(imgRegex.test(file.name)) return "img"
388
389
 
389
390
  const docRegex = new RegExp("\.("+this.fileSettings.docsExtensions+")", "i")
390
391
  if(docRegex.test(file.name)) return "doc"
391
392
 
392
- if(!stopAlert) return
393
+ if(!stopAlert) return false
393
394
  if (!document.querySelector(".toasted.toasted-primary.error")) this.$toasted.global.defaultError({ msg: this.dictionary.msg_formato_invalido })
394
395
  const str = {
395
396
  img: this.fileSettings.imagesExtensions.split("|").join(", "),
@@ -717,6 +718,7 @@ ul {
717
718
  }
718
719
 
719
720
  .text-footer-container .text-footer-preview-container {
721
+ width: 100%;
720
722
  cursor: default;
721
723
  position: absolute;
722
724
  left: 0;
@@ -7,45 +7,46 @@
7
7
  {{dictionary.img_com_erro}}
8
8
  </div>
9
9
  </div>
10
- <Loader v-if="carregando" :small="true" key="anexo-loader" :slow="true" />
10
+ <Loader v-if="isLoading" :small="true" key="anexo-loader" :slow="true" />
11
11
  <div v-else key="anexo-mensagem" class="anexo-mensagem">
12
- <img v-if="imgAnexo" @click="abrirVisualizacaoImg(imgAnexo)" :src="imgAnexo" :alt="dictionary.alt_msg_img">
13
- <div class="anexos-links-container" v-if="imgAnexo">
14
- <a href="#" @click="abrirVisualizacaoImg(imgAnexo)"> {{ dictionary.titulo_visualizar_img }} </a>
15
- <fa-icon :icon="['fas', 'search-plus']" @click="abrirVisualizacaoImg(imgAnexo)" />
12
+ <img v-if="imageURL" @click="showImage(imageURL)" :src="imageURL" :alt="dictionary.alt_msg_img">
13
+ <div class="anexos-links-container" v-if="imageURL">
14
+ <a href="#" @click.prevent="showImage(imageURL)"> {{ dictionary.titulo_visualizar_img }} </a>
15
+ <fa-icon :icon="['fas', 'search-plus']" @click="showImage(imageURL)" />
16
16
  </div>
17
- <div v-else-if="docAnexo" class="anexo-container">
17
+ <div v-else-if="docURL" class="anexo-container">
18
18
  <template v-if="audio || video">
19
- <audio v-if="audio" :src="docAnexo" controls :title="`${tipoDoc} - ${nomeArquivo}`">
20
- <p> {{ dictionary.msg_erro_audio }} <a :href="docAnexo" target="_blank" rel="noreferrer noopener"> {{ dictionary.msg_abrir_audio }} </a> </p>
19
+ <audio v-if="audio" :src="docURL" controls :title="`${fileType} - ${filename}`">
20
+ <p> {{ dictionary.msg_erro_audio }} <a :href="docURL" target="_blank" rel="noreferrer noopener"> {{ dictionary.msg_abrir_audio }} </a> </p>
21
21
  </audio>
22
- <video v-if="video" :src="docAnexo" controls :title="`${tipoDoc} - ${nomeArquivo}`">
23
- <p> {{ dictionary.msg_erro_video }} <a v-if="tipoDoc != 'erro'" :href="docAnexo" target="_blank" rel="noreferrer noopener"> {{ dictionary.msg_abrir_video }} </a> </p>
22
+ <video v-if="video" :src="docURL" controls :title="`${fileType} - ${filename}`">
23
+ <p> {{ dictionary.msg_erro_video }} <a v-if="fileType != 'erro'" :href="docURL" target="_blank" rel="noreferrer noopener"> {{ dictionary.msg_abrir_video }} </a> </p>
24
24
  </video>
25
25
  </template>
26
26
  <template v-else>
27
- <a v-if="tipoDoc != 'erro'" :href="docAnexo" target="_blank" rel="noreferrer noopener" :title="`${tipoDoc} - ${nomeArquivo}`">
28
- <fa-icon :icon="this.icone" />
29
- <p v-text="nomeArquivo"></p>
27
+ <a v-if="fileType != 'erro'" :href="docURL" target="_blank" rel="noreferrer noopener" :title="`${fileType} - ${filename}`">
28
+ <fa-icon :class="[iconClass]" :icon="icon" />
29
+ <p v-text="filename"></p>
30
30
  </a>
31
- <p v-else :title="`${tipoDoc} - ${nomeArquivo}`" class="arquivo-erro">
31
+ <p v-else :title="`${fileType} - ${filename}`" class="arquivo-erro">
32
32
  <fa-icon :icon="['fas', 'file-alt']" />
33
- {{ nomeArquivo }}
33
+ {{ filename }}
34
34
  </p>
35
35
  </template>
36
36
  </div>
37
- <a v-if="imgAnexo" :href="imgAnexo" :download="`${nomeArquivo}`" target="_blank" rel="noreferrer noopener"> {{ dictionary.titulo_baixar_img }} <fa-icon :icon="['fas', 'download']" /> </a>
38
- <a v-if="docAnexo" :href="docAnexo" :download="`${nomeArquivo}`" target="_blank" rel="noreferrer noopener"> {{ dictionary.titulo_baixar_doc }} <fa-icon :icon="['fas', 'download']" /> </a>
37
+ <a v-if="imageURL" :href="imageURL" :download="`${filename}`" target="_blank" rel="noreferrer noopener"> {{ dictionary.titulo_baixar_img }} <fa-icon :icon="['fas', 'download']" /> </a>
38
+ <a v-if="docURL" :href="docURL" :download="`${filename}`" target="_blank" rel="noreferrer noopener"> {{ dictionary.titulo_baixar_doc }} <fa-icon :icon="['fas', 'download']" /> </a>
39
39
  </div>
40
40
  </transition-group>
41
41
  </div>
42
42
  </template>
43
43
 
44
44
  <script>
45
- import { gerarVariaveisAnexo } from "../../services/formatMessage"
45
+ import { fileHandler } from "../../mixins/fileHandler"
46
46
  import Loader from "../Loader/Loader"
47
47
 
48
48
  export default {
49
+ mixins: [fileHandler],
49
50
  components: { Loader },
50
51
  props: {
51
52
  anexo: {
@@ -67,86 +68,37 @@ export default {
67
68
  },
68
69
  data() {
69
70
  return {
70
- carregando: true,
71
- isAnexo: false,
72
- imgAnexo: "",
73
- tipoDoc: "",
74
- docAnexo: "",
75
- nomeArquivo: "",
76
- audio: false,
77
- video: false,
78
- icone: [],
79
71
  imgErro: false,
80
72
  imgMsgErro: '',
81
73
  }
82
74
  },
83
75
  mounted() {
84
76
  if(this.validarAnexo()){
85
- this.setVariaveisAnexo()
77
+ this.setFileVars(this.anexo, { dominio: this.dominio })
86
78
  }
87
79
  },
88
80
  methods: {
89
- abrirVisualizacaoImg(imagem){
90
- this.$emit("abrir-imagem", imagem)
91
- },
92
- setVariaveisAnexo() {
93
- try {
94
- const {
95
- anexo,
96
- imgAnexo,
97
- tipoDoc,
98
- docAnexo,
99
- nomeArquivo,
100
- audio,
101
- video
102
- } = gerarVariaveisAnexo(this.anexo, { dominio: this.dominio });
103
-
104
- this.isAnexo = anexo;
105
- this.imgAnexo = imgAnexo;
106
- this.tipoDoc = tipoDoc;
107
- this.docAnexo = docAnexo;
108
- this.nomeArquivo = nomeArquivo;
109
- this.audio = audio;
110
- this.video = video;
111
-
112
- this.gerarIcone();
113
-
114
- this.carregando = false;
115
- }catch(e) {
116
- console.error("Erro ao gerar as variaveis dos anexos")
117
- console.error(e)
118
- }
119
- },
120
81
  validarAnexo(){
121
- let status = true;
82
+ let status = true
122
83
  //caso for audio ou documento ignorar
123
- if(this.anexo.docAnexo || this.anexo.audio){
124
- return true;
125
- }
84
+ if(this.anexo.docURL || this.anexo.audio) return true
126
85
  if(!this.anexo.name){
127
86
  this.imgMsgErro = this.dictionary.img_com_erro_nome
128
- status = false;
87
+ status = false
129
88
  }
130
89
  if(!this.anexo.nomeGravacao){
131
90
  this.imgMsgErro = this.dictionary.img_com_erro_nome_gravacao
132
- status = false;
91
+ status = false
133
92
  }
134
- // if(!this.anexo.size || this.anexo.size == 0){
135
- // this.imgMsgErro = this.dictionary.img_com_erro_tamanho
136
- // status = false;
137
- // }
138
93
  if(!this.anexo.type){
139
94
  this.imgMsgErro = this.dictionary.img_com_erro_tipo
140
- status = false;
95
+ status = false
141
96
  }
142
97
  if(status == false){
143
- this.imgErro = true;
144
- this.carregando = false;
98
+ this.imgErro = true
99
+ this.isLoading = false
145
100
  }
146
- return status;
147
- },
148
- gerarIcone() {
149
- this.icone = this.tipoDoc === "pdf" ? ['fas', 'file-pdf'] : ['fas', 'file-alt']
101
+ return status
150
102
  }
151
103
  }
152
104
  }
@@ -254,4 +206,12 @@ export default {
254
206
  font-size: 1.025em;
255
207
  margin-right: 2px;
256
208
  }
209
+
210
+ .pdf {
211
+ color: #E74C3C;
212
+ }
213
+
214
+ .doc {
215
+ color: #006bc9
216
+ }
257
217
  </style>