diff --git a/src/app/view/admin/admin-routing.module.ts b/src/app/view/admin/admin-routing.module.ts index 3e715e6..dee7c4e 100644 --- a/src/app/view/admin/admin-routing.module.ts +++ b/src/app/view/admin/admin-routing.module.ts @@ -45,6 +45,10 @@ const routes: Routes = [ loadChildren: () => import('./admin-visitor/admin-visitor.module').then(mod => mod.AdminVisitorModule), // canActivate: [AuthGuard] }, + { + path: 'test', + loadChildren: () => import('./test-common-table/test-common-table.module').then(Mod => Mod.TestCommonTableModule) + }, { path: '**', loadChildren: () => import('./admin-dashboard/admin-dashboard.module').then(mod => mod.AdminDashboardModule), diff --git a/src/app/view/admin/components/common-table/common-table.component.html b/src/app/view/admin/components/common-table/common-table.component.html index f2c6b45..670afdf 100644 --- a/src/app/view/admin/components/common-table/common-table.component.html +++ b/src/app/view/admin/components/common-table/common-table.component.html @@ -1,24 +1,33 @@ - - {{headData.fieldName}} - + + + {{headData.fieldName}} + + - - - - {{headData.fieldName}} - - - - {{action.name}} - - - + + + + + {{t[headData.fieldValue]}} + + + + {{action.name}} + + + + + + + + diff --git a/src/app/view/admin/components/common-table/common-table.component.ts b/src/app/view/admin/components/common-table/common-table.component.ts index f4beb4e..b17761a 100644 --- a/src/app/view/admin/components/common-table/common-table.component.ts +++ b/src/app/view/admin/components/common-table/common-table.component.ts @@ -1,5 +1,7 @@ import {Component, Input, OnInit} from '@angular/core'; import {Data} from './data'; +import {PageList, RequestObj} from '../../../../class/HttpReqAndResp'; +import {HttpService} from '../../../../api/http/http.service'; @Component({ selector: 'app-common-table', @@ -8,12 +10,27 @@ import {Data} from './data'; }) export class CommonTableComponent implements OnInit { - constructor() { + constructor(private httpService: HttpService) { + } @Input() data: Data[] + @Input() request: RequestObj + + dataList: PageList = new PageList(); ngOnInit(): void { + this.httpService.Service>(this.request).subscribe(resp => { + this.dataList = resp.result; + }); + this.data.forEach(dat => { + if (!dat.action) return; + dat.action.forEach(act => { + if (!act.hover) { + act.hover = () => null; + } + }) + }) } } diff --git a/src/app/view/admin/components/common-table/common-table.module.ts b/src/app/view/admin/components/common-table/common-table.module.ts index 298ce25..3e832b6 100644 --- a/src/app/view/admin/components/common-table/common-table.module.ts +++ b/src/app/view/admin/components/common-table/common-table.module.ts @@ -1,16 +1,20 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {CommonTableComponent} from './common-table.component'; -import {NzTableModule} from "ng-zorro-antd"; +import {NzDividerModule, NzTableModule} from 'ng-zorro-antd'; @NgModule({ declarations: [ CommonTableComponent ], + exports: [ + CommonTableComponent + ], imports: [ CommonModule, - NzTableModule + NzTableModule, + NzDividerModule ] }) export class CommonTableModule { diff --git a/src/app/view/admin/components/common-table/data.d.ts b/src/app/view/admin/components/common-table/data.d.ts deleted file mode 100644 index 6c8ccd5..0000000 --- a/src/app/view/admin/components/common-table/data.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export class Data { - fieldName: string; - fieldValue: string; - show: boolean; - bindData?: T; - isActionColumns: boolean; - action: { - name: string, - color: string, - order: number, - fontSize: string, - click: (data: T) => void, - hover: (data: T) => void; - }[] -} diff --git a/src/app/view/admin/components/common-table/data.ts b/src/app/view/admin/components/common-table/data.ts new file mode 100644 index 0000000..83a6c7b --- /dev/null +++ b/src/app/view/admin/components/common-table/data.ts @@ -0,0 +1,15 @@ +export class Data { + fieldName: string; + fieldValue: string; + show: boolean = true; + primaryKey?: boolean = false; + isActionColumns?: boolean = false; + action?: { + name: string, + color?: string, + order?: number, + fontSize?: string, + click: (data: T) => void, + hover?: (data: T) => void | null; + }[] = [] +}