import { Component, OnInit } from "@angular/core"; import { HttpClient } from "@angular/common/http"; import { MatSnackBar } from "@angular/material/snack-bar"; import { ActivatedRoute, Router } from "@angular/router"; import { TreeService } from "src/app/http-interceptors/tree.service"; @Component({ selector: "app-station-examinee", templateUrl: "./station-examinee.component.html", styleUrls: ["./station-examinee.component.scss"], }) export class StationExamineeComponent implements OnInit { constructor( private router: Router, private route: ActivatedRoute, public http: HttpClient, public snackBar: MatSnackBar, private tree: TreeService ) {} loginUserInfo; ngOnInit() { this.loginUserInfo = JSON.parse(sessionStorage.getItem("creatorData")); this.orId = this.route.snapshot.queryParams.organizationId; this.getOrganizations(); this.getAlltabledate(); } //获取登录账号的个人资料 Profiles: any; getProfiles() { return new Promise((resolve) => { this.http.get("/api/ExamAccounts/Profiles").subscribe((data: any) => { this.Profiles = data; sessionStorage.setItem("creatorData", JSON.stringify(data)); resolve(data); }); }); } //获得所有组织机构 allorganizations; treedata; nodes = []; expandedKeys = []; getOrganizations() { this.http .get("/api/Organizations", { params: { strict: "true", }, }) .subscribe((data: any) => { this.allorganizations = data; this.allorganizations.forEach((element) => { if (element.id === this.loginUserInfo.organizationId) { element.parentId = null; } }); this.nodes = [...this.tree.toTree(data)]; }); } //获取表格信息 PageNumber = 1; PageSize = 10; name; orId; orIdChecked; tabledataSource; length; getAlltabledate() { let paramsdata: any = { ExamineeRealName: this.name || "", OrganizationId: this.orId || "", PageNumber: this.PageNumber, PageSize: this.PageSize, }; this.http .get("/api/ExamStatisticalAnalyses/ExaminationStatistics/Examinees", { params: paramsdata, }) .subscribe((data: any) => { console.log("数据", data); this.tabledataSource = data.items; this.length = data.totalCount; }); } //分页事件 chagePage(e) { this.PageNumber = e.pageIndex + 1; this.getAlltabledate(); } To(item) { this.router.navigate(["/home/statistic-examination/examinee-papers"], { queryParams: { examineeId: item.examineeId, examineeRealName: item.examineeRealName, }, }); //登陆成功跳转页面 } //查询按钮 Submit() { if (!this.orId) { this.snackBar.open("组织机构不能为空", "确定", { verticalPosition: "top", duration: 3000, }); return; } this.getAlltabledate(); } //重置按钮 Reset() { this.name = ""; this.orId = this.route.snapshot.queryParams.organizationId; // this.orIdChecked = true; this.getAlltabledate(); } }