This commit is contained in:
2023-11-02 15:53:37 +07:00
parent 136c9a2f6d
commit 21af45bfa6
15 changed files with 108 additions and 233 deletions

View File

@@ -44,7 +44,8 @@ export class LoginComponent implements OnInit {
if (!form.valid) return false;
try {
const result = await lastValueFrom(this.authService.login(this.dataForm));
// const cathayResult = await lastValueFrom(this.cathayAuthService.login(this.cathayForm))
const cathayResult: any = await lastValueFrom(this.cathayAuthService.login(this.cathayForm));
this.appService.setToken(cathayResult.token.token)
this.appService.setAuth(result);
return this.router.navigate(['/pages']);
} catch (err) {

View File

@@ -1,93 +0,0 @@
import { HttpClient, HttpEventType } from '@angular/common/http';
import { Optional } from '@angular/core';
import { Observable, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { environment } from 'src/environments/environment';
export interface IapiResponse<T>{
apiResponse:{
id:number,
desc:string,
},
data:Array<T>
}
export class BaseStoreService {
protected host:string = `${environment.storeApi}`
protected prefix:string = `${this.host}`
protected fullUrl:string = ''
constructor(
endpoint:string,
protected http: HttpClient,
) {
this.fullUrl = this.prefix + endpoint
}
uploadDocument<HttpHeaderResponse>(target: FormData){
return this.http.post(this.fullUrl,target,{
reportProgress: true,
observe:'events'
}).pipe(
map((event) => {
switch(event.type){
case HttpEventType.UploadProgress:
const progress = Math.round(100 * event.loaded / event.total);
return { status: 'progress', message: `${progress}` };
case HttpEventType.Response:
return { status: 'success', message: event.body };
default:
return `Unhandled event: ${event.type}`;
}
}
),
catchError(err => {
return of({ status: 'error', message: `${err.message}` })
})
)
}
getAll<T>(): Observable<T[]>{
return this.http.get<T[]>(this.fullUrl)
}
add<T>(data: T): Observable<T> {
return this.http.post<T>(this.fullUrl,data)
}
get<T>(id: any): Observable<T> {
return this.http.get<T>(`${this.fullUrl}/${id}`)
}
update<T>(id: number,data: T): Observable<Response>{
return this.http.put<Response>(`${this.fullUrl}/${id}`,data)
}
update2<T>(data: T): Observable<Response>{
return this.http.put<Response>(this.fullUrl,data)
}
deleteData(id: number | string): Observable<Response> {
return this.http.delete<Response>(`${this.fullUrl}/${id}`)
}
query<T>(query: string): Observable<T> {
return this.http.get<T>(`${this.fullUrl}/${query}`)
}
queryString<T>(query: string): Observable<T>{
return this.http.get<T>(`${this.fullUrl}?${query}`)
}
addMany<T>(data: T): Observable<T> {
return this.http.post<T>(`${this.fullUrl}/s`,data)
}
updateMany<T>(data: T): Observable<Response> {
return this.http.put<Response>(`${this.fullUrl}/s`,data)
}
}

View File

@@ -18,5 +18,4 @@ export class CathayAuthService extends BaseService{
login(payload : {'mobileDeviceId': string , 'userName': string , 'password' : string}){
return this.http.post(`${this.fullUrl}/login`, payload)
}
}

View File

@@ -0,0 +1,18 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BaseService } from 'src/app/core/base/base-service';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class ReportService extends BaseService{
API_URL = environment.CATHAYAPIURL
constructor(
public http: HttpClient
) {
super('', http)
super.fullUrl = `${this.API_URL}/v2/Payment/getTransactionWeb`
}
}

View File

@@ -0,0 +1,16 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BaseService } from 'src/app/core/base/base-service';
@Injectable({
providedIn: 'root'
})
export class UploadService extends BaseService{
constructor(
public http: HttpClient
) {
super('/common/upload', http)
}
}

View File

@@ -25,7 +25,7 @@
<ng-container matColumnDef="1">
<th mat-header-cell *matHeaderCellDef class="tac">ลำดับ</th>
<td mat-cell *matCellDef="let item; let i = index;" width="150" class="tac">{{getIndex(i)}}</td>
<td mat-cell *matCellDef="let item; let i = index;" width="100" class="tac">{{getIndex(i)}}</td>
</ng-container>
<ng-container matColumnDef="2">
@@ -46,7 +46,7 @@
</ng-container>
<ng-container matColumnDef="5">
<th mat-header-cell *matHeaderCellDef class="tac" width="150">คำนำหน้า</th>
<th mat-header-cell *matHeaderCellDef class="tac" width="100">คำนำหน้า</th>
<td mat-cell *matCellDef="let item" class="tac">{{item.prefix_name}}</td>
</ng-container>
@@ -74,8 +74,8 @@
</td>
</ng-container>
<ng-container matColumnDef="10">
<th mat-header-cell *matHeaderCellDef class="tac" width="150">E-mail</th>
<td mat-cell *matCellDef="let item" class="tac">
<th mat-header-cell *matHeaderCellDef class="tal" width="150">E-mail</th>
<td mat-cell *matCellDef="let item" class="tal">
<div> {{item.email}}</div>
</td>
</ng-container>

View File

@@ -34,7 +34,6 @@ export class ListComponent extends BaseList implements OnChanges {
}
onFilterCard($event) {
// this.filterCard.next($event);
const filterValue = this.query.card;
this.kycList.filter = filterValue.trim().toLowerCase();
}

View File

@@ -1 +1 @@
<app-list [kycList]="kyc$ | async"></app-list>
<app-list [reportList]="report$ | async"></app-list>

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { KycService } from 'src/app/core/service/common/kyc.service';
import { ReportService } from 'src/app/core/service/common/report.service';
@Component({
selector: 'app-transactions',
@@ -8,10 +8,10 @@ import { KycService } from 'src/app/core/service/common/kyc.service';
styleUrls: ['./transactions.container.scss']
})
export class TransactionsContainer {
kyc$ = new Observable();
report$ = new Observable();
constructor(
private kycService: KycService
private reportService: ReportService
) {
this.kyc$ = this.kycService.getAll();
this.report$ = this.reportService.getAll()
}
}

View File

@@ -15,15 +15,17 @@
</mat-form-field>
</div>
<div class="col-span-2 xl:col-span-3 xl:order-2">
<mat-form-field>
<i matTextPrefix class="bi bi-search"></i>
<input matInput placeholder="วันที่ชำระ">
<mat-form-field >
<input matInput [matDatepicker]="startDate" placeholder="วันที่ชำระ" (dateChange)="test()" />
<mat-datepicker-toggle [for]="startDate" matSuffix></mat-datepicker-toggle>
<mat-datepicker #startDate></mat-datepicker>
</mat-form-field>
</div>
<div class="col-span-2 xl:col-span-3 xl:order-2">
<mat-form-field>
<i matTextPrefix class="bi bi-search"></i>
<input matInput placeholder="ถึงวันที่">
<mat-form-field >
<input matInput [matDatepicker]="endDate" placeholder="ถึงวันที่" (dateChange)="test()"/>
<mat-datepicker-toggle [for]="endDate" matSuffix></mat-datepicker-toggle>
<mat-datepicker #endDate></mat-datepicker>
</mat-form-field>
</div>
</div>
@@ -31,51 +33,51 @@
<div class="card-body">
<div class="table-wrap">
<table class="table table-main" mat-table [dataSource]="kycList" matSort>
<table class="table table-main" mat-table [dataSource]="reportList" matSort>
<tr mat-header-row *matHeaderRowDef="['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15']"></tr>
<tr mat-row *matRowDef="let row; columns: ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'];"></tr>
<ng-container matColumnDef="1">
<th mat-header-cell *matHeaderCellDef class="tac" mat-sort-header>ลำดับ</th>
<td mat-cell *matCellDef="let item" width="150" class="tac">{{item.code}}</td>
<td mat-cell *matCellDef="let item; let i = index" width="150" class="tac">{{getIndex(i)}}</td>
</ng-container>
<ng-container matColumnDef="2">
<th mat-header-cell *matHeaderCellDef class="tal">Phone</th>
<td mat-cell *matCellDef="let item" class="" style="min-width: 200px;">
{{item.name }}
{{item.phoneNumber}}
</td>
</ng-container>
<ng-container matColumnDef="3">
<th mat-header-cell *matHeaderCellDef class="tal" mat-sort-header>ID</th>
<td mat-cell *matCellDef="let item" class="">{{item?.masterProductBrand.name }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item.id }}</td>
</ng-container>
<ng-container matColumnDef="4">
<th mat-header-cell *matHeaderCellDef class="tal" mat-sort-header>PayeeFullname</th>
<td mat-cell *matCellDef="let item" class="">{{item?.masterProductBrand.name }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item?.payeeUserAccountId }}</td>
</ng-container>
<ng-container matColumnDef="5">
<th mat-header-cell *matHeaderCellDef class="tal" width="150">PayerFullname</th>
<td mat-cell *matCellDef="let item" class="">{{item.size }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item.payerUserAccountId }}</td>
</ng-container>
<ng-container matColumnDef="6">
<th mat-header-cell *matHeaderCellDef class="tal" width="150">InvoiceID</th>
<td mat-cell *matCellDef="let item" class="">{{item.weight }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item.invoiceId }}</td>
</ng-container>
<ng-container matColumnDef="7">
<th mat-header-cell *matHeaderCellDef class="tal" width="150">ref 1</th>
<td mat-cell *matCellDef="let item" class="">{{item.color }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item.referencE1 }}</td>
</ng-container>
<ng-container matColumnDef="8">
<th mat-header-cell *matHeaderCellDef class="tal" width="150">ref 2</th>
<td mat-cell *matCellDef="let item" class="">{{item.year }}</td>
<td mat-cell *matCellDef="let item" class="">{{ item.referencE2 }}</td>
</ng-container>
<ng-container matColumnDef="9">
@@ -87,35 +89,31 @@
<ng-container matColumnDef="10">
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>paymentStatus</th>
<td mat-cell *matCellDef="let item" class="">
<div class="b-color-green"> {{item.latestPrice | number : '1.2-2' }}</div>
<div class="b-color-green"> {{ item.referencE3 }}</div>
</td>
</ng-container>
<ng-container matColumnDef="11">
<th mat-header-cell *matHeaderCellDef width="80">payment Channel</th>
<td mat-cell *matCellDef="let item">
<div class="action flex justify-center">
<div class="item">
<i class="bi bi-file-earmark-text icon-doc"></i>
</div>
</div>
<div class="b-color-green"> {{ item.paymentChannel }}</div>
</td>
</ng-container>
<ng-container matColumnDef="12">
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>จำนวนเงิน</th>
<td mat-cell *matCellDef="let item" class="">
<div class="b-color-green"> {{item.latestPrice | number : '1.2-2' }}</div>
<div class="b-color-green"> {{ item.amount | number : '1.2-2' }}</div>
</td>
</ng-container>
<ng-container matColumnDef="13">
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Create by</th>
<td mat-cell *matCellDef="let item" class="">
<div class="b-color-green"> {{item.latestPrice | number : '1.2-2' }}</div>
<div class="b-color-green"> {{ item.createBy }}</div>
</td>
</ng-container>
<ng-container matColumnDef="14">
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Update by</th>
<td mat-cell *matCellDef="let item" class="">
<div class="b-color-green"> {{item.latestPrice | number : '1.2-2' }}</div>
<div class="b-color-green"> {{ item.updateBy }}</div>
</td>
</ng-container>
<ng-container matColumnDef="15">
@@ -131,6 +129,6 @@
</table>
</div>
<!-- <div *ngIf="dataSourceCount === 0" class="no-data"></div> -->
<mat-paginator [pageSizeOptions]="[5,10,20]" showFirstLastButtons (page)="getData($event)"></mat-paginator>
<mat-paginator [pageSizeOptions]="[5,10,20]" showFirstLastButtons></mat-paginator>
</div>
</div>

View File

@@ -6,12 +6,12 @@ import { Component, Input } from '@angular/core';
styleUrls: ['./list.component.scss']
})
export class ListComponent {
@Input() kycList: any = [];
@Input() reportList: any = [];
constructor() {
}
getData(event: any) {
test(){
console.log('test')
}
}

View File

@@ -59,14 +59,14 @@
<div class="lg:flex lg:flex-col grid grid-cols-9 gap-2">
<mat-label class="col-span-1 lg:text-left lg:self-auto text-right self-center mr-4">แนบรูป</mat-label>
<div class="col-span-7">
<div class="list-images" style="min-height: auto !important;">
<div class="list-images" *ngIf="form.get('file_url').value !== null" style="min-height: auto !important;">
<div class=" grid grid-cols-12 gap-2 md:gap-2 items-center">
<div class="col-span-2 md:col-span-4">
<div class="flex justify-center items-center list-images-item">
<div class="list-images-action">
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
</div>
<img (click)="onAttachmentsView()" src="" alt="">
<img (click)="onAttachmentsView()" [src]="form.get('file_url').value" alt="">
</div>
</div>
</div>

View File

@@ -3,12 +3,13 @@ import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { catchError, tap, throwError } from 'rxjs';
import { catchError, lastValueFrom, tap, throwError } from 'rxjs';
import { IDialogConfigData } from 'src/app/@common/interface/Dialog';
import { EAction, EText } from 'src/app/@config/app';
import { AppService } from 'src/app/app.service';
import { BaseForm } from 'src/app/core/base/base-form';
import { BannerService } from 'src/app/core/service/common/banner.service';
import { UploadService } from 'src/app/core/service/common/upload.service';
@Component({
selector: 'app-dialog',
@@ -25,6 +26,7 @@ export class DialogComponent extends BaseForm implements OnInit {
public location: Location,
public bannerService: BannerService,
public appService: AppService,
public uploadService: UploadService,
public cdr: ChangeDetectorRef
) {
super(router, activatedRoute, fb, location)
@@ -82,61 +84,28 @@ export class DialogComponent extends BaseForm implements OnInit {
).subscribe()
}
// async onSubmit(form: any) {
// if (!form.valid) return false;
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.CREATE));
// if (!sweetalert.isConfirmed) return;
// this.dataForm.images = this.attachments?.[0] ? this.attachments.join(",") : null;
// this.dataForm.pageAction = 'financePaying';
// return await this.onUpdate();
// }
// async onUpdate() {
// try {
// await lastValueFrom(this.appService.post(`${this.api.quotation}/update/${this.ids}`, this.dataForm));
// await this.appService.message(EAction.SUCCESS, EText.UPDATE);
// await this.router.navigate(["/pages/finance/paying/list", this.action]);
// } catch (err) {
// this.appService.message(EAction.ERROR, EText.ERROR);
// }
// }
async onAttachments($event: any) {
const file = $event.target.files[0];
if (!file) return;
const formData = new FormData();
formData.append("ref", 'images');
formData.append("file", file);
// try {
// const res = await lastValueFrom(this.appService.post(`${API.attachments}/images`, formData));
// this.dataForm.sellerPaymentImages = res.fileName;
// this.uploadFile.nativeElement.value = null;
// this.changeDetectorRef.detectChanges();
// } catch (e) {
// this.appService.message(EText.ERROR);
// }
try {
const res = await lastValueFrom(this.uploadService.add(formData));
this.form.get('file_url').setValue(res[0].file_name)
this.form.get('file_name').setValue(res[0].name)
this.cdr.detectChanges();
} catch (e) {
this.appService.message(EText.ERROR);
}
}
async onRemoveAttachments() {
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.DELETE));
// if (!sweetalert.isConfirmed) return;
// this.dataForm.paymentImages = null;
// this.changeDetectorRef.detectChanges();
onRemoveAttachments() {
this.form.get('file_url').setValue(null)
this.form.get('file_name').setValue(null)
}
async onAttachmentsView() {
// const dialogConfig = deepCopy(this.dialogConfig);
// dialogConfig.data.action = EAction.POPUP;
// dialogConfig.data.title = 'ไฟล์แนบ';
// dialogConfig.data.type = 'images';
// dialogConfig.data.images = this.dataForm.sellerPaymentImages;
// const dialogRef = this.attachmentsView.open(AttachmentsViewComponent, dialogConfig);
// const afterClosed = await lastValueFrom(dialogRef.afterClosed());
onAttachmentsView() {
window.open(this.form.get('file_url').value)
}
}

View File

@@ -59,14 +59,14 @@
<div class="lg:flex lg:flex-col grid grid-cols-9 gap-2">
<mat-label class="col-span-1 lg:text-left lg:self-auto text-right self-center mr-4">แนบรูป</mat-label>
<div class="col-span-7">
<div class="list-images" style="min-height: auto !important;" *ngIf="data">
<div class="list-images" *ngIf="form.get('file_url').value !== null" style="min-height: auto !important;">
<div class=" grid grid-cols-12 gap-2 md:gap-2 items-center">
<div class="col-span-2 md:col-span-4">
<div class="flex justify-center items-center list-images-item">
<div class="list-images-action">
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
</div>
<img (click)="onAttachmentsView()" src="" alt="">
<img (click)="onAttachmentsView()" [src]="form.get('file_url').value" alt="">
</div>
</div>
</div>

View File

@@ -3,12 +3,13 @@ import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { catchError, tap, throwError } from 'rxjs';
import { catchError, lastValueFrom, tap, throwError } from 'rxjs';
import { IDialogConfigData } from 'src/app/@common/interface/Dialog';
import { EAction, EText } from 'src/app/@config/app';
import { AppService } from 'src/app/app.service';
import { BaseForm } from 'src/app/core/base/base-form';
import { PromotionService } from 'src/app/core/service/common/promotion.service';
import { UploadService } from 'src/app/core/service/common/upload.service';
@Component({
selector: 'app-dialog',
@@ -16,7 +17,6 @@ import { PromotionService } from 'src/app/core/service/common/promotion.service'
styleUrls: ['./dialog.component.scss']
})
export class DialogComponent extends BaseForm implements OnInit {
data = false;
constructor(
public dialogRef: MatDialogRef<DialogComponent>,
@Inject(MAT_DIALOG_DATA) public dialog: IDialogConfigData,
@@ -26,7 +26,8 @@ export class DialogComponent extends BaseForm implements OnInit {
public location: Location,
public promotionService: PromotionService,
public appService: AppService,
public cdr: ChangeDetectorRef
public cdr: ChangeDetectorRef,
public uploadService: UploadService
) {
super(router, activatedRoute, fb, location)
}
@@ -83,61 +84,28 @@ export class DialogComponent extends BaseForm implements OnInit {
).subscribe()
}
// async onSubmit(form: any) {
// if (!form.valid) return false;
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.CREATE));
// if (!sweetalert.isConfirmed) return;
// this.dataForm.images = this.attachments?.[0] ? this.attachments.join(",") : null;
// this.dataForm.pageAction = 'financePaying';
// return await this.onUpdate();
// }
// async onUpdate() {
// try {
// await lastValueFrom(this.appService.post(`${this.api.quotation}/update/${this.ids}`, this.dataForm));
// await this.appService.message(EAction.SUCCESS, EText.UPDATE);
// await this.router.navigate(["/pages/finance/paying/list", this.action]);
// } catch (err) {
// this.appService.message(EAction.ERROR, EText.ERROR);
// }
// }
async onAttachments($event: any) {
const file = $event.target.files[0];
if (!file) return;
const formData = new FormData();
formData.append("ref", 'images');
formData.append("file", file);
// try {
// const res = await lastValueFrom(this.appService.post(`${API.attachments}/images`, formData));
// this.dataForm.sellerPaymentImages = res.fileName;
// this.uploadFile.nativeElement.value = null;
// this.changeDetectorRef.detectChanges();
// } catch (e) {
// this.appService.message(EText.ERROR);
// }
try {
const res = await lastValueFrom(this.uploadService.add(formData));
this.form.get('file_url').setValue(res[0].file_name)
this.form.get('file_name').setValue(res[0].name)
this.cdr.detectChanges();
} catch (e) {
this.appService.message(EText.ERROR);
}
}
async onRemoveAttachments() {
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.DELETE));
// if (!sweetalert.isConfirmed) return;
// this.dataForm.paymentImages = null;
// this.changeDetectorRef.detectChanges();
onRemoveAttachments() {
this.form.get('file_url').setValue(null)
this.form.get('file_name').setValue(null)
}
async onAttachmentsView() {
// const dialogConfig = deepCopy(this.dialogConfig);
// dialogConfig.data.action = EAction.POPUP;
// dialogConfig.data.title = 'ไฟล์แนบ';
// dialogConfig.data.type = 'images';
// dialogConfig.data.images = this.dataForm.sellerPaymentImages;
// const dialogRef = this.attachmentsView.open(AttachmentsViewComponent, dialogConfig);
// const afterClosed = await lastValueFrom(dialogRef.afterClosed());
onAttachmentsView() {
window.open(this.form.get('file_url').value)
}
}