|
|
@@ -1,12 +1,13 @@
|
|
|
import { Component, ElementRef, Inject, Input, OnInit, ViewChild } from '@angular/core';
|
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|
|
-import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
+import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { lastValueFrom, Subscription } from 'rxjs';
|
|
|
import { GETBGMService } from 'src/app/services/getb/getbgm/getbgm.service';
|
|
|
import { GetbmeService } from 'src/app/services/getb/getbme/getbme.service';
|
|
|
import { GETBSMService } from 'src/app/services/getb/getbsm/getbsm.service';
|
|
|
import { ValidationsService } from 'src/app/services/validations.service';
|
|
|
+import { GetbmeSubirImagenComponent } from '../getbme-subir-imagen/getbme-subir-imagen.component';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-getbme-form',
|
|
|
@@ -18,26 +19,33 @@ export class GetbmeFormComponent implements OnInit {
|
|
|
public isLoadingComponent: boolean = false;
|
|
|
|
|
|
submodulos: SubmoduloResponse[] = []
|
|
|
-
|
|
|
+
|
|
|
@ViewChild("foto", {
|
|
|
read: ElementRef
|
|
|
}) foto!: ElementRef;
|
|
|
|
|
|
- name_menu: string = ''
|
|
|
- img_menu: string = ''
|
|
|
- submodule: string = ''
|
|
|
+ // name_menu: string = ''
|
|
|
+ // img_menu: string = ''
|
|
|
+ // submodule: string = ''
|
|
|
|
|
|
constructor(
|
|
|
private _moduloService: GETBGMService,
|
|
|
private _submoduleService: GETBSMService,
|
|
|
private _router: Router,
|
|
|
+ public dialog: MatDialog,
|
|
|
private _validations: ValidationsService,
|
|
|
private _menu: GetbmeService,
|
|
|
+
|
|
|
public dialogRef: MatDialogRef<any>,
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
|
) {
|
|
|
this.formGroup = this.createFromGroup();
|
|
|
this.obtenerSubmodulos()
|
|
|
+
|
|
|
+ console.log("Data del formulario principal");
|
|
|
+
|
|
|
+ console.log(data);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
ngOnInit(): void { }
|
|
|
@@ -66,37 +74,32 @@ export class GetbmeFormComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async registar() {
|
|
|
- let datos: any = {
|
|
|
- name_menu: this.name_menu,
|
|
|
- img_menu: this.img_menu,
|
|
|
- submodule: this.submodule
|
|
|
+ openDialogSubirImagen(){
|
|
|
+ let dataAction = {
|
|
|
+ name_menu: this.name_menu?.value,
|
|
|
+ submodule: this.submodule?.value,
|
|
|
+ action: this.data.action,
|
|
|
+ menu_code: this.data.data.CODIGO_MENU
|
|
|
}
|
|
|
- console.log(datos);
|
|
|
+ const dialogRef = this.dialog.open(GetbmeSubirImagenComponent, {
|
|
|
+ data: dataAction,
|
|
|
+ width: '350px',
|
|
|
+ disableClose: true,
|
|
|
|
|
|
- if (this.data.action == 'registro') {
|
|
|
- await lastValueFrom(this._menu.postMenu(datos)).then(
|
|
|
- (value: any) => {
|
|
|
- if (value.error == false) {
|
|
|
- this._router.navigate(['sam/getbme'])
|
|
|
- }
|
|
|
- }, (error: any) =>
|
|
|
- this._validations.verificarErrores(error)
|
|
|
- )
|
|
|
- this._router.navigate(['sam/getbme'])
|
|
|
- } else {
|
|
|
- await lastValueFrom(this._menu.updateMenu(datos)).then(
|
|
|
- (value: any) => {
|
|
|
- if (value.error == false) {
|
|
|
- this._router.navigate(['sam/getbme'])
|
|
|
- }
|
|
|
- }, (error: any) =>
|
|
|
- this._validations.verificarErrores(error)
|
|
|
- )
|
|
|
- this._router.navigate(['sam/getbme'])
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ get name_menu() {
|
|
|
+ return this.formGroup.get('name_menu')
|
|
|
+ }
|
|
|
+
|
|
|
+ get img_menu() {
|
|
|
+ return this.formGroup.get('img_menu')
|
|
|
+ }
|
|
|
+
|
|
|
+ get submodule() {
|
|
|
+ return this.formGroup.get('submodule')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export interface ModuloResponse {
|