|
|
@@ -631,31 +631,31 @@ export class ModalCircularesEdit {
|
|
|
onFilesSelected(event: any) {
|
|
|
const files = event.target.files;
|
|
|
|
|
|
-
|
|
|
- for (let i = 0; i < files.length; i++) {
|
|
|
- const file = files[i];
|
|
|
- const reader = new FileReader();
|
|
|
-
|
|
|
- const uniqueId = this.generateUniqueId();
|
|
|
-
|
|
|
- reader.onload = (e: any) => {
|
|
|
- const base64String = e.target.result;
|
|
|
- this.adjuntos.push({
|
|
|
- id: uniqueId,
|
|
|
- nombre: file.name,
|
|
|
- tamanio: Math.round((file.size / 1000 * 10)) / 10,
|
|
|
- });
|
|
|
- console.log(this.adjuntos);
|
|
|
- this.bases64.push({
|
|
|
- id: uniqueId,
|
|
|
- nombre: file.name,
|
|
|
- base64: base64String
|
|
|
- });
|
|
|
|
|
|
- };
|
|
|
+ for (let i = 0; i < files.length; i++) {
|
|
|
+ const file = files[i];
|
|
|
+ const reader = new FileReader();
|
|
|
|
|
|
- reader.readAsDataURL(file);
|
|
|
- }
|
|
|
+ const uniqueId = this.generateUniqueId();
|
|
|
+
|
|
|
+ reader.onload = (e: any) => {
|
|
|
+ const base64String = e.target.result;
|
|
|
+ this.adjuntos.push({
|
|
|
+ id: uniqueId,
|
|
|
+ nombre: file.name,
|
|
|
+ tamanio: Math.round((file.size / 1000 * 10)) / 10,
|
|
|
+ });
|
|
|
+ console.log(this.adjuntos);
|
|
|
+ this.bases64.push({
|
|
|
+ id: uniqueId,
|
|
|
+ nombre: file.name,
|
|
|
+ base64: base64String
|
|
|
+ });
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
generateUniqueId(): string {
|
|
|
@@ -666,44 +666,52 @@ export class ModalCircularesEdit {
|
|
|
}
|
|
|
|
|
|
deleteIndex(i: number, archivo: any) {
|
|
|
- console.log('ruta', archivo);
|
|
|
+ Swal.fire({
|
|
|
+ title: '¿Está seguro que desea eliminar el archivo?',
|
|
|
+ icon: 'warning',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#d33',
|
|
|
+ confirmButtonText: 'Sí, eliminar',
|
|
|
+ cancelButtonText: 'Cancelar'
|
|
|
+ }).then((result) => {
|
|
|
+ if (result.isConfirmed) {
|
|
|
+ if (!archivo.ruta) {
|
|
|
+ this.adjuntos.splice(i, 1);
|
|
|
+ } else {
|
|
|
+ this.adjuntos.splice(i, 1);
|
|
|
+ const archivoEliminar = { idArchivo: archivo.id, url: archivo.ruta, idCircular: this.data.idCircular };
|
|
|
|
|
|
- if (!archivo.ruta) {
|
|
|
- console.log('entra');
|
|
|
- this.adjuntos.splice(i, 1);
|
|
|
- } else {
|
|
|
- console.log('entra2');
|
|
|
- this.adjuntos.splice(i, 1);
|
|
|
- archivo = { idArchivo: archivo.id, url: archivo.ruta, idCircular: this.data.idCircular };
|
|
|
- console.log('data', archivo);
|
|
|
+ Swal.fire({
|
|
|
+ title: 'Eliminando archivo...',
|
|
|
+ allowOutsideClick: false,
|
|
|
+ didOpen: () => {
|
|
|
+ Swal.showLoading();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- Swal.fire({
|
|
|
- title: 'Eliminando archivo...',
|
|
|
- allowOutsideClick: false,
|
|
|
- didOpen: () => {
|
|
|
- Swal.showLoading();
|
|
|
+ this.circularService.eliminarArchivo(archivoEliminar).subscribe((response: any) => {
|
|
|
+ Swal.close();
|
|
|
+ Swal.fire({
|
|
|
+ icon: 'success',
|
|
|
+ title: `${response.mensaje}`,
|
|
|
+ });
|
|
|
+ }, (err) => {
|
|
|
+ Swal.close();
|
|
|
+ console.error('Error al eliminar el archivo:', err);
|
|
|
+ Swal.fire({
|
|
|
+ icon: 'error',
|
|
|
+ title: `${err.error.mensaje}`,
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- this.circularService.eliminarArchivo(archivo).subscribe((response: any) => {
|
|
|
- Swal.close();
|
|
|
- Swal.fire({
|
|
|
- icon: 'success',
|
|
|
- title: `${response.mensaje}`,
|
|
|
- });
|
|
|
- }, (err) => {
|
|
|
- Swal.close();
|
|
|
- console.error('Error al eliminar el archivo:', err);
|
|
|
- Swal.fire({
|
|
|
- icon: 'error',
|
|
|
- title: `${err.error.mensaje}`,
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public horasDelDia: any = this.generarHorasDelDia();
|
|
|
generarHorasDelDia(): { hora24: string, hora12: string }[] {
|
|
|
const horas: { hora24: string, hora12: string }[] = [];
|