From 7f959cfefdf452aa1cf123316578e130f136575e Mon Sep 17 00:00:00 2001 From: jeva prahayusma Date: Fri, 22 May 2020 20:26:06 +0700 Subject: [PATCH] fix(Billing): build edit , add and delete --- package-lock.json | 65 +++-------- src/app/@core/data/billing.ts | 85 ++++++++++++++ src/app/@core/data/service-agreement.ts | 83 ++++++++++++++ .../billing-detail.component.html | 87 +++++++++++++++ .../billing-detail.component.scss | 12 ++ .../billing-detail.component.ts | 43 ++++++++ src/app/pages/billing/billing.component.html | 12 ++ src/app/pages/billing/billing.component.scss | 7 ++ src/app/pages/billing/billing.component.ts | 95 ++++++++++++++++ src/app/pages/billing/billing.module.ts | 45 ++++++++ src/app/pages/billing/billing.service.ts | 104 ++++++++++++++++++ src/app/pages/pages-routing.module.ts | 6 +- .../pages/promotion/promotion.component.ts | 1 + .../pages/service-agreement/sa.component.html | 13 +++ .../pages/service-agreement/sa.component.scss | 7 ++ .../pages/service-agreement/sa.component.ts | 75 +++++++++++++ src/app/pages/service-agreement/sa.module.ts | 30 +++++ src/app/pages/service-agreement/sa.service.ts | 51 +++++++++ .../service-agreement-detail.component.html | 81 ++++++++++++++ .../service-agreement-detail.component.scss | 12 ++ .../service-agreement-detail.component.ts | 22 ++++ 21 files changed, 886 insertions(+), 50 deletions(-) create mode 100644 src/app/@core/data/billing.ts create mode 100644 src/app/@core/data/service-agreement.ts create mode 100644 src/app/pages/billing/billing-detail/billing-detail.component.html create mode 100644 src/app/pages/billing/billing-detail/billing-detail.component.scss create mode 100644 src/app/pages/billing/billing-detail/billing-detail.component.ts create mode 100644 src/app/pages/billing/billing.component.html create mode 100644 src/app/pages/billing/billing.component.scss create mode 100644 src/app/pages/billing/billing.component.ts create mode 100644 src/app/pages/billing/billing.module.ts create mode 100644 src/app/pages/billing/billing.service.ts create mode 100644 src/app/pages/service-agreement/sa.component.html create mode 100644 src/app/pages/service-agreement/sa.component.scss create mode 100644 src/app/pages/service-agreement/sa.component.ts create mode 100644 src/app/pages/service-agreement/sa.module.ts create mode 100644 src/app/pages/service-agreement/sa.service.ts create mode 100644 src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html create mode 100644 src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.scss create mode 100644 src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts diff --git a/package-lock.json b/package-lock.json index 8f0a2b87..57a71dae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2540,7 +2540,6 @@ "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2", "longest": "^1.0.1", @@ -11554,15 +11553,13 @@ "version": "1.43.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", - "dev": true, - "optional": true + "dev": true }, "mime-types": { "version": "2.1.26", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", "dev": true, - "optional": true, "requires": { "mime-db": "1.43.0" } @@ -12121,8 +12118,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true, - "optional": true + "dev": true }, "loose-envify": { "version": "1.3.1", @@ -20415,8 +20411,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -20459,8 +20454,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", @@ -20471,8 +20465,7 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -20589,8 +20582,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -20602,7 +20594,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -20632,7 +20623,6 @@ "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -20651,7 +20641,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -20741,8 +20730,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -20754,7 +20742,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -20840,8 +20827,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -20877,7 +20863,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -20897,7 +20882,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -20941,14 +20925,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -22032,8 +22014,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -22076,8 +22057,7 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", @@ -22088,8 +22068,7 @@ "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -22206,8 +22185,7 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -22219,7 +22197,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -22249,7 +22226,6 @@ "version": "2.9.0", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -22268,7 +22244,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -22371,7 +22346,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -22457,8 +22431,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -22494,7 +22467,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -22514,7 +22486,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -22558,14 +22529,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/src/app/@core/data/billing.ts b/src/app/@core/data/billing.ts new file mode 100644 index 00000000..b494f458 --- /dev/null +++ b/src/app/@core/data/billing.ts @@ -0,0 +1,85 @@ +export interface BillingList { + ebCustomerId: number; + customerCode: string; + customerCodeParent: string; + customerFullname: string; + customerShortname: string; + customerCoprName: string; + customerCoprAdd: string; + customerBusiness: string; + reconciliationName: string; + reconciliationHp: string; + reconciliationTel: string; + reconciliationEmail: string; + reconciliationAdd: string; + startTime: string; + endTime: string; + billTitle: number; + lastBillTm: string; + nextBillTm: string; + billCode: string; + payCycle?: number; + modifyTm: string; + isActive: number; + tax: number; + vat: number; + tipe: number; + price: number; + percentage: number; + state: string; + startTimeString: string; + endTimeString: string; + nextBillTimeString: string; + saNo: string; + requestType: string; + partnerBillCode: string; + itemType: string; + itemTypeOthers: string; + compName: number; + compIdNumber: string; + compIndustry: string; + compAddress: string; + compPhone: string; + compNoHp: string; + personalName: string; + personalJobTitle: string; + personalSiupNo: string; + personalNpwp: string; + personalEmail: string; + personalFaxNo: string; + personalAddress: string; + csName: string; + csAddress: string; + csContactName: string; + csHp: string; + csEmail: string; + financeName: string; + financeAddress: string; + financeContactName: string; + financeHp: string; + financeEmail: string; + serviceProfile: string; + pickupAddress: string; + paymentSurcharge: string; + paymentBillingCycle: string; + paymentTermOfPayment: string; + docCompany: string; + docPersonel: string; + signSalesName: string; + signSalesDate: string; + signVpSalesName: string; + signVpSalesDate: string; + signFinanceName: string; + signFinanceDate: string; + signVpFinanceName: string; + signVpFinanceDate: string; + partnerSignDate: string; + status: string; + ecmUrl: string; + + } + + export interface RootObject { + billingList: BillingList[]; + } + \ No newline at end of file diff --git a/src/app/@core/data/service-agreement.ts b/src/app/@core/data/service-agreement.ts new file mode 100644 index 00000000..82d67f11 --- /dev/null +++ b/src/app/@core/data/service-agreement.ts @@ -0,0 +1,83 @@ +export interface ServiceAgreementList { + ebCustomerId: number; + customerCode: string; + customerCodeParent: string; + customerFullname: string; + customerShortname: string; + customerCoprName: string; + customerCoprAdd: string; + customerBusiness: string; + reconciliationName: string; + reconciliationHp: string; + reconciliationTel: string; + reconciliationEmail: string; + reconciliationAdd: string; + startTime: string; + endTime: string; + lastBillTm: string; + nextBillTm: string; + billCode: string; + payCycle: number; + modifyTm: string; + isActive: number; + tax: number; + tipe: number; + price?: number; + percentage: number; + state: string; + startTimeString: string; + endTimeString: string; + nextBillTimeString: string; + saNo: string; + requestType: string; + partnerBillCode: string; + itemType: string; + itemTypeOthers: string; + compName: number; + compIdNumber: string; + compIndustry: string; + compAddress: string; + compPhone: string; + compNoHp: string; + personalName: string; + personalJobTitle: string; + personalSiupNo: string; + personalNpwp: string; + personalEmail: string; + personalFaxNo: string; + personalAddress: string; + csName: string; + csAddress: string; + csContactName: string; + csHp: string; + csEmail: string; + financeName: string; + financeAddress: string; + financeContactName: string; + financeHp: string; + financeEmail: string; + serviceProfile: string; + pickupAddress: string; + paymentSurcharge: string; + paymentBillingCycle: string; + paymentTermOfPayment: string; + docCompany: string; + docPersonel: string; + signSalesName: string; + signSalesDate: string; + signVpSalesName: string; + signVpSalesDate: string; + signFinanceName: string; + signFinanceDate: string; + signVpFinanceName: string; + signVpFinanceDate: string; + partnerSignDate: string; + status: string; + ecmUrl: string; + + } + + export interface RootObject { + serviceAgreementList: ServiceAgreementList[]; + } + \ No newline at end of file diff --git a/src/app/pages/billing/billing-detail/billing-detail.component.html b/src/app/pages/billing/billing-detail/billing-detail.component.html new file mode 100644 index 00000000..1bc2d685 --- /dev/null +++ b/src/app/pages/billing/billing-detail/billing-detail.component.html @@ -0,0 +1,87 @@ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + + +
+
+
+
+ + + + Invoice + Debit Note + Surat Perintah Penagihan + + +
+
+ + +
+
+ + + +
+
+ + + + Exclude + + + Include + + +
+
+ + % +
+
+ + Rp. + % +
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/app/pages/billing/billing-detail/billing-detail.component.scss b/src/app/pages/billing/billing-detail/billing-detail.component.scss new file mode 100644 index 00000000..5aaba5bf --- /dev/null +++ b/src/app/pages/billing/billing-detail/billing-detail.component.scss @@ -0,0 +1,12 @@ +@import '../../../@theme/styles/themes'; + +@include nb-install-component() { + ::ng-deep .form { + display: flex; + flex-direction: column; + + .text-label { + margin-top: 1.5rem; + } + } +} diff --git a/src/app/pages/billing/billing-detail/billing-detail.component.ts b/src/app/pages/billing/billing-detail/billing-detail.component.ts new file mode 100644 index 00000000..ac784f4f --- /dev/null +++ b/src/app/pages/billing/billing-detail/billing-detail.component.ts @@ -0,0 +1,43 @@ +import { Component, Inject, Input } from '@angular/core'; +import { NbWindowRef, NB_WINDOW_CONTEXT } from '@nebular/theme'; +import { BillingList } from '../../../@core/data/billing'; +import { BillingService } from '../billing.service'; + +@Component({ + selector: 'ngx-billing-detail', + templateUrl: './billing-detail.component.html', + styleUrls: ['billing-detail.component.scss'], +}) +export class BillingDetailComponent { + + @Input() data: BillingList; + constructor(private service: BillingService, 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.postBilling(this.data).subscribe((value) => { + this.close(); + }); + } + + close() { + this.windowRef.close(); + } + + numberOnly(event): boolean { + const charCode = (event.which) ? event.which : event.keyCode; + if (charCode > 31 && (charCode < 48 || charCode > 57)) { + return false; + } + return true; + + } +} diff --git a/src/app/pages/billing/billing.component.html b/src/app/pages/billing/billing.component.html new file mode 100644 index 00000000..af49bae5 --- /dev/null +++ b/src/app/pages/billing/billing.component.html @@ -0,0 +1,12 @@ + + + Billing - 90% + + + + + + + \ No newline at end of file diff --git a/src/app/pages/billing/billing.component.scss b/src/app/pages/billing/billing.component.scss new file mode 100644 index 00000000..449237f6 --- /dev/null +++ b/src/app/pages/billing/billing.component.scss @@ -0,0 +1,7 @@ +@import '../../@theme/styles/themes'; + +@include nb-install-component() { + nb-card { + transform: translate3d(0, 0, 0); + } +} \ No newline at end of file diff --git a/src/app/pages/billing/billing.component.ts b/src/app/pages/billing/billing.component.ts new file mode 100644 index 00000000..c7327389 --- /dev/null +++ b/src/app/pages/billing/billing.component.ts @@ -0,0 +1,95 @@ +import { Component, OnInit } from '@angular/core'; +import { BillingList } from '../../@core/data/billing'; +import { BillingService } from './billing.service'; +import { BillingDetailComponent } from './billing-detail/billing-detail.component'; +import { NbWindowService } from '@nebular/theme'; + +@Component({ + selector: 'ngx-billing', + templateUrl: './billing.component.html', + styleUrls: ['./billing.component.scss'], +}) +export class BillingComponent implements OnInit { + + settings = { + mode: 'inline', + add: { + addButtonContent: '', + createButtonContent: '', + cancelButtonContent: '', + }, + edit: { + editButtonContent: '', + saveButtonContent: '', + cancelButtonContent: '', + }, + delete: { + deleteButtonContent: '', + confirmDelete: true, + }, + columns: { + customerCode: { + title: 'Partner Code', + type: 'string', + }, + customerFullname: { + title: 'Partner Name', + type: 'string', + }, + nextBillTimeString: { + title: 'Next Billing', + type: 'string', + }, + }, + }; + + source: BillingList[] = []; + + constructor(private service: BillingService, private windowService: NbWindowService) { + } + + ngOnInit(): void { + this.initData(); + } + initData(){ + this.service.getBilling().subscribe((result) => { + this.source = Object.assign([], result); + console.log('test', result); + }); + } + onCreateConfirm(event) { + if (window.confirm('Are you sure you want to save?')) { + event.newData.status = 1; + this.service.postBilling(event.newData).subscribe((value) => { + this.initData(); + }); + event.confirm.resolve(event.newData); + } else { + event.confirm.reject(); + } + } + + onDeleteConfirm(event): void { + if (window.confirm('Are you sure you want to delete?')) { + this.service.deleteBilling(event.data).subscribe((value) => { + this.initData(); + }); + event.confirm.resolve(); + } else { + event.confirm.reject(); + } + } + + openWindowForm(event) { + + let temp = event.data.billTitle.toString() + event.data.billTitle = temp + console.log('data kirim', event.data) + this.windowService.open(BillingDetailComponent, { + title: 'Billing Detail', + context: { + data: event.data, + }, + }); + } +} diff --git a/src/app/pages/billing/billing.module.ts b/src/app/pages/billing/billing.module.ts new file mode 100644 index 00000000..02b72f41 --- /dev/null +++ b/src/app/pages/billing/billing.module.ts @@ -0,0 +1,45 @@ +import { NgModule } from '@angular/core'; +import { NbCardModule, + NbIconModule, + NbInputModule, + NbTreeGridModule, + NbButtonModule, + NbCheckboxModule, + NbRadioModule, + NbSelectModule, + NbDatepickerModule} from '@nebular/theme'; +import { Ng2SmartTableModule } from 'ng2-smart-table'; + +import { ThemeModule } from '../../@theme/theme.module'; +import { BillingComponent } from './billing.component'; +import { BillingService } from './billing.service'; +import { BillingDetailComponent } from './billing-detail/billing-detail.component'; +import { FormsModule } from '@angular/forms'; +@NgModule({ + imports: [ + NbCardModule, + NbTreeGridModule, + NbIconModule, + NbInputModule, + ThemeModule, + NbButtonModule, + NbRadioModule, + NbCheckboxModule, + Ng2SmartTableModule, + FormsModule, + NbSelectModule, + NbDatepickerModule, + ], + declarations: [ + BillingComponent, + BillingDetailComponent, + ], + providers: [ + BillingService, + BillingDetailComponent, + ], + entryComponents: [ + BillingDetailComponent, + ], +}) +export class BillingModule { } \ No newline at end of file diff --git a/src/app/pages/billing/billing.service.ts b/src/app/pages/billing/billing.service.ts new file mode 100644 index 00000000..e71db61e --- /dev/null +++ b/src/app/pages/billing/billing.service.ts @@ -0,0 +1,104 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {Observable, throwError} from 'rxjs'; +import {map, catchError} from 'rxjs/operators'; +import {HttpErrorResponse} from '@angular/common/http'; +import { BillingList } from '../../@core/data/billing'; +import { DatePipe } from '@angular/common' + +@Injectable({ + providedIn: 'root', +}) +export class BillingService { + constructor(private http: HttpClient, public datepipe: DatePipe) { + } + + postData = { + start: 0, + sort: '', + length: 20, + column: 'startTime', + customerCode: '', + customerFullname: '', + customerBusiness: '', + payCycle: '', + nextBillTmFirst: '', + nextBillTmLast: '', + isActive: '1' + }; + + json; + getBilling(): Observable { + const url = 'http://34.87.6.140:8011/api/customerStatic/pagingSearchParamBilling?start=0&sort=desc&length=20&column=startTime&customerCode=&customerFullname=&customerBusiness=&payCycle=&nextBillTmFirst=&nextBillTmLast=&isActive=1'; + // const options = { headers: headers}; + return this.http.post(url, null).pipe( + map(this.extractData), + catchError(this.handleError), + ); + // '?start=' + this.postData.start + '&sort='+ this.postData.sort + + // '&length=' + this.postData.length + '&column=' + this.postData.column + '&customerCode=' + + // this.postData.customerCode + '&customerFullname=' + this.postData.customerFullname + + // '&customerBusiness=' + this.postData.customerBusiness + '&payCycle=' + this.postData.payCycle + + // '&nextBillTmFirst=' + this.postData.nextBillTmFirst + '&nextBillTmLast='+ this.postData.nextBillTmLast + + // '&isActive=' + this.postData.isActive + } + // params: [{ start: 0, sort: '', length: 20, column: 'startTime', customerCode: '', customerFullname: '' + // , customerBusiness: '', payCycle: '', nextBillTmFirst: '', nextBillTmLast: '', isActive: '1'}] + private extractData(body: any): BillingList[] { + console.log('coba', body.content) + return Object.assign(body.content); + } + + postBilling(data: BillingList): 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), + ); + } + + deleteBilling(data: BillingList): Observable { + const id = data.ebCustomerId; + const headers = new HttpHeaders({ + 'Content-Type': 'application/json', + 'X-Requested-Method': 'PUT', + }); + const options = { headers: headers }; + const url = 'http://34.87.6.140:8011/api/customerStatic/delete'; + return this.http.put(url, id, options).pipe( + catchError(this.handleError), + ); + } + + private handleError(error: HttpErrorResponse | any) { + let errMsg: string; + let errObj: any; + + if (error instanceof HttpErrorResponse) { + const err = error.message || JSON.stringify(error); + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; + errObj = error.error.message; + } else { + errMsg = error.message ? error.message : error.toString(); + const body = error.message || ''; + errObj = body; + } + + return throwError(errObj); + } +} diff --git a/src/app/pages/pages-routing.module.ts b/src/app/pages/pages-routing.module.ts index f39ff8d2..6be8320c 100644 --- a/src/app/pages/pages-routing.module.ts +++ b/src/app/pages/pages-routing.module.ts @@ -5,6 +5,8 @@ import {PagesComponent} from './pages.component'; import {NotFoundComponent} from './miscellaneous/not-found/not-found.component'; import {PromotionComponent} from './promotion/promotion.component'; import { PartnerPriceComponent } from './partner-price/partner-price.component'; +import {BillingComponent} from './billing/billing.component'; +import {ServiceAgreementComponent} from './service-agreement/sa.component'; const routes: Routes = [{ path: '', @@ -20,7 +22,7 @@ const routes: Routes = [{ }, { path: 'service-agreement', - component: NotFoundComponent, + component: ServiceAgreementComponent, }, { path: 'partner-branch', @@ -28,7 +30,7 @@ const routes: Routes = [{ }, { path: 'billing', - component: NotFoundComponent, + component: BillingComponent, }, ], }]; diff --git a/src/app/pages/promotion/promotion.component.ts b/src/app/pages/promotion/promotion.component.ts index 4e0dfb25..fb9eb7ab 100644 --- a/src/app/pages/promotion/promotion.component.ts +++ b/src/app/pages/promotion/promotion.component.ts @@ -61,6 +61,7 @@ export class PromotionComponent implements OnInit { initData() { this.service.getPromotion().subscribe((result) => { this.source = Object.assign([], result); + console.log('test', result); }); } diff --git a/src/app/pages/service-agreement/sa.component.html b/src/app/pages/service-agreement/sa.component.html new file mode 100644 index 00000000..a54254ab --- /dev/null +++ b/src/app/pages/service-agreement/sa.component.html @@ -0,0 +1,13 @@ + + + + Service Agreement + + + + + + + \ No newline at end of file diff --git a/src/app/pages/service-agreement/sa.component.scss b/src/app/pages/service-agreement/sa.component.scss new file mode 100644 index 00000000..449237f6 --- /dev/null +++ b/src/app/pages/service-agreement/sa.component.scss @@ -0,0 +1,7 @@ +@import '../../@theme/styles/themes'; + +@include nb-install-component() { + nb-card { + transform: translate3d(0, 0, 0); + } +} \ 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 new file mode 100644 index 00000000..1a000038 --- /dev/null +++ b/src/app/pages/service-agreement/sa.component.ts @@ -0,0 +1,75 @@ +import { Component, OnInit } from '@angular/core'; +import { LocalDataSource } from 'ng2-smart-table'; +import { NbWindowService } from '@nebular/theme'; + +import { SmartTableData } from '../../@core/data/smart-table'; +import { ServiceAgreementList } from '../../@core/data/service-agreement'; +import { ServiceAgreementService } from './sa.service'; +import { ServiceAgreementDetailComponent } from './service-agreement-detail/service-agreement-detail.component'; + +@Component({ + selector: 'ngx-sa', + templateUrl: './sa.component.html', + styleUrls: ['./sa.component.scss'], +}) +export class ServiceAgreementComponent implements OnInit{ + + settings = { + add: { + addButtonContent: '', + createButtonContent: '', + cancelButtonContent: '', + }, + edit: { + editButtonContent: '', + saveButtonContent: '', + cancelButtonContent: '', + }, + delete: { + deleteButtonContent: '', + confirmDelete: true, + }, + columns: { + customerCode: { + title: 'Partner Code', + type: 'string', + }, + customerFullname: { + title: 'Partner Name', + type: 'string', + }, + customerBusiness: { + title: 'Business', + type: 'string', + }, + status: { + title: 'Status', + type: 'string', + } + }, + }; + + source: ServiceAgreementList[] = []; + + constructor(private service: ServiceAgreementService, private windowService: NbWindowService) { + console.log('test', this.source); + } + + ngOnInit(): void { + this.service.getServiceAgreement().subscribe((result) => { + this.source = Object.assign([], result); + }); + } + + onDeleteConfirm(event): void { + if (window.confirm('Are you sure you want to delete?')) { + event.confirm.resolve(); + } else { + event.confirm.reject(); + } + } + + openWindowForm() { + this.windowService.open(ServiceAgreementDetailComponent, { title: `Service Agreement Detail` }); + } +} diff --git a/src/app/pages/service-agreement/sa.module.ts b/src/app/pages/service-agreement/sa.module.ts new file mode 100644 index 00000000..13103edc --- /dev/null +++ b/src/app/pages/service-agreement/sa.module.ts @@ -0,0 +1,30 @@ +import { NgModule } from '@angular/core'; +import { NbCardModule, NbIconModule, NbInputModule, NbTreeGridModule } from '@nebular/theme'; +import { Ng2SmartTableModule } from 'ng2-smart-table'; + +import { ThemeModule } from '../../@theme/theme.module'; +import { ServiceAgreementComponent } from './sa.component'; +import { ServiceAgreementService } from './sa.service'; +import { ServiceAgreementDetailComponent } from './service-agreement-detail/service-agreement-detail.component'; + +@NgModule({ + imports: [ + NbCardModule, + NbTreeGridModule, + NbIconModule, + NbInputModule, + ThemeModule, + Ng2SmartTableModule, + ], + declarations: [ + ServiceAgreementComponent, + ServiceAgreementDetailComponent, + ], + providers: [ + ServiceAgreementService, + ], + entryComponents: [ + ServiceAgreementDetailComponent, + ], +}) +export class ServiceAgreementModule { } diff --git a/src/app/pages/service-agreement/sa.service.ts b/src/app/pages/service-agreement/sa.service.ts new file mode 100644 index 00000000..a13215e2 --- /dev/null +++ b/src/app/pages/service-agreement/sa.service.ts @@ -0,0 +1,51 @@ +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {Observable, throwError} from 'rxjs'; +import {map, catchError} from 'rxjs/operators'; +import {HttpErrorResponse} from '@angular/common/http'; +import { ServiceAgreementList } from '../../@core/data/service-agreement'; + +@Injectable({ + providedIn: 'root', +}) +export class ServiceAgreementService { + constructor(private http: HttpClient) { + } + url = 'http://localhost:8011/api/customerStatic/pagingSearchParam?start=0&sort=desc&length=20&column=startTime&customerCode=&customerFullname=&customerBusiness=&payCycle=&isActive='; + json; + getServiceAgreement(): Observable { + const headers = new HttpHeaders({ + 'Content-Type': 'application/json', + 'X-Requested-Method': 'POST', + }); + const options = { headers: headers }; + return this.http.post(this.url, null).pipe( + map(this.extractData), + catchError(this.handleError), + ); + + + } + + private extractData(body: any): ServiceAgreementList[] { + // console.log('test', body.serviceAgreementList); + return Object.assign(body.content); + } + + private handleError(error: HttpErrorResponse | any) { + let errMsg: string; + let errObj: any; + + if (error instanceof HttpErrorResponse) { + const err = error.message || JSON.stringify(error); + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; + errObj = error.error.message; + } else { + errMsg = error.message ? error.message : error.toString(); + const body = error.message || ''; + errObj = body; + } + + return throwError(errObj); + } +} 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 new file mode 100644 index 00000000..7325b409 --- /dev/null +++ b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.html @@ -0,0 +1,81 @@ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.scss b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.scss new file mode 100644 index 00000000..5aaba5bf --- /dev/null +++ b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.scss @@ -0,0 +1,12 @@ +@import '../../../@theme/styles/themes'; + +@include nb-install-component() { + ::ng-deep .form { + display: flex; + flex-direction: column; + + .text-label { + margin-top: 1.5rem; + } + } +} 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 new file mode 100644 index 00000000..db440965 --- /dev/null +++ b/src/app/pages/service-agreement/service-agreement-detail/service-agreement-detail.component.ts @@ -0,0 +1,22 @@ +import { Component } from '@angular/core'; +import { NbWindowRef } from '@nebular/theme'; + +@Component({ + template: ` +
+ + + + + +
+ `, + styleUrls: ['service-agreement-detail.component.scss'], +}) +export class ServiceAgreementDetailComponent { + constructor(public windowRef: NbWindowRef) {} + + close() { + this.windowRef.close(); + } +}