[EDIT] AGREGAR NUEVOS CAMBPOS Y REGISTRO DE NUEVAS EVIDENCIAS

parent b14a3610
......@@ -48,19 +48,20 @@
<div class="basis-2/4">
<div class="flex flex-row gap-x-2">
<!--<mat-form-field class="w-full" appearance="outline" floatLabel="always">
<mat-label>Sede designada</mat-label>
<mat-select formControlName="sedePersonal" placeholder="[Seleccionar sede]" required>
<mat-option *ngFor="let option of this.sede_list" [value]="option?.idlocal">
{{option?.deslocal}}
<mat-form-field class="w-full" appearance="outline" floatLabel="always">
<mat-label>Zona</mat-label>
<mat-select formControlName="zonaPersonal" placeholder="[Seleccionar zona]" required>
<mat-option *ngFor="let option of this.zona_list" [value]="option.value">
{{option.viewValue}}
</mat-option>
</mat-select>
</mat-form-field> -->
</mat-form-field>
<mat-form-field class="w-full" appearance="outline" floatLabel="always">
<mat-label>Sede designada</mat-label>
<mat-select formControlName="sedePersonal" placeholder="[Seleccionar sede]" required>
<mat-option *ngFor="let option of this.sede_list" [value]="opcionEnvironmnet === 1 ? option.idlocal : option.id_local">
{{option.deslocal}}
<mat-option *ngFor="let option of this.listSedesAtencion" [value]="option.value">
{{option.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
......@@ -272,15 +273,15 @@
<mat-label>SUBIR EVIDENCIA DEL PROBLEMA</mat-label>
<mat-icon>file_open</mat-icon>
</button>
<input type="file" #file1 (change)="onEventoSubirArchivo($event)" class="hidden" multiple accept="image/png">
<input type="file" #file1 (change)="onEventoSubirArchivo($event)" class="hidden" multiple accept="image/png, image/jpeg">
<br>
<div *ngFor="let archivo of archivosEvidencia; let i = index" class="flex mt-2">
<div *ngIf="archivo.tipoEvidencia === 1" class="flex w-full">
<p class="w-2/4">{{ (archivo.file.name + ' (' + (archivo.file.size / 1000) + ' KB)') | truncate:30:true }}</p>
<div class="w-2/4 grid grid-cols-3 gap-4">
<button (click)="gestionArchivos(i,1,archivo.file)"><mat-icon>info</mat-icon></button>
<button (click)="seleccionarInput(i,1)"><mat-icon>edit</mat-icon></button>
<input type="file" #fileEditar1 (change)="gestionArchivos(i,2,$event)" class="hidden" multiple accept="image/png">
<button (click)="seleccionarInput(archivo,1)"><mat-icon>edit</mat-icon></button>
<input type="file" #fileEditar1 (change)="gestionArchivos(i,2,$event)" class="hidden" multiple accept="image/png, image/jpeg">
<button (click)="gestionArchivos(i,3)"><mat-icon>delete</mat-icon></button>
</div>
</div>
......@@ -293,15 +294,15 @@
<mat-label>SUBIR EVIDENCIA DE LA SOLUCIÓN</mat-label>
<mat-icon>file_open</mat-icon>
</button>
<input type="file" #file2 (change)="onEventoSubirArchivo($event,2)" class="hidden" multiple accept="image/png">
<input type="file" #file2 (change)="onEventoSubirArchivo($event,2)" class="hidden" multiple accept="image/png, image/jpeg">
<br>
<div *ngFor="let archivo of archivosEvidencia; let i = index" class="flex mt-2">
<div *ngIf="archivo.tipoEvidencia === 2" class="flex w-full">
<p class="w-2/4">{{ (archivo.file.name + ' (' + (archivo.file.size / 1000) + ' KB)') | truncate:30:true }}</p>
<div class="w-2/4 grid grid-cols-3 gap-4">
<button (click)="gestionArchivos(i,1,archivo.file,2)"><mat-icon>info</mat-icon></button>
<button (click)="seleccionarInput(i,2)"><mat-icon>edit</mat-icon></button>
<input type="file" #fileEditar2 (change)="gestionArchivos(i,2,$event,2)" class="hidden" multiple accept="image/png">
<button (click)="seleccionarInput(archivo,2)"><mat-icon>edit</mat-icon></button>
<input type="file" #fileEditar2 (change)="gestionArchivos(i,2,$event,2)" class="hidden" multiple accept="image/png, image/jpeg">
<button (click)="gestionArchivos(i,3,2)"><mat-icon>delete</mat-icon></button>
</div>
</div>
......@@ -361,6 +362,58 @@
</ng-container>
</mat-card>
<mat-card appearance="outlined" class="mt-4 flex flex-col gap-2.5 text-[#222] !shadow-xl w-[90vw] sm:w-[85vw] md:w-[75vw]" [formGroup]="existeMaterialS">
<mat-card-header class="flex flex-col items-start w-full">
<mat-label class="flex items-center text-[1.1em] font-bold">
ADICIONALES
</mat-label>
</mat-card-header>
<mat-card-content class="w-full my-2.5">
<div class="div-serviocisPrestados divisionGeneral">
<div class="grid grid-flow-col md:grid-cols-2 gap-5">
<div>
<div><b class="md:text-[1rem] text-[1em] text-black/60">EVIDENCIA DE ATC: *</b></div>
<button mat-fab class="!w-full" [color]="'blue'" (click)="fotoATC.click()">
<mat-label>SUBIR FOTO DE LA ATC</mat-label>
<mat-icon>file_open</mat-icon>
</button>
<input type="file" #fotoATC (change)="onEventoSubirArchivo($event,3)" class="hidden" accept="image/png, image/jpeg">
<br>
<div *ngFor="let archivo of archivosEvidencia; let i = index" class="flex mt-2">
<div *ngIf="archivo.tipoEvidencia === 3" class="flex w-full">
<p class="w-2/4">{{ (archivo.file.name + ' (' + (archivo.file.size / 1000) + ' KB)') | truncate:30:true }}</p>
<div class="w-2/4 grid grid-cols-3 gap-4">
<button (click)="gestionArchivos(i,1,archivo.file)"><mat-icon>info</mat-icon></button>
<button (click)="gestionArchivos(i,3)"><mat-icon>delete</mat-icon></button>
</div>
</div>
</div>
</div>
<div>
<div><b class="md:text-[1rem] text-[1em] text-black/60">FIRMA DEL ENCARGADO: *</b></div>
<button mat-fab class="!w-full" [color]="'blue'" (click)="fotoFirma.click()">
<mat-label>SUBIR EVIDENCIA DE LA FIRMA</mat-label>
<mat-icon>file_open</mat-icon>
</button>
<input type="file" #fotoFirma (change)="onEventoSubirArchivo($event,4)" class="hidden" accept="image/png, image/jpeg">
<br>
<div *ngFor="let archivo of archivosEvidencia; let i = index" class="flex mt-2">
<div *ngIf="archivo.tipoEvidencia === 4" class="flex w-full">
<p class="w-2/4">{{ (archivo.file.name + ' (' + (archivo.file.size / 1000) + ' KB)') | truncate:30:true }}</p>
<div class="w-2/4 grid grid-cols-3 gap-4">
<button (click)="gestionArchivos(i,1,archivo.file)"><mat-icon>info</mat-icon></button>
<button (click)="gestionArchivos(i,3,2)"><mat-icon>delete</mat-icon></button>
</div>
</div>
</div>
</div>
</div>
</div>
</mat-card-content>
</mat-card>
<div class="mt-4 flex flex-col">
<button mat-fab extended (click)="gestionConformidad()">
<mat-icon>app_registration</mat-icon>
......
......@@ -152,10 +152,12 @@ export class ConformidadComponent implements AfterViewInit {
opcionEnvironmnet : number = environment.opcion;
personal_list: any = [];
sede_list: any = [];
zona_list: any = [];
requerimientosFiltrados: any[] = [];
listSedesAtencion : lugaresTrabajo[] = [];
listRequerimientos: interRequerimientos[] = [];
listTipoTrabajo: tiposTrabajo[] = [];
listadoSedesTrabajo : lugaresTrabajo[] = [];
//listadoSedesTrabajo : lugaresTrabajo[] = []; // SEDE DE TRABAJO PARA PASAJES
listPersonal : interPersonal[] = [{ index: 0 , id: 0 , nombre: '' }];
idBotones: number = 0;
//indexPasaje : number = 0 ;
......@@ -177,14 +179,18 @@ export class ConformidadComponent implements AfterViewInit {
maxFechaLimite: Date | null = new Date();
archivosEvidencia : interFile[] = [];
archivosProblema : interFile[] = [];
archivosSolucion : interFile[] = [];
archivosATC : interFile[] = [];
archivosFirma : interFile[] = [];
//INICIALIZACION DE VARIABLES UTILIZABLES
// GROUPO DE FORMULARIO
// GRUPO DE FORMULARIO
datos_personal = new FormGroup({
tecnicoPersonal0 : new FormControl(null ,Validators.required),
areaPersonal0 : new FormControl<string>('' ,Validators.required),
zonaPersonal : new FormControl(null,Validators.required),
sedePersonal : new FormControl(null,Validators.required),
minFechaTrabajo : new FormControl<Date>(new Date(), Validators.required),
maxFechaTrabajo : new FormControl<Date>(new Date(), Validators.required),
......@@ -202,8 +208,7 @@ export class ConformidadComponent implements AfterViewInit {
descripcionTrabajo : new FormControl<string>('' ,Validators.required),
});
/*datos_pasajeAcumulado = new FormGroup<any>({
});
/*datos_pasajeAcumulado = new FormGroup<any>({});
datos_lugarOrigen : FormGroup = new FormGroup<any>({}) ;
......@@ -213,8 +218,6 @@ export class ConformidadComponent implements AfterViewInit {
existeMaterial : new FormControl(null ,Validators.required),
});
//formulario: FormGroup | undefined;
// GROUPO DE FORMULARIO
constructor(
......@@ -273,7 +276,8 @@ export class ConformidadComponent implements AfterViewInit {
this.personal_list = personal;
this.sede_list = sede;
//this.dataSource = [];
this.zona_list = [{ value: 1, viewValue: 'NORTE' },{ value: 2, viewValue: 'SUR' },{ value: 3, viewValue: 'ESTE' },{ value: 4, viewValue: 'CENTRO' }];
//this.dataSource = []; // Inicializa la tabla de pasajes
this.activarPasajes = false;
const jsonTipoTrabajo = JSON.parse(tipoTrabajo);
......@@ -300,6 +304,11 @@ export class ConformidadComponent implements AfterViewInit {
}*/
});
this.obtenerFormControl(this.datos_personal,'zonaPersonal')?.valueChanges.subscribe((value : any) => {
console.log('VALOR SELECCIONAD0 : ' + value);
this.listSedesAtencion = this.sede_list.filter((item: any) => item.zona === value).map((item: any) => ({ value: item.id_local, viewValue: item.deslocal }));
});
// Sincronizar el valor de 'sedePersonal' con los selects la tabla de pasaje
/*this.obtenerFormControl(this.datos_personal,'sedePersonal')?.valueChanges.subscribe((value : any) => {
this.lugarDestinoPasaje = this.listadoSedesTrabajo.find((item: any) => item.value === value)?.viewValue || '';
......@@ -689,20 +698,46 @@ export class ConformidadComponent implements AfterViewInit {
onEventoSubirArchivo(event: any, tipo : number = 1) {
const archivosSeleccionados: FileList = event.target.files;
const nuevosArchivos = Array.from(archivosSeleccionados).filter(file => file.type === 'image/png');
const nuevosArchivos = Array.from(archivosSeleccionados).filter(file => file.type === 'image/png' || file.type === 'image/jpeg');
nuevosArchivos.forEach( async (file) => {
if(!this.archivosEvidencia.find((item) => item.file.name === file.name)){
this.archivosEvidencia.push({tipoEvidencia : tipo , file : file });
if(tipo === 3 || tipo === 4){
const Encontrado = this.archivosEvidencia.find((item) => item.tipoEvidencia === tipo);
if (Encontrado) {
this.archivosEvidencia = this.archivosEvidencia.filter((item) => item.tipoEvidencia !== tipo);
this.archivosEvidencia.push({tipoEvidencia: tipo, file: file});
}else{
this.archivosEvidencia.push({tipoEvidencia: tipo, file: file});
}
}else {
if (!this.archivosEvidencia.find((item) => item.file.name === file.name)) {
this.archivosEvidencia.push({tipoEvidencia: tipo, file: file});
}
}
});
this.archivosProblema = this.archivosEvidencia.filter((item) => item.tipoEvidencia === 1);
this.archivosSolucion = this.archivosEvidencia.filter((item) => item.tipoEvidencia === 2);
}
seleccionarInput(index : number, tipo : number){
seleccionarInput(archivo : any, tipo : number){
if(tipo === 1){
const index = this.archivosProblema.findIndex((item) => item.file.name === archivo.file.name);
const input = this.fileInputs1.toArray()[index];
input.nativeElement.click(); // Simula el clic en el input file correspondiente
}else{
}else if(tipo === 2){
const index = this.archivosSolucion.findIndex((item) => item.file.name === archivo.file.name);
const input = this.fileInputs2.toArray()[index];
input.nativeElement.click(); // Simula el clic en el input file correspondiente
}
......@@ -728,7 +763,7 @@ export class ConformidadComponent implements AfterViewInit {
//OBTENER EL ARCHIVO FILE Y UBICARLO EN EL ARRAY DE archivosEP EN EL MISMO INDEX
if(archivoSeleccionado) {
//COMPRAR EL NOMBRE DEL ARCHIVOS CON TODA LA LISTA EXISTENTE PARA EVITAR REPETICIONES
if(!this.archivosEvidencia.find((item) => item.file.name === archivoSeleccionado.name)){
if(!this.archivosEvidencia.find((item) => item.file.name === archivoSeleccionado.name && item.tipoEvidencia === tipo)){
this.archivosEvidencia[index].file = archivoSeleccionado;
}else{
this.barraAlerta.open( 'ARCHIVO YA SE ENCUENTRA EN LA LISTA' , '' , {
......@@ -750,7 +785,7 @@ export class ConformidadComponent implements AfterViewInit {
//Obtener todos los datos del form Group datos_personal
const datosPersonal = this.datos_personal.getRawValue();
const personal = this.listPersonal;
//const datosPasajes = this.dataSource;
//const datosPasajes = this.dataSource; // Obtener todos los datos de la tabla de pasajes
const datosServicio = this.datos_servicio.getRawValue();
const requerimientoRelacionados = this.listRequerimientos;
const datosTrabajo = this.datos_trabajo.getRawValue();
......@@ -759,6 +794,9 @@ export class ConformidadComponent implements AfterViewInit {
const archivosEvidencias = this.archivosEvidencia;
let contadorEP = 1;
let contadorES = 1;
let constadorATC = 1;
let contadorFirma = 1;
let contadorExtras = 1;
const datosMaterialSobrante = this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value : '';
Notiflix.Loading.pulse(); // Muestra un loading
......@@ -869,14 +907,22 @@ export class ConformidadComponent implements AfterViewInit {
archivo: item.file,
idCarpeta: registroCarpeta.idCarpeta,
tipoEvidencia: item.tipoEvidencia,
nombreArchivo: (item.tipoEvidencia === 1) ? 'EVIDENCIA_PROBLEMA_' + codigoConformidad + "_" + (contadorEP++) : 'EVIDENCIA_SOLUCION_' + codigoConformidad + "_" + (contadorES++)
nombreArchivo: (item.tipoEvidencia === 1) ? 'EVIDENCIA_PROBLEMA_' + codigoConformidad + "_" + (contadorEP++) :
(item.tipoEvidencia === 2) ? 'EVIDENCIA_SOLUCION_' + codigoConformidad + "_" + (contadorES++) :
(item.tipoEvidencia === 3) ? 'EVINDENCIA_ATC' + codigoConformidad + "_" + (constadorATC++) :
(item.tipoEvidencia === 4) ? 'FIRMA' + codigoConformidad + "_" + (contadorFirma++) : 'DATO_EXTRA'+ codigoConformidad + "_" + (contadorExtras++)
};
});
const filtroEvidenciasProblemas = registroArchivos.filter((item) => item.tipoEvidencia === 1);
const filtroEvidenciasSoluciones = registroArchivos.filter((item) => item.tipoEvidencia === 2);
const filtroEvidenciasExtras = registroArchivos.filter((item) => item.tipoEvidencia === 3 || item.tipoEvidencia === 4);
const registroEvidencia = await Promise.all([this.conformidadHelper.subidaEvidencia2(filtroEvidenciasProblemas), this.conformidadHelper.subidaEvidencia2(filtroEvidenciasSoluciones)]);
const registroEvidencia = await Promise.all([
this.conformidadHelper.subidaEvidencia2(filtroEvidenciasProblemas),
this.conformidadHelper.subidaEvidencia2(filtroEvidenciasSoluciones),
this.conformidadHelper.subidaEvidencia2(filtroEvidenciasExtras)]);
//console.log(registroEvidencia);
if (!(registroEvidencia[0].status && registroEvidencia[1].status)) {
......
......@@ -44,11 +44,6 @@ export class ConformidadHelper {
}
}
async subidaEvidencia( json : any ){
const respuesta = await this.ConformidadService.subidaEvidencia(json);
return respuesta
}
async subidaEvidencia2( json : any ){
const respuesta = await this.ConformidadService.subidaEvidencia2(json);
return respuesta
......
......@@ -121,71 +121,6 @@ export class ConformidadService {
return respuesta;
}
async subidaEvidencia(json:any){
const url = `${this.t_redireccionamiento}/google/drive`;
let respuesta: any;
const formData = new FormData();
formData.append('archivo_nombre', json.nombreArchivo);
formData.append('archivo_binario', json.archivo);
formData.append('archivo_id_actual', '');
formData.append('carpeta_id', this.value_idDrive);
formData.append('correo', this.value_correoDrive);
formData.append('app_nombre', 'EVIDENCIA_CONFORMIDAD');
formData.append('carpeta_nombre', 'CONFORMIDAD_' + json.codconformidad);
formData.append('subcarpeta_nombre', json.tipoEvidencia === 1 ? 'EVIDENCIAS_PROBLEMAS' : 'EVIDENCIAS_SOLUCIONES');
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000); // 30 segundos
try {
const response = await fetch(url, {
method: 'POST',
body: formData,
signal: controller.signal, // 30 segundos de timeout
});
const statusCode = response.status;
const responseBody = await response.json();
clearTimeout(timeout); // Limpiar, REVISA SI ESTO ESTA BIEN O QUITARLO
//let respuesta: any;
if (statusCode === 200) {
const registroEvidencia = await this.registroDocumento({
codconformidad: json.codconformidad || 0,
tipoEvidencia: json.tipoEvidencia || 0,
idDrive: responseBody.data.archivo_id || '',
enlaceDrive: responseBody.data.archivo_url_vista || '',
enlaceDescarga: responseBody.data.archivo_url || '',
nombreDocumento: json.nombreArchivo || ''
});
if (registroEvidencia?.status) {
respuesta = {status: true, message: "Imagenes subidas"};
} else {
respuesta = {status: false, message: "Fallo en subir imagenes"};
}
} else {
respuesta = {status: false, message: "Imagenes subidas"};
}
//return respuesta;
} catch (error) {
console.error('Error al registrar el archivo:', error);
//throw error;
respuesta = {status: false, message: error};
}
return respuesta;
}
async subidaEvidencia2(json:any){
const url = `${this.t_redireccionamiento}/google/drive`;
let respuesta: any;
......@@ -200,8 +135,9 @@ export class ConformidadService {
formData.append('archivo_id_actual', '');
formData.append('carpeta_id', datos.idCarpeta || this.value_idDrive);
formData.append('correo', this.value_correoDrive);
formData.append('app_nombre', 'ORDEN_COMPRA'); // USANDO ESTE NOMBRE DE APP YA QUE NO CUENTA CON LA CONFIGURACION DE SUBCARPETAS
formData.append('carpeta_nombre', datos.tipoEvidencia === 1 ? 'EVIDENCIAS_PROBLEMAS' : 'EVIDENCIAS_SOLUCIONES');
formData.append('app_nombre', 'ORDEN_COMPRA'); // USANDO ESTE NOMBRE DE APP(ORDEN_COMPRA) YA QUE NO CUENTA CON LA CONFIGURACION DE SUBCARPETAS
formData.append('carpeta_nombre', datos.tipoEvidencia === 1 ? 'EVIDENCIAS_PROBLEMAS' :
datos.tipoEvidencia === 2 ? 'EVIDENCIAS_SOLUCIONES' : 'EVIDENCIAS_EXTRAS' );
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30000); // 30 segundos
try {
......
......@@ -3,9 +3,9 @@ export const environment = {
//trismegisto_services_link: 'https://tp-services.sacooliveros.edu.pe',
t_asistencia_rest_link: 'https://tp-rest.sacooliveros.edu.pe',
redireccionamiento: 'https://fichaonline.sacooliveros.edu.pe:8000/trismegisto-apis/api/v1',
//facturacion_electronica_link: 'https://fichaonline.sacooliveros.edu.pe:8080/FacturacionElectronicaSIIAA',
facturacion_electronica_link: 'https://fichaonline.sacooliveros.edu.pe:8080/FacturacionElectronicaSIIAA',
//facturacion_electronica_link: 'http://pruebaintranet.sacooliveros.pe:8080/FacturacionElectronicaSIIAA',
facturacion_electronica_link: 'https://prueba-intranet.sacooliveros.edu.pe:8443/FacturacionElectronicaSIIAA',
//facturacion_electronica_link: 'https://prueba-intranet.sacooliveros.edu.pe:8443/FacturacionElectronicaSIIAA',
horizon_services_link: 'https://api-horizon.sacooliveros.edu.pe',
//horizon_services_link: 'http://prueba-intranet.sacooliveros.edu.pe:8080/trismegisto-api-horizons',
ID_CARPETA_DRIVE_LOGISTICA:'13mGZo3AnFqgkNRyiVAgJoW9mUoQdABdC',
......
......@@ -5,10 +5,7 @@ export const environment = {
redireccionamiento: 'https://fichaonline.sacooliveros.edu.pe:8000/trismegisto-apis/api/v1',
facturacion_electronica_link: 'http://localhost:8080/FacturacionElectronicaSIIAA',
horizon_services_link: 'http://localhost:8080/trismegisto-api-horizons',
ID_CARPETA_DRIVE_LOGISTICA:'13mGZo3AnFqgkNRyiVAgJoW9mUoQdABdC',
ID_CARPETA_DRIVE_LOGISTICA:'1zYWsmpIAKR6nBmO5dnnBSAHJr81img0s',
CORREO_DRIVE_LOGISTICA : 'trismegisto.logistica@sacooliveros.edu.pe',
opcion : 1
};
// /api/v1/Conformidad/listadoGeneral
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment