anc.component.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { Component, OnInit, Input } from "@angular/core";
  2. import { InstrumentComponent } from "@app/components/investment-proposals/instrument/instrument.component";
  3. import { FormBuilder, FormGroup, Validators } from "@angular/forms";
  4. import { IAngularMyDpOptions, IMyDateModel } from "angular-mydatepicker";
  5. import { formatDate, DatePipe } from "@angular/common";
  6. import { Router } from "@angular/router";
  7. import { FormInvestmentProposalService } from "@app/services/form-investment-proposal.service";
  8. @Component({
  9. selector: "app-anc",
  10. templateUrl: "./anc.component.html"
  11. })
  12. export class ANCComponent implements InstrumentComponent {
  13. title: string = "Acciones nacionales comunes";
  14. @Input() data: any;
  15. form: any;
  16. // For daterange
  17. daysLabels: any = {
  18. su: "Dom",
  19. mo: "Lun",
  20. tu: "Mar",
  21. we: "Mie",
  22. th: "Jue",
  23. fr: "Vie",
  24. sa: "Sab"
  25. };
  26. monthsLabels: any = {
  27. 1: "Ene",
  28. 2: "Feb",
  29. 3: "Mar",
  30. 4: "Abr",
  31. 5: "May",
  32. 6: "Jun",
  33. 7: "Jul",
  34. 8: "Ago",
  35. 9: "Sep",
  36. 10: "Oct",
  37. 11: "Nov",
  38. 12: "Dic"
  39. };
  40. investmentProposalForm: FormGroup;
  41. myDpOptions: IAngularMyDpOptions = {
  42. dateRange: false,
  43. dateFormat: "dd/mm/yyyy",
  44. dayLabels: this.daysLabels,
  45. monthLabels: this.monthsLabels
  46. };
  47. myDateInit: boolean = true;
  48. model: IMyDateModel = null;
  49. constructor(
  50. private formBuilder: FormBuilder,
  51. private router: Router,
  52. private formDataService: FormInvestmentProposalService
  53. ) {
  54. console.log("init");
  55. this.investmentProposalForm = this.formBuilder.group({
  56. precio_limpio: ["", Validators.required],
  57. unidades: ["", Validators.required],
  58. comision_casa: ["", Validators.required],
  59. comision_bolsa: ["", Validators.required],
  60. fecha_operacion: ["", Validators.required],
  61. fecha_vencimiento: ["", Validators.required]
  62. });
  63. }
  64. save(form: any): boolean {
  65. /*if (!form.valid) {
  66. return false;
  67. }*/
  68. this.formDataService.setWork(this.investmentProposalForm.value);
  69. return true;
  70. }
  71. goToNext(form: any) {
  72. if (this.save(form)) {
  73. console.log("all good");
  74. // Navigate to the work page
  75. this.router.navigate(["/address"]);
  76. }
  77. }
  78. }