Browse Source

[完善] 增加管理员考官,考生管理页面

master
陈鹏飞 4 years ago
parent
commit
b989186ed5
  1. 1
      src/app/app.component.ts
  2. 3
      src/app/examiner/examiner-index/examiner-index.component.ts
  3. 1
      src/app/http-interceptors/cache-token.service.ts
  4. 10
      src/app/navigation/navigation.component.html
  5. 5
      src/app/navigation/navigation.component.ts
  6. 49
      src/app/ui/enterpriseuser/addenterpriseuser.component.html
  7. 67
      src/app/ui/enterpriseuser/addenterpriseuser.component.ts
  8. 46
      src/app/ui/enterpriseuser/editenterpriseuser.html
  9. 77
      src/app/ui/enterpriseuser/enterpriseuser.component.html
  10. 54
      src/app/ui/enterpriseuser/enterpriseuser.component.scss
  11. 25
      src/app/ui/enterpriseuser/enterpriseuser.component.spec.ts
  12. 273
      src/app/ui/enterpriseuser/enterpriseuser.component.ts
  13. 0
      src/app/ui/enterpriseuser/seeenterpriseuser.html
  14. 49
      src/app/ui/teacherManagement/addenterpriseuser.component.html
  15. 67
      src/app/ui/teacherManagement/addenterpriseuser.component.ts
  16. 46
      src/app/ui/teacherManagement/editenterpriseuser.html
  17. 72
      src/app/ui/teacherManagement/enterpriseuser.component.html
  18. 54
      src/app/ui/teacherManagement/enterpriseuser.component.scss
  19. 272
      src/app/ui/teacherManagement/enterpriseuser.component.ts
  20. 0
      src/app/ui/teacherManagement/seeenterpriseuser.html
  21. 4
      src/app/ui/ui-routing.module.ts
  22. 6
      src/app/ui/ui.module.ts

1
src/app/app.component.ts

@ -28,6 +28,7 @@ export class AppComponent {
sessionStorage.setItem("roleType",data.roleType);
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
sessionStorage.setItem("level",data.level);
this.token.startUp()
})
} else {

3
src/app/examiner/examiner-index/examiner-index.component.ts

@ -79,9 +79,7 @@ export class ExaminerIndexComponent implements OnInit {
this.http.get("/api/Papers",{params:paramsdata}).subscribe((data:any)=>{
this.tabledataSource=data.items
this.length=data.totalCount
console.log(data)
})
//console.log(this.tabledataSource)
}
//获取消防救援对信息
getHelp(){
@ -98,7 +96,6 @@ export class ExaminerIndexComponent implements OnInit {
SortType:''
}
this.http.get("/api/ExamUsers",{params:paramsdata}).subscribe((data:any)=>{
console.log(data)
this.helpName=data.items
})
}

1
src/app/http-interceptors/cache-token.service.ts

@ -25,6 +25,7 @@ export class CacheTokenService {
sessionStorage.setItem("roleType",data.roleType);
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
sessionStorage.setItem("level",data.level);
})
} else { this.delete() }
},18*60*1000)

10
src/app/navigation/navigation.component.html

@ -22,7 +22,7 @@
</div>
</div>
<div class="navbox">
<ul class="teacher">
<ul class="teacher" *ngIf="roleType == '1'">
<li [routerLink]="['/home/createexam-index']" routerLinkActive="clickStyle">
<img src="../../assets/images/found.png" style="background-color: #fff;"><label>创建考试</label>
</li>
@ -33,6 +33,14 @@
<img src="../../assets/images/Statistics.png" style="background-color: #07CDCF;"><label>统计分析</label>
</li>
</ul>
<ul class="teacher" *ngIf="roleType == '0'">
<li [routerLink]="['/home/teachear']" routerLinkActive="clickStyle">
<label>考官管理</label>
</li>
<li [routerLink]="['/home/examinee']" routerLinkActive="clickStyle">
<label>考生管理</label>
</li>
</ul>
<img style="width: 191px;height: 113px; position: absolute; bottom: 0;" src="../../assets/images/backbottom.png">
</div>

5
src/app/navigation/navigation.component.ts

@ -16,8 +16,7 @@ export class NavigationComponent implements OnInit {
constructor(private router:Router,public emitService: ComponentServiceService,public navmenus:CacheTokenService,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public islogin:IsLoginService) { }
isAdmin:boolean = false
ngOnInit() {
}
roleType = sessionStorage.getItem('roleType')
ngOnInit() {}
}

49
src/app/ui/enterpriseuser/addenterpriseuser.component.html

@ -0,0 +1,49 @@
<h2 mat-dialog-title>创建用户</h2>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div>
<mat-form-field>
<input matInput id="idNumber" name="idNumber"
required ngModel placeholder="请输入身份证号" autocomplete="off" pattern="^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$">
<mat-error>
<strong>请输入正确身份证号</strong>
</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field>
<input matInput id="realName" name="realName"
maxlength="100"
required ngModel placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</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 || toppings.value == null">确定</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>

67
src/app/ui/enterpriseuser/addenterpriseuser.component.ts

@ -0,0 +1,67 @@
import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {MatDialogRef} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Component({
selector: 'addenterpriseuser',
templateUrl: './addenterpriseuser.component.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class AddEnterpriserUser {
toppings = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddEnterpriserUser>,public snackBar: MatSnackBar) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
ngOnInit(): void {
this.getAllPosts()
}
//获得所有职务
getAllPosts(){
this.http.get("/api/Posts").subscribe( (data:any) =>{
data.forEach(item => {
if(item.name.indexOf("支队级") != -1){
this.detachmentPosts.push(item)
}else if(item.name.indexOf("大队级") != -1){
this.brigadePosts.push(item)
}else{
this.RescueStationPosts.push(item)
}
});
})
}
//提交创建表单
onSubmit (e) {
let date = new Date()
let postsArr = this.toppings.value
let postsObj = []
postsArr.forEach((item) => {
postsObj.push({id:item, name:""})
})
let body = {
name : e.idNumber,
realName : e.realName,
roleType : 2,
enabled : true,
creationTime : date,
posts : postsObj
}
this.http.post("/api/Users",body).subscribe( data => {
this.dialogRef.close(data);
},err => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open(err,'确定',config);
})
}
}

46
src/app/ui/enterpriseuser/editenterpriseuser.html

@ -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 id="idNumber" name="idNumber"
required [(ngModel)]="IdNumber" placeholder="请输入身份证号" autocomplete="off" disabled pattern="^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$">
</mat-form-field>
</div>
<div>
<mat-form-field>
<input matInput id="realName" name="realName"
maxlength="100"
required [(ngModel)]="realName" placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</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 || toppings.value == null">确定</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>

77
src/app/ui/enterpriseuser/enterpriseuser.component.html

@ -0,0 +1,77 @@
<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)]="name" name="name" autocomplete="off" placeholder="请输入用户姓名">
</div>
<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)]="fireTeam" name="fireTeam" autocomplete="off" placeholder="请选择消防救援站">
</div>
<div class="queryField">
<button mat-raised-button (click)='initData()' 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="name">
<th mat-header-cell *matHeaderCellDef>用户姓名</th>
<td mat-cell *matCellDef="let element">{{element.realName}}</td>
</ng-container>
<ng-container matColumnDef="identitycard">
<th mat-header-cell *matHeaderCellDef>身份证号</th>
<td mat-cell *matCellDef="let element">{{element.name}}</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="tel">
<th mat-header-cell *matHeaderCellDef>手机号</th>
<td mat-cell *matCellDef="let element">{{element.phone}}</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"
[pageSizeOptions]="pageSizeOptions"
(page)="chagePage($event)">
</mat-paginator>
</div>

54
src/app/ui/enterpriseuser/enterpriseuser.component.scss

@ -0,0 +1,54 @@
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: 34px;
line-height: 34px;
border-radius: 5px;
padding-left: 5px;
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; }
}

25
src/app/ui/enterpriseuser/enterpriseuser.component.spec.ts

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EnterpriseuserComponent } from './enterpriseuser.component';
describe('EnterpriseuserComponent', () => {
let component: EnterpriseuserComponent;
let fixture: ComponentFixture<EnterpriseuserComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EnterpriseuserComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EnterpriseuserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

273
src/app/ui/enterpriseuser/enterpriseuser.component.ts

@ -0,0 +1,273 @@
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 { AddEnterpriserUser } from './addenterpriseuser.component'
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FormControl} from '@angular/forms';
import { Router,ActivatedRoute } from '@angular/router'
@Component({
selector: 'app-enterpriseuser',
templateUrl: './enterpriseuser.component.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class EnterpriseuserComponent implements OnInit {
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private router:Router,private route:ActivatedRoute) { }
ngOnInit() {
this.initData()
}
displayedColumns: string[] = [ 'name','identitycard', 'post', 'tel', 'time', 'operation',];
dataSource:any; //所有企业用户
name:any //姓名
identityCard:any //身份证
fireTeam:any; //消防救援站
//分页
@ViewChild(MatPaginator, {static: true})
pageEvent: PageEvent;
paginator: MatPaginator;
length:any; //共多少条数据
pageSize:any; //每页条数
pageSizeOptions: number[] = [10] //设置每页条数
pageNumber:number = 1; //第几页
//分页切换
chagePage (e) {
this.pageNumber = e.pageIndex+1
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '2',
PageNumber: String(this.pageNumber),
}
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)
})
}
//页面初始化 + 查询 + 重置
initData () {
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '2',
}
this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{
this.length = data.totalCount
this.pageSize = data.pageSize
this.pageEvent.pageIndex = 0
this.dataSource = new MatTableDataSource<any>(data.items)
})
}
//更新当前页数据
getAllUsers () {
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '2',
PageNumber: String(this.pageNumber),
}
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)
})
}
//清空搜索
empty () {
this.identityCard = ''
this.name = ''
this.initData()
}
//创建用户
open(){
let dialogRef = this.dialog.open(AddEnterpriserUser, {//调用open方法打开对话框并且携带参数过去
width: '250px',
});
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 dialogRef = this.dialog.open(editenterpriseuser,{
width: '250px',
data:e
});
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.name}/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) {
let date = new Date()
let body = {
name : e.name,
realName : e.realName,
roleType : e.roleType,
enabled : true,
creationTime : date,
posts : e.posts
}
this.http.put(`/api/ExamUsers/${e.name}`,body).subscribe(data => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000;
this.snackBar.open('启用成功!','确定',config);
this.getAllUsers();
})
}
//禁用
noEnabled (e) {
let date = new Date()
let body = {
name : e.name,
realName : e.realName,
roleType : e.roleType,
enabled : false,
creationTime : date,
posts : e.posts
}
this.http.put(`/api/ExamUsers/${e.name}`,body).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.name}`).subscribe(data=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除成功!','确定',config);
this.getAllUsers()
})
}
}
}
//编辑企业用户
@Component({
selector: 'app-editenterpriseuser',
templateUrl: './editenterpriseuser.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class editenterpriseuser {
toppings:any = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<editenterpriseuser>,@Inject(MAT_DIALOG_DATA) public data) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
IdNumber:any //身份证号
realName:any //真实姓名
ngOnInit(): void {
this.toppings.value = []
this.IdNumber = this.data.name
this.realName = this.data.realName
this.data.posts.forEach((item) => {
this.toppings.value.push(item.id)
})
}
//获得所有职务
getAllPosts(){
}
//提交创建表单
onSubmit (e) {
let date = new Date()
let postsArr = this.toppings.value
let postsObj = []
postsArr.forEach((item) => {
postsObj.push({id:item, name:""})
})
let body = {
name : this.data.name,
realName : e.realName,
roleType : 2,
enabled : this.data.enabled,
creationTime : date,
posts : postsObj
}
this.http.put(`/api/ExamUsers/${this.data.name}`,body).subscribe(data => {
this.dialogRef.close("修改成功");
})
}
}
//查看企业用户
@Component({
selector: 'app-seeenterpriseuser',
templateUrl: './seeenterpriseuser.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class seeenterpriseuser {
constructor(public http: HttpClient,public dialog: MatDialog,
@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit() {}
}

0
src/app/ui/enterpriseuser/seeenterpriseuser.html

49
src/app/ui/teacherManagement/addenterpriseuser.component.html

@ -0,0 +1,49 @@
<h2 mat-dialog-title>创建教员</h2>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div>
<mat-form-field>
<input matInput id="idNumber" name="idNumber"
required ngModel placeholder="请输入帐号" autocomplete="off" pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$">
<mat-error>
<strong>帐号格式为字母+数字</strong>
</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field>
<input matInput id="realName" name="realName"
maxlength="100"
required ngModel placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</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 || toppings.value == null">确定</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>

67
src/app/ui/teacherManagement/addenterpriseuser.component.ts

@ -0,0 +1,67 @@
import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {MatDialogRef} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Component({
selector: 'addenterpriseuser',
templateUrl: './addenterpriseuser.component.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class AddTeacher {
toppings = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddTeacher>,public snackBar: MatSnackBar) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
ngOnInit(): void {
this.getAllPosts()
}
//获得所有职务
getAllPosts(){
this.http.get("/api/Posts").subscribe( (data:any) =>{
data.forEach(item => {
if(item.name.indexOf("支队级") != -1){
this.detachmentPosts.push(item)
}else if(item.name.indexOf("大队级") != -1){
this.brigadePosts.push(item)
}else{
this.RescueStationPosts.push(item)
}
});
})
}
//提交创建表单
onSubmit (e) {
let date = new Date()
let postsArr = this.toppings.value
let postsObj = []
postsArr.forEach((item) => {
postsObj.push({id:item, name:""})
})
let body = {
name : e.idNumber,
realName : e.realName,
roleType : 1,
enabled : true,
creationTime : date,
posts : postsObj
}
this.http.post("/api/Users",body).subscribe( data => {
this.dialogRef.close(data);
},err=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open(err,'确定',config);
})
}
}

46
src/app/ui/teacherManagement/editenterpriseuser.html

@ -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 id="idNumber" name="idNumber"
required [(ngModel)]="IdNumber" placeholder="请输入帐号" autocomplete="off" disabled pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$">
</mat-form-field>
</div>
<div>
<mat-form-field>
<input matInput id="realName" name="realName"
maxlength="100"
required [(ngModel)]="realName" placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</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 || toppings.value == null">确定</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>

72
src/app/ui/teacherManagement/enterpriseuser.component.html

@ -0,0 +1,72 @@
<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">
<label style="margin-right: 10px;">消防救援站:</label>
<input type="text" [(ngModel)]="fireTeam" name="fireTeam" autocomplete="off" placeholder="请选择消防救援站">
</div>
<div class="queryField">
<button mat-raised-button (click)='initData()' 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"
[pageSizeOptions]="pageSizeOptions"
(page)="chagePage($event)">
</mat-paginator>
</div>

54
src/app/ui/teacherManagement/enterpriseuser.component.scss

@ -0,0 +1,54 @@
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: 34px;
line-height: 34px;
border-radius: 5px;
padding-left: 5px;
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; }
}

272
src/app/ui/teacherManagement/enterpriseuser.component.ts

@ -0,0 +1,272 @@
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 { AddTeacher } from './addenterpriseuser.component'
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FormControl} from '@angular/forms';
@Component({
selector: 'app-enterpriseuser',
templateUrl: './enterpriseuser.component.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class TeacherManagementComponent implements OnInit {
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
ngOnInit() {
this.initData()
}
displayedColumns: string[] = ['identitycard', 'name', 'post', 'time', 'operation',];
dataSource:any; //所有企业用户
name:any //用户姓名
identityCard:any //用户账号
fireTeam:any; //消防救援站
//分页
@ViewChild(MatPaginator, {static: true})
pageEvent: PageEvent;
paginator: MatPaginator;
length:any; //共多少条数据
pageSize:any; //每页条数
pageSizeOptions: number[] = [10] //设置每页条数
pageNumber:number = 1; //第几页
//分页切换
chagePage (e) {
this.pageNumber = e.pageIndex+1
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '1',
PageNumber: String(this.pageNumber),
}
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)
})
}
//页面初始化 + 查询 + 重置
initData () {
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '1',
}
this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{
this.length = data.totalCount
this.pageSize = data.pageSize
this.pageEvent.pageIndex = 0
this.dataSource = new MatTableDataSource<any>(data.items)
})
}
//更新当前页数据
getAllUsers () {
let data= {
Name: this.identityCard || '',
RealName: this.name || '',
RoleType: '1',
PageNumber: String(this.pageNumber),
}
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)
})
}
//清空搜索
empty () {
this.identityCard = ''
this.name = ''
this.initData()
}
//创建教员
open(){
let dialogRef = this.dialog.open(AddTeacher, {//调用open方法打开对话框并且携带参数过去
width: '250px',
});
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 dialogRef = this.dialog.open(editTeacher,{
width: '250px',
data:e
});
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.name}/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) {
let date = new Date()
let body = {
name : e.name,
realName : e.realName,
roleType : e.roleType,
enabled : true,
creationTime : date,
posts : e.posts
}
this.http.put(`/api/ExamUsers/${e.name}`,body).subscribe(data => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000;
this.snackBar.open('启用成功!','确定',config);
this.getAllUsers();
})
}
//禁用
noEnabled (e) {
let date = new Date()
let body = {
name : e.name,
realName : e.realName,
roleType : e.roleType,
enabled : false,
creationTime : date,
posts : e.posts
}
this.http.put(`/api/ExamUsers/${e.name}`,body).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.name}`).subscribe(data=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除成功!','确定',config);
this.getAllUsers()
})
}
}
}
//编辑企业用户
@Component({
selector: 'app-editenterpriseuser',
templateUrl: './editenterpriseuser.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class editTeacher {
toppings:any = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<editTeacher>,@Inject(MAT_DIALOG_DATA) public data) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
IdNumber:any //身份证号
realName:any //真实姓名
ngOnInit(): void {
this.toppings.value = []
this.IdNumber = this.data.name
this.realName = this.data.realName
this.data.posts.forEach((item) => {
this.toppings.value.push(item.id)
})
}
//获得所有职务
getAllPosts(){
}
//提交创建表单
onSubmit (e) {
let date = new Date()
let postsArr = this.toppings.value
let postsObj = []
postsArr.forEach((item) => {
postsObj.push({id:item, name:""})
})
let body = {
name : this.data.name,
realName : e.realName,
roleType : 1,
enabled : this.data.enabled,
creationTime : date,
posts : postsObj
}
this.http.put(`/api/ExamUsers/${this.data.name}`,body).subscribe(data => {
this.dialogRef.close("修改成功");
})
}
}
//查看企业用户
@Component({
selector: 'app-seeenterpriseuser',
templateUrl: './seeenterpriseuser.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class seeTeacher {
constructor(public http: HttpClient,public dialog: MatDialog,
@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit() {}
}

0
src/app/ui/teacherManagement/seeenterpriseuser.html

4
src/app/ui/ui-routing.module.ts

@ -1,7 +1,11 @@
import { Routes, RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { TeacherManagementComponent } from './teacherManagement/enterpriseuser.component';
import { EnterpriseuserComponent } from './enterpriseuser/enterpriseuser.component';
const routes: Routes = [
{ path: 'teachear', component:TeacherManagementComponent }, //管理员 教员页面
{ path: 'examinee', component:EnterpriseuserComponent }, //管理员 考生页面
]
@NgModule({
imports: [RouterModule.forChild(routes)],

6
src/app/ui/ui.module.ts

@ -58,8 +58,12 @@ import {saveOneDialog,saveTwoDialog} from './collection-tools/save'
import {WorkingAreaComponent} from '../working-area/working-area.component'
import { NzTreeModule } from 'ng-zorro-antd/tree';
import { examinationQuestions,uploadQuestions } from './collection-tools/examinationQuestions'
import {AddEnterpriserUser} from './enterpriseuser/addenterpriseuser.component'
import {EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser} from './enterpriseuser/enterpriseuser.component'
import {AddTeacher} from './teacherManagement/addenterpriseuser.component'
import {TeacherManagementComponent,editTeacher,seeTeacher} from './teacherManagement/enterpriseuser.component'
@NgModule({
declarations: [ChangepasswordComponent,ConfirmpswDirective, ChangeuserdataComponent,testState,CollectionToolsComponent,CreateBuilding,EditBuilding,ViewDetailss,leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent,saveOneDialog,saveTwoDialog,WorkingAreaComponent,examinationQuestions,uploadQuestions],
declarations: [ChangepasswordComponent,ConfirmpswDirective, ChangeuserdataComponent,testState,CollectionToolsComponent,CreateBuilding,EditBuilding,ViewDetailss,leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent,saveOneDialog,saveTwoDialog,WorkingAreaComponent,examinationQuestions,uploadQuestions,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,AddTeacher,TeacherManagementComponent,editTeacher,seeTeacher],
imports: [
NzDatePickerModule,

Loading…
Cancel
Save