Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import icDoneAll from '@iconify/icons-ic/twotone-done-all';
- import icArrowDownward from '@iconify/icons-ic/arrow-downward';
- import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
- import icAdd from '@iconify/icons-ic/twotone-add';
- import icSearch from '@iconify/icons-ic/twotone-search';
- import icMoreHoriz from '@iconify/icons-ic/twotone-more-horiz';
- import icEdit from '@iconify/icons-ic/twotone-edit';
- import icAccess from '@iconify/icons-ic/twotone-dns';
- import icPageView from '@iconify/icons-ic/twotone-pageview';
- import { samplingVoucherList } from 'src/app/shared/services/uji-tuntas/config';
- import { SamplingCabangComponent } from './sampling-cabang/sampling-cabang.component';
- import icDelete from '@iconify/icons-ic/twotone-delete';
- import { RepositoryService } from 'src/app/shared/services/repository.service';
- import { TableRequest } from './model/simulasi-jumlah-sampling.model';
- import { UjiTuntasService } from 'src/app/shared/services/uji-tuntas/uji-tuntas.service';
- import { MatSnackBar } from '@angular/material/snack-bar';
- import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
- import { ActivatedRoute } from '@angular/router';
- import icUploadFile from '@iconify/icons-ic/twotone-cloud-upload';
- import { DocumentFormModel } from '../../model/detail-uji-tuntas.model';
- @Component({
- selector: 'vex-simulasi-jumlah-sampling',
- templateUrl: './simulasi-jumlah-sampling.component.html',
- styleUrls: ['./simulasi-jumlah-sampling.component.scss']
- })
- export class SimulasiJumlahSamplingComponent implements OnInit {
- icDoneAll = icDoneAll;
- icArrowDownward = icArrowDownward;
- icUploadFile = icUploadFile;
- isConfirmation = false;
- formModel: DocumentFormModel = {} as DocumentFormModel;
- public rows: Array<object> = [];
- public columns: Array<object>;
- public pageSize: number;
- public recordsTotal: number = 0;
- public paramRequest: TableRequest;
- public isLoading = true;
- icSearch = icSearch;
- icAdd = icAdd;
- icMoreHoriz = icMoreHoriz;
- icEdit = icEdit;
- icDelete = icDelete;
- icAccess = icAccess;
- icPageView = icPageView;
- selectRow: any;
- sort: string;
- search: string;
- token: string;
- listAttribute: any;
- debounceTimer: any;
- debounceTime = 500;
- typeId: any;
- idAttr:any
- asumsiNominalForm:FormGroup;
- submitted = false;
- sortField: string;
- index: any;
- colsName: any = [];
- load= false
- currentLink: string;
- previousLink: string;
- rootLink: string;
- crumbsValue: any[] = [];
- idSelect:any
- isCheckedEdit:boolean= false
- public last:any = 0;
- constructor(
- private repositoryService: RepositoryService,
- private ujituntasService: UjiTuntasService,
- public dialog: MatDialog,
- private snackbar: MatSnackBar,
- private formBuilder: FormBuilder,
- private route: ActivatedRoute,
- ) {
- this.route.params.subscribe((params) => {
- this.idSelect = params['id'];
- localStorage.setItem('id',this.idSelect)
- });
- }
- ngOnInit(): void {
- console.log('window.location.href : ', window.location.href);
- // init route
- this.currentLink = window.location.pathname;
- this.previousLink = this.currentLink.split('simulasi-jumlah-sampling')[0];
- this.rootLink = this.previousLink.split('detail-uji-tuntas')[0];
- this.crumbsValue = [
- { label: 'GPEB', route: this.rootLink },
- { label: 'Perencanaan Uji Tuntas', route: this.rootLink },
- { label: 'Data BDPI dan BDPK', route: this.rootLink },
- { label: 'Detail Uji Tuntas', route: this.previousLink.split('atur-tim-uji-tuntas')[0] },
- { label: 'Atur Tim Uji Tuntas', route: this.previousLink },
- { label: 'Simulasi Jumlah Sampling', route: this.currentLink },
- ];
- this.sortField = 'no Rekening';
- this.idAttr =''
- this.token = localStorage.getItem('token');
- this.columns = [
- { name: 'No Rekening', field: 'no Rekening' },
- { name: 'No Nasabah', field: 'no Nasabah"' },
- { name: 'Nama Kantor', field: 'nama Kantor' },
- { name: 'Kd Kualitas', field: 'kd Kualitas' },
- { name: 'Jumlah Bulan Laporan Net', field: 'jumlah Bulan Laporan Net' },
- { name: 'Kd Gol Nasabah', field: 'kdGolNasabah' },
- { name: 'Gol Nasabah', field: 'golNasabah' },
- { name: 'Jenis Penggunaan', field: 'jenisPenggunaan' },
- { name: 'Jenis Kredit', field: 'jenis_Kredit' },
- { name: 'Jenis Valuta', field: 'jenisValuta' },
- ];
- this.pageSize = 10;
- this.paramRequest = {
- start: 0,
- length: this.pageSize,
- };
- // this.getDataJson(this.paramRequest)
- this.getAttribute();
- this.initForm();
- }
- get f() {
- return this.asumsiNominalForm.controls;
- }
- form: FormGroup = new FormGroup({
- name: new FormControl('',Validators.required),
- samplingSaldo: new FormControl('', Validators.required),
- keterangan: new FormControl(''),
- });
- initForm() {
- this.asumsiNominalForm = this.formBuilder.group({
- // name:['',[Validators.required]],
- isCheckedEdit: [false],
- samplingSaldo: ['', [Validators.required]],
- keterangan: [''],
- });
- {
- this.f.samplingSaldo.setValue('');
- this.f.keterangan.setValue('');
- this.f.isCheckedEdit.setValue(this.isCheckedEdit ? this.isCheckedEdit : false);
- }
- }
- onClear() {
- this.asumsiNominalForm.reset();
- this.idAttr= ''
- }
- onSubmit() {
- console.log('check', this.asumsiNominalForm, this.asumsiNominalForm.valid);
- this.submitted = true;
- if (this.asumsiNominalForm.invalid) {
- return;
- } else {
- this.isConfirmation = true;
- }
- }
- postAsumsiNominal() {
- let reqBody = {
- samplingSaldo:this.f.samplingSaldo.value,
- id: this.idAttr ? this.idAttr : '',
- keterangan: this.f.keterangan.value,
- }
- this.repositoryService.postDataWithToken(samplingVoucherList.asumsiNominal, reqBody, this.token, null).subscribe((data: any) => {
- this.snackbar.open(data.detail, data.message, {
- duration: 10000,
- });
- if (data.status === 200) {
- // this.dialogRef.close('Add OK');
- console.log('Add OK')
- }
- (err: any) => {
- console.log('error', err);
- this.snackbar.open('Opsss.. ' + err.name, 'Error', {
- duration: 10000,
- });
- }
- },
- )
- }
- list_att :any = [];
- objectValue:any
- onChangeUser(evt:Event) {
- const index = this.listAttribute.findIndex(item => item['id'] === evt);
- const modelDataUser = this.listAttribute[index];
- this.idAttr = modelDataUser.name
- this.objectValue = modelDataUser.id
- this.list_att.push(this.idAttr)
- console.log(this.idAttr,modelDataUser.id)
- // this.listAttribute.map(items => {
- // this.list_att.push(this.idAttr,modelDataUser.id)
- // console.log(items.id,items.name)
- // })
- }
- removeListAttr(index:number){
- this.list_att.splice(index, 1);
- console.log(index)
- }
- getAttribute() {
- this.isLoading = true;
- this.repositoryService.getDataWithToken(samplingVoucherList.attribut, this.token).subscribe(
- (value: any) => {
- this.listAttribute = value.data;
- this.idAttr =value.data.id
- this.isLoading = false;
- }, error => {
- this.isLoading = false;
- console.log('error', error);
- this.snackbar.open("Opss.. "+error['name'], 'Error', {
- duration: 7000
- });
- }
- );
- }
- getDataJson(param: TableRequest) {
- this.isLoading = true;
- const index = this.index ? this.index : 0;
- const formData = new FormData();
- formData.append('start', param.start.toString());
- formData.append('length', param.length.toString());
- formData.append('search[value]', this.search ? this.search.toString() : '');
- formData.append('search[regex]', 'false');
- formData.append('columns['+index+'][data]', index+1);
- formData.append('columns['+index+'][orderable]', 'true');
- formData.append('columns['+index+'][searchable]', 'true');
- formData.append('columns['+index+'][name]', this.sortField);
- formData.append('order[0][column]', index+1);
- formData.append('order[0][dir]', this.sort ? this.sort : 'desc');
- this.repositoryService.postDataWithToken(samplingVoucherList.samplingVoucherList+"/" + this.idSelect , formData, this.token, null).subscribe((res: any) => {
- this.recordsTotal = res.data.recordsFiltered as number;
- this.rows = res.data.data;
- this.colsName = res.data.colsName.split(', ');
- this.isLoading = false;
- });
- }
- getDataJsonFilterAsumsi(param: TableRequest) {
- this.isLoading = true;
- const index = this.index ? this.index : 0;
- const formData = new FormData();
- formData.append('start', param.start.toString());
- formData.append('length', param.length.toString());
- formData.append('search[value]', this.search ? this.search.toString() : '');
- formData.append('search[regex]', 'false');
- formData.append('columns['+index+'][data]', index+1);
- formData.append('columns['+index+'][orderable]', 'true');
- formData.append('columns['+index+'][searchable]', 'true');
- formData.append('columns['+index+'][name]', this.sortField);
- formData.append('order[0][column]', index+1);
- formData.append('order[0][dir]', this.sort ? this.sort : 'desc');
- this.repositoryService.postDataWithToken(samplingVoucherList.filterAsumsiNominal+"/" + this.idSelect +'/'+this.f.samplingSaldo.value+'/'+this.idAttr,formData, this.token, null).subscribe((res: any) => {
- this.recordsTotal = res.data.recordsFiltered as number;
- this.rows = res.data.data;
- this.colsName = res.data.colsName.split(', ');
- this.isLoading = false;
- });
- }
- btnUploadDftrNomintafi(event:any){
- this.isLoading = true
- if (event.target.files.length > 0) {
- const file = event.target.files[0];
- this.formModel.fileContent = file;
- }
- const formData = new FormData();
- formData.append('',this.formModel.fileContent)
- formData.append('masterPenugasanUtid',this.idSelect)
- this.repositoryService.postDataWithToken(samplingVoucherList.sampleImportExcel, formData, this.token,null).subscribe((data: any) => {
- this.snackbar.open(data.detail, data.message, {
- duration: 10000,
- });
- if (data.status === 200) {
- this.getDataJson(this.paramRequest)
- console.log('Add OK')
- }
- (err: any) => {
- console.log('error', err);
- this.snackbar.open('Opsss.. ' + err.name, 'Error', {
- duration: 10000,
- });
- }
- },
- )
- }
- loadTableAsumsi(){
- this.pageSize = 10;
- this.paramRequest = {
- start: 0,
- length: this.pageSize,
- };
- if(this.load = true){
- this.getDataJsonFilterAsumsi(this.paramRequest)
- }else{
- this.load = false
- this.getDataJson(this.paramRequest);
- }
- }
- daftarNominatif(){
- this.pageSize = 10;
- this.paramRequest = {
- start: 0,
- length: this.pageSize,
- };
- this.load = true
- this.getDataJson(this.paramRequest)
- }
- // onChangeType(val: any){
- // this.typeId = val;
- // this.paramRequest = {
- // start: 0,
- // length: this.pageSize,
- // };
- // this.getDataJson(this.paramRequest);
- // }
- sortPage(page: any) {
- this.index = this.colsName?.findIndex(item => item == page.sortField);
- this.sort = page?.sortOrder === 1 ? 'asc' : 'desc';
- this.sortField = page?.sortField ? page.sortField : 'id';
- }
- updatePage(page: any) {
- if (page && page.sortField && page.sortOrder) {
- this.sortPage(page);
- }
- this.paramRequest = {
- start: page.first / page.rows,
- length: page.rows,
- };
- this.getDataJson(this.paramRequest);
- }
- samplingCabangDialog() {
- const dialogConfig = new MatDialogConfig();
- dialogConfig.disableClose = true;
- dialogConfig.width = '1200px';
- const dialogRef = this.dialog.open(SamplingCabangComponent, dialogConfig);
- dialogRef.afterClosed().subscribe(result => {
- console.log(`Dialog result: ${result}`);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement