111 lines
3.5 KiB
Markdown
111 lines
3.5 KiB
Markdown
# 🚨 Solução de Emergência - Cantoneiras
|
|
|
|
## Execute no Console do Navegador
|
|
|
|
Abra o console (F12) e cole este código:
|
|
|
|
```javascript
|
|
// SOLUÇÃO DE EMERGÊNCIA - FORÇAR CARREGAMENTO DE CANTONEIRAS
|
|
(async function() {
|
|
console.log('🚨 SOLUÇÃO DE EMERGÊNCIA INICIADA');
|
|
|
|
// 1. Verificar elemento
|
|
const tbody = document.getElementById('cantoneiras-tbody');
|
|
if (!tbody) {
|
|
console.error('❌ Elemento tbody não encontrado!');
|
|
console.log('Elementos disponíveis:', document.querySelectorAll('[id*="cant"]'));
|
|
return;
|
|
}
|
|
|
|
console.log('✅ Elemento tbody encontrado');
|
|
|
|
// 2. Carregar CSV
|
|
console.log('📥 Carregando CSV...');
|
|
const response = await fetch('BD/perfis/cantoneiras_brasil_completo.csv');
|
|
if (!response.ok) {
|
|
console.error('❌ Erro ao carregar CSV:', response.status);
|
|
return;
|
|
}
|
|
|
|
const csvText = await response.text();
|
|
const linhas = csvText.trim().split('\n');
|
|
console.log(`📊 CSV carregado: ${linhas.length} linhas`);
|
|
|
|
// 3. Processar dados
|
|
const dados = [];
|
|
for (let i = 1; i < linhas.length; i++) {
|
|
const linha = linhas[i].trim();
|
|
if (!linha) continue;
|
|
|
|
const colunas = linha.split(',');
|
|
if (colunas.length >= 9) {
|
|
dados.push({
|
|
id: colunas[0].trim(),
|
|
nome: colunas[1].trim(),
|
|
lado_mm: parseFloat(colunas[2]),
|
|
espessura_mm: parseFloat(colunas[3]),
|
|
peso_kg_m: parseFloat(colunas[4]),
|
|
area_cm2: parseFloat(colunas[5]),
|
|
momento_inercia_cm4: parseFloat(colunas[6]),
|
|
raio_giracao_cm: parseFloat(colunas[7]),
|
|
tipo: colunas[8].trim()
|
|
});
|
|
}
|
|
}
|
|
|
|
console.log(`✅ Processados: ${dados.length} cantoneiras`);
|
|
console.log('📋 Primeiro item:', dados[0]);
|
|
|
|
// 4. Exibir na tabela
|
|
console.log('🎨 Gerando HTML...');
|
|
tbody.innerHTML = dados.map(item => `
|
|
<tr>
|
|
<td><strong>${item.nome}</strong></td>
|
|
<td>${item.lado_mm}</td>
|
|
<td>${item.espessura_mm}</td>
|
|
<td>${item.peso_kg_m.toFixed(2)}</td>
|
|
<td>${item.area_cm2.toFixed(2)}</td>
|
|
<td>${item.momento_inercia_cm4.toFixed(2)}</td>
|
|
<td>${item.raio_giracao_cm.toFixed(2)}</td>
|
|
<td><span class="badge badge-info">${item.tipo}</span></td>
|
|
<td><button class="btn btn-sm btn-primary">👁️ Ver</button></td>
|
|
</tr>
|
|
`).join('');
|
|
|
|
console.log('🎉 TABELA PREENCHIDA COM SUCESSO!');
|
|
console.log(`📊 Total de linhas na tabela: ${tbody.querySelectorAll('tr').length}`);
|
|
|
|
// 5. Atualizar contador
|
|
const totalEl = document.getElementById('cant-total');
|
|
if (totalEl) {
|
|
totalEl.textContent = dados.length;
|
|
console.log('✅ Contador atualizado');
|
|
}
|
|
|
|
console.log('✅ SOLUÇÃO DE EMERGÊNCIA CONCLUÍDA');
|
|
})();
|
|
```
|
|
|
|
## O Que Este Código Faz
|
|
|
|
1. ✅ Verifica se o elemento tbody existe
|
|
2. ✅ Carrega o CSV diretamente
|
|
3. ✅ Processa os dados
|
|
4. ✅ Exibe na tabela
|
|
5. ✅ Atualiza o contador
|
|
|
|
## Se Funcionar
|
|
|
|
Se este código funcionar, significa que:
|
|
- ✅ O CSV está OK
|
|
- ✅ O elemento HTML existe
|
|
- ❌ O problema está no carregamento automático
|
|
|
|
## Próximo Passo
|
|
|
|
Se funcionar, vou criar um botão "Carregar Dados" na interface para você clicar manualmente.
|
|
|
|
---
|
|
|
|
**Cole o código acima no console e me diga o resultado!**
|