feat(puesto-control): paridad completa de busqueda/seleccion de lote, validaciones estrictas y control de cacheo de garita
This commit is contained in:
@@ -64,6 +64,12 @@ export const accessApi = {
|
||||
});
|
||||
},
|
||||
|
||||
getLotResidents: (loteId: number) => {
|
||||
return request<import('../types').LotResident[]>(`/access/lots/${loteId}/residents`, {
|
||||
method: 'GET',
|
||||
});
|
||||
},
|
||||
|
||||
getTicketOccupants: (ticketId: number) => {
|
||||
return request<any[]>(`/access/tickets/${ticketId}/occupants`, {
|
||||
method: 'GET',
|
||||
|
||||
@@ -256,6 +256,30 @@ export const ExitVerificationModal: React.FC<ExitVerificationModalProps> = ({
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Alerta de Cacheo Obligatorio de Salida / Baúl (Requisito de Seguridad) */}
|
||||
{ticket.cacheo_salida && (
|
||||
<div
|
||||
style={{
|
||||
padding: '0.65rem 1.25rem',
|
||||
backgroundColor: 'rgba(239, 68, 68, 0.14)',
|
||||
borderBottom: '1px solid var(--status-danger)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.65rem',
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: '1.25rem' }}>🚨</span>
|
||||
<div>
|
||||
<strong style={{ color: 'var(--status-danger)', fontSize: '0.85rem' }}>
|
||||
CONTROL DE GUARDIA: CACHEO A LA SALIDA OBLIGATORIO
|
||||
</strong>
|
||||
<div style={{ fontSize: '0.78rem', color: 'var(--text-primary)' }}>
|
||||
Este vehículo tiene registrado cacheo obligatorio al egresar. Inspeccione el baúl y habitáculo antes de autorizar la apertura.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Input Rápido de DNI y Escáner Activo */}
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -0,0 +1,503 @@
|
||||
// ==============================================================================
|
||||
// Modal de Búsqueda y Selección de Lotes con Padrón de Residentes
|
||||
// Paridad 1:1 con DialogoBuscarLote (pct_dialogs.py - OemspotPySYS / OneverAccess)
|
||||
// ==============================================================================
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { LotSearchItem, LotResident, LotPermission } from '../../types';
|
||||
import { accessApi } from '../../api/accessApi';
|
||||
|
||||
interface LotSearchModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onSelectLot: (lote: LotSearchItem, permission?: LotPermission | null) => void;
|
||||
selectedLotId?: number | null;
|
||||
}
|
||||
|
||||
export const LotSearchModal: React.FC<LotSearchModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onSelectLot,
|
||||
selectedLotId,
|
||||
}) => {
|
||||
const [query, setQuery] = useState<string>('');
|
||||
const [lotes, setLotes] = useState<LotSearchItem[]>([]);
|
||||
const [isLoadingLotes, setIsLoadingLotes] = useState<boolean>(false);
|
||||
const [selectedLot, setSelectedLot] = useState<LotSearchItem | null>(null);
|
||||
|
||||
const [residentes, setResidentes] = useState<LotResident[]>([]);
|
||||
const [isLoadingResidentes, setIsLoadingResidentes] = useState<boolean>(false);
|
||||
const [lotPermission, setLotPermission] = useState<LotPermission | null>(null);
|
||||
|
||||
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const loadLotes = useCallback(async (searchTerm: string) => {
|
||||
setIsLoadingLotes(true);
|
||||
try {
|
||||
const data = await accessApi.searchLots(searchTerm);
|
||||
setLotes(data);
|
||||
// Si hay un lote seleccionado actualmente, preservarlo o seleccionar el primero
|
||||
if (data.length > 0) {
|
||||
if (selectedLotId) {
|
||||
const match = data.find((l) => l.lote_id === selectedLotId);
|
||||
if (match) {
|
||||
setSelectedLot(match);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Si no había seleccionado o no se encontró, seleccionar el primero
|
||||
setSelectedLot((prev) => (prev ? (data.find((l) => l.lote_id === prev.lote_id) || data[0]) : data[0]));
|
||||
} else {
|
||||
setSelectedLot(null);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error al cargar lotes:', e);
|
||||
setLotes([]);
|
||||
setSelectedLot(null);
|
||||
} finally {
|
||||
setIsLoadingLotes(false);
|
||||
}
|
||||
}, [selectedLotId]);
|
||||
|
||||
// Al abrir el modal, cargar inicialmente
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
loadLotes('');
|
||||
} else {
|
||||
setQuery('');
|
||||
setResidentes([]);
|
||||
setLotPermission(null);
|
||||
}
|
||||
}, [isOpen, loadLotes]);
|
||||
|
||||
// Debounce en el input de búsqueda
|
||||
const handleQueryChange = (text: string) => {
|
||||
setQuery(text);
|
||||
if (searchTimerRef.current) {
|
||||
clearTimeout(searchTimerRef.current);
|
||||
}
|
||||
searchTimerRef.current = setTimeout(() => {
|
||||
loadLotes(text);
|
||||
}, 250);
|
||||
};
|
||||
|
||||
// Al cambiar el lote seleccionado, cargar sus residentes y permiso
|
||||
useEffect(() => {
|
||||
if (!selectedLot) {
|
||||
setResidentes([]);
|
||||
setLotPermission(null);
|
||||
return;
|
||||
}
|
||||
|
||||
let isMounted = true;
|
||||
setIsLoadingResidentes(true);
|
||||
|
||||
Promise.all([
|
||||
accessApi.getLotResidents(selectedLot.lote_id),
|
||||
accessApi.getLotPermission(selectedLot.lote_id).catch(() => null),
|
||||
])
|
||||
.then(([resData, permData]) => {
|
||||
if (isMounted) {
|
||||
setResidentes(resData);
|
||||
setLotPermission(permData);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error('Error al cargar datos del lote:', e);
|
||||
if (isMounted) {
|
||||
setResidentes([]);
|
||||
setLotPermission(null);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (isMounted) setIsLoadingResidentes(false);
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [selectedLot]);
|
||||
|
||||
const handleConfirm = (loteToConfirm?: LotSearchItem) => {
|
||||
const target = loteToConfirm || selectedLot;
|
||||
if (target) {
|
||||
onSelectLot(target, lotPermission);
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
zIndex: 1100,
|
||||
padding: '0.75rem',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
maxWidth: '920px',
|
||||
maxHeight: '92vh',
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
boxShadow: 'var(--shadow-xl)',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
}}
|
||||
>
|
||||
{/* Cabecera del Modal */}
|
||||
<div
|
||||
style={{
|
||||
padding: '1rem 1.25rem',
|
||||
backgroundColor: 'var(--bg-surface)',
|
||||
borderBottom: '1px solid var(--border-subtle)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
|
||||
<span style={{ fontSize: '1.3rem' }}>🏘️</span>
|
||||
<h2 style={{ margin: 0, fontSize: '1.15rem', fontWeight: 700, color: 'var(--text-primary)' }}>
|
||||
Buscador de Lotes y Padrón de Residentes
|
||||
</h2>
|
||||
</div>
|
||||
<div style={{ fontSize: '0.8rem', color: 'var(--text-secondary)', marginTop: '0.2rem' }}>
|
||||
Consulte el padrón de propietarios, residentes y teléfonos de contacto para autorizar el ingreso.
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
style={{
|
||||
background: 'transparent',
|
||||
border: 'none',
|
||||
fontSize: '1.4rem',
|
||||
color: 'var(--text-secondary)',
|
||||
cursor: 'pointer',
|
||||
padding: '0.25rem 0.5rem',
|
||||
}}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Barra de Filtro de Búsqueda */}
|
||||
<div style={{ padding: '0.85rem 1.25rem', borderBottom: '1px solid var(--border-subtle)', display: 'flex', gap: '0.5rem' }}>
|
||||
<div style={{ position: 'relative', flex: 1 }}>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
autoFocus
|
||||
placeholder="🔍 Buscar por número de lote, UF, residente o calle..."
|
||||
value={query}
|
||||
onChange={(e) => handleQueryChange(e.target.value)}
|
||||
style={{ width: '100%', minHeight: '44px', paddingLeft: '1rem', fontSize: '0.95rem' }}
|
||||
/>
|
||||
{query && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setQuery('');
|
||||
loadLotes('');
|
||||
}}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
right: '10px',
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
background: 'transparent',
|
||||
border: 'none',
|
||||
fontSize: '1rem',
|
||||
color: 'var(--text-secondary)',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() => loadLotes(query)}
|
||||
style={{ minHeight: '44px', padding: '0 1.25rem', fontWeight: 600 }}
|
||||
>
|
||||
Buscar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Cuerpo Principal Dividido: Panel Superior de Lotes + Panel Inferior de Residentes */}
|
||||
<div style={{ flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: '0.75rem', padding: '1rem 1.25rem' }}>
|
||||
{/* 1. SECCIÓN: LOTES ENCONTRADOS */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.35rem' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-secondary)', textTransform: 'uppercase' }}>
|
||||
Lotes Registrados ({lotes.length}) {isLoadingLotes && '• Cargando...'}
|
||||
</span>
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
|
||||
Tocar para seleccionar • Doble toque para confirmar
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
maxHeight: '180px',
|
||||
overflowY: 'auto',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
backgroundColor: 'var(--bg-app)',
|
||||
}}
|
||||
>
|
||||
{lotes.length === 0 && !isLoadingLotes ? (
|
||||
<div style={{ padding: '1.5rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
|
||||
No se encontraron lotes que coincidan con la búsqueda.
|
||||
</div>
|
||||
) : (
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
|
||||
<thead>
|
||||
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
|
||||
<th style={{ padding: '0.5rem 0.75rem', width: '100px' }}>Lote / UF</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem' }}>Calle y Ubicación</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem' }}>Titular / Propietario</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem', width: '130px' }}>Estado / Cat</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{lotes.map((l) => {
|
||||
const isSel = selectedLot?.lote_id === l.lote_id;
|
||||
return (
|
||||
<tr
|
||||
key={l.lote_id}
|
||||
onClick={() => setSelectedLot(l)}
|
||||
onDoubleClick={() => handleConfirm(l)}
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
backgroundColor: isSel ? 'rgba(37, 99, 235, 0.18)' : 'transparent',
|
||||
borderBottom: '1px solid var(--border-subtle)',
|
||||
fontWeight: isSel ? 700 : 400,
|
||||
borderLeft: isSel ? '4px solid var(--accent-primary)' : '4px solid transparent',
|
||||
transition: 'background 0.1s ease',
|
||||
}}
|
||||
>
|
||||
<td style={{ padding: '0.55rem 0.75rem' }}>
|
||||
<strong style={{ fontSize: '0.95rem', color: 'var(--text-primary)' }}>
|
||||
Lote {l.codigo}
|
||||
</strong>
|
||||
{l.uf && l.uf !== l.codigo && (
|
||||
<div style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>UF: {l.uf}</div>
|
||||
)}
|
||||
</td>
|
||||
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
|
||||
{l.calle ? `${l.calle} ${l.numero || ''}`.trim() : 'Sin calle asignada'}
|
||||
</td>
|
||||
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
|
||||
{l.propietario || <span style={{ color: 'var(--text-muted)' }}>-</span>}
|
||||
</td>
|
||||
<td style={{ padding: '0.55rem 0.75rem' }}>
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
padding: '0.2rem 0.5rem',
|
||||
borderRadius: '4px',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 600,
|
||||
backgroundColor:
|
||||
l.estado === 'Habilitado' || l.estado === 'Residencia Permanente'
|
||||
? 'rgba(16, 185, 129, 0.15)'
|
||||
: 'rgba(239, 68, 68, 0.15)',
|
||||
color:
|
||||
l.estado === 'Habilitado' || l.estado === 'Residencia Permanente'
|
||||
? 'var(--status-success)'
|
||||
: 'var(--status-danger)',
|
||||
}}
|
||||
>
|
||||
{l.estado || 'General'}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2. SECCIÓN: PADRÓN DE RESIDENTES DEL LOTE SELECCIONADO */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.35rem', flex: 1 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-secondary)', textTransform: 'uppercase' }}>
|
||||
Padrón de Residentes del Lote {selectedLot ? `"${selectedLot.codigo}"` : ''} ({residentes.length}){' '}
|
||||
{isLoadingResidentes && '• Cargando residentes...'}
|
||||
</span>
|
||||
|
||||
{/* Badge de Permiso del Lote */}
|
||||
{lotPermission && (
|
||||
<div
|
||||
style={{
|
||||
fontSize: '0.8rem',
|
||||
fontWeight: 700,
|
||||
padding: '0.2rem 0.6rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: lotPermission.bg_color,
|
||||
color: lotPermission.color,
|
||||
border: `1px solid ${lotPermission.color}`,
|
||||
}}
|
||||
>
|
||||
{lotPermission.estado}: {lotPermission.detalle}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
minHeight: '140px',
|
||||
maxHeight: '220px',
|
||||
overflowY: 'auto',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
backgroundColor: 'var(--bg-app)',
|
||||
}}
|
||||
>
|
||||
{!selectedLot ? (
|
||||
<div style={{ padding: '1.5rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
|
||||
Seleccione un lote en la grilla superior para visualizar sus residentes y teléfonos.
|
||||
</div>
|
||||
) : residentes.length === 0 && !isLoadingResidentes ? (
|
||||
<div style={{ padding: '1.5rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
|
||||
No hay residentes o contactos registrados en la ficha de este lote.
|
||||
</div>
|
||||
) : (
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
|
||||
<thead>
|
||||
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
|
||||
<th style={{ padding: '0.5rem 0.75rem' }}>Residente</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem', width: '100px' }}>DNI</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem', width: '130px' }}>Perfil / Relación</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem' }}>Teléfonos de Contacto</th>
|
||||
<th style={{ padding: '0.5rem 0.75rem', width: '90px' }}>Estado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{residentes.map((r) => (
|
||||
<tr key={r.persona_id} style={{ borderBottom: '1px solid var(--border-subtle)' }}>
|
||||
<td style={{ padding: '0.5rem 0.75rem', fontWeight: 600, color: 'var(--text-primary)' }}>
|
||||
{r.apellido}, {r.nombre}
|
||||
</td>
|
||||
<td style={{ padding: '0.5rem 0.75rem', color: 'var(--text-secondary)' }}>
|
||||
{r.documento || '-'}
|
||||
</td>
|
||||
<td style={{ padding: '0.5rem 0.75rem' }}>
|
||||
<span className="badge badge-info" style={{ fontSize: '0.75rem' }}>
|
||||
{r.perfil}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{ padding: '0.5rem 0.75rem', color: 'var(--text-primary)' }}>
|
||||
{r.telefonos && r.telefonos !== '-' ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.4rem', flexWrap: 'wrap' }}>
|
||||
<span>{r.telefonos}</span>
|
||||
<a
|
||||
href={`tel:${r.telefonos.split('/')[0].trim()}`}
|
||||
style={{
|
||||
fontSize: '0.75rem',
|
||||
padding: '0.15rem 0.4rem',
|
||||
backgroundColor: 'rgba(37, 99, 235, 0.15)',
|
||||
color: 'var(--accent-primary)',
|
||||
borderRadius: '4px',
|
||||
textDecoration: 'none',
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
📞 Llamar
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
<span style={{ color: 'var(--text-muted)' }}>Sin teléfono</span>
|
||||
)}
|
||||
</td>
|
||||
<td style={{ padding: '0.5rem 0.75rem' }}>
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--status-success)', fontWeight: 600 }}>
|
||||
{r.estado}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Pie de Acciones del Modal */}
|
||||
<div
|
||||
style={{
|
||||
padding: '0.85rem 1.25rem',
|
||||
backgroundColor: 'var(--bg-surface)',
|
||||
borderTop: '1px solid var(--border-subtle)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
{selectedLot ? (
|
||||
<span style={{ fontSize: '0.9rem', color: 'var(--text-primary)' }}>
|
||||
Lote seleccionado:{' '}
|
||||
<strong style={{ color: 'var(--accent-primary)', fontSize: '1rem' }}>
|
||||
Lote {selectedLot.codigo}
|
||||
</strong>{' '}
|
||||
{selectedLot.calle ? `(${selectedLot.calle})` : ''}
|
||||
</span>
|
||||
) : (
|
||||
<span style={{ fontSize: '0.85rem', color: 'var(--text-muted)' }}>
|
||||
Seleccione un lote para continuar
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: '0.75rem' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={onClose}
|
||||
style={{ minHeight: '44px', padding: '0 1.25rem' }}
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
disabled={!selectedLot}
|
||||
onClick={() => handleConfirm()}
|
||||
style={{
|
||||
minHeight: '44px',
|
||||
padding: '0 1.5rem',
|
||||
fontWeight: 700,
|
||||
backgroundColor: 'var(--status-success)',
|
||||
color: '#fff',
|
||||
}}
|
||||
>
|
||||
✓ Seleccionar Lote
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -50,6 +50,7 @@ export interface EntryFormData {
|
||||
cantidad_ocupantes: number;
|
||||
cantidad_menores: number;
|
||||
cacheo_salida: boolean;
|
||||
baul_inspeccionado?: boolean;
|
||||
abrir_barrera: boolean;
|
||||
integrantes: Companion[];
|
||||
seguro_empresa?: string;
|
||||
@@ -142,6 +143,7 @@ export interface ActiveTicket {
|
||||
modulo_ingreso: string;
|
||||
fecha_ingreso: string;
|
||||
ocupantes: number;
|
||||
cacheo_salida?: boolean;
|
||||
}
|
||||
|
||||
export interface PersonSearchItem {
|
||||
@@ -155,9 +157,23 @@ export interface PersonSearchItem {
|
||||
export interface LotSearchItem {
|
||||
lote_id: number;
|
||||
codigo: string;
|
||||
uf?: string | null;
|
||||
calle?: string | null;
|
||||
numero?: string | null;
|
||||
estado?: string | null;
|
||||
propietario?: string | null;
|
||||
}
|
||||
|
||||
export interface LotResident {
|
||||
persona_id: number;
|
||||
apellido: string;
|
||||
nombre: string;
|
||||
documento?: string | null;
|
||||
perfil: string;
|
||||
estado: string;
|
||||
telefonos?: string | null;
|
||||
}
|
||||
|
||||
export interface DNIParsedResult {
|
||||
valido: boolean;
|
||||
documento: string;
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useTheme } from '../hooks/useTheme';
|
||||
import { CameraScannerModal } from '../components/scanner/CameraScannerModal';
|
||||
import { CompanionsRegistrationModal } from '../components/modals/CompanionsRegistrationModal';
|
||||
import { ExitVerificationModal } from '../components/modals/ExitVerificationModal';
|
||||
import { LotSearchModal } from '../components/modals/LotSearchModal';
|
||||
import { APP_VERSION, APP_BUILD } from '../version';
|
||||
import {
|
||||
WorkstationConfig,
|
||||
@@ -54,7 +55,8 @@ export const ControlPostView: React.FC = () => {
|
||||
entidad: '',
|
||||
cantidad_ocupantes: 1,
|
||||
cantidad_menores: 0,
|
||||
cacheo_salida: false,
|
||||
cacheo_salida: true,
|
||||
baul_inspeccionado: false,
|
||||
abrir_barrera: true,
|
||||
integrantes: [],
|
||||
seguro_empresa: '',
|
||||
@@ -77,10 +79,9 @@ export const ControlPostView: React.FC = () => {
|
||||
const [confirmRestrictedModal, setConfirmRestrictedModal] = useState<boolean>(false);
|
||||
|
||||
|
||||
// Autocompletado y validación de Lotes
|
||||
const [lotSuggestions, setLotSuggestions] = useState<LotSearchItem[]>([]);
|
||||
const [showLotSuggestions, setShowLotSuggestions] = useState<boolean>(false);
|
||||
// Validación y selección de Lotes
|
||||
const [lotPermission, setLotPermission] = useState<LotPermission | null>(null);
|
||||
const [isLotModalOpen, setIsLotModalOpen] = useState<boolean>(false);
|
||||
|
||||
// Modales y Alertas
|
||||
const [scannerOpen, setScannerOpen] = useState<boolean>(false);
|
||||
@@ -186,48 +187,39 @@ export const ControlPostView: React.FC = () => {
|
||||
onMessage: handleWsEvent,
|
||||
});
|
||||
|
||||
// Búsqueda autocompletada y validación de Lotes (Cat 26)
|
||||
const handleLotSearch = async (val: string) => {
|
||||
const cod = val.toUpperCase();
|
||||
setForm((prev) => ({ ...prev, lote_codigo: cod, lote_id: null }));
|
||||
setLotPermission(null);
|
||||
|
||||
if (cod.trim().length >= 1) {
|
||||
try {
|
||||
const results = await accessApi.searchLots(cod.trim());
|
||||
setLotSuggestions(results);
|
||||
setShowLotSuggestions(true);
|
||||
const selectLot = async (lot: LotSearchItem, preloadedPermission?: LotPermission | null) => {
|
||||
const displayName = lot.calle
|
||||
? `Lote ${lot.codigo} - ${lot.calle} ${lot.numero || ''}`.trim()
|
||||
: `Lote ${lot.codigo}`;
|
||||
|
||||
const matchExacto = results.find((r) => r.codigo.toUpperCase() === cod.trim());
|
||||
if (matchExacto) {
|
||||
setForm((prev) => ({ ...prev, lote_id: matchExacto.lote_id }));
|
||||
const perm = await accessApi.getLotPermission(matchExacto.lote_id);
|
||||
setLotPermission(perm);
|
||||
}
|
||||
} catch {
|
||||
setLotSuggestions([]);
|
||||
}
|
||||
} else {
|
||||
setLotSuggestions([]);
|
||||
setShowLotSuggestions(false);
|
||||
}
|
||||
};
|
||||
|
||||
const selectLot = async (lot: LotSearchItem) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
lote_id: lot.lote_id,
|
||||
lote_codigo: lot.codigo,
|
||||
lote_codigo: displayName,
|
||||
}));
|
||||
setShowLotSuggestions(false);
|
||||
try {
|
||||
const perm = await accessApi.getLotPermission(lot.lote_id);
|
||||
setLotPermission(perm);
|
||||
} catch {
|
||||
setLotPermission(null);
|
||||
|
||||
if (preloadedPermission !== undefined) {
|
||||
setLotPermission(preloadedPermission);
|
||||
} else {
|
||||
try {
|
||||
const perm = await accessApi.getLotPermission(lot.lote_id);
|
||||
setLotPermission(perm);
|
||||
} catch {
|
||||
setLotPermission(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const clearLot = () => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
lote_id: null,
|
||||
lote_codigo: '',
|
||||
}));
|
||||
setLotPermission(null);
|
||||
};
|
||||
|
||||
// Evaluación de vigencia de pólizas (Paridad pct_view.py)
|
||||
const getPolicyStatus = (dateStr?: string) => {
|
||||
if (!dateStr || dateStr === '1900-01-01' || dateStr === '-' || !dateStr.trim()) {
|
||||
@@ -350,9 +342,9 @@ export const ControlPostView: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Validar Lote de Destino
|
||||
if (!form.lote_id && !form.lote_codigo.trim()) {
|
||||
setActionError('Debe seleccionar el lote de destino (obligatorio).');
|
||||
// 3. Validar Lote de Destino (Paridad puestocontrol: pct_view.py:3183)
|
||||
if (!form.lote_id || form.lote_id <= 0) {
|
||||
setActionError('Falta Seleccionar Lote de Destino (obligatorio).');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -410,6 +402,7 @@ export const ControlPostView: React.FC = () => {
|
||||
apellido: form.apellido.trim().toUpperCase(),
|
||||
nombre: form.nombre.trim().toUpperCase(),
|
||||
patente: form.tipo_ingreso === 'CONDUCTOR' ? form.patente.trim().toUpperCase() : '',
|
||||
baul_inspeccionado: form.tipo_ingreso === 'CONDUCTOR' ? !!form.baul_inspeccionado : false,
|
||||
forzar_ingreso_lote_restringido: forceRestricted || form.forzar_ingreso_lote_restringido,
|
||||
};
|
||||
|
||||
@@ -432,7 +425,8 @@ export const ControlPostView: React.FC = () => {
|
||||
entidad: '',
|
||||
cantidad_ocupantes: 1,
|
||||
cantidad_menores: 0,
|
||||
cacheo_salida: false,
|
||||
cacheo_salida: true,
|
||||
baul_inspeccionado: false,
|
||||
abrir_barrera: true,
|
||||
integrantes: [],
|
||||
seguro_empresa: '',
|
||||
@@ -1046,61 +1040,91 @@ export const ControlPostView: React.FC = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ position: 'relative' }}>
|
||||
{/* Selector de Lote con Paridad Desktop DialogoBuscarLote */}
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
LOTE / DESTINO <span style={{ color: '#f44336' }}>*</span>:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.lote_codigo}
|
||||
onChange={(e) => handleLotSearch(e.target.value)}
|
||||
onFocus={() => {
|
||||
if (lotSuggestions.length > 0) setShowLotSuggestions(true);
|
||||
}}
|
||||
placeholder="Ej: 142"
|
||||
required
|
||||
style={{ width: '100%', marginTop: '0.25rem' }}
|
||||
/>
|
||||
{/* Desplegable de sugerencias de Lotes */}
|
||||
{showLotSuggestions && lotSuggestions.length > 0 && (
|
||||
<div style={{ display: 'flex', gap: '0.5rem', marginTop: '0.25rem', alignItems: 'stretch' }}>
|
||||
<div
|
||||
onClick={() => setIsLotModalOpen(true)}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '100%',
|
||||
left: 0,
|
||||
right: 0,
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
flex: 1,
|
||||
backgroundColor: form.lote_id ? 'var(--bg-card)' : 'rgba(0,0,0,0.1)',
|
||||
border: form.lote_id ? '2px solid var(--accent-primary)' : '1px dashed var(--border-subtle)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
boxShadow: 'var(--shadow-md)',
|
||||
zIndex: 100,
|
||||
maxHeight: '160px',
|
||||
overflowY: 'auto',
|
||||
padding: '0.65rem 0.85rem',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
cursor: 'pointer',
|
||||
minHeight: '48px',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
title="Haga clic para buscar o seleccionar lote de destino"
|
||||
>
|
||||
{lotSuggestions.map((lot) => (
|
||||
<div
|
||||
key={lot.lote_id}
|
||||
onClick={() => selectLot(lot)}
|
||||
style={{
|
||||
padding: '0.6rem 0.75rem',
|
||||
cursor: 'pointer',
|
||||
fontSize: '0.9rem',
|
||||
borderBottom: '1px solid var(--border-subtle)',
|
||||
}}
|
||||
>
|
||||
Lote <strong>{lot.codigo}</strong>
|
||||
{form.lote_id ? (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', overflow: 'hidden' }}>
|
||||
<span style={{ fontSize: '1.1rem' }}>🏡</span>
|
||||
<span style={{ fontWeight: 700, fontSize: '1rem', color: 'var(--text-primary)', textOverflow: 'ellipsis', whiteSpace: 'nowrap', overflow: 'hidden' }}>
|
||||
{form.lote_codigo}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
) : (
|
||||
<span style={{ color: 'var(--text-muted)', fontSize: '0.9rem', fontStyle: 'italic' }}>
|
||||
Toque para seleccionar lote...
|
||||
</span>
|
||||
)}
|
||||
<span style={{ fontSize: '0.85rem', color: 'var(--accent-primary)', fontWeight: 600 }}>
|
||||
{form.lote_id ? 'Cambiar' : 'Elegir'}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => setIsLotModalOpen(true)}
|
||||
style={{
|
||||
minWidth: '52px',
|
||||
minHeight: '48px',
|
||||
padding: '0 0.85rem',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: '1rem',
|
||||
fontWeight: 600,
|
||||
}}
|
||||
title="Abrir buscador de lotes y residentes"
|
||||
>
|
||||
🔍
|
||||
</button>
|
||||
|
||||
{form.lote_id && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn"
|
||||
onClick={clearLot}
|
||||
style={{
|
||||
minWidth: '44px',
|
||||
minHeight: '48px',
|
||||
padding: '0 0.6rem',
|
||||
backgroundColor: 'rgba(239, 68, 68, 0.15)',
|
||||
color: 'var(--status-danger)',
|
||||
border: '1px solid rgba(239, 68, 68, 0.3)',
|
||||
fontSize: '0.9rem',
|
||||
}}
|
||||
title="Quitar lote seleccionado"
|
||||
>
|
||||
🧹
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Badge de Validación de Lote (Categoría 26: Habilitado / Moroso / En Obra) */}
|
||||
{lotPermission && (
|
||||
<div
|
||||
style={{
|
||||
marginTop: '0.35rem',
|
||||
marginTop: '0.4rem',
|
||||
padding: '0.35rem 0.65rem',
|
||||
borderRadius: '6px',
|
||||
fontSize: '0.8rem',
|
||||
@@ -1515,6 +1539,69 @@ export const ControlPostView: React.FC = () => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Control de Cacheo de Garita (Corazón de la seguridad en puesto de control) */}
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
padding: '0.75rem',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
marginTop: '0.25rem',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '0.5rem',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: '0.75rem', fontWeight: 700, color: 'var(--text-secondary)', letterSpacing: '0.5px' }}>
|
||||
SEGURIDAD Y CONTROL DE GUARDIA (CACHEO)
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '1rem', alignItems: 'center' }}>
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.5rem',
|
||||
cursor: 'pointer',
|
||||
fontSize: '0.9rem',
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.cacheo_salida}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, cacheo_salida: e.target.checked }))}
|
||||
style={{ width: '20px', height: '20px', cursor: 'pointer' }}
|
||||
/>
|
||||
<span>Cacheo Obligatorio a la Salida</span>
|
||||
</label>
|
||||
|
||||
{form.tipo_ingreso === 'CONDUCTOR' && (
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.5rem',
|
||||
cursor: 'pointer',
|
||||
fontSize: '0.9rem',
|
||||
fontWeight: 700,
|
||||
color: form.baul_inspeccionado ? 'var(--status-success)' : 'var(--text-primary)',
|
||||
backgroundColor: form.baul_inspeccionado ? 'rgba(76, 175, 80, 0.1)' : 'transparent',
|
||||
padding: '0.2rem 0.5rem',
|
||||
borderRadius: '4px',
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.baul_inspeccionado}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, baul_inspeccionado: e.target.checked }))}
|
||||
style={{ width: '20px', height: '20px', cursor: 'pointer' }}
|
||||
/>
|
||||
<span>✓ Baúl inspeccionado al ingreso (OK)</span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Switch Abrir Barrera / Molinete */}
|
||||
<div
|
||||
style={{
|
||||
@@ -1780,6 +1867,25 @@ export const ControlPostView: React.FC = () => {
|
||||
<div style={{ fontSize: '0.8rem', color: 'var(--text-secondary)', marginTop: '0.2rem' }}>
|
||||
Destino: <strong>Lote {t.lote_codigo || 'S/D'}</strong> • Ingreso:{' '}
|
||||
{t.fecha_ingreso} ({t.modulo_ingreso})
|
||||
{t.cacheo_salida && (
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: '0.2rem',
|
||||
marginLeft: '0.5rem',
|
||||
backgroundColor: 'rgba(239, 68, 68, 0.15)',
|
||||
color: 'var(--status-danger)',
|
||||
border: '1px solid rgba(239, 68, 68, 0.4)',
|
||||
padding: '0.1rem 0.45rem',
|
||||
borderRadius: '4px',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
🔍 CACHEO OBLIGATORIO
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2058,6 +2164,14 @@ export const ControlPostView: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Modal de Búsqueda y Selección de Lote (Paridad DialogoBuscarLote) */}
|
||||
<LotSearchModal
|
||||
isOpen={isLotModalOpen}
|
||||
onClose={() => setIsLotModalOpen(false)}
|
||||
onSelectLot={selectLot}
|
||||
selectedLotId={form.lote_id}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user