From 311885894f6125cab066e5843d2ee056a50e014f Mon Sep 17 00:00:00 2001 From: jeva prahayusma Date: Thu, 28 May 2020 13:32:55 +0700 Subject: [PATCH] fix(Billing): Fixing bug billing --- .../billing-detail.component.ts | 13 +- src/app/pages/billing/billing.component.html | 2 +- src/app/pages/billing/billing.component.ts | 13 +- .../pages/service-agreement/sa.component.html | 7 +- .../pages/service-agreement/sa.component.ts | 13 +- src/app/pages/service-agreement/sa.module.ts | 20 ++- src/app/pages/service-agreement/sa.service.ts | 28 +++- .../service-agreement-detail.component.html | 156 +++++++++--------- .../service-agreement-detail.component.ts | 35 ++-- 9 files changed, 183 insertions(+), 104 deletions(-) diff --git a/src/app/pages/billing/billing-detail/billing-detail.component.ts b/src/app/pages/billing/billing-detail/billing-detail.component.ts index ac784f4f..3308da5b 100644 --- a/src/app/pages/billing/billing-detail/billing-detail.component.ts +++ b/src/app/pages/billing/billing-detail/billing-detail.component.ts @@ -1,7 +1,9 @@ -import { Component, Inject, Input } from '@angular/core'; +import { Component, Inject, Input, ChangeDetectorRef } from '@angular/core'; import { NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme'; import { BillingList } from '../../../@core/data/billing'; +import { ActivatedRoute } from '@angular/router'; import { BillingService } from '../billing.service'; +import { BillingComponent } from '../billing.component'; @Component({ selector: 'ngx-billing-detail', @@ -11,11 +13,12 @@ import { BillingService } from '../billing.service'; export class BillingDetailComponent { @Input() data: BillingList; - constructor(private service: BillingService, public windowRef: NbWindowRef, @Inject(NB_WINDOW_CONTEXT) context) { + constructor(private service: BillingService, public windowRef: NbWindowRef, @Inject(NB_WINDOW_CONTEXT) context, private changeDetectorRefs: ChangeDetectorRef) { if (context != null) { this.data = Object.assign({}, context.data); } } + private router: ActivatedRoute; onSubmit(){ console.log('isi json',this.data.billTitle) @@ -24,11 +27,17 @@ export class BillingDetailComponent { this.data.billTitle = Math.floor(temp) console.log('after', this.data) this.service.postBilling(this.data).subscribe((value) => { + this.changeDetectorRefs.detectChanges() + // this.router.routeReuseStrategy.shouldReuseRoute = function () { + // return false; + // }; + window.location.reload(); this.close(); }); } close() { + console.log('masuk') this.windowRef.close(); } diff --git a/src/app/pages/billing/billing.component.html b/src/app/pages/billing/billing.component.html index af49bae5..4c7aba1b 100644 --- a/src/app/pages/billing/billing.component.html +++ b/src/app/pages/billing/billing.component.html @@ -1,6 +1,6 @@ - Billing - 90% + Billing - 100% diff --git a/src/app/pages/billing/billing.component.ts b/src/app/pages/billing/billing.component.ts index c7327389..b9f3d9f2 100644 --- a/src/app/pages/billing/billing.component.ts +++ b/src/app/pages/billing/billing.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ChangeDetectorRef } from '@angular/core'; import { BillingList } from '../../@core/data/billing'; import { BillingService } from './billing.service'; import { BillingDetailComponent } from './billing-detail/billing-detail.component'; @@ -10,9 +10,11 @@ import { NbWindowService } from '@nebular/theme'; styleUrls: ['./billing.component.scss'], }) export class BillingComponent implements OnInit { - settings = { mode: 'inline', + actions: { + add: false, + }, add: { addButtonContent: '', createButtonContent: '', @@ -45,7 +47,9 @@ export class BillingComponent implements OnInit { source: BillingList[] = []; - constructor(private service: BillingService, private windowService: NbWindowService) { + constructor(private service: BillingService, private windowService: NbWindowService, private changeDetectorRefs: ChangeDetectorRef) { + console.log('masuk cons') + this.initData(); } ngOnInit(): void { @@ -54,7 +58,8 @@ export class BillingComponent implements OnInit { initData(){ this.service.getBilling().subscribe((result) => { this.source = Object.assign([], result); - console.log('test', result); + console.log('hasil', result); + this.changeDetectorRefs.detectChanges(); }); } onCreateConfirm(event) { diff --git a/src/app/pages/service-agreement/sa.component.html b/src/app/pages/service-agreement/sa.component.html index a54254ab..39d4cf21 100644 --- a/src/app/pages/service-agreement/sa.component.html +++ b/src/app/pages/service-agreement/sa.component.html @@ -1,13 +1,12 @@ - Service Agreement - + \ No newline at end of file diff --git a/src/app/pages/service-agreement/sa.component.ts b/src/app/pages/service-agreement/sa.component.ts index 1a000038..a76410d3 100644 --- a/src/app/pages/service-agreement/sa.component.ts +++ b/src/app/pages/service-agreement/sa.component.ts @@ -69,7 +69,16 @@ export class ServiceAgreementComponent implements OnInit{ } } - openWindowForm() { - this.windowService.open(ServiceAgreementDetailComponent, { title: `Service Agreement Detail` }); + openWindowForm(event) { + + // let temp = event.data.billTitle.toString() + // event.data.billTitle = temp + console.log('data kirim', event.data) + this.windowService.open(ServiceAgreementDetailComponent, { + title: 'Service Agreement Detail', + context: { + data: event.data, + }, + }); } } diff --git a/src/app/pages/service-agreement/sa.module.ts b/src/app/pages/service-agreement/sa.module.ts index 13103edc..1491bb56 100644 --- a/src/app/pages/service-agreement/sa.module.ts +++ b/src/app/pages/service-agreement/sa.module.ts @@ -1,7 +1,16 @@ import { NgModule } from '@angular/core'; -import { NbCardModule, NbIconModule, NbInputModule, NbTreeGridModule } from '@nebular/theme'; +import { NbCardModule + , NbIconModule + , NbInputModule + , NbTreeGridModule + , NbButtonModule, + NbCheckboxModule, + NbRadioModule, + NbSelectModule, + NbDatepickerModule + } from '@nebular/theme'; import { Ng2SmartTableModule } from 'ng2-smart-table'; - +import { FormsModule } from '@angular/forms'; import { ThemeModule } from '../../@theme/theme.module'; import { ServiceAgreementComponent } from './sa.component'; import { ServiceAgreementService } from './sa.service'; @@ -15,6 +24,12 @@ import { ServiceAgreementDetailComponent } from './service-agreement-detail/serv NbInputModule, ThemeModule, Ng2SmartTableModule, + NbButtonModule, + NbCheckboxModule, + NbRadioModule, + NbSelectModule, + NbDatepickerModule, + FormsModule ], declarations: [ ServiceAgreementComponent, @@ -22,6 +37,7 @@ import { ServiceAgreementDetailComponent } from './service-agreement-detail/serv ], providers: [ ServiceAgreementService, + ServiceAgreementDetailComponent ], entryComponents: [ ServiceAgreementDetailComponent, diff --git a/src/app/pages/service-agreement/sa.service.ts b/src/app/pages/service-agreement/sa.service.ts index a13215e2..969f2b8d 100644 --- a/src/app/pages/service-agreement/sa.service.ts +++ b/src/app/pages/service-agreement/sa.service.ts @@ -4,14 +4,15 @@ import {Observable, throwError} from 'rxjs'; import {map, catchError} from 'rxjs/operators'; import {HttpErrorResponse} from '@angular/common/http'; import { ServiceAgreementList } from '../../@core/data/service-agreement'; +import { DatePipe } from '@angular/common' @Injectable({ providedIn: 'root', }) export class ServiceAgreementService { - constructor(private http: HttpClient) { + constructor(private http: HttpClient, public datepipe: DatePipe) { } - url = 'http://localhost:8011/api/customerStatic/pagingSearchParam?start=0&sort=desc&length=20&column=startTime&customerCode=&customerFullname=&customerBusiness=&payCycle=&isActive='; + url = 'http://34.87.6.140:8011/api/customerStatic/pagingSearchParam?start=0&sort=desc&length=20&column=startTime&customerCode=&customerFullname=&customerBusiness=&payCycle=&isActive='; json; getServiceAgreement(): Observable { const headers = new HttpHeaders({ @@ -27,6 +28,29 @@ export class ServiceAgreementService { } + postServiceAgreement(data: ServiceAgreementList): Observable { + const headers = new HttpHeaders({ + 'Content-Type': 'application/json', + 'X-Requested-Method': 'POST', + }); + console.log('isiiii', data.ebCustomerId) + const id = data.ebCustomerId + let nextBill_date =this.datepipe.transform(data.nextBillTm, 'yyyy-MM-dd'+'T'+'HH:mm:ss.SSS'); + let endTime_date =this.datepipe.transform(data.endTime, 'yyyy-MM-dd'+'T'+'HH:mm:ss.SSS'); + let startTime_date =this.datepipe.transform(data.startTime, 'yyyy-MM-dd'+'T'+'HH:mm:ss.SSS'); + let modifyTm_date =this.datepipe.transform(data.modifyTm, 'yyyy-MM-dd'+'T'+'HH:mm:ss.SSS'); + data.nextBillTm = nextBill_date + data.endTime = endTime_date + data.startTime = startTime_date + data.modifyTm = modifyTm_date + console.log('isi tanggal' ,data) + const options = { headers: headers }; + const url = 'http://34.87.6.140:8011/api/customerStatic/insertData'; + return this.http.post(url, JSON.stringify(data) , options).pipe( + catchError(this.handleError), + ); + } + private extractData(body: any): ServiceAgreementList[] { // console.log('test', body.serviceAgreementList); return Object.assign(body.content); diff --git a/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html index 7325b409..35eb08a1 100644 --- a/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html +++ b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html @@ -1,81 +1,87 @@
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+
+ +
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+ +
+
+ + +
+
+ + +
+
+ + + +
+
+ + + +
+
+
+
+ + + + Invoice + Debit Note + Surat Perintah Penagihan + + +
+
+ + +
+
+ + + +
+
+ + + + Exclude + + + Include + + +
+
+ + % +
+
+ + Rp. + % +
+
+
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
\ No newline at end of file +
+
\ No newline at end of file diff --git a/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts index db440965..76e12de5 100644 --- a/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts +++ b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts @@ -1,20 +1,31 @@ -import { Component } from '@angular/core'; -import { NbWindowRef } from '@nebular/theme'; +import { Component, Inject, Input, ChangeDetectorRef } from '@angular/core'; +import { NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme'; +import { ServiceAgreementList } from '../../../@core/data/service-agreement'; +import { ServiceAgreementService } from '../sa.service'; @Component({ - template: ` -
- - - - - -
- `, + selector: 'ngx-service-agreement-detail', + templateUrl: './service-agreement-detail.component.html', styleUrls: ['service-agreement-detail.component.scss'], }) export class ServiceAgreementDetailComponent { - constructor(public windowRef: NbWindowRef) {} + @Input() data: ServiceAgreementList; + constructor(private service: ServiceAgreementService, public windowRef: NbWindowRef, @Inject(NB_WINDOW_CONTEXT) context) { + if (context != null) { + this.data = Object.assign({}, context.data); + } + } + onSubmit(){ + // console.log('isi json',this.data.billTitle) + // let temp = this.data.billTitle + // this.data.state = 'updated' + // this.data.billTitle = Math.floor(temp) + // console.log('after', this.data) + this.service.postServiceAgreement(this.data).subscribe((value) => { + //this.changeDetectorRefs.detectChanges() + this.close(); + }); + } close() { this.windowRef.close();