Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. interface IViajesConcluidos{
  2. idViaje: number;
  3. cliente: string;
  4. conductor: string;
  5. descripcion: string;
  6. costo: number;
  7. fechaRegistro: string;
  8. fechaEntrega: string;
  9. estatusPago: string;
  10. }
  11.  
  12. export class ViajesProgramadosComponent implements OnInit {
  13. //VARIABLES GENERALES
  14. public arregloViajes: IViajesConcluidos[];
  15. public usuarioObtenido:string;
  16. public closeResult: string;
  17. public modal: NgbModalRef;
  18. //VARIABLES PARA EL FORMULARIO
  19. public frmViajes: FormGroup;
  20. public formValid:Boolean=false;
  21.  
  22. constructor(private modalService: NgbModal, public formBuilder: FormBuilder, public formatoFecha: DateFormatService,public router:Router) {
  23. //DATOS DE INICIO
  24. this.arregloViajes=[];
  25.  
  26. //INICIALIZACION (CONSTRUCCION) DEL FORMGROUP
  27. this.frmViajes = this.formBuilder.group({
  28. cliente:["",Validators.required],
  29. descripcion:["",Validators.required],
  30. costo:["",Validators.required]
  31. });
  32. }
  33. //PASO LOS DATOS POR PARAMETRO
  34. pasarDatos(idViaje:number){
  35. alert(idViaje);
  36. let registro = this.arregloViajes[idViaje-1];
  37. this.router.navigate(['/viajes-concluidos'],{queryParams:{arregloViajes: JSON.stringify(registro)}});
  38. this.arregloViajes.splice(idViaje,1);
  39. }
  40. ngOnInit() {
  41. this.obtenerLocalStorage();
  42. this.generarFecha();
  43.  
  44. }
  45. }
  46.  
  47. interface IViajesConcluidos{
  48. idViaje: number;
  49. cliente: string;
  50. conductor: string;
  51. descripcion: string;
  52. costo: number;
  53. fechaRegistro: string;
  54. fechaEntrega: string;
  55. estatusPago: string;
  56. }
  57.  
  58. export class ViajesConcluidosComponent implements OnInit {
  59. public viajesC: IViajesConcluidos[];
  60. public usuarioObtenido:string;
  61. public viajes:Array<any>;
  62. constructor(public router:Router, public activeRoute:ActivatedRoute ) {
  63. this.viajesC=[];
  64. this.viajesC.push(
  65. {idViaje:5,cliente:'Juan',conductor:"Miguel Diaz",descripcion:"Es fragil",costo:1000,fechaRegistro:'12-05-2019',fechaEntrega:'18-05-2019',estatusPago:'pagado'}
  66. );
  67. //this.viajes.push({idViaje:2,cliente:'Pedro',conductor:"Jose Diaz",descripcion:"Es fragil",costo:2000,fechaRegistro:'12-06-2019',fechaEntrega:'10-06-2019',estatusPago:'pagado'});
  68. }
  69. //AQUI SE PRESENTA EL PROBLEMA
  70. ngOnInit() {
  71. this.activeRoute.queryParams.subscribe(queryParams => {
  72. alert(JSON.stringify(queryParams)); //ME IMPRIME BIEN LOS DATOS EN EL ALERT
  73. this.viajesC = JSON.parse(queryParams.arregloViajes); //ESTA PARTE ES LO QUE NO FUNCIONA
  74. });
  75. }
  76.  
  77. }
  78.  
  79. <table id="customers" border="1" class="w3-table-all w3-hoverable">
  80. <tr class="w3-black">
  81. <th>ID Viaje</th>
  82. <th>Cliente</th>
  83. <th>Conductor</th>
  84. <th>Descripcion</th>
  85. <th>Costo $MXN</th>
  86. <th>Fecha Registro</th>
  87. <th>Fecha Entrega</th>
  88. <th>Estatus de pago</th>
  89. </tr>
  90. <tbody id="idTabla" *ngFor="let i of viajesC | filter:term">
  91. <tr>
  92. <td>
  93. {{i.idViaje}}
  94. </td>
  95. <td>
  96. {{i.cliente}}
  97. </td>
  98. <td>
  99. {{i.conductor}}
  100. </td>
  101. <td>
  102. {{i.descripcion}}
  103. </td>
  104. <td>
  105. {{i.costo}}
  106. </td>
  107. <td>
  108. {{i.fechaRegistro}}
  109. </td>
  110. <td>
  111. {{i.fechaEntrega}}
  112. </td>
  113. <td>
  114. {{i.estatusPago}}
  115. </td>
  116. </tr>
  117. </tbody>
  118. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement