[update]
This commit is contained in:
@@ -44,7 +44,8 @@ export class LoginComponent implements OnInit {
|
|||||||
if (!form.valid) return false;
|
if (!form.valid) return false;
|
||||||
try {
|
try {
|
||||||
const result = await lastValueFrom(this.authService.login(this.dataForm));
|
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);
|
this.appService.setAuth(result);
|
||||||
return this.router.navigate(['/pages']);
|
return this.router.navigate(['/pages']);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -18,5 +18,4 @@ export class CathayAuthService extends BaseService{
|
|||||||
login(payload : {'mobileDeviceId': string , 'userName': string , 'password' : string}){
|
login(payload : {'mobileDeviceId': string , 'userName': string , 'password' : string}){
|
||||||
return this.http.post(`${this.fullUrl}/login`, payload)
|
return this.http.post(`${this.fullUrl}/login`, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/app/core/service/common/report.service.ts
Normal file
18
src/app/core/service/common/report.service.ts
Normal 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`
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
16
src/app/core/service/common/upload.service.ts
Normal file
16
src/app/core/service/common/upload.service.ts
Normal 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<ng-container matColumnDef="1">
|
<ng-container matColumnDef="1">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tac">ลำดับ</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="2">
|
<ng-container matColumnDef="2">
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="5">
|
<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>
|
<td mat-cell *matCellDef="let item" class="tac">{{item.prefix_name}}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@
|
|||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="10">
|
<ng-container matColumnDef="10">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tac" width="150">E-mail</th>
|
<th mat-header-cell *matHeaderCellDef class="tal" width="150">E-mail</th>
|
||||||
<td mat-cell *matCellDef="let item" class="tac">
|
<td mat-cell *matCellDef="let item" class="tal">
|
||||||
<div> {{item.email}}</div>
|
<div> {{item.email}}</div>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export class ListComponent extends BaseList implements OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFilterCard($event) {
|
onFilterCard($event) {
|
||||||
// this.filterCard.next($event);
|
|
||||||
const filterValue = this.query.card;
|
const filterValue = this.query.card;
|
||||||
this.kycList.filter = filterValue.trim().toLowerCase();
|
this.kycList.filter = filterValue.trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<app-list [kycList]="kyc$ | async"></app-list>
|
<app-list [reportList]="report$ | async"></app-list>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
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({
|
@Component({
|
||||||
selector: 'app-transactions',
|
selector: 'app-transactions',
|
||||||
@@ -8,10 +8,10 @@ import { KycService } from 'src/app/core/service/common/kyc.service';
|
|||||||
styleUrls: ['./transactions.container.scss']
|
styleUrls: ['./transactions.container.scss']
|
||||||
})
|
})
|
||||||
export class TransactionsContainer {
|
export class TransactionsContainer {
|
||||||
kyc$ = new Observable();
|
report$ = new Observable();
|
||||||
constructor(
|
constructor(
|
||||||
private kycService: KycService
|
private reportService: ReportService
|
||||||
) {
|
) {
|
||||||
this.kyc$ = this.kycService.getAll();
|
this.report$ = this.reportService.getAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,17 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-2 xl:col-span-3 xl:order-2">
|
<div class="col-span-2 xl:col-span-3 xl:order-2">
|
||||||
<mat-form-field>
|
<mat-form-field >
|
||||||
<i matTextPrefix class="bi bi-search"></i>
|
<input matInput [matDatepicker]="startDate" placeholder="วันที่ชำระ" (dateChange)="test()" />
|
||||||
<input matInput placeholder="วันที่ชำระ">
|
<mat-datepicker-toggle [for]="startDate" matSuffix></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #startDate></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-2 xl:col-span-3 xl:order-2">
|
<div class="col-span-2 xl:col-span-3 xl:order-2">
|
||||||
<mat-form-field>
|
<mat-form-field >
|
||||||
<i matTextPrefix class="bi bi-search"></i>
|
<input matInput [matDatepicker]="endDate" placeholder="ถึงวันที่" (dateChange)="test()"/>
|
||||||
<input matInput placeholder="ถึงวันที่">
|
<mat-datepicker-toggle [for]="endDate" matSuffix></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #endDate></mat-datepicker>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,51 +33,51 @@
|
|||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="table-wrap">
|
<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-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>
|
<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">
|
<ng-container matColumnDef="1">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tac" mat-sort-header>ลำดับ</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="2">
|
<ng-container matColumnDef="2">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal">Phone</th>
|
<th mat-header-cell *matHeaderCellDef class="tal">Phone</th>
|
||||||
<td mat-cell *matCellDef="let item" class="" style="min-width: 200px;">
|
<td mat-cell *matCellDef="let item" class="" style="min-width: 200px;">
|
||||||
{{item.name }}
|
{{item.phoneNumber}}
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="3">
|
<ng-container matColumnDef="3">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" mat-sort-header>ID</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="4">
|
<ng-container matColumnDef="4">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" mat-sort-header>PayeeFullname</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="5">
|
<ng-container matColumnDef="5">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150">PayerFullname</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="6">
|
<ng-container matColumnDef="6">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150">InvoiceID</th>
|
<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>
|
||||||
|
|
||||||
|
|
||||||
<ng-container matColumnDef="7">
|
<ng-container matColumnDef="7">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150">ref 1</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="8">
|
<ng-container matColumnDef="8">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150">ref 2</th>
|
<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>
|
||||||
|
|
||||||
<ng-container matColumnDef="9">
|
<ng-container matColumnDef="9">
|
||||||
@@ -87,35 +89,31 @@
|
|||||||
<ng-container matColumnDef="10">
|
<ng-container matColumnDef="10">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>paymentStatus</th>
|
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>paymentStatus</th>
|
||||||
<td mat-cell *matCellDef="let item" class="">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="11">
|
<ng-container matColumnDef="11">
|
||||||
<th mat-header-cell *matHeaderCellDef width="80">payment Channel</th>
|
<th mat-header-cell *matHeaderCellDef width="80">payment Channel</th>
|
||||||
<td mat-cell *matCellDef="let item">
|
<td mat-cell *matCellDef="let item">
|
||||||
<div class="action flex justify-center">
|
<div class="b-color-green"> {{ item.paymentChannel }}</div>
|
||||||
<div class="item">
|
|
||||||
<i class="bi bi-file-earmark-text icon-doc"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="12">
|
<ng-container matColumnDef="12">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>จำนวนเงิน</th>
|
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>จำนวนเงิน</th>
|
||||||
<td mat-cell *matCellDef="let item" class="">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="13">
|
<ng-container matColumnDef="13">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Create by</th>
|
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Create by</th>
|
||||||
<td mat-cell *matCellDef="let item" class="">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="14">
|
<ng-container matColumnDef="14">
|
||||||
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Update by</th>
|
<th mat-header-cell *matHeaderCellDef class="tal" width="150" mat-sort-header>Update by</th>
|
||||||
<td mat-cell *matCellDef="let item" class="">
|
<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>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container matColumnDef="15">
|
<ng-container matColumnDef="15">
|
||||||
@@ -131,6 +129,6 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div *ngIf="dataSourceCount === 0" class="no-data"></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>
|
||||||
</div>
|
</div>
|
||||||
@@ -6,12 +6,12 @@ import { Component, Input } from '@angular/core';
|
|||||||
styleUrls: ['./list.component.scss']
|
styleUrls: ['./list.component.scss']
|
||||||
})
|
})
|
||||||
export class ListComponent {
|
export class ListComponent {
|
||||||
@Input() kycList: any = [];
|
@Input() reportList: any = [];
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(event: any) {
|
test(){
|
||||||
|
console.log('test')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,14 +59,14 @@
|
|||||||
<div class="lg:flex lg:flex-col grid grid-cols-9 gap-2">
|
<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>
|
<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="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=" grid grid-cols-12 gap-2 md:gap-2 items-center">
|
||||||
<div class="col-span-2 md:col-span-4">
|
<div class="col-span-2 md:col-span-4">
|
||||||
<div class="flex justify-center items-center list-images-item">
|
<div class="flex justify-center items-center list-images-item">
|
||||||
<div class="list-images-action">
|
<div class="list-images-action">
|
||||||
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
|
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
|
||||||
</div>
|
</div>
|
||||||
<img (click)="onAttachmentsView()" src="" alt="">
|
<img (click)="onAttachmentsView()" [src]="form.get('file_url').value" alt="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
|
|||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
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 { IDialogConfigData } from 'src/app/@common/interface/Dialog';
|
||||||
import { EAction, EText } from 'src/app/@config/app';
|
import { EAction, EText } from 'src/app/@config/app';
|
||||||
import { AppService } from 'src/app/app.service';
|
import { AppService } from 'src/app/app.service';
|
||||||
import { BaseForm } from 'src/app/core/base/base-form';
|
import { BaseForm } from 'src/app/core/base/base-form';
|
||||||
import { BannerService } from 'src/app/core/service/common/banner.service';
|
import { BannerService } from 'src/app/core/service/common/banner.service';
|
||||||
|
import { UploadService } from 'src/app/core/service/common/upload.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dialog',
|
selector: 'app-dialog',
|
||||||
@@ -25,6 +26,7 @@ export class DialogComponent extends BaseForm implements OnInit {
|
|||||||
public location: Location,
|
public location: Location,
|
||||||
public bannerService: BannerService,
|
public bannerService: BannerService,
|
||||||
public appService: AppService,
|
public appService: AppService,
|
||||||
|
public uploadService: UploadService,
|
||||||
public cdr: ChangeDetectorRef
|
public cdr: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
super(router, activatedRoute, fb, location)
|
super(router, activatedRoute, fb, location)
|
||||||
@@ -82,61 +84,28 @@ export class DialogComponent extends BaseForm implements OnInit {
|
|||||||
).subscribe()
|
).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) {
|
async onAttachments($event: any) {
|
||||||
const file = $event.target.files[0];
|
const file = $event.target.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("ref", 'images');
|
formData.append("ref", 'images');
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
// try {
|
try {
|
||||||
// const res = await lastValueFrom(this.appService.post(`${API.attachments}/images`, formData));
|
const res = await lastValueFrom(this.uploadService.add(formData));
|
||||||
// this.dataForm.sellerPaymentImages = res.fileName;
|
this.form.get('file_url').setValue(res[0].file_name)
|
||||||
// this.uploadFile.nativeElement.value = null;
|
this.form.get('file_name').setValue(res[0].name)
|
||||||
// this.changeDetectorRef.detectChanges();
|
this.cdr.detectChanges();
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// this.appService.message(EText.ERROR);
|
this.appService.message(EText.ERROR);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onRemoveAttachments() {
|
onRemoveAttachments() {
|
||||||
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.DELETE));
|
this.form.get('file_url').setValue(null)
|
||||||
// if (!sweetalert.isConfirmed) return;
|
this.form.get('file_name').setValue(null)
|
||||||
// this.dataForm.paymentImages = null;
|
|
||||||
// this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAttachmentsView() {
|
onAttachmentsView() {
|
||||||
// const dialogConfig = deepCopy(this.dialogConfig);
|
window.open(this.form.get('file_url').value)
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,14 +59,14 @@
|
|||||||
<div class="lg:flex lg:flex-col grid grid-cols-9 gap-2">
|
<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>
|
<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="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=" grid grid-cols-12 gap-2 md:gap-2 items-center">
|
||||||
<div class="col-span-2 md:col-span-4">
|
<div class="col-span-2 md:col-span-4">
|
||||||
<div class="flex justify-center items-center list-images-item">
|
<div class="flex justify-center items-center list-images-item">
|
||||||
<div class="list-images-action">
|
<div class="list-images-action">
|
||||||
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
|
<i (click)="onRemoveAttachments()"class="bi bi-x-circle color-red cursor-pointer select-none"></i>
|
||||||
</div>
|
</div>
|
||||||
<img (click)="onAttachmentsView()" src="" alt="">
|
<img (click)="onAttachmentsView()" [src]="form.get('file_url').value" alt="">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
|
|||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
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 { IDialogConfigData } from 'src/app/@common/interface/Dialog';
|
||||||
import { EAction, EText } from 'src/app/@config/app';
|
import { EAction, EText } from 'src/app/@config/app';
|
||||||
import { AppService } from 'src/app/app.service';
|
import { AppService } from 'src/app/app.service';
|
||||||
import { BaseForm } from 'src/app/core/base/base-form';
|
import { BaseForm } from 'src/app/core/base/base-form';
|
||||||
import { PromotionService } from 'src/app/core/service/common/promotion.service';
|
import { PromotionService } from 'src/app/core/service/common/promotion.service';
|
||||||
|
import { UploadService } from 'src/app/core/service/common/upload.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dialog',
|
selector: 'app-dialog',
|
||||||
@@ -16,7 +17,6 @@ import { PromotionService } from 'src/app/core/service/common/promotion.service'
|
|||||||
styleUrls: ['./dialog.component.scss']
|
styleUrls: ['./dialog.component.scss']
|
||||||
})
|
})
|
||||||
export class DialogComponent extends BaseForm implements OnInit {
|
export class DialogComponent extends BaseForm implements OnInit {
|
||||||
data = false;
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: MatDialogRef<DialogComponent>,
|
public dialogRef: MatDialogRef<DialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public dialog: IDialogConfigData,
|
@Inject(MAT_DIALOG_DATA) public dialog: IDialogConfigData,
|
||||||
@@ -26,7 +26,8 @@ export class DialogComponent extends BaseForm implements OnInit {
|
|||||||
public location: Location,
|
public location: Location,
|
||||||
public promotionService: PromotionService,
|
public promotionService: PromotionService,
|
||||||
public appService: AppService,
|
public appService: AppService,
|
||||||
public cdr: ChangeDetectorRef
|
public cdr: ChangeDetectorRef,
|
||||||
|
public uploadService: UploadService
|
||||||
) {
|
) {
|
||||||
super(router, activatedRoute, fb, location)
|
super(router, activatedRoute, fb, location)
|
||||||
}
|
}
|
||||||
@@ -83,61 +84,28 @@ export class DialogComponent extends BaseForm implements OnInit {
|
|||||||
).subscribe()
|
).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) {
|
async onAttachments($event: any) {
|
||||||
const file = $event.target.files[0];
|
const file = $event.target.files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("ref", 'images');
|
formData.append("ref", 'images');
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
// try {
|
try {
|
||||||
// const res = await lastValueFrom(this.appService.post(`${API.attachments}/images`, formData));
|
const res = await lastValueFrom(this.uploadService.add(formData));
|
||||||
// this.dataForm.sellerPaymentImages = res.fileName;
|
this.form.get('file_url').setValue(res[0].file_name)
|
||||||
// this.uploadFile.nativeElement.value = null;
|
this.form.get('file_name').setValue(res[0].name)
|
||||||
// this.changeDetectorRef.detectChanges();
|
this.cdr.detectChanges();
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// this.appService.message(EText.ERROR);
|
this.appService.message(EText.ERROR);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onRemoveAttachments() {
|
onRemoveAttachments() {
|
||||||
// const sweetalert = await lastValueFrom(this.appService.confirm(EAction.DELETE));
|
this.form.get('file_url').setValue(null)
|
||||||
// if (!sweetalert.isConfirmed) return;
|
this.form.get('file_name').setValue(null)
|
||||||
// this.dataForm.paymentImages = null;
|
|
||||||
// this.changeDetectorRef.detectChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async onAttachmentsView() {
|
onAttachmentsView() {
|
||||||
// const dialogConfig = deepCopy(this.dialogConfig);
|
window.open(this.form.get('file_url').value)
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user