From 418becaeda9cfe93b945504514c6397fa42b5906 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 8 May 2025 18:15:32 -0400 Subject: [PATCH] FIX: onChange --- .../views/ventas/facturacion/show.blade.php | 2 ++ .../ventas/facturacion/show/propietario.blade.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/resources/views/ventas/facturacion/show.blade.php b/app/resources/views/ventas/facturacion/show.blade.php index f936710..b5e3f0d 100644 --- a/app/resources/views/ventas/facturacion/show.blade.php +++ b/app/resources/views/ventas/facturacion/show.blade.php @@ -18,6 +18,8 @@ @endsection +@include('layout.body.scripts.rut') + @push('page_scripts') @include('ventas.facturacion.show.factura') @include('ventas.facturacion.show.propietario') diff --git a/app/resources/views/ventas/facturacion/show/propietario.blade.php b/app/resources/views/ventas/facturacion/show/propietario.blade.php index 03f076d..1de3dd0 100644 --- a/app/resources/views/ventas/facturacion/show/propietario.blade.php +++ b/app/resources/views/ventas/facturacion/show/propietario.blade.php @@ -28,7 +28,11 @@ facturas.draw().facturas() }, rut: rut => { - this.props.rut = rut + rut = rut.replaceAll(/~\d|\.|-/g, '') + const digito = rut.slice(-1) + rut = rut.slice(0, -1) + this.props.rut = Rut.format(rut) + '-' + digito + document.getElementById('rut'+this.props.index).value = this.props.rut facturas.venta.update().facturas() facturas.draw().facturas() }, @@ -72,7 +76,7 @@ }) }, rut: () => { - document.getElementById('rut'+this.props.index).addEventListener('input', inputEvent => { + document.getElementById('rut'+this.props.index).addEventListener('change', inputEvent => { const rut = inputEvent.currentTarget.value if (rut === this.props.rut) { return @@ -81,7 +85,7 @@ }) }, nombre: () => { - document.getElementById('propietario'+this.props.index).addEventListener('input', inputEvent => { + document.getElementById('propietario'+this.props.index).addEventListener('change', inputEvent => { const nombre = inputEvent.currentTarget.value if (nombre === this.props.nombre) { return @@ -90,7 +94,7 @@ }) }, direccion: () => { - document.getElementById('direccion_propietario'+this.props.index).addEventListener('input', inputEvent => { + document.getElementById('direccion_propietario'+this.props.index).addEventListener('change', inputEvent => { const direccion = inputEvent.currentTarget.value if (direccion === this.props.direccion) { return