From e282628952269a78df42c30dfe8413c3942a7367 Mon Sep 17 00:00:00 2001 From: gabrielb Date: Wed, 20 May 2026 00:20:52 -0300 Subject: [PATCH] =?UTF-8?q?feat(dados):=20adicionar=20formata=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20documentos=20para=20exibi=C3=A7=C3=A3o=20correta=20de?= =?UTF-8?q?=20CPF=20e=20CNPJ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/portal/dados.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/portal/dados.vue b/src/pages/portal/dados.vue index c4d8aa4..b354189 100644 --- a/src/pages/portal/dados.vue +++ b/src/pages/portal/dados.vue @@ -30,6 +30,16 @@ onMounted(async () => { } }) +function formatarDocumento(doc, tipo) { + if (!doc) return '—' + const d = doc.replace(/\D/g, '') + if (tipo === 'JURIDICA' && d.length === 14) + return d.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5') + if (d.length === 11) + return d.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4') + return doc +} + async function salvarContato() { salvando.value = true mensagemErro.value = '' @@ -93,7 +103,7 @@ function formatarTelefone(e) {

{{ dados.tipoPessoa === 'JURIDICA' ? 'CNPJ' : 'CPF' }}

-

{{ dados.documento }}

+

{{ formatarDocumento(dados.documento, dados.tipoPessoa) }}

{{ dados.tipoPessoa === 'JURIDICA' ? 'Razão Social' : 'Nome completo' }}