[init] init version
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { BaseListComponent } from "../../../../@common/base/base-list.component";
|
||||
import { debounceTime, distinctUntilChanged, lastValueFrom, Subject } from "rxjs";
|
||||
import { MatDialog } from "@angular/material/dialog";
|
||||
import { AppService } from "../../../../app.service";
|
||||
import { API } from "../../../../@config/app";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: "app-appraisal-1st-time-index",
|
||||
templateUrl: "./appraisal-1st-time-index.component.html",
|
||||
styleUrls: []
|
||||
})
|
||||
export class Appraisal1stTimeIndexComponent extends BaseListComponent implements OnInit {
|
||||
|
||||
pageTitle = "สินค้า";
|
||||
apiUrl: string = API.products;
|
||||
api: any = API;
|
||||
displayedColumns: string[] = ["action", "price", "latestPrice","code", "name", "brandId", "size",'weight', "color", "year" ];
|
||||
masterProductCategory: any = [];
|
||||
masterProductBrand: any = [];
|
||||
filterKeyword: Subject<string> = new Subject<string>();
|
||||
|
||||
constructor(
|
||||
private dialog: MatDialog,
|
||||
private router: Router,
|
||||
public appService: AppService
|
||||
) {
|
||||
super();
|
||||
|
||||
this.filterKeyword.pipe(debounceTime(1000), distinctUntilChanged()).subscribe(model => {
|
||||
this.getData();
|
||||
});
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
this.masterProductCategory = await lastValueFrom(this.appService.get(`${this.api.masterProductCategory}?showAll=true&status=true`));
|
||||
this.masterProductBrand = await lastValueFrom(this.appService.get(`${this.api.masterProductBrand}?showAll=true&status=true`));
|
||||
await this.getData();
|
||||
}
|
||||
|
||||
onAction(id?: any) {
|
||||
if (id) return this.router.navigate(["/pages/appraisal/1st-time/do", "create", id]);
|
||||
return this.router.navigate(["/pages/appraisal/1st-time/history"]);
|
||||
}
|
||||
|
||||
async getData($event?: any) {
|
||||
try {
|
||||
this.dataFilter.keywordColumn = "name,price,latestPrice";
|
||||
const dataSource = await lastValueFrom(this.appService.get(this.setParams(this.apiUrl, $event)));
|
||||
this.dataSource = this.setDataSource<any>(dataSource);
|
||||
} catch (e) {
|
||||
this.dataSource = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onFilter($event?: any) {
|
||||
this.filterKeyword.next($event);
|
||||
}
|
||||
|
||||
async onSort($event: any) {
|
||||
this.dataFilter.orderBy = $event.active;
|
||||
this.dataFilter.sort = $event.direction;
|
||||
await this.getData();
|
||||
console.log($event);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user