编写通用组件
This commit is contained in:
@@ -1,4 +1,10 @@
|
|||||||
<nz-table>
|
<nz-table nzTableLayout="fixed"
|
||||||
|
[nzData]="dataList.list"
|
||||||
|
[nzTotal]="dataList.total"
|
||||||
|
[(nzPageIndex)]="dataList.pageNum"
|
||||||
|
[nzPageSize]="dataList.pageSize"
|
||||||
|
(nzPageIndexChange)="getData()"
|
||||||
|
nzFrontPagination="false">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<ng-container *ngFor="let headData of data">
|
<ng-container *ngFor="let headData of data">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||||
import {Data} from './data';
|
import {Data} from './data';
|
||||||
import {PageList, RequestObj} from '../../../../class/HttpReqAndResp';
|
import {PageList, RequestObj} from '../../../../class/HttpReqAndResp';
|
||||||
import {HttpService} from '../../../../api/http/http.service';
|
import {HttpService} from '../../../../api/http/http.service';
|
||||||
@@ -8,7 +8,7 @@ import {HttpService} from '../../../../api/http/http.service';
|
|||||||
templateUrl: './common-table.component.html',
|
templateUrl: './common-table.component.html',
|
||||||
styleUrls: ['./common-table.component.less']
|
styleUrls: ['./common-table.component.less']
|
||||||
})
|
})
|
||||||
export class CommonTableComponent<T> implements OnInit {
|
export class CommonTableComponent<T> implements OnInit, OnChanges {
|
||||||
|
|
||||||
constructor(private httpService: HttpService) {
|
constructor(private httpService: HttpService) {
|
||||||
|
|
||||||
@@ -20,9 +20,7 @@ export class CommonTableComponent<T> implements OnInit {
|
|||||||
dataList: PageList<T> = new PageList<T>();
|
dataList: PageList<T> = new PageList<T>();
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.httpService.Service<PageList<T>>(this.request).subscribe(resp => {
|
this.getData();
|
||||||
this.dataList = resp.result;
|
|
||||||
});
|
|
||||||
this.data.forEach(dat => {
|
this.data.forEach(dat => {
|
||||||
if (!dat.action) return;
|
if (!dat.action) return;
|
||||||
dat.action.forEach(act => {
|
dat.action.forEach(act => {
|
||||||
@@ -33,4 +31,13 @@ export class CommonTableComponent<T> implements OnInit {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getData = () => {
|
||||||
|
this.httpService.Service<PageList<T>>(this.request).subscribe(resp => {
|
||||||
|
this.dataList = resp.result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user