|
5 | 5 | <AsideDashboard pageName='home' />
|
6 | 6 | <div class="content">
|
7 | 7 | <h1>Boletins a serem validados</h1>
|
8 |
| - |
| 8 | + |
9 | 9 | <div v-if="boletins.length === 0">Nenhum boletim em análise encontrado.</div>
|
10 | 10 |
|
11 | 11 | <div v-for="boletim in boletins" :key="boletim.id" class="boletim-item">
|
|
15 | 15 | <strong>Link:</strong> <a :href="boletim.url" target="_blank">Baixar Boletim</a>
|
16 | 16 | </div>
|
17 | 17 | <input type="file" @change="(event) => handleFileChange(event, boletim.id)" />
|
18 |
| - <button @click="compareBoletim(boletim.id)">Comparar</button> |
| 18 | + <button :disabled="!selectedFiles[boletim.id]" @click="compareBoletim(boletim.id)"> |
| 19 | + Comparar |
| 20 | + </button> |
19 | 21 | </div>
|
20 | 22 | </div>
|
21 | 23 | </main>
|
@@ -45,28 +47,27 @@ export default {
|
45 | 47 | },
|
46 | 48 | methods: {
|
47 | 49 | async fetchBoletins() {
|
48 |
| - const token = this.getToken(); |
49 |
| - const response = await getBoletins(token); |
50 |
| - this.boletins = response.data || []; // Assumindo que os dados vêm na estrutura correta |
| 50 | + const response = await getBoletins(this.funcionario.token); |
| 51 | + this.boletins = response.data; |
51 | 52 | },
|
52 | 53 | handleFileChange(event, boletimId) {
|
53 | 54 | this.selectedFiles[boletimId] = event.target.files[0];
|
54 | 55 | },
|
55 | 56 | async compareBoletim(boletimId) {
|
56 | 57 | const file = this.selectedFiles[boletimId];
|
57 |
| - const token = this.getToken(); |
58 | 58 |
|
59 | 59 | if (file) {
|
60 |
| - const response = await compareBoletins(file, boletimId, token); |
61 |
| - alert(response.message || 'Erro ao comparar boletim.'); // Você pode modificar essa parte para melhor feedback ao usuário |
| 60 | + const response = await compareBoletins(file, boletimId, this.funcionario.token); |
| 61 | + alert(response.message || 'Erro ao comparar boletim.'); |
62 | 62 | } else {
|
63 | 63 | alert('Por favor, selecione um arquivo para comparação.');
|
64 | 64 | }
|
65 | 65 | }
|
66 | 66 | },
|
67 | 67 | mixins: [mixinFuncionario],
|
68 | 68 | async created() {
|
69 |
| - await this.fetchBoletins(); // Carrega os boletins ao criar o componente |
| 69 | + await this.getToken(); |
| 70 | + await this.fetchBoletins(); |
70 | 71 | }
|
71 | 72 | }
|
72 | 73 | </script>
|
|
0 commit comments