developer #4

Open
gabrielb wants to merge 20 commits from developer into main
2 changed files with 34 additions and 16 deletions
Showing only changes of commit 425146d59a - Show all commits

View File

@ -12,26 +12,29 @@ const MOCK_ATIVO = true
const PAGAMENTOS_MOCK = [ const PAGAMENTOS_MOCK = [
{ {
id: 101, id: 101,
idContaCorrente: 201,
descricao: 'IPTU 2024 — Parcela 1/3', descricao: 'IPTU 2024 — Parcela 1/3',
referencia: '202401', referencia: '202401',
dataPagamento: '2024-02-05', dataPagamento: '2024-02-05',
formaPagamento: 'BOLETO', formaPagamento: 'GUIA',
valor: 382.50, valor: 382.50,
}, },
{ {
id: 102, id: 102,
idContaCorrente: 202,
descricao: 'Taxa de Licença de Funcionamento', descricao: 'Taxa de Licença de Funcionamento',
referencia: '202403', referencia: '202403',
dataPagamento: '2024-03-20', dataPagamento: '2024-03-20',
formaPagamento: 'PIX', formaPagamento: 'GUIA',
valor: 215.00, valor: 215.00,
}, },
{ {
id: 103, id: 103,
idContaCorrente: null,
descricao: 'ISSQN 2023 — 4º Trimestre', descricao: 'ISSQN 2023 — 4º Trimestre',
referencia: '202312', referencia: '202312',
dataPagamento: '2024-01-10', dataPagamento: '2024-01-10',
formaPagamento: 'BOLETO', formaPagamento: 'DIRETO',
valor: 540.00, valor: 540.00,
}, },
] ]
@ -70,15 +73,19 @@ async function carregar() {
async function baixarComprovante(pag) { async function baixarComprovante(pag) {
carregandoComprovante.value = pag.id carregandoComprovante.value = pag.id
try { try {
const buf = await portalService.getComprovante(pag.id) const buf = await portalService.getComprovante(pag.idContaCorrente)
const url = URL.createObjectURL(new Blob([buf], { type: 'application/pdf' })) const blob = new Blob([buf], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const janela = window.open(url, '_blank')
if (!janela) {
const a = document.createElement('a') const a = document.createElement('a')
a.href = url a.href = url
a.download = `comprovante-${pag.id}.pdf` a.download = `comprovante-${pag.idContaCorrente}.pdf`
a.click() a.click()
URL.revokeObjectURL(url) }
setTimeout(() => URL.revokeObjectURL(url), 60000)
} catch { } catch {
mensagemErro.value = 'Erro ao baixar o comprovante.' mensagemErro.value = 'Erro ao gerar o comprovante.'
} finally { } finally {
carregandoComprovante.value = null carregandoComprovante.value = null
} }
@ -170,12 +177,12 @@ const formaPagMap = {
</p> </p>
<div class="w-28 flex justify-end"> <div class="w-28 flex justify-end">
<Button <Button
icon="pi pi-download" icon="pi pi-print"
label="Comprovante" label="Comprovante"
size="small" size="small"
text text
:loading="carregandoComprovante === pag.id" :loading="carregandoComprovante === pag.id"
:disabled="!!carregandoComprovante" :disabled="!!carregandoComprovante || !pag.idContaCorrente"
@click="baixarComprovante(pag)" @click="baixarComprovante(pag)"
/> />
</div> </div>

View File

@ -19,7 +19,8 @@ const RESUMO_MOCK = {
totalDebitos: 1250.90, totalDebitos: 1250.90,
certidoesAtivas: 2, certidoesAtivas: 2,
alvarasAndamento: 2, alvarasAndamento: 2,
ultimoPagamento: 430.00, ultimoPagamento: '2025-05-15',
valorUltimoPagamento: 430.00,
debitosVencidos: 1, debitosVencidos: 1,
} }
const ATIVIDADES_MOCK = [ const ATIVIDADES_MOCK = [
@ -72,6 +73,11 @@ function formatarMoeda(valor) {
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number.isNaN(n) ? 0 : n) return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(Number.isNaN(n) ? 0 : n)
} }
function formatarData(data) {
if (!data) return ''
return new Date(data + 'T00:00:00').toLocaleDateString('pt-BR')
}
const iconeAtividade = { const iconeAtividade = {
DEBITO: 'pi-receipt', DEBITO: 'pi-receipt',
CERTIDAO: 'pi-file-check', CERTIDAO: 'pi-file-check',
@ -150,9 +156,14 @@ const iconeAtividade = {
<div> <div>
<p class="text-2xl font-bold text-slate-800 dark:text-slate-100"> <p class="text-2xl font-bold text-slate-800 dark:text-slate-100">
<span v-if="carregando" class="inline-block w-16 h-7 bg-slate-200 dark:bg-slate-700 rounded animate-pulse" /> <span v-if="carregando" class="inline-block w-16 h-7 bg-slate-200 dark:bg-slate-700 rounded animate-pulse" />
<template v-else>{{ formatarMoeda(resumo?.ultimoPagamento) }}</template> <template v-else>{{ formatarMoeda(resumo?.valorUltimoPagamento) }}</template>
</p>
<p class="text-xs text-slate-500 dark:text-slate-400 mt-0.5">
Último pagamento
<template v-if="!carregando && resumo?.ultimoPagamento">
· {{ formatarData(resumo.ultimoPagamento) }}
</template>
</p> </p>
<p class="text-xs text-slate-500 dark:text-slate-400 mt-0.5">Último pagamento</p>
</div> </div>
</div> </div>