[ADD] DATO NUMERO ORDEN Y EVIDENCIA MATERIAL SOBRANTE

parent 62206147
......@@ -120,126 +120,6 @@
</div>
<!------------------------------------------------------------------------- DATOS GENERALES ------------------------------------------------------------------------------>
<!------------------------------------------------------------------------- LISTADO DE PASAJES ---------------------------------------------------------------------------->
<!-- <div class="flex flex-row gap-4">
<div class="sm:basis-3/12 w-full">
<mat-form-field class="w-full sm:w-[20rem]" appearance="outline" floatLabel="always">
<mat-label>Pasaje designado : </mat-label>
<input matInput formControlName="pasajeTotal" placeholder="Calculo final del pasaje" value="" readonly>
</mat-form-field>
</div>
<div class="sm:basis-9/12 w-full">
<div class="grid gap-4 grid-cols-1 sm:grid-cols-2">
<mat-label class="text-[1.1em] font-bold mb-4 flex items-center">LISTADO DE PASAJES
<mat-icon>attach_money</mat-icon>
</mat-label>
<button mat-raised-button [ngStyle]="{'visibility': activarPasajes ? 'visible' : 'hidden'}" [disabled]="!activarPasajes" (click)="onEventoNuevoPasaje($event)">
<mat-icon>add</mat-icon>
<b>Agregar pasaje</b>
</button>
</div>
<div class="overflow-x-auto">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8 w-full">
<ng-container matColumnDef="lugarOrigen">
<th mat-header-cell *matHeaderCellDef class="w-1/5"> LUGAR DE ORIGEN </th>
<td mat-cell *matCellDef="let element">
<ng-container *ngIf="element.isNew; else displayOrigen">
<mat-form-field [formGroup]="datos_lugarOrigen" appearance="outline">
<mat-select formControlName="lugarOrigen{{element.index}}" placeholder="[Seleccionar de origen]" required>
<mat-option *ngFor="let option of this.sede_list" [value]="option?.value">
{{option?.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
</ng-container>
<ng-template #displayOrigen>
{{element.lugarOrigen}}
</ng-template>
</td>
</ng-container>
<ng-container matColumnDef="lugarDestino">
<th mat-header-cell *matHeaderCellDef class="w-1/5"> LUGAR DESTINO </th>
<td mat-cell *matCellDef="let element">
<ng-container *ngIf="element.isNew; else displayOrigen">
<mat-form-field appearance="outline">
<input matInput placeholder="[Lugar de Destino]" [value]="lugarDestinoPasaje" readonly>
</mat-form-field>
</ng-container>
<ng-template #displayOrigen>
{{element.lugarDestino}}
</ng-template>
</td>
</ng-container>
<ng-container matColumnDef="monto">
<th mat-header-cell *matHeaderCellDef class="w-1/10"> MONTO </th>
<td mat-cell *matCellDef="let element">
<ng-container *ngIf="element.isNew; else displayOrigen">
<mat-form-field [formGroup]="datos_pasajeAcumulado" appearance="outline">
<input matInput formControlName="montoPasaje{{element.index}}" soloNumeros="decimal" placeholder="[Monto]" value="" maxlength="6" (blur)="formatMontoPasaje(this.datos_pasajeAcumulado,'montoPasaje'+element.index)">
</mat-form-field>
</ng-container>
<ng-template #displayOrigen>
{{element.monto}}
</ng-template>
</td>
</ng-container>
<ng-container matColumnDef="fecha">
<th mat-header-cell *matHeaderCellDef class="w-1/5"> FECHA </th>
<td mat-cell *matCellDef="let element">
<ng-container *ngIf="element.isNew; else displayOrigen">
<mat-form-field [formGroup]="datos_fechaPasaje" appearance="outline">
<input matInput [matDatepicker]="fechaPasaje" formControlName="fechaPasaje{{element.index}}" [min]="minFechaLimite" [max]="maxFechaLimite">
<mat-hint>DD/MM/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="fechaPasaje"></mat-datepicker-toggle>
<mat-datepicker #fechaPasaje></mat-datepicker>
</mat-form-field>
</ng-container>
<ng-template #displayOrigen>
{{formatoFecha(element.fecha)}}
</ng-template>
</td>
</ng-container>
<ng-container matColumnDef="accion">
<th mat-header-cell *matHeaderCellDef class="w-3/10"> ACCIÓN </th>
<td mat-cell *matCellDef="let element">
<ng-container *ngIf="element.acciones; else sinAcciones">
<ng-container *ngIf="element.isNew; else accionesEditar">
<button mat-icon-button (click)="onEventoConfirmarPasaje($event, element)">
<mat-icon>check_circle</mat-icon>
</button>
<button mat-icon-button (click)="onEventoCancelarPasaje($event, element)">
<mat-icon>cancel</mat-icon>
</button>
</ng-container>
<ng-template #accionesEditar>
<button mat-icon-button (click)="onEventoEditarPasaje($event, element)">
<mat-icon>edit</mat-icon>
</button>
<button mat-icon-button (click)="onEventoEliminarPasaje($event, element)">
<mat-icon>delete</mat-icon>
</button>
</ng-template>
</ng-container>
<ng-template #sinAcciones></ng-template>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="columnasPasaje"></tr>
<tr mat-row *matRowDef="let row; columns: columnasPasaje;"></tr>
</table>
</div>
</div>
</div> -->
<!------------------------------------------------------------------------- LISTADO DE PASAJES ---------------------------------------------------------------------------->
</mat-card-content>
</mat-card>
</div>
......@@ -471,8 +351,6 @@
REGISTRO CONFORMIDAD
</button>
</div>
<!-- <signature-pad #signature [options]="signaturePadOptions" (drawStart)="drawStart($event)" (drawEnd)="drawComplete($event)"></signature-pad> -->
</div>
......
......@@ -33,7 +33,6 @@ import { ordenSalidaComponent } from "../ordensalida/ordensalida.componente";
import {elementSelectors} from "@angular/cdk/schematics";
import { CustomDateAdapter } from '../../service/directivas_service/formatoFecha/custom-date'; // Archivo personalizado
import Notiflix from 'notiflix';
import { DecimalPipe } from '@angular/common';
import {environment} from "../../../environment/env";
interface tiposTrabajo {
......@@ -108,7 +107,6 @@ interface interFile{
providers: [
provideNativeDateAdapter(),
DatePipe,
DecimalPipe,
{ provide: MAT_DATE_LOCALE, useValue: 'es-ES' }, // Configurar el idioma español
{ provide: DateAdapter, useClass: CustomDateAdapter } // Adaptador personalizado
],
......@@ -156,9 +154,6 @@ export class ConformidadComponent implements AfterViewInit {
alertaPosicionVertical: MatSnackBarVerticalPosition = 'bottom';
alertaDuracion : number = 3;
minFechaLimite: Date | null = new Date();
maxFechaLimite: Date | null = new Date();
archivosEvidencia : interFile[] = [];
archivosProblema : interFile[] = [];
archivosSolucion : interFile[] = [];
......@@ -204,7 +199,6 @@ export class ConformidadComponent implements AfterViewInit {
public dialog: MatDialog,
private datePipe: DatePipe,
private fb: FormBuilder,
private decimalPipe: DecimalPipe,
private snackBar: MatSnackBar
) {
this.requerimientosFiltrados = [];
......@@ -350,7 +344,6 @@ export class ConformidadComponent implements AfterViewInit {
//QUITAR UN TECNICP
onEventoQuitarPersonal(){
if(this.listPersonal.length === 1){
this.personalText = 'Debe de haber un trabajador como minimo'; // Cambia el texto
this.personalFading = false; // Resetea el estado de opacidad para mostrar el texto
......@@ -374,14 +367,11 @@ export class ConformidadComponent implements AfterViewInit {
const personal_list = this.personal_list;
const personal_datos = personal_list.find((item: any) => item.codper === codigoPer);
const areaControl = this.datos_personal.get('areaPersonal'+elemento.index);
const validarRepetido = this.listPersonal.find((item: any) => item.id === codigoPer && item.index != elemento.index);
if(validarRepetido){
this.datos_personal.get('tecnicoPersonal'+elemento.index)?.setValue(null);
this.personalText = 'Personal ya seleccionado'; // Cambia el texto
this.personalFading = false; // Resetea el estado de opacidad para mostrar el texto
......@@ -433,23 +423,9 @@ export class ConformidadComponent implements AfterViewInit {
const archivosSeleccionados: FileList = event.target.files;
const nuevosArchivos = Array.from(archivosSeleccionados).filter(file => file.type === 'image/png' || file.type === 'image/jpeg');
nuevosArchivos.forEach( async (file) => {
if(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);
......@@ -519,16 +495,23 @@ export class ConformidadComponent implements AfterViewInit {
const datosTrabajo = this.datos_trabajo.getRawValue();
const existeMaterial = parseInt(this.existeMaterialS.get('existeMaterial')?.value) || 0;
const datosMaterial = this.ordenSalidaComponent?.dataSource.length > 0 ? this.ordenSalidaComponent?.dataSource : [];
const evidenciaMaterial = this.ordenSalidaComponent?.archivosMaterial.length > 0 ? this.ordenSalidaComponent?.archivosMaterial : [];
const archivosEvidencias = this.archivosEvidencia;
let contadorEP = 1;
let contadorES = 1;
let constadorATS = 1;
let contadorFirma = 1;
let contadorMaterialSobrante = 1;
let contadorExtras = 1;
const datosMaterialSobrante = this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value : '';
const ordenSalidaMaterial = this.ordenSalidaComponent?.datos_materialSobrante?.get('numeroOrden')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('numeroOrden')?.value : '';
const descripcionMaterial = this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value ? this.ordenSalidaComponent?.datos_materialSobrante?.get('descMaterial')?.value : '';
Notiflix.Loading.standard('Cargando...');
if(evidenciaMaterial.length > 0){
archivosEvidencias.push(...evidenciaMaterial);
}
if (!this.validarDatosPersonales(datosPersonal)) {
this.mostrarAlerta('VALIDAR DATOS PERSONALES');
return;
......@@ -587,7 +570,8 @@ export class ConformidadComponent implements AfterViewInit {
nombreArchivo: (item.tipoEvidencia === 1) ? 'EVIDENCIA_PROBLEMA_' + codigoConformidad + "_" + (contadorEP++) :
(item.tipoEvidencia === 2) ? 'EVIDENCIA_SOLUCION_' + codigoConformidad + "_" + (contadorES++) :
(item.tipoEvidencia === 3) ? 'EVIDENCIA_ATS_' + codigoConformidad + "_" + (constadorATS++) :
(item.tipoEvidencia === 4) ? 'FIRMA_' + codigoConformidad + "_" + (contadorFirma++) : 'DATO_EXTRA_' + codigoConformidad + "_" + (contadorExtras++)
(item.tipoEvidencia === 4) ? 'EVIDENCIA_FIRMA_' + codigoConformidad + "_" + (contadorFirma++) :
(item.tipoEvidencia === 5) ? 'EVIDENCIA_MATERIALSOBRANTE_' + codigoConformidad + "_" + (contadorMaterialSobrante++) : 'EVIDENCIA_DATOEXTRA_' + codigoConformidad + "_" + (contadorExtras++)
};
});
......@@ -663,7 +647,8 @@ export class ConformidadComponent implements AfterViewInit {
accion: 1,
codlocal: datosPersonal.sedePersonal + '',
fechaRegistro: this.formatoFechaRegistro(new Date()),
descripcion: datosMaterialSobrante
descripcion: descripcionMaterial,
numordensalida : ordenSalidaMaterial
});
const respuestaOrdenSalida: any = JSON.parse(registroOrdenSalida);
......
import { Component, OnInit, ChangeDetectorRef, Renderer2, ElementRef, ViewChild, inject, QueryList, ViewChildren , Input } from '@angular/core';
import { Component, OnInit, ElementRef, ViewChild, inject, QueryList, ViewChildren , Input } from '@angular/core';
import {MatOption, provideNativeDateAdapter} from "@angular/material/core";
import {MatIconModule} from '@angular/material/icon';
import {FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
......@@ -10,7 +10,7 @@ import {MatFormField, MatHint, MatLabel, MatSuffix,MatFormFieldModule} from "@an
import {MatIcon} from "@angular/material/icon";
import {MatInput} from "@angular/material/input";
import {MatTooltip} from "@angular/material/tooltip";
import {DatePipe, NgForOf, NgIf, NgStyle} from "@angular/common";
import {NgForOf, NgIf, NgStyle} from "@angular/common";
import {
MatCell,
MatCellDef,
......@@ -26,21 +26,11 @@ import {SoloNumerosDirective} from "../../service/directivas_service/soloNumeros
import {MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition} from "@angular/material/snack-bar";
import {ConformidadHelper} from "../conformidad/helper/conformidad.helper";
import {MatDialog} from "@angular/material/dialog";
import { ConfirmarEliminacionComponent } from '../conformidad/modalEliminarPasaje/eliminarPasaje.componente';
import { modalArticuloOC } from '../conformidad/modalArticuloOC/modalArticuloOC.componente'
import {ConfirmarEliminacionComponent} from '../conformidad/modalEliminarPasaje/eliminarPasaje.componente';
import {modalArticuloOC} from '../conformidad/modalArticuloOC/modalArticuloOC.componente'
import {modalRequerimientoComponent} from "../conformidad/modalRequerimiento/modalRequerimiento.componente";
interface interArticulo{
index: number;
codigoArticulo : string;
nombre: string;
unidad: string;
cantidad: number;
estado : number; // 1 = BUENO ESTADO , 2 = OBSERVACIÓN , 3 = MAL ESTADO
isNew: boolean;
isEdit : boolean;
acciones: boolean;
}
import {truncarCaracteresDirective} from "../../service/directivas_service/restriccionCaracteres/truncarCaracteres.directive";
import {modalEvidenciaComponent} from "../conformidad/modalEvidencia/modalEvidencia.componente";
interface listaArticulos{
index: number,
......@@ -56,6 +46,11 @@ interface listadoComun {
nombre: string;
}
interface interFile{
tipoEvidencia: number;
file: File;
}
@Component({
selector: 'ordensalida-component',
templateUrl: './ordensalida.componente.html',
......@@ -106,26 +101,27 @@ interface listadoComun {
MatCardHeader,
MatCardTitle,
MatCardFooter,
truncarCaracteresDirective
]
})
export class ordenSalidaComponent implements OnInit {
@Input() datosDesdeConformidad: any; // Variable para recibir datos
private barraAlerta = inject(MatSnackBar);
alertaPosicionHorizontal: MatSnackBarHorizontalPosition = 'center';
alertaPosicionVertical: MatSnackBarVerticalPosition = 'bottom';
alertaDuracion: number = 3;
//FORM GROUP
public datos_materialSobrante: FormGroup = new FormGroup<any>({
descMaterial : new FormControl<String | null>(null,[Validators.maxLength(100)]),
numeroOrden : new FormControl<String | null>(null,[Validators.maxLength(6)]),
});
//FORM GROUP
// INICIALIZACION DATOS
alertaPosicionHorizontal: MatSnackBarHorizontalPosition = 'center';
alertaPosicionVertical: MatSnackBarVerticalPosition = 'bottom';
alertaDuracion : number = 3;
activarNuevoArticulo: boolean = true;
indexArticulo: number = 0;
public dataSource: listaArticulos[] = [];
......@@ -133,11 +129,11 @@ export class ordenSalidaComponent implements OnInit {
listEstadoArticulo: listadoComun[] = [];
columnasArticulos: string[] = ['nombre', 'unidad', 'cantidad', 'estado', 'accion'];
articulosList: any[] = [];
public archivosMaterial : interFile[] = [];
// INICIALIZACION DATOS
// OBTENER DATOS DEL FORM GROUP
formGroupMS(accion: number , formControlName : string , formControl : FormControl = new FormControl()): any {
if(accion === 1){
return this.datos_materialSobrante.addControl(formControlName, formControl);
}else if(accion === 2){
......@@ -150,29 +146,24 @@ export class ordenSalidaComponent implements OnInit {
constructor(
private conformidadHelper: ConformidadHelper,
private renderer: Renderer2,
private detectorChange : ChangeDetectorRef,
public dialog: MatDialog,
private datePipe: DatePipe,
) {
this.articulosList = [];
}
async ngOnInit(): Promise<void> {
this.dataSource = [];
this.archivosMaterial = [];
this.listUnidades = this.datosDesdeConformidad.map((item: any) => ({codigo: item.CODIGO , nombre: item.NOMBRE}));
this.listEstadoArticulo = [{ codigo: '1', nombre: 'VERDE'}, { codigo: '2', nombre: 'AMARILLO' },{ codigo: '3', nombre: 'ROJO' } ];
}
onEventoAgregarArticulo(event : any){
const dialogRef = this.dialog.open(modalArticuloOC,{
//width: '100%',
//height: '80%',
data: { Unidades : this.listUnidades , Estados : this.listEstadoArticulo , Editar: false }
});
dialogRef.afterClosed().subscribe(result => {
//console.log(result);
if(!result.Cancelado){
const NuevaFila : listaArticulos = {
......@@ -193,10 +184,7 @@ export class ordenSalidaComponent implements OnInit {
onEventoEditarArticulo(event: any, elemento : any) {
const DatoArticulo = this.dataSource.find((item) => item.index === elemento.index);
const dialogRef = this.dialog.open(modalArticuloOC, {
//width: '100%',
//height: '80%',
data: {Unidades: this.listUnidades, Estados: this.listEstadoArticulo , DatoArticulo , Editar: true}
});
......@@ -241,7 +229,55 @@ export class ordenSalidaComponent implements OnInit {
});
}
async onBusquedaArticulo(event: any , index : number) { // OMITIR LA BUSQUEDA POR AHORA YA QUE NO CONOCEN LOS ARTICULOS
onEventoSubirArchivo(event: any, tipo : number = 1) {
const archivosSeleccionados: FileList = event.target.files;
const nuevosArchivos = Array.from(archivosSeleccionados).filter(file => file.type === 'image/png' || file.type === 'image/jpeg');
nuevosArchivos.forEach(async (file) => {
if (!this.archivosMaterial.find((item) => item.file.name === file.name)) {
this.archivosMaterial.push({tipoEvidencia: tipo, file: file});
}
});
}
async gestionArchivos(index: number, accion : number, file : any = [], tipo : number = 1){
if(accion === 1){
const fileReader = new FileReader();
fileReader.onload = () => {
this.dialog.open(modalEvidenciaComponent, {
data: {
imageUrl: fileReader.result // Pasar la imagen al modal
}
});
};
fileReader.readAsDataURL(file); // Convertir el archivo a URL para mostrarlo
}else if(accion === 2){
const archivoSeleccionado = file.target.files[0]; // Obteniendo el File
//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.archivosMaterial.find((item) => item.file.name === archivoSeleccionado.name && item.tipoEvidencia === tipo)){
this.archivosMaterial[index].file = archivoSeleccionado;
}else{
this.barraAlerta.open( 'ARCHIVO YA SE ENCUENTRA EN LA LISTA' , '' , {
horizontalPosition: this.alertaPosicionHorizontal,
verticalPosition: this.alertaPosicionVertical,
duration: this.alertaDuracion * 1000
});
}
}
}else{
this.archivosMaterial.splice(index, 1); // Eliminar el archivo del array de archivosEP
}
}
/*async onBusquedaArticulo(event: any , index : number) { // OMITIR LA BUSQUEDA POR AHORA YA QUE NO CONOCEN LOS ARTICULOS
const busquedaArt = event.target.value;
......@@ -268,17 +304,15 @@ export class ordenSalidaComponent implements OnInit {
//SE BUSCA EL VALUE DENTRO DEL LISTADO DE ARTICULOS
const articulo = this.articulosList.find((item) => item.codigo === selectedOption);
//console.log(articulo);
//SE OPTIENE EL NOMBRE PARA PONERLO EN EL INPUT
this.formGroupMS(2,'articulo'+index)?.setValue(articulo.nombre);
this.formGroupMS(2,'codigoArticulo'+index)?.setValue(articulo.codigo);
this.formGroupMS(2,'unidad'+index)?.setValue(articulo.unidad);
// this.codigoUnidad = articulo.unidad;
//SE VUELVE A LIMPIAR EL LISTADO DE ARTICULOS PARA DEJAR PASO A OTRA FUTURA BUSQUEDA.
this.articulosList = [];
}
}*/
formatoEstado(estado: any) {
return this.listEstadoArticulo.find((item) => item.codigo === estado)?.nombre;
......
......@@ -411,7 +411,7 @@ export class ConformidadService {
unidad : json.unidad || '-',
cantidad : json.cantidad || 0,
estado : json.estado || 0,
numordensalida : json.numordensalida || ''
};
try {
......
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