implementado defectos
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
import { onMount } from "svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import type { AltaDefectoDto, CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import FormAltaDefecto from "../Componentes/FormAltaDefecto.svelte";
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
|
||||
@@ -26,6 +27,7 @@
|
||||
mesesAumento:0,
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -55,14 +57,24 @@
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||
const respoDefect = fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c, d] = await Promise.all([respPropiedad, respgarantes, respCanons, respoDefect]);
|
||||
|
||||
const datosPropiedad = await p.json();
|
||||
const datosGarantes = await g.json();
|
||||
const datosCanons = await c.json();
|
||||
const datosDefect = await d.json();
|
||||
|
||||
prop = datosPropiedad;
|
||||
garantes = datosGarantes;
|
||||
canons = datosCanons;
|
||||
defectos = datosDefect;
|
||||
|
||||
} catch {
|
||||
modaldata = "Fallo hacer las request";
|
||||
}
|
||||
@@ -145,7 +157,7 @@
|
||||
}
|
||||
|
||||
|
||||
function generarTiket(mod) {
|
||||
function generarTiket(mod:any) {
|
||||
selMod = mod;
|
||||
showmodal =true;
|
||||
}
|
||||
@@ -174,6 +186,43 @@
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function cargarDefecto(data: AltaDefectoDto) {
|
||||
if(data.idcontrato ==0) data.idcontrato = prop.id;
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defecto", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
let dr = await r.json();
|
||||
modaldata = dr.message;
|
||||
if (r.ok) {
|
||||
refreshDefectos();
|
||||
}
|
||||
}catch{
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDefectos() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let rr =await r.json();
|
||||
defectos = rr;
|
||||
} catch {
|
||||
modaldata ="No se pudo pedir la lista de Defectos";
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -307,6 +356,69 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="ht">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#ct"
|
||||
aria-expanded="false"
|
||||
aria-controls="ct"
|
||||
>
|
||||
Defectos
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="ct"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Notificar Defecto en Propiedad
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<FormAltaDefecto onConfirm={cargarDefecto} idcontrato={prop.id} />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción</th>
|
||||
<th>Costo</th>
|
||||
<th>Estado</th>
|
||||
<th>Paga Inquilino</th>
|
||||
<th>Divisa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if defectos.length == 0}
|
||||
<tr>
|
||||
<td colspan="6">No hay defectos que mostrar</td>
|
||||
</tr>
|
||||
{:else}
|
||||
{#each defectos as defecto}
|
||||
<tr>
|
||||
<td>{defecto.descripcion}</td>
|
||||
<td>{defecto.costo}</td>
|
||||
<td>{defecto.estado}</td>
|
||||
<td>{defecto.pagainquilino}</td>
|
||||
<td>{defecto.divisa}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
@@ -34,6 +34,7 @@
|
||||
mesesAumento:0,
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -49,29 +50,38 @@
|
||||
const respPropiedad = fetch($urlG+"/api/contrato/propietario?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respgarantes = fetch($urlG+"/api/contratos/garantes?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respCanons = fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||
const respoDefect = fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c, d] = await Promise.all([respPropiedad, respgarantes, respCanons, respoDefect]);
|
||||
|
||||
const datosPropiedad = await p.json();
|
||||
const datosGarantes = await g.json();
|
||||
const datosCanons = await c.json();
|
||||
const datosDefect = await d.json();
|
||||
|
||||
prop = datosPropiedad;
|
||||
garantes = datosGarantes;
|
||||
canons = datosCanons;
|
||||
defectos = datosDefect;
|
||||
} catch {
|
||||
modaldata = "Fallo hacer las request";
|
||||
}
|
||||
@@ -233,6 +243,44 @@
|
||||
function abrirModalNotif() {
|
||||
shownotif = true;
|
||||
}
|
||||
|
||||
|
||||
async function marcarDefectoPago(defecto: DefectoDto) {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/defecto/marcarpago?iddefecto="+defecto.id, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
let dr = await r.json();
|
||||
modaldata = dr.message;
|
||||
if (r.ok) {
|
||||
refreshDefectos();
|
||||
}
|
||||
|
||||
}catch {
|
||||
modaldata = "No se pudo marcar como pago";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDefectos() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let rr =await r.json();
|
||||
defectos = rr;
|
||||
} catch {
|
||||
modaldata ="No se pudo pedir la lista de Defectos";
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -405,6 +453,64 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="ht">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#ct"
|
||||
aria-expanded="false"
|
||||
aria-controls="ct"
|
||||
>
|
||||
Defectos
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="ct"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción</th>
|
||||
<th>Costo</th>
|
||||
<th>Estado</th>
|
||||
<th>Paga Inquilino</th>
|
||||
<th>Divisa</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if defectos.length == 0}
|
||||
<tr>
|
||||
<td colspan="6">No hay defectos que mostrar</td>
|
||||
</tr>
|
||||
{:else}
|
||||
{#each defectos as defecto}
|
||||
<tr>
|
||||
<td>{defecto.descripcion}</td>
|
||||
<td>{defecto.costo}</td>
|
||||
<td>{defecto.estado}</td>
|
||||
<td>{defecto.pagainquilino}</td>
|
||||
<td>{defecto.divisa}</td>
|
||||
<td>
|
||||
{#if defecto.estado !== "Pagado"}
|
||||
<button class="btn btn-secondary" onclick={()=>marcarDefectoPago(defecto)}>Marcar Pago</button>
|
||||
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user