diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0a77d73..388e788 100644 --- a/src/app/app.component.ts +++ b/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 { diff --git a/src/app/examiner/examiner-index/examiner-index.component.ts b/src/app/examiner/examiner-index/examiner-index.component.ts index 076bb9d..74c556c 100644 --- a/src/app/examiner/examiner-index/examiner-index.component.ts +++ b/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 }) } diff --git a/src/app/http-interceptors/cache-token.service.ts b/src/app/http-interceptors/cache-token.service.ts index c5a8399..917bbd1 100644 --- a/src/app/http-interceptors/cache-token.service.ts +++ b/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) diff --git a/src/app/navigation/navigation.component.html b/src/app/navigation/navigation.component.html index 820a46e..f389b85 100644 --- a/src/app/navigation/navigation.component.html +++ b/src/app/navigation/navigation.component.html @@ -22,7 +22,7 @@ diff --git a/src/app/navigation/navigation.component.ts b/src/app/navigation/navigation.component.ts index 9c3a581..99c7683 100644 --- a/src/app/navigation/navigation.component.ts +++ b/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() {} } diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.html b/src/app/ui/enterpriseuser/addenterpriseuser.component.html new file mode 100644 index 0000000..3c624ef --- /dev/null +++ b/src/app/ui/enterpriseuser/addenterpriseuser.component.html @@ -0,0 +1,49 @@ +

创建用户

+ +
+ +
+ + + + 请输入正确身份证号 + + +
+ +
+ + + +
+ +
+ + +
+ {{item.name}} +
+
+ {{item.name}} +
+
+ {{item.name}} +
+
+
+
+ + +
+

{{errmsg}}

+
+ +
+ + +
+ +
\ No newline at end of file diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.ts b/src/app/ui/enterpriseuser/addenterpriseuser.component.ts new file mode 100644 index 0000000..e7aab20 --- /dev/null +++ b/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,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); + }) + + } + +} \ No newline at end of file diff --git a/src/app/ui/enterpriseuser/editenterpriseuser.html b/src/app/ui/enterpriseuser/editenterpriseuser.html new file mode 100644 index 0000000..964e833 --- /dev/null +++ b/src/app/ui/enterpriseuser/editenterpriseuser.html @@ -0,0 +1,46 @@ +

编辑用户

+ +
+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+ {{item.name}} +
+
+ {{item.name}} +
+
+ {{item.name}} +
+
+
+
+ + +
+

{{errmsg}}

+
+ +
+ + +
+ +
\ No newline at end of file diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.html b/src/app/ui/enterpriseuser/enterpriseuser.component.html new file mode 100644 index 0000000..ca37553 --- /dev/null +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.html @@ -0,0 +1,77 @@ +
+
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
用户姓名{{element.realName}}身份证号{{element.name}}消防救援站{{element.organizationName}}手机号{{element.phone}}创建时间{{element.creationTime | date:'yyyy-MM-dd'}}操作 + 重置密码 + 编辑 + 禁用 + 禁用 + 删除 +
+ + + +
diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.scss b/src/app/ui/enterpriseuser/enterpriseuser.component.scss new file mode 100644 index 0000000..71c0551 --- /dev/null +++ b/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; } +} diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.spec.ts b/src/app/ui/enterpriseuser/enterpriseuser.component.spec.ts new file mode 100644 index 0000000..044b696 --- /dev/null +++ b/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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EnterpriseuserComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EnterpriseuserComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.ts b/src/app/ui/enterpriseuser/enterpriseuser.component.ts new file mode 100644 index 0000000..6967c81 --- /dev/null +++ b/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(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(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(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,@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() {} + +} \ No newline at end of file diff --git a/src/app/ui/enterpriseuser/seeenterpriseuser.html b/src/app/ui/enterpriseuser/seeenterpriseuser.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/ui/teacherManagement/addenterpriseuser.component.html b/src/app/ui/teacherManagement/addenterpriseuser.component.html new file mode 100644 index 0000000..36be501 --- /dev/null +++ b/src/app/ui/teacherManagement/addenterpriseuser.component.html @@ -0,0 +1,49 @@ +

创建教员

+ +
+ +
+ + + + 帐号格式为字母+数字 + + +
+ +
+ + + +
+ +
+ + +
+ {{item.name}} +
+
+ {{item.name}} +
+
+ {{item.name}} +
+
+
+
+ + +
+

{{errmsg}}

+
+ +
+ + +
+ +
\ No newline at end of file diff --git a/src/app/ui/teacherManagement/addenterpriseuser.component.ts b/src/app/ui/teacherManagement/addenterpriseuser.component.ts new file mode 100644 index 0000000..c4d6c72 --- /dev/null +++ b/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,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); + }) + + } + +} \ No newline at end of file diff --git a/src/app/ui/teacherManagement/editenterpriseuser.html b/src/app/ui/teacherManagement/editenterpriseuser.html new file mode 100644 index 0000000..013cd42 --- /dev/null +++ b/src/app/ui/teacherManagement/editenterpriseuser.html @@ -0,0 +1,46 @@ +

编辑教员

+ +
+ +
+ + + +
+ +
+ + + +
+ +
+ + +
+ {{item.name}} +
+
+ {{item.name}} +
+
+ {{item.name}} +
+
+
+
+ + +
+

{{errmsg}}

+
+ +
+ + +
+ +
\ No newline at end of file diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.html b/src/app/ui/teacherManagement/enterpriseuser.component.html new file mode 100644 index 0000000..b2f662d --- /dev/null +++ b/src/app/ui/teacherManagement/enterpriseuser.component.html @@ -0,0 +1,72 @@ +
+
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
用户帐号{{element.name}}用户姓名{{element.realName}}消防救援站{{element.organizationName}}创建时间{{element.creationTime | date:'yyyy-MM-dd'}}操作 + 重置密码 + 编辑 + 禁用 + 禁用 + 删除 +
+ + + +
diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.scss b/src/app/ui/teacherManagement/enterpriseuser.component.scss new file mode 100644 index 0000000..71c0551 --- /dev/null +++ b/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; } +} diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.ts b/src/app/ui/teacherManagement/enterpriseuser.component.ts new file mode 100644 index 0000000..1da79e2 --- /dev/null +++ b/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(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(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(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,@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() {} + +} \ No newline at end of file diff --git a/src/app/ui/teacherManagement/seeenterpriseuser.html b/src/app/ui/teacherManagement/seeenterpriseuser.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/ui/ui-routing.module.ts b/src/app/ui/ui-routing.module.ts index 811a429..d2cefd8 100644 --- a/src/app/ui/ui-routing.module.ts +++ b/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)], diff --git a/src/app/ui/ui.module.ts b/src/app/ui/ui.module.ts index e868da5..be7bbbe 100644 --- a/src/app/ui/ui.module.ts +++ b/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,