se cambia input de rut
parent
409524fe25
commit
f2f5eafab5
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import { getPhoto } from "$/services/personas";
|
||||
import InputRut from "$/components/InputRut.svelte";
|
||||
import { getPhoto } from "$/services/personas";
|
||||
import { getTiposPersona } from "$/services/tipos_persona";
|
||||
|
||||
export let form = {}
|
||||
|
@ -12,6 +13,7 @@ let urlPhoto = null
|
|||
|
||||
$: begin(es_nuevo)
|
||||
$: !es_nuevo && (rut = `${form.rut || ''}-${form.dv || ''}`);
|
||||
$: onChangeRut(rut)
|
||||
$: cargarPhoto(form.rut)
|
||||
|
||||
async function begin(es_nuevo) {
|
||||
|
@ -31,8 +33,8 @@ async function cargarPhoto(rut) {
|
|||
}
|
||||
}
|
||||
|
||||
function onChangeRut({ target: { value } }) {
|
||||
const valorRut = value.replace(/[.|-]/,'');
|
||||
function onChangeRut(value) {
|
||||
const valorRut = value.replace(/[.|-]/g,'');
|
||||
const dv = valorRut.substring(valorRut.length -1)
|
||||
const rut = valorRut.substring(0, valorRut.length -1)
|
||||
form = { ...form, rut, dv }
|
||||
|
@ -42,7 +44,7 @@ function onChangeRut({ target: { value } }) {
|
|||
<div class="row">
|
||||
<div class="col-md mb-3">
|
||||
RUT
|
||||
<input type="text" value={rut} class="form-control" required disabled={!es_nuevo} on:input={onChangeRut}>
|
||||
<InputRut bind:value={rut} class="form-control" required disabled={!es_nuevo} />
|
||||
</div>
|
||||
<div class="col-md mb-3">
|
||||
Tipo Tratamiento
|
||||
|
|
Loading…
Reference in New Issue