You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.2 KiB
114 lines
3.2 KiB
import { Component, OnInit, ViewChild, Inject } from "@angular/core"; |
|
import { HttpClient } from "@angular/common/http"; |
|
import { |
|
MatTreeFlatDataSource, |
|
MatTreeFlattener, |
|
} from "@angular/material/tree"; |
|
import { MatPaginator } from "@angular/material/paginator"; |
|
import { FlatTreeControl } from "@angular/cdk/tree"; |
|
import { FormControl } from "@angular/forms"; |
|
import { Router, ActivatedRoute } from "@angular/router"; |
|
import { PageEvent } from "@angular/material/paginator"; |
|
import { MatDialog } from "@angular/material/dialog"; |
|
import { MatSnackBar } from "@angular/material/snack-bar"; |
|
import { TreeService } from "../../http-interceptors/tree.service"; |
|
@Component({ |
|
selector: "app-drill-record", |
|
templateUrl: "./drill-record.component.html", |
|
styleUrls: ["./drill-record.component.scss"], |
|
}) |
|
export class DrillRecordComponent implements OnInit { |
|
constructor( |
|
private http: HttpClient, |
|
private router: Router, |
|
private route: ActivatedRoute, |
|
private tree: TreeService, |
|
public dialog: MatDialog, |
|
public snackBar: MatSnackBar |
|
) {} |
|
|
|
private _transformer = (node, level: number) => { |
|
//初始化tree |
|
return { |
|
expandable: !!node.children && node.children.length > 0, |
|
name: node.name, |
|
level: level, |
|
id: node.id, |
|
parentId: node.parentId, |
|
children: node.children, |
|
}; |
|
}; |
|
treeControl = new FlatTreeControl<any>( |
|
(node) => node.level, |
|
(node) => node.expandable |
|
); |
|
treeFlattener = new MatTreeFlattener( |
|
this._transformer, |
|
(node) => node.level, |
|
(node) => node.expandable, |
|
(node) => node.children |
|
); |
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); |
|
myControl = new FormControl(); |
|
hasChild = (_: number, node: any) => node.expandable; |
|
//分页 |
|
@ViewChild(MatPaginator, { static: true }) |
|
pageEvent: PageEvent; |
|
paginator: MatPaginator; |
|
length: any = 4; //共多少条数据 |
|
pageSize: any = 10; //每页条数 |
|
pageSizeOptions: number[] = [10]; //设置每页条数 |
|
PageNumber: any = 1; //第几页 |
|
|
|
displayedColumns: string[] = ["name", "time1", "time2", "type", "operate"]; |
|
allorganizations: any; //所有组织机构 |
|
allunittype: any; //所有单位类型 |
|
tabledataSource: any; //表格数据 |
|
IsNewData = ""; //维护更新活新增 |
|
|
|
preparelevels: any; |
|
ngOnInit(): void { |
|
this.tabledataSource = [ |
|
{ |
|
name: "中保大厦有限公司", |
|
time1: "2023-5-18 07:19", |
|
time2: "2023.5.18-2023.5.19", |
|
type: "二维预案演练", |
|
}, |
|
{ |
|
name: "上海通高制造有限公司", |
|
time1: "2023-5-19 09:09", |
|
time2: "2023.5.19-2023.5.19", |
|
type: "二维预案演练", |
|
}, |
|
{ |
|
name: "怡莲超市", |
|
time1: "2023-5-20 08:23", |
|
time2: "2023.5.20-2023.5.21", |
|
type: "二维预案演练", |
|
}, |
|
{ |
|
name: "永兴商务广场", |
|
time1: "2023-5-25 12:50", |
|
time2: "2023.5.25-2023.5.26", |
|
type: "二维预案演练", |
|
}, |
|
]; |
|
} |
|
|
|
//分页事件 |
|
chagePage(e) { |
|
this.PageNumber = e.pageIndex + 1; |
|
} |
|
|
|
name; |
|
time; |
|
//查询 |
|
onSubmit(e) { |
|
this.PageNumber = 1; |
|
this.pageEvent.pageIndex = 0; |
|
} |
|
|
|
//重置 |
|
reset() {} |
|
}
|
|
|