编写通用组件

This commit is contained in:
禾几海
2020-06-30 23:56:16 +08:00
parent c271b1a8cf
commit 781513d8c9
6 changed files with 67 additions and 33 deletions

View File

@@ -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;
}
})
})
}
}