plant.component.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { Component, OnInit } from '@angular/core';
  2. import { FormBuilder, FormGroup, Validators } from '@angular/forms';
  3. import { PlantsService } from '@app/services/plants.service';
  4. import { ActivatedRoute } from '@angular/router';
  5. import Swal from 'sweetalert2';
  6. @Component({
  7. selector: 'app-plant',
  8. templateUrl: './plant.component.html',
  9. styleUrls: ['./plant.component.scss']
  10. })
  11. export class PlantComponent implements OnInit {
  12. [x: string]: any;
  13. title:string = "Detalle de la planta";
  14. listPlant: any;
  15. organizationExists:boolean;
  16. assetForm: FormGroup;
  17. assetID:any;
  18. role_number: any;
  19. assetExists:boolean;
  20. distributor = ['CAESS', 'DEL SUR', 'AES-CLESA', 'EEO', 'DEUSEM'];
  21. categoria_tarifaria = [
  22. { key: "PD", value: "PD Pequeña Demanda" },
  23. { key: "MD", value: "MD Mediana Demanda" },
  24. { key: "GD", value: "GD Gran Demanda" }
  25. ];
  26. codigo_tarifa = [
  27. { key:"R", value: "R Residencial" },
  28. { key:"G", value: "G General" },
  29. { key:"AP", value: "AP Alumbrado Público" },
  30. { key:"MD CMP - BT" ,value: "MD CMP-BT Mediana Demanda Con Medicion de Potencia Baja Tensión" },
  31. { key:"MD CMP - MT" ,value: "MD CMP-MT Mediana Demanda Con Medicion de Potencia Media Tensión" },
  32. { key:"MD CMH - BT" ,value: "MD CMH-BT Mediana Demanda Con Medicion Horaria Baja Tensión" },
  33. { key:"MD CMH - MT" ,value: "MD CMH-MT Mediana Demanda Con Medicion Horaria Media Tensión" },
  34. { key:"GD CMH - BT", value: "GD CMH-BT Gran Demanda Con Medicion Horaria Baja Tensión" },
  35. { key:"GD CMH - MT", value: "GD CMH-MT Gran Demanda Con Medicion Horaria Media Tensión" }
  36. ];
  37. constructor(private plantsService: PlantsService, private formBuilder: FormBuilder, private route: ActivatedRoute) {
  38. this.route.params.subscribe(params => {
  39. this.assetID = params['id'];
  40. });
  41. this.plantsService.getAssetById(this.assetID).subscribe(res => {
  42. this.listPlant = res["data"]["asset"];
  43. this.organizationExists = true;
  44. this.assetForm = this.formBuilder.group({
  45. name: [this.listPlant.name],
  46. country: [this.listPlant.country],
  47. city: [this.listPlant.city],
  48. address: [this.listPlant.address],
  49. distribuidora: [this.listPlant.distribuidora],
  50. categoria_tarifaria: [this.listPlant.categoria_tarifaria],
  51. cod_tarifa: [this.listPlant.cod_tarifa],
  52. });
  53. this.assetExists = true;
  54. }, (err) => {
  55. Swal.fire({
  56. type: 'error',
  57. title: 'Error en el servidor',
  58. text: err.message
  59. });
  60. });
  61. }
  62. ngOnInit() {
  63. }
  64. }