feat(puesto-control): paridad completa de busqueda/seleccion de lote, validaciones estrictas y control de cacheo de garita
This commit is contained in:
@@ -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