| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- import {
- Component,
- OnInit,
- Input,
- ViewChild,
- ComponentFactoryResolver
- } from "@angular/core";
- import { Router } from "@angular/router";
- import { InvestmentProposalForm } from "@app/models/investment-proposal-form";
- import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
- import { Instrument } from "@app/models/instrument";
- import { InvestmentProposalWorkflowService } from "@app/services/investment-proposal-workflow.service";
- import { InstrumentDirective } from "../instrument/instrument.directive";
- import { InstrumentComponent } from "../instrument/instrument.component";
- import { InstrumentsService } from "@app/services/instruments.service";
- import Swal from "sweetalert2";
- @Component({
- selector: "app-investment-proposal-review",
- templateUrl: "./review.component.html",
- styleUrls: ["./review.component.scss"]
- })
- export class InvestmentProposalReviewComponent implements OnInit {
- title = "Revisión de propuesta";
- @Input() ads: Instrument[];
- @Input() formData: InvestmentProposalForm;
- @ViewChild(InstrumentDirective, { static: true })
- adHost: InstrumentDirective;
- isFormValid: boolean = false;
- general: any;
- instrument: any;
- complement: any;
- final: any;
- workType: string;
- form: any;
- currentAdIndex = -1;
- interval: any;
- indexDynamicComponent: number;
- constructor(
- private router: Router,
- private formDataService: FormInvestmentProposalService,
- private componentFactoryResolver: ComponentFactoryResolver,
- private instrumentService: InvestmentProposalWorkflowService,
- private loadInstrumentsService: InstrumentsService
- ) {}
- ngOnInit() {
- this.formData = this.formDataService.getFormData();
- this.isFormValid = this.formDataService.isFormValid();
- this.ads = this.loadInstrumentsService.getInstruments();
- this.formData.instrumentos;
- this.indexDynamicComponent = this.ads.findIndex(
- x => x.component.name == this.formData.instrumentos
- );
- if (this.indexDynamicComponent >= 0) {
- this.loadComponent();
- } else {
- console.log("No existe el componente");
- }
- this.general = this.formDataService.getGeneralInfo();
- this.instrument = this.formDataService.getWork();
- this.complement = this.formDataService.getComplementInfo();
- this.final = {};
- Object.assign(this.final, this.general, this.instrument, this.complement);
- console.log("Result feature loaded!");
- console.log(this.final);
- }
- loadComponent() {
- this.currentAdIndex = this.indexDynamicComponent % this.ads.length;
- const adItem = this.ads[this.currentAdIndex];
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(
- adItem.component
- );
- const viewContainerRef = this.adHost.viewContainerRef;
- viewContainerRef.clear();
- const componentRef = viewContainerRef.createComponent(componentFactory);
- (<InstrumentComponent>componentRef.instance).data = adItem.data;
- (<InstrumentComponent>componentRef.instance).summary = true;
- }
- approve_proposal() {
- (async () => {
- const { value: formValues } = await Swal.fire({
- title: "<h3>Aprobar propuesta de inversión</h3>",
- icon: "info",
- input: "textarea",
- showCancelButton: true,
- confirmButtonText: "Aprobar propuesta",
- cancelButtonText: "Cancelar",
- inputValidator: value => {
- if (!value) {
- return "Debe ingresar un comentario";
- }
- }
- });
- if (formValues) {
- Swal.fire(JSON.stringify(formValues));
- }
- })();
- }
- dismiss_proposal() {
- (async () => {
- const { value: formValues } = await Swal.fire({
- title: "<h3>Rechazar propuesta de inversión</h3>",
- icon: "info",
- input: "textarea",
- showCancelButton: true,
- confirmButtonText: "Rechazar propuesta",
- confirmButtonColor: "#C82333",
- cancelButtonText: "Cancelar",
- inputValidator: value => {
- if (!value) {
- return "Debe ingresar un comentario";
- }
- }
- });
- if (formValues) {
- Swal.fire(JSON.stringify(formValues));
- }
- })();
- }
- }
|