Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions src/app/components/top/solicitudes/solicitudes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,24 @@ export class SolicitudesComponent implements OnInit {
public check;
public collapse = false;
public loader = true;
public sort = 'fechaSolicitudAsc';
public sortBy = 'fechaSolicitud';
public sortOrder = 'asc';
public columns = [
{
key: 'fecha',
label: 'Fecha',
key: 'fechaRegistro',
label: 'Fecha registro',
sorteable: true
},
{
key: 'fechaSolicitud',
label: 'Fecha Solicitud',
sorteable: true
},
{
key: 'paciente',
label: 'Paciente',
sorteable: false
},
{
key: 'origen',
Expand All @@ -150,7 +160,8 @@ export class SolicitudesComponent implements OnInit {
},
{
key: 'actualizacion',
label: 'actualización',
label: 'Actualización',
sorteable: true
},
{
key: 'EstadoAcciones',
Expand Down Expand Up @@ -287,10 +298,11 @@ export class SolicitudesComponent implements OnInit {
}

closeSidebar() {
if (!this.columns.some(col => col.key === 'paciente')) {
this.columns.splice(1, 0, { key: 'paciente', label: 'Paciente' });
if (this.columns && !this.columns.some(col => col.key === 'paciente')) {
this.columns.splice(2, 0, { key: 'paciente', label: 'Paciente', sorteable: false });
this.showPacienteData = true;
}
this.showPacienteData = true;

this.showAuditar = false;
this.showReferir = false;
this.showSidebar = false;
Expand All @@ -308,9 +320,8 @@ export class SolicitudesComponent implements OnInit {
this.closeSidebar();
} else {
this.prestacionSeleccionada = prestacion;
const tableCols = (this.columnas as any).columns$.source._value;
if (tableCols.some(col => col.key === 'paciente')) {
(this.columnas as any).columns$.source._value.splice(1, 1);
if (this.columns.some(col => col.key === 'paciente')) {
this.columns = this.columns.filter(col => col.key !== 'paciente');
this.showPacienteData = false;
}
(this.tipoSolicitud === 'entrada' ? this.prestacionesEntrada : this.prestacionesSalida).forEach(e => e.seleccionada = false);
Expand Down Expand Up @@ -428,6 +439,21 @@ export class SolicitudesComponent implements OnInit {
this.buscarSolicitudes();
}

sortTable(event: string) {
const column = this.columns.find(p => p.key === event);
if (!column?.sorteable) {
return;
}
if (this.sortBy === event) {
this.sortOrder = (this.sortOrder === 'asc') ? 'desc' : 'asc';
} else {
this.sortBy = event;
this.sortOrder = 'desc';
}
this.sort = this.sortBy + (this.sortOrder === 'asc' ? 'Asc' : 'Desc');
this.cargarSolicitudes();
}

getParams() {
const params: any = {
estados: [
Expand All @@ -447,7 +473,10 @@ export class SolicitudesComponent implements OnInit {
} else {
params['solicitudDesdeActualizacion'] = this.fechaDesde;
params['solicitudHastaActualizacion'] = this.fechaHasta;
params['ordenFechaDescAct'] = true;
params['solicitudHastaActualizacion'] = this.fechaHasta;
if (!this.sort) {
params['sortBy'] = 'fechaSolicitudDesc';
}
}
/*
TODO: Se remueve temporalmente la inclusión de referidas en la búsqueda de prestaciones.
Expand Down Expand Up @@ -499,7 +528,10 @@ export class SolicitudesComponent implements OnInit {
} else {
params['solicitudDesdeActualizacion'] = this.fechaDesde;
params['solicitudHastaActualizacion'] = this.fechaHasta;
params['ordenFechaDescAct'] = true;
params['solicitudHastaActualizacion'] = this.fechaHasta;
if (!this.sort) {
params['sortBy'] = 'fechaSolicitudDesc';
}
}
if (this.asignadas) {
params['idProfesionalOrigen'] = this.auth.profesional;
Expand Down Expand Up @@ -538,6 +570,9 @@ export class SolicitudesComponent implements OnInit {
}
}
this.setOrganizacionesParams(params);
if (this.sort) {
params['sortBy'] = this.sort;
}
params['skip'] = this.skip;
params['limit'] = this.limit;
return params;
Expand Down Expand Up @@ -638,7 +673,7 @@ export class SolicitudesComponent implements OnInit {
this.showAuditar = false;
this.showReferir = false;
this.showSidebar = false;
this.columns.splice(1, 0, { key: 'paciente', label: 'Paciente' });
this.columns.splice(2, 0, { key: 'paciente', label: 'Paciente', sorteable: false });
if (event.status !== false) {
if (event?.status !== this.prestacionSeleccionada.estados && this.prestacionSeleccionada.estados?.length) {
const patch = {
Expand Down Expand Up @@ -674,9 +709,11 @@ export class SolicitudesComponent implements OnInit {
this.closeSidebar();
}

onScroll() {
if (!this.scrollEnd) {
this.buscarSolicitudes();
onScroll(event: any) {
if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight - 50) {
if (!this.scrollEnd) {
this.buscarSolicitudes();
}
}
}

Expand Down
Loading