40 changed files with 3049 additions and 2110 deletions
@ -1,62 +1,69 @@ |
|||||||
import { Component, OnInit } from '@angular/core'; |
import { Component, OnInit } from "@angular/core"; |
||||||
import { Router,ActivatedRoute } from '@angular/router' |
import { Router, ActivatedRoute } from "@angular/router"; |
||||||
import { MatSnackBarConfig, MatSnackBar } from '@angular/material/snack-bar'; |
import { MatSnackBarConfig, MatSnackBar } from "@angular/material/snack-bar"; |
||||||
import { HttpClient } from '@angular/common/http'; |
import { HttpClient } from "@angular/common/http"; |
||||||
import { IsLoginService } from '../../is-login.service'//引入服务
|
import { IsLoginService } from "../../is-login.service"; //引入服务
|
||||||
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
|
import { CacheTokenService } from "../../http-interceptors/cache-token.service"; //引入服务
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({ |
@Component({ |
||||||
selector: 'app-lockscreen', |
selector: "app-lockscreen", |
||||||
templateUrl: './lockscreen.component.html', |
templateUrl: "./lockscreen.component.html", |
||||||
styleUrls: ['./lockscreen.component.scss'] |
styleUrls: ["./lockscreen.component.scss"], |
||||||
}) |
}) |
||||||
export class LockscreenComponent implements OnInit { |
export class LockscreenComponent implements OnInit { |
||||||
|
constructor( |
||||||
|
private http: HttpClient, |
||||||
|
private router: Router, |
||||||
|
private route: ActivatedRoute, |
||||||
|
public token: CacheTokenService, |
||||||
|
public snackBar: MatSnackBar, |
||||||
|
private isLogin: IsLoginService |
||||||
|
) {} |
||||||
|
|
||||||
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar,private isLogin:IsLoginService) { } |
ngOnInit() {} |
||||||
|
|
||||||
ngOnInit() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
roleType:string = '1'; //登录角色
|
|
||||||
errmsg :string = ''; //错误信息
|
|
||||||
|
|
||||||
|
|
||||||
|
roleType: string = "1"; //登录角色
|
||||||
|
errmsg: string = ""; //错误信息
|
||||||
|
|
||||||
//登录
|
//登录
|
||||||
onSubmit(e) { |
onSubmit(e) { |
||||||
let params = { roleType: this.roleType } |
let params = { roleType: this.roleType }; |
||||||
this.http.post('/api/ExamAccounts/SignIn',e,{params}).subscribe((data:any)=>{ |
this.http.post("/api/ExamAccounts/SignIn", e, { params }).subscribe( |
||||||
|
(data: any) => { |
||||||
sessionStorage.setItem("realName", data.realName); |
sessionStorage.setItem("realName", data.realName); |
||||||
sessionStorage.setItem("roleType", data.roleType); |
sessionStorage.setItem("roleType", data.roleType); |
||||||
sessionStorage.setItem("token", data.token); |
sessionStorage.setItem("token", data.token); |
||||||
sessionStorage.setItem("refreshToken", data.refreshToken); |
sessionStorage.setItem("refreshToken", data.refreshToken); |
||||||
sessionStorage.setItem("level", data.level); |
sessionStorage.setItem("level", data.level); |
||||||
|
this.http.get("/api/ExamAccounts/Profiles").subscribe((v: any) => { |
||||||
this.token.startUp(); //登陆成功启动定时器刷新token
|
this.token.startUp(); //登陆成功启动定时器刷新token
|
||||||
this.roleType == '1'? this.router.navigate(['/home/createexam-index']) : this.router.navigate(['/home/student-index']) |
this.roleType == "1" |
||||||
},(err) => {this.errmsg = err}) |
? this.router.navigate(["/home/createexam-index"]) |
||||||
|
: this.router.navigate(["/home/student-index"]); |
||||||
|
sessionStorage.setItem("creatorData", JSON.stringify(v)); |
||||||
|
}); |
||||||
|
}, |
||||||
|
(err) => { |
||||||
|
this.errmsg = err; |
||||||
|
} |
||||||
|
); |
||||||
} |
} |
||||||
|
|
||||||
//切换登录角色
|
//切换登录角色
|
||||||
toggle(e) { |
toggle(e) { |
||||||
this.roleType = e |
this.roleType = e; |
||||||
} |
} |
||||||
|
|
||||||
//跳转管理员登录页面
|
//跳转管理员登录页面
|
||||||
toAdminLogin() { |
toAdminLogin() { |
||||||
this.router.navigate(['/adminLogin']) //跳转管理员登录页面
|
this.router.navigate(["/adminLogin"]); //跳转管理员登录页面
|
||||||
} |
} |
||||||
|
|
||||||
//忘记密码弹窗
|
//忘记密码弹窗
|
||||||
forget() { |
forget() { |
||||||
const config = new MatSnackBarConfig(); |
const config = new MatSnackBarConfig(); |
||||||
config.verticalPosition = 'top'; |
config.verticalPosition = "top"; |
||||||
config.duration = 3000 |
config.duration = 3000; |
||||||
this.snackBar.open('请联系管理员重置密码','确定',config); |
this.snackBar.open("请联系管理员重置密码", "确定", config); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,46 @@ |
|||||||
|
<h2 mat-dialog-title>新增/编辑管理员</h2> |
||||||
|
|
||||||
|
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> |
||||||
|
|
||||||
|
<div> |
||||||
|
<mat-form-field> |
||||||
|
<input matInput name="name" [(ngModel)]="name" required placeholder="登录账号" autocomplete="off"> |
||||||
|
</mat-form-field> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div> |
||||||
|
<mat-form-field> |
||||||
|
<input matInput name="realName" [(ngModel)]="realName" required placeholder="用户姓名" autocomplete="off"> |
||||||
|
</mat-form-field> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div style="margin-bottom: 10px;"> |
||||||
|
<p style="font-size: 14px;">消防救援站: <label style="margin-left: 10px;">{{organizationName}}</label></p> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="treeDiv"> |
||||||
|
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> |
||||||
|
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'> |
||||||
|
<button type="button" mat-icon-button disabled></button> |
||||||
|
<li>{{node.name}}</li> |
||||||
|
</mat-tree-node> |
||||||
|
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'> |
||||||
|
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name"> |
||||||
|
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : |
||||||
|
'chevron_right'}}</mat-icon> |
||||||
|
</button> |
||||||
|
<li>{{node.name}}</li> |
||||||
|
</mat-tree-node> |
||||||
|
</mat-tree> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div mat-dialog-content *ngIf="errmsg"> |
||||||
|
<p style="font-size: 14px; color: red;">{{errmsg}}</p> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div mat-dialog-actions> |
||||||
|
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button> |
||||||
|
<button mat-raised-button mat-dialog-close>取消</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
</form> |
@ -0,0 +1,25 @@ |
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||||
|
|
||||||
|
import { AddEditAdminComponent } from './add-edit-admin.component'; |
||||||
|
|
||||||
|
describe('AddEditAdminComponent', () => { |
||||||
|
let component: AddEditAdminComponent; |
||||||
|
let fixture: ComponentFixture<AddEditAdminComponent>; |
||||||
|
|
||||||
|
beforeEach(async(() => { |
||||||
|
TestBed.configureTestingModule({ |
||||||
|
declarations: [ AddEditAdminComponent ] |
||||||
|
}) |
||||||
|
.compileComponents(); |
||||||
|
})); |
||||||
|
|
||||||
|
beforeEach(() => { |
||||||
|
fixture = TestBed.createComponent(AddEditAdminComponent); |
||||||
|
component = fixture.componentInstance; |
||||||
|
fixture.detectChanges(); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should create', () => { |
||||||
|
expect(component).toBeTruthy(); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,110 @@ |
|||||||
|
import { HttpClient } from "@angular/common/http"; |
||||||
|
import { Component, OnInit, Inject } from "@angular/core"; |
||||||
|
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; |
||||||
|
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar"; |
||||||
|
import { |
||||||
|
MatTreeFlatDataSource, |
||||||
|
MatTreeFlattener, |
||||||
|
} from "@angular/material/tree"; |
||||||
|
import { FlatTreeControl } from "@angular/cdk/tree"; |
||||||
|
@Component({ |
||||||
|
selector: "app-add-edit-admin", |
||||||
|
templateUrl: "./add-edit-admin.component.html", |
||||||
|
styleUrls: ["./add-edit-admin.component.scss"], |
||||||
|
}) |
||||||
|
export class AddEditAdminComponent implements OnInit { |
||||||
|
constructor( |
||||||
|
private http: HttpClient, |
||||||
|
public dialogRef: MatDialogRef<AddEditAdminComponent>, |
||||||
|
@Inject(MAT_DIALOG_DATA) public data, |
||||||
|
public snackBar: MatSnackBar |
||||||
|
) {} |
||||||
|
|
||||||
|
ngOnInit(): void { |
||||||
|
this.dataSource.data = this.data.treeData; |
||||||
|
if (this.data.userData) { |
||||||
|
this.name = JSON.parse(JSON.stringify(this.data.userData.name)); |
||||||
|
this.realName = JSON.parse(JSON.stringify(this.data.userData.realName)); |
||||||
|
this.organizationId = JSON.parse( |
||||||
|
JSON.stringify(this.data.userData.organizationId) |
||||||
|
); |
||||||
|
this.organizationName = JSON.parse( |
||||||
|
JSON.stringify(this.data.userData.organizationName) |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
errmsg: string = null; //捕获错误信息
|
||||||
|
|
||||||
|
name: string = null; |
||||||
|
realName: string = null; |
||||||
|
organizationId: string = null; |
||||||
|
organizationName: string = null; |
||||||
|
|
||||||
|
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); |
||||||
|
hasChild = (_: number, node: any) => node.expandable; |
||||||
|
|
||||||
|
//选择tree节点
|
||||||
|
selectTree(e) { |
||||||
|
this.organizationId = e.id; |
||||||
|
this.organizationName = e.name; |
||||||
|
} |
||||||
|
|
||||||
|
//提交创建表单
|
||||||
|
onSubmit(e) { |
||||||
|
if (this.organizationId && this.organizationName) { |
||||||
|
if (this.data.userData) { |
||||||
|
e.phone = this.data.userData.phone; |
||||||
|
e.identityCard = this.data.userData.identityCard; |
||||||
|
e.roleType = 0; |
||||||
|
e.id = this.data.userData.id; |
||||||
|
e.enabled = this.data.userData.enabled; |
||||||
|
e.creationTime = new Date(); |
||||||
|
e.organizationId = this.organizationId; |
||||||
|
e.organizationName = this.organizationName; |
||||||
|
this.http |
||||||
|
.put(`/api/ExamUsers/${this.data.userData.id}`, e) |
||||||
|
.subscribe((data) => { |
||||||
|
this.dialogRef.close("success"); |
||||||
|
}); |
||||||
|
} else { |
||||||
|
e.phone = '13864512542'; |
||||||
|
e.identityCard = '370304199809261911'; |
||||||
|
e.roleType = 0; |
||||||
|
e.enabled = true; |
||||||
|
e.creationTime = new Date(); |
||||||
|
e.organizationId = this.organizationId; |
||||||
|
e.organizationName = this.organizationName; |
||||||
|
this.http.post(`/api/ExamUsers`, e).subscribe((data) => { |
||||||
|
this.dialogRef.close("success"); |
||||||
|
}); |
||||||
|
} |
||||||
|
} else { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("请选择消防救援站", "确定", config); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
<div class="content"> |
||||||
|
<div class="header"> |
||||||
|
<form #form="ngForm"> |
||||||
|
<div class="queryBox"> |
||||||
|
<div class="queryField"> |
||||||
|
<label style="margin-right: 10px;">用户账号:</label> |
||||||
|
<input type="text" [(ngModel)]="identityCard" name="identityCard" autocomplete="off" |
||||||
|
placeholder="请输入用户账号"> |
||||||
|
</div> |
||||||
|
<div class="queryField"> |
||||||
|
<label style="margin-right: 10px;">用户姓名:</label> |
||||||
|
<input type="text" [(ngModel)]="name" name="name" autocomplete="off" placeholder="请输入用户姓名"> |
||||||
|
</div> |
||||||
|
<div class="queryField" style="position: relative;"> |
||||||
|
<label style="margin-right: 10px;">消防救援站:</label> |
||||||
|
<nz-tree-select [nzDropdownClassName]="'maxHeightTreeSelect'" style="width: 180px" [nzNodes]="nodes" |
||||||
|
nzShowSearch nzPlaceHolder="请选择救援站" name="orTree" [(ngModel)]="organizationId" |
||||||
|
[nzAllowClear]="false"> |
||||||
|
</nz-tree-select> |
||||||
|
</div> |
||||||
|
<div class="queryField"> |
||||||
|
<button mat-raised-button (click)='getAllUsers()' style="background-color: #07CDCF;">查询</button> |
||||||
|
<button mat-raised-button (click)='empty()' |
||||||
|
style="margin-left: 10px; background-color: #FF8678;">重置</button> |
||||||
|
</div> |
||||||
|
<div class="queryField"> |
||||||
|
<button mat-raised-button (click)='open()' style="background-color: #07CDCF;">新增管理员</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
<table mat-table [dataSource]="dataSource"> |
||||||
|
<ng-container matColumnDef="identitycard"> |
||||||
|
<th mat-header-cell *matHeaderCellDef>用户帐号</th> |
||||||
|
<td mat-cell *matCellDef="let element">{{element.name}}</td> |
||||||
|
</ng-container> |
||||||
|
|
||||||
|
<ng-container matColumnDef="name"> |
||||||
|
<th mat-header-cell *matHeaderCellDef>用户姓名</th> |
||||||
|
<td mat-cell *matCellDef="let element">{{element.realName}}</td> |
||||||
|
</ng-container> |
||||||
|
|
||||||
|
<ng-container matColumnDef="post"> |
||||||
|
<th mat-header-cell *matHeaderCellDef>消防救援站</th> |
||||||
|
<td mat-cell *matCellDef="let element">{{element.organizationName}}</td> |
||||||
|
</ng-container> |
||||||
|
|
||||||
|
<ng-container matColumnDef="time"> |
||||||
|
<th mat-header-cell *matHeaderCellDef>创建时间</th> |
||||||
|
<td mat-cell *matCellDef="let element">{{element.creationTime | date:'yyyy-MM-dd'}}</td> |
||||||
|
</ng-container> |
||||||
|
|
||||||
|
<ng-container matColumnDef="operation"> |
||||||
|
<th mat-header-cell *matHeaderCellDef>操作</th> |
||||||
|
<td mat-cell *matCellDef="let element"> |
||||||
|
<span class="operationSpan"><span class="spanbtn green" (click)="reset(element)">重置密码</span></span> |
||||||
|
<span class="operationSpan"><span class="spanbtn green" (click)="edit(element)">编辑</span></span> |
||||||
|
<span *ngIf="element.enabled" class="operationSpan"><span class="spanbtn red" |
||||||
|
(click)="noEnabled(element)">禁用</span></span> |
||||||
|
<span *ngIf="!element.enabled" class="operationSpan"><span class="spanbtn gray" |
||||||
|
(click)="enabled(element)">启用</span></span> |
||||||
|
<span class="operationSpan"><span class="spanbtn red" (click)="delete(element)">删除</span></span> |
||||||
|
</td> |
||||||
|
</ng-container> |
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> |
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> |
||||||
|
</table> |
||||||
|
<mat-paginator [length]="length" [pageSize]="pageSize" (page)="chagePage($event)"> |
||||||
|
</mat-paginator> |
||||||
|
|
||||||
|
</div> |
@ -0,0 +1,115 @@ |
|||||||
|
table { |
||||||
|
width: 100%; |
||||||
|
text-align: center; |
||||||
|
|
||||||
|
.cdk-header-cell { |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
.content { |
||||||
|
width: 100%; |
||||||
|
height: 100%; |
||||||
|
overflow: hidden; |
||||||
|
background: #F2F5F6; |
||||||
|
} |
||||||
|
|
||||||
|
.header { |
||||||
|
width: 100%; |
||||||
|
padding: 10px; |
||||||
|
margin-bottom: 10px; |
||||||
|
box-sizing: border-box; |
||||||
|
|
||||||
|
.queryBox { |
||||||
|
box-sizing: border-box; |
||||||
|
padding: 5px 15px; |
||||||
|
display: flex; |
||||||
|
flex-direction: row; |
||||||
|
flex-wrap: wrap; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
|
||||||
|
.queryField { |
||||||
|
margin: 0 25px; |
||||||
|
font-size: 14px; |
||||||
|
|
||||||
|
input { |
||||||
|
width: 160px; |
||||||
|
height: 30px; |
||||||
|
line-height: 30px; |
||||||
|
border-radius: 2px; |
||||||
|
padding-left: 6px; |
||||||
|
outline: none; |
||||||
|
border: 1px solid rgb(226, 211, 211); |
||||||
|
} |
||||||
|
|
||||||
|
button { |
||||||
|
color: #fff; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//queryBox |
||||||
|
} |
||||||
|
|
||||||
|
.operationSpan { |
||||||
|
margin: 0 10px; |
||||||
|
|
||||||
|
.spanbtn { |
||||||
|
font-weight: 550; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
|
||||||
|
.green { |
||||||
|
color: #04ced1; |
||||||
|
} |
||||||
|
|
||||||
|
.red { |
||||||
|
color: #FF8678 |
||||||
|
} |
||||||
|
|
||||||
|
.gray { |
||||||
|
color: gray; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//tree |
||||||
|
.treeDiv { |
||||||
|
max-height: 300px; |
||||||
|
overflow-y: auto; |
||||||
|
|
||||||
|
.mat-icon-button { |
||||||
|
width: 20px; |
||||||
|
height: 20px; |
||||||
|
line-height: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
li { |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
|
||||||
|
.mat-tree-node:hover { |
||||||
|
background-color: rgb(240, 236, 236); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
.closeTree { |
||||||
|
cursor: pointer; |
||||||
|
position: absolute; |
||||||
|
top: 40px; |
||||||
|
right: -95px; |
||||||
|
z-index: 100; |
||||||
|
} |
||||||
|
|
||||||
|
.searchTree { |
||||||
|
.mat-tree-node button .mat-icon { |
||||||
|
color: #000; |
||||||
|
} |
||||||
|
|
||||||
|
border: 1px solid rgb(207, 204, 204); |
||||||
|
width: 350px; |
||||||
|
max-height: 150px; |
||||||
|
position: absolute; |
||||||
|
top: 40px; |
||||||
|
left: 0; |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||||
|
|
||||||
|
import { AdministratorsComponent } from './administrators.component'; |
||||||
|
|
||||||
|
describe('AdministratorsComponent', () => { |
||||||
|
let component: AdministratorsComponent; |
||||||
|
let fixture: ComponentFixture<AdministratorsComponent>; |
||||||
|
|
||||||
|
beforeEach(async(() => { |
||||||
|
TestBed.configureTestingModule({ |
||||||
|
declarations: [ AdministratorsComponent ] |
||||||
|
}) |
||||||
|
.compileComponents(); |
||||||
|
})); |
||||||
|
|
||||||
|
beforeEach(() => { |
||||||
|
fixture = TestBed.createComponent(AdministratorsComponent); |
||||||
|
component = fixture.componentInstance; |
||||||
|
fixture.detectChanges(); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should create', () => { |
||||||
|
expect(component).toBeTruthy(); |
||||||
|
}); |
||||||
|
}); |
@ -0,0 +1,200 @@ |
|||||||
|
import { Component, OnInit, ViewChild, Inject } from "@angular/core"; |
||||||
|
import { HttpClient } from "@angular/common/http"; |
||||||
|
import { |
||||||
|
MatDialogRef, |
||||||
|
MatDialog, |
||||||
|
MAT_DIALOG_DATA, |
||||||
|
} from "@angular/material/dialog"; |
||||||
|
import { MatPaginator } from "@angular/material/paginator"; |
||||||
|
import { MatTableDataSource } from "@angular/material/table"; |
||||||
|
import { PageEvent } from "@angular/material/paginator"; |
||||||
|
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar"; |
||||||
|
import { FormControl } from "@angular/forms"; |
||||||
|
import { FlatTreeControl } from "@angular/cdk/tree"; |
||||||
|
import { |
||||||
|
MatTreeFlatDataSource, |
||||||
|
MatTreeFlattener, |
||||||
|
} from "@angular/material/tree"; |
||||||
|
import { TreeService } from "src/app/http-interceptors/tree.service"; |
||||||
|
import { AddEditAdminComponent } from "./add-edit-admin/add-edit-admin.component"; |
||||||
|
|
||||||
|
@Component({ |
||||||
|
selector: "app-administrators", |
||||||
|
templateUrl: "./administrators.component.html", |
||||||
|
styleUrls: ["./administrators.component.scss"], |
||||||
|
}) |
||||||
|
export class AdministratorsComponent implements OnInit { |
||||||
|
constructor( |
||||||
|
public http: HttpClient, |
||||||
|
public dialog: MatDialog, |
||||||
|
public snackBar: MatSnackBar, |
||||||
|
public treeService: TreeService |
||||||
|
) {} |
||||||
|
|
||||||
|
loginUserInfo; |
||||||
|
ngOnInit() { |
||||||
|
this.loginUserInfo = JSON.parse(sessionStorage.getItem("creatorData")); |
||||||
|
this.getOrganizations(); |
||||||
|
} |
||||||
|
name: any; //用户姓名
|
||||||
|
identityCard: any; //用户账号
|
||||||
|
organizationId; |
||||||
|
allOrganizations: any; //所有组织机构
|
||||||
|
nodes = []; |
||||||
|
//获取所有组织机构
|
||||||
|
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.treeService.toTree(this.allOrganizations)]; |
||||||
|
this.organizationId = this.loginUserInfo.organizationId; |
||||||
|
this.getAllUsers(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
displayedColumns: string[] = [ |
||||||
|
"identitycard", |
||||||
|
"name", |
||||||
|
"post", |
||||||
|
"time", |
||||||
|
"operation", |
||||||
|
]; |
||||||
|
|
||||||
|
dataSource: any; //所有企业用户表格数据
|
||||||
|
//更新当前页数据
|
||||||
|
pageNumber: number = 1; //第几页
|
||||||
|
pageSize: any = "10"; //每页条数
|
||||||
|
getAllUsers() { |
||||||
|
let data = { |
||||||
|
Name: this.identityCard || "", |
||||||
|
RealName: this.name || "", |
||||||
|
OrganizationId: this.organizationId || "", |
||||||
|
RoleType: "0", |
||||||
|
PageNumber: String(this.pageNumber), |
||||||
|
PageSize: this.pageSize, |
||||||
|
}; |
||||||
|
this.http.get("/api/ExamUsers", { params: data }).subscribe((data: any) => { |
||||||
|
this.length = data.totalCount; |
||||||
|
this.pageSize = data.pageSize; |
||||||
|
this.dataSource = new MatTableDataSource<any>(data.items); |
||||||
|
}); |
||||||
|
} |
||||||
|
//分页
|
||||||
|
@ViewChild(MatPaginator, { static: true }) |
||||||
|
pageEvent: PageEvent; |
||||||
|
paginator: MatPaginator; |
||||||
|
length: any; //共多少条数据
|
||||||
|
|
||||||
|
//分页切换
|
||||||
|
chagePage(e) { |
||||||
|
this.pageNumber = e.pageIndex + 1; |
||||||
|
this.getAllUsers(); |
||||||
|
} |
||||||
|
|
||||||
|
//清空搜索
|
||||||
|
empty() { |
||||||
|
this.pageNumber = 1; |
||||||
|
this.name = ""; |
||||||
|
this.identityCard = ""; |
||||||
|
this.organizationId = this.loginUserInfo.organizationId; |
||||||
|
this.getAllUsers(); |
||||||
|
} |
||||||
|
|
||||||
|
//创建教员
|
||||||
|
open() { |
||||||
|
let data = { treeData: this.nodes, userData: null }; |
||||||
|
let dialogRef = this.dialog.open(AddEditAdminComponent, { data }); |
||||||
|
dialogRef.afterClosed().subscribe((data) => { |
||||||
|
if (data) { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("创建成功!", "确定", config); |
||||||
|
this.getAllUsers(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//编辑企业用户
|
||||||
|
edit(e) { |
||||||
|
let data = { treeData: this.nodes, userData: e }; |
||||||
|
let dialogRef = this.dialog.open(AddEditAdminComponent, { data }); |
||||||
|
dialogRef.afterClosed().subscribe((data) => { |
||||||
|
if (data) { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("修改成功!", "确定", config); |
||||||
|
this.getAllUsers(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//重置密码
|
||||||
|
reset(e) { |
||||||
|
this.http.put(`/api/ExamUsers/${e.id}/ResetPassword`, {}).subscribe( |
||||||
|
(data) => { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("重置密码成功!", "确定", config); |
||||||
|
}, |
||||||
|
(err) => { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("重置密码失败!", "确定", config); |
||||||
|
} |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
//启用
|
||||||
|
enabled(e) { |
||||||
|
e.date = new Date(); |
||||||
|
e.enabled = true; |
||||||
|
this.http.put(`/api/ExamUsers/${e.id}`, e).subscribe((data) => { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("启用成功!", "确定", config); |
||||||
|
this.getAllUsers(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//禁用
|
||||||
|
noEnabled(e) { |
||||||
|
e.date = new Date(); |
||||||
|
e.enabled = false; |
||||||
|
this.http.put(`/api/ExamUsers/${e.id}`, e).subscribe((data) => { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("禁用成功!", "确定", config); |
||||||
|
this.getAllUsers(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
//删除
|
||||||
|
delete(e) { |
||||||
|
let isTrue = confirm("您确定要删除吗"); |
||||||
|
if (isTrue) { |
||||||
|
this.http.delete(`/api/ExamUsers/${e.id}`).subscribe((data) => { |
||||||
|
const config = new MatSnackBarConfig(); |
||||||
|
config.verticalPosition = "top"; |
||||||
|
config.duration = 3000; |
||||||
|
this.snackBar.open("删除成功!", "确定", config); |
||||||
|
this.getAllUsers(); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,35 @@ |
|||||||
|
.box{ |
||||||
|
width: 280px; |
||||||
|
height: 280px; |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
} |
||||||
|
|
||||||
|
.content{ |
||||||
|
width: 100%; |
||||||
|
flex: 1; |
||||||
|
margin: 15px 0; |
||||||
|
|
||||||
|
.formItem{ |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
margin: 5px 0; |
||||||
|
span{ |
||||||
|
font-size: 14px; |
||||||
|
} |
||||||
|
input{ |
||||||
|
width: 100%; |
||||||
|
height: 36px; |
||||||
|
} |
||||||
|
textarea{ |
||||||
|
width: 278px; |
||||||
|
height: 90px; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
.btnbox{ |
.btnbox{ |
||||||
button{ |
button{ |
||||||
margin: 0 5px; |
margin: 0 5px; |
||||||
} |
} |
||||||
} |
} |
||||||
.contant{ |
|
||||||
height: 60px; |
|
||||||
width: 100%; |
|
||||||
margin: 15px 0; |
|
||||||
} |
|
@ -1,14 +1,15 @@ |
|||||||
import { Routes, RouterModule } from '@angular/router'; |
import { Routes, RouterModule } from "@angular/router"; |
||||||
import { NgModule } from '@angular/core'; |
import { NgModule } from "@angular/core"; |
||||||
import { TeacherManagementComponent } from './teacherManagement/enterpriseuser.component'; |
import { TeacherManagementComponent } from "./teacherManagement/enterpriseuser.component"; |
||||||
import { EnterpriseuserComponent } from './enterpriseuser/enterpriseuser.component'; |
import { EnterpriseuserComponent } from "./enterpriseuser/enterpriseuser.component"; |
||||||
|
import { AdministratorsComponent } from "./administrators/administrators.component"; |
||||||
const routes: Routes = [ |
const routes: Routes = [ |
||||||
{ path: 'teachear', component:TeacherManagementComponent }, //管理员 教员页面
|
{ path: "teachear", component: TeacherManagementComponent }, //管理员 教员页面
|
||||||
{ path: 'examinee', component:EnterpriseuserComponent }, //管理员 考生页面
|
{ path: "examinee", component: EnterpriseuserComponent }, //管理员 考生页面
|
||||||
] |
{ path: "admin", component: AdministratorsComponent }, //管理员 考生页面
|
||||||
|
]; |
||||||
@NgModule({ |
@NgModule({ |
||||||
imports: [RouterModule.forChild(routes)], |
imports: [RouterModule.forChild(routes)], |
||||||
exports: [RouterModule] |
exports: [RouterModule], |
||||||
}) |
}) |
||||||
export class UiRoutingModule {} |
export class UiRoutingModule {} |
||||||
|
Loading…
Reference in new issue