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-examinee-papers", templateUrl: "./examinee-papers.component.html", styleUrls: ["./examinee-papers.component.scss"], }) export class ExamineePapersComponent implements OnInit { constructor( private router: Router, private route: ActivatedRoute, public http: HttpClient, public snackBar: MatSnackBar, private tree: TreeService ) {} examineeId; //获取登录账号的个人资料 Profiles: any; ngOnInit(): void { this.Profiles = JSON.parse(sessionStorage.getItem("creatorData")); this.examineeId = this.route.snapshot.queryParams.examineeId; this.getAlltabledate(); } //获得所有组织机构 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.Profiles.organizationId) { element.parentId = null; } }); this.treedata = this.tree.toTree(data); this.getpresentOrganization(); }); } //得到当前单位所在组织机构的tree型数据 organizationName; newallorganizations; getpresentOrganization() { this.newallorganizations = this.allorganizations; this.newallorganizations.forEach((item) => { item.children = []; this.newallorganizations.forEach((element) => { if (element.parentId == item.id) { item.children.push(element); } }); }); this.organizationName = this.Profiles.organizationName; if (this.organizationName) { this.newallorganizations.forEach((item) => { if (item.name == this.organizationName) { this.nodes = [item]; this.expandedKeys = [item.key]; } }); } else { this.nodes = this.tree.toTree(this.treedata); this.expandedKeys = this.nodes[0].key; } } //获取表格信息 PageNumber = 1; PageSize = 10; name; starttime; endtime; orId; orIdChecked; tabledataSource; length; getAlltabledate() { console.log(5, this.starttime); let paramsdata: any = { ExamineeId: this.examineeId, ExaminationName: this.name || "", EndTimeBegin: this.starttime ? this.starttime + " " + "0:0:0" : "", EndTimeEnd: this.endtime ? this.endtime + " " + "23:59:59" : "", PageNumber: this.PageNumber, PageSize: this.PageSize, }; this.http .get("/api/ExamStatisticalAnalyses/ExaminationStatistics/Examinations", { params: paramsdata, }) .subscribe((data: any) => { this.tabledataSource = data.items; this.length = data.totalCount; }); } //分页事件 chagePage(e) { this.PageNumber = e.pageIndex + 1; this.getAlltabledate(); } To(item) { window.open(`/reviewFiles?examId=${item.examinationId}&paperType=1`); } //查询按钮 Submit() { this.getAlltabledate(); } //重置按钮 Reset() { this.name = ""; this.starttime = ""; this.endtime = ""; this.getAlltabledate(); } goback() { history.go(-1); } }