Advertisement
coffeecode12

component jaminan ts

Jun 8th, 2022
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
  2. import { MatPaginator } from '@angular/material/paginator';
  3. import { MatSort } from '@angular/material/sort';
  4. import { MatTableDataSource } from '@angular/material/table';
  5. import { UserData, DataService } from '../data.service';
  6. import { SelectionModel } from '@angular/cdk/collections';
  7. import { CoverNoteService } from 'src/app/services/cover-note.service';
  8. import { HttpErrorResponse } from '@angular/common/http';
  9. import { TglPlusSatu } from 'src/app/services/tglplussatu';
  10. import icEye from '@iconify/icons-ic/twotone-remove-red-eye';
  11. import icMoreHoriz from '@iconify/icons-ic/twotone-more-horiz';
  12. import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
  13. import icSearch from '@iconify/icons-ic/twotone-search';
  14. import icFile from '@iconify/icons-ic/sharp-file-open';
  15. import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
  16. import { DialogJaminanComponent } from '../dialog-jaminan/dialog-jaminan.component';
  17. @Component({
  18.   selector: 'app-tables',
  19.   templateUrl: './tables.component.html',
  20.   styleUrls: ['./tables.component.scss']
  21. })
  22. export class TablesComponent implements OnInit {
  23.   icEye = icEye;
  24.   icFile = icFile
  25.   icSearch= icSearch
  26.   icMoreHoriz = icMoreHoriz;
  27.   loadingPage: boolean = true;
  28.   pesanError: string;
  29.   isToastGagal: boolean;
  30.   isToastSukses: boolean;
  31.   tglMulai: string = '';
  32.   tglAkhir: string = '';
  33.   size: string = '20';
  34.   page: string = '1';
  35.   tglFilter: any = { startDate: '1990-12-25', endDate: '1990-12-25' };
  36.   sliceAwal: number = 0;
  37.   sliceAkhir: number = 10;
  38.   pageSize: number = 100;
  39.   id: string = '';
  40.   arrayAdendum: any[] = [{}];
  41.   isAddAdendum: boolean = true;
  42.   tampungSession: any;
  43.   tglStart: any;
  44.   blnStart: any;
  45.   thnStart: any;
  46.   tbls:any[] = []
  47.   tglEnd: any;
  48.   hariStart: string;
  49.   blnEnd: any;
  50.   thnEnd: any;
  51.   debounceTimer:any;
  52.   hariEnd: string;
  53.   tglMulaiDepan: string;
  54.   tglAkhirDepan: string;
  55.   search:any;
  56.   debounceTime = 500;
  57.   ShiftForm:FormGroup
  58.   endDate:any;
  59.   startDate:any
  60.  
  61.  
  62.  
  63.   constructor(private readonly dataService: DataService, private HelperTglDefault: TglPlusSatu,
  64.     private dashboardCovernote: CoverNoteService, private formBuilder: FormBuilder, public dialog: MatDialog) {
  65.    
  66.     localStorage.removeItem('LSparameter');
  67.     localStorage.removeItem('isLogs');
  68.     // this.tglMulai = this.HelperTglDefault.defaultThnMinusSatu(this.tglMulai)
  69.     this.tglMulai = '01/01/2018';
  70.     this.tglAkhir = this.HelperTglDefault.defaultTglHariIni(this.tglMulai);
  71.     this.tglFilter = this.HelperTglDefault.generateTglUtkFilter(this.tglFilter);
  72.    
  73.   }
  74.  
  75.  
  76.   ngOnInit() {
  77.     this.getNew();
  78.    this.initForm()
  79.  
  80.    this.startDate = new FormControl(new Date());
  81.    this.endDate = new FormControl(new Date());
  82.  
  83.  
  84.   }
  85.  
  86.   get f() {
  87.     return this.ShiftForm.controls;
  88.   }
  89.  
  90.  
  91.   initForm(){
  92.     this.ShiftForm = this.formBuilder.group({
  93.       startDate : new FormControl(new Date()),
  94.       endDate : new FormControl(new Date())
  95.     })
  96.     this.ShiftForm.get('startDate').patchValue(this.formatDate(new Date()));
  97.     this.ShiftForm.get('endDate').patchValue(this.formatDate(new Date()));
  98.   }
  99.  
  100.   private formatDate(date) {
  101.     const d = new Date(date);
  102.     let month = '' + (d.getMonth() + 1);
  103.     let day = '' + d.getDate();
  104.     const year = d.getFullYear();
  105.     if (month.length < 2) month = '0' + month;
  106.     if (day.length < 2) day = '0' + day;
  107.     return [year, month, day].join('-');
  108.   }
  109.  
  110.  
  111.   selectTampilakanData(event: any) {
  112.     this.size = event.target.value;
  113.   }
  114.  
  115.   gantiFormatTgl1(evt: any) {
  116.     let formatTglAngular = new Date(evt.target.value);
  117.     let year = formatTglAngular.getFullYear();
  118.     let month = formatTglAngular.getMonth() + 1;
  119.     let day = formatTglAngular.getDate();
  120.     let Hari = day.toString();
  121.     let Bln = month.toString();
  122.     if (Hari.length === 1) {
  123.       Hari = '0' + Hari;
  124.     }
  125.     if (Bln.length === 1) {
  126.       Bln = '0' + Bln;
  127.     }
  128.     this.tglFilter.startDate = year + '-' + Bln + '-' + Hari;
  129.     this.tglMulai = year + '/' + Bln + '/' + Hari;
  130.   }
  131.  
  132.  
  133.  
  134.   detailDataBank(id) {
  135.     // this.router.navigate([this.router.url + '/detail-data-bank/' + id]);
  136.   }
  137.  
  138.  
  139.   getNew() {
  140.     this.tglStart = this.tglMulai.slice(3, 5);
  141.     this.blnStart = this.tglMulai.slice(0, 2);
  142.     this.thnStart = this.tglMulai.slice(6, 10);
  143.     this.tglMulaiDepan =
  144.       this.thnStart + '-' + this.blnStart + '-' + this.tglStart;
  145.     this.tglEnd = this.tglAkhir.slice(3, 5);
  146.     this.blnEnd = this.tglAkhir.slice(0, 2);
  147.     this.thnEnd = this.tglAkhir.slice(6, 10);
  148.     this.tglAkhirDepan = this.thnEnd + '-' + this.blnEnd + '-' + this.tglEnd;
  149.     this.loadingPage = true;
  150.     this.dashboardCovernote
  151.       .getTblDashboardCovernote(
  152.         this.tglMulai,
  153.         this.tglAkhir,
  154.         this.page,
  155.         this.size
  156.       )
  157.       .subscribe(
  158.         (data) => {
  159.           this.tbls = data;
  160.           this.loadingPage = false
  161.           console.log(this.tbls)
  162.         },
  163.         (error: HttpErrorResponse) => {
  164.           if (error.status === 401) {
  165.             this.pesanError = '401 Unauthorized';
  166.           } else if (error.status === 403) {
  167.             this.pesanError = '403 Tidak Di Izinkan';
  168.           } else if (error.status === 408) {
  169.             this.pesanError = '408 Request Timeout';
  170.           } else if (error.status === 400) {
  171.             this.pesanError = '400 Java Springboot Error';
  172.           } else {
  173.             this.pesanError = 'Koneksi Buruk';
  174.           }
  175.           // this.isToastGagal = true;
  176.           // setTimeout(() => {
  177.           //   this.isToastGagal = false;
  178.           // }, 5000);
  179.         }
  180.       );
  181.   }
  182.  
  183.   btnFilter() {
  184.     this.tglStart = this.tglMulaiDepan.slice(8, 10);
  185.     this.blnStart = this.tglMulaiDepan.slice(5, 7);
  186.     this.thnStart = this.tglMulaiDepan.slice(0, 4);
  187.     this.hariStart = this.blnStart + '/' + this.tglStart + '/' + this.thnStart;
  188.  
  189.     this.tglEnd = this.tglAkhirDepan.slice(8, 10);
  190.     this.blnEnd = this.tglAkhirDepan.slice(5, 7);
  191.     this.thnEnd = this.tglAkhirDepan.slice(0, 4);
  192.     this.hariEnd = this.blnEnd + '/' + this.tglEnd + '/' + this.thnEnd;
  193.     this.tglMulai = this.HelperTglDefault.defaultThnMinusSatu(this.tglMulai);
  194.     this.loadingPage = true;
  195.  
  196.     this.dashboardCovernote
  197.       .getTblDashboardCovernote(
  198.         this.hariStart,
  199.         this.hariEnd,
  200.         this.page,
  201.         this.size
  202.       )
  203.       .subscribe(
  204.         (data) => {
  205.           this.tbls = data;
  206.           this.loadingPage = false
  207.         },
  208.         (error: HttpErrorResponse) => {
  209.           if (error.status === 401) {
  210.             this.pesanError = '401 Unauthorized';
  211.           } else if (error.status === 403) {
  212.             this.pesanError = '403 Tidak Di Izinkan';
  213.           } else if (error.status === 408) {
  214.             this.pesanError = '408 Request Timeout';
  215.           } else if (error.status === 400) {
  216.             this.pesanError = '400 Java Springboot Error';
  217.           } else {
  218.             this.pesanError = 'Koneksi Buruk';
  219.           }
  220.           this.isToastGagal = true;
  221.           setTimeout(() => {
  222.             this.isToastGagal = false;
  223.           }, 5000);
  224.         }
  225.       );
  226.   }
  227.  
  228.   onInputSearch(value: string) {
  229.     const input = value;
  230.     clearTimeout(this.debounceTimer);
  231.     this.debounceTimer = setTimeout(() => {
  232.       this.search = input;
  233.       this.getNew();
  234.     }, this.debounceTime);
  235.   }
  236.  
  237.   dialogJumlahRekening(id:any) {
  238.     const index = this.tbls.findIndex(item => item['jumlahRekeningSelish'] === id);
  239.     const modelData = this.tbls[id];
  240.     const dialogConfig = new MatDialogConfig();
  241.     dialogConfig.disableClose = true;
  242.     dialogConfig.width = '1200px';
  243.     dialogConfig.data = {
  244.         function: 'Edit',
  245.         id,      
  246.     };
  247.     const dialogRef = this.dialog.open(DialogJaminanComponent, dialogConfig);
  248.     dialogRef.afterClosed().subscribe(result => {
  249.       if (result == true) {
  250.       }
  251.     });
  252.     }
  253.  
  254.  
  255.    
  256.  
  257.  
  258.  
  259. }
  260.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement