编写通用组件
This commit is contained in:
@@ -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<T> implements OnInit {
|
||||
|
||||
constructor() {
|
||||
constructor(private httpService: HttpService) {
|
||||
|
||||
}
|
||||
|
||||
@Input() data: Data<T>[]
|
||||
@Input() request: RequestObj
|
||||
|
||||
dataList: PageList<T> = new PageList<T>();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.httpService.Service<PageList<T>>(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;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user