diff --git a/src/app/navigation/navigation.component.html b/src/app/navigation/navigation.component.html index 126b0ba..5515279 100644 --- a/src/app/navigation/navigation.component.html +++ b/src/app/navigation/navigation.component.html @@ -31,7 +31,7 @@ --> - + 支队级 diff --git a/src/app/navigation/navigation.component.ts b/src/app/navigation/navigation.component.ts index 0e16f62..9345fe9 100644 --- a/src/app/navigation/navigation.component.ts +++ b/src/app/navigation/navigation.component.ts @@ -60,7 +60,8 @@ export class NavigationComponent implements OnInit { //系统管理菜单 systemManagement:any = [ - { id:"用户管理", name:"用户管理" }, + { id:"学员管理", name:"学员管理" }, + { id:"教员管理", name:"教员管理" } ] @@ -91,7 +92,12 @@ export class NavigationComponent implements OnInit { //点击用户管理 clickUser(item){ this.selectedDataBank = item.id - this.router.navigate([`/home/userManagement`]) + if(item.name == "学员管理"){ + this.router.navigate([`/home/userManagement`]) + }else if(item.name == "教员管理"){ + this.router.navigate([`/home/teacherManagement`]) + } + } //新增资料库 diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.html b/src/app/ui/enterpriseuser/addenterpriseuser.component.html index 1ee3b98..3c624ef 100644 --- a/src/app/ui/enterpriseuser/addenterpriseuser.component.html +++ b/src/app/ui/enterpriseuser/addenterpriseuser.component.html @@ -1,43 +1,48 @@ -

创建企业用户

+

创建用户

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

{{errmsg}}

- +
diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.ts b/src/app/ui/enterpriseuser/addenterpriseuser.component.ts index 0ebea60..f52acd0 100644 --- a/src/app/ui/enterpriseuser/addenterpriseuser.component.ts +++ b/src/app/ui/enterpriseuser/addenterpriseuser.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import {MatDialogRef} from '@angular/material/dialog'; - +import {FormControl} from '@angular/forms'; @Component({ @@ -11,25 +11,54 @@ import {MatDialogRef} from '@angular/material/dialog'; }) export class AddEnterpriserUser { + toppings = new FormControl(); constructor(private http: HttpClient,public dialogRef: MatDialogRef) {} - errmsg:any; //捕获错误信息 + detachmentPosts: any = []//支队职务列表 + brigadePosts: any = []//大队职务列表 + RescueStationPosts: any = []//救援站职务列表 + ngOnInit(): void { + this.getAllPosts() + } + + //获得所有职务 + getAllPosts(){ + this.http.get("/api/Posts").subscribe( (data:any) =>{ + console.log(123,data) + 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() - this.http.post('/api/CompanyUsers',{ - name:e.loginName, - phone:e.tel, - enabled:true, - creationTime:date, - usci:e.creditcode, - companyName:e.unitname - }).subscribe(data=>{ - this.dialogRef.close(data)}, - error=>{this.errmsg=error} - ) - } - + let postsArr = this.toppings.value + let postsObj = [] + postsArr.forEach((item) => { + postsObj.push({id:item, name:""}) + }) + // console.log(666,postsObj) + 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); + }) + } } \ No newline at end of file diff --git a/src/app/ui/enterpriseuser/editenterpriseuser.html b/src/app/ui/enterpriseuser/editenterpriseuser.html index 2b8a15a..964e833 100644 --- a/src/app/ui/enterpriseuser/editenterpriseuser.html +++ b/src/app/ui/enterpriseuser/editenterpriseuser.html @@ -1,39 +1,45 @@ -

编辑企业用户

+

编辑用户

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

{{errmsg}}

- +
diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.html b/src/app/ui/enterpriseuser/enterpriseuser.component.html index 5cf8322..1fe73b3 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.html +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.html @@ -28,29 +28,32 @@ 姓名 - {{element.name}} + {{element.realName}} 身份证号 - {{element.companyName}} + {{element.name}} 职务 - {{element.usci}} + + + {{item.name}} + + 操作 - - - - - - - + assessment查看学习记录 + cached重置密码 + edit修改 + remove_circle禁用 + remove_circle禁用 + delete删除 diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.scss b/src/app/ui/enterpriseuser/enterpriseuser.component.scss index 458e252..e54613b 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.scss +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.scss @@ -39,4 +39,25 @@ table { } } //queryBox -} \ No newline at end of file +} + +.operationSpan{ + margin: 0 5px; + .spanbtn:hover{ + text-decoration: underline; + cursor: pointer; + } + .blue{ + color:rgb(24, 144, 255) ; + } + .red{ + color: rgb(245, 34, 45); + } + .gray{ + color: gray; + } +} +.icon{ + font-size: 18px; + vertical-align: top; +} diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.ts b/src/app/ui/enterpriseuser/enterpriseuser.component.ts index 3ef43ff..e5e4bb8 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.ts +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.ts @@ -6,8 +6,7 @@ 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'; @Component({ selector: 'app-enterpriseuser', @@ -50,7 +49,7 @@ export class EnterpriseuserComponent implements OnInit { RoleType: '2', PageNumber: String(this.pageNumber), } - this.http.get('/api/CompanyUsers',{params:data}).subscribe((data:any)=>{ + this.http.get('/api/Users',{params:data}).subscribe((data:any)=>{ this.length = data.totalCount this.pageSize = data.pageSize this.dataSource = new MatTableDataSource(data.items) @@ -74,14 +73,14 @@ export class EnterpriseuserComponent implements OnInit { } //更新当前页数据 - getAllCompanyUsers () { + getAllUsers () { let data= { - Name: this.userLogin || '', - CompanyName: this.userName || '', - USCI: this.creditcode || '', + Name: this.identityCard || '', + RealName: this.name || '', + RoleType: '2', PageNumber: String(this.pageNumber), } - this.http.get('/api/CompanyUsers',{params:data}).subscribe((data:any)=>{ + this.http.get('/api/Users',{params:data}).subscribe((data:any)=>{ this.length = data.totalCount this.pageSize = data.pageSize this.dataSource = new MatTableDataSource(data.items) @@ -90,36 +89,58 @@ export class EnterpriseuserComponent implements OnInit { //清空搜索 empty () { - this.userLogin = '' - this.userName = '' - this.creditcode = '' + this.identityCard = '' + this.name = '' this.initData() } - //创建企业用户 + //创建用户 open(){ - let dialogRef = this.dialog.open(AddEnterpriserUser); + let dialogRef = this.dialog.open(AddEnterpriserUser, {//调用open方法打开对话框并且携带参数过去 + width: '250px', + }); dialogRef.afterClosed().subscribe(data=>{ - if (data) {this.getAllCompanyUsers()} + 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,{data:e}); + let dialogRef = this.dialog.open(editenterpriseuser,{ + width: '250px', + data:e + }); dialogRef.afterClosed().subscribe(data=>{ - if (data) {this.getAllCompanyUsers()} + if (data) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('修改成功!','确定',config); + this.getAllUsers() + } }); } //重置密码 reset (e) { - this.http.put(`/api/CompanyUsers/${e.name}/ResetPassword`,{}).subscribe(data=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('重置密码成功!','确定',config); - }) + this.http.put(`/api/Users/${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); + }) } //查看企业信息 @@ -134,49 +155,55 @@ export class EnterpriseuserComponent implements OnInit { //启用 enabled (e) { - this.http.put(`/api/CompanyUsers/${e.name}`,{ - name:e.name, - phone:e.phone, - enabled:true, - creationTime:e.creationTime, - usci:e.usci, - companyId:e.companyId, - companyName:e.companyName - }).subscribe(data=>{ - this.getAllCompanyUsers() + 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/Users/${e.name}`,body).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000; + this.snackBar.open('启用成功!','确定',config); + this.getAllUsers(); }) } //禁用 noEnabled (e) { - this.http.put(`/api/CompanyUsers/${e.name}`,{ - name:e.name, - phone:e.phone, - enabled:false, - creationTime:e.creationTime, - usci:e.usci, - companyId:e.companyId, - companyName:e.companyName - }).subscribe(data=>{ - this.getAllCompanyUsers() + 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/Users/${e.name}`,body).subscribe(data => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000; + this.snackBar.open('禁用成功!','确定',config); + this.getAllUsers(); }) } - //注销用户 - logoff (e) { - let isTrue = confirm('注销是不可逆操作,您确定要注销吗') - if (isTrue) { - this.http.delete(`/api/CompanyUsers/${e.name}/Cancel`).subscribe(data=>{ - this.getAllCompanyUsers() }) - } - } //删除 delete (e) { let isTrue = confirm('您确定要删除吗') if (isTrue) { - this.http.delete(`/api/CompanyUsers/${e.name}`).subscribe(data=>{ - this.getAllCompanyUsers() + this.http.delete(`/api/Users/${e.name}`).subscribe(data=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('删除成功!','确定',config); + this.getAllUsers() }) } } @@ -195,36 +222,63 @@ export class EnterpriseuserComponent implements OnInit { }) export class editenterpriseuser { - constructor(public http: HttpClient,public dialog: MatDialog, - @Inject(MAT_DIALOG_DATA) public data,public dialogRef: MatDialogRef,) { } - - ngOnInit() { - this.companyName = this.data.companyName - this.companyPhone = this.data.phone - this.companyUsci = this.data.usci + 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) + }) + this.getAllPosts() + } + + //获得所有职务 + getAllPosts(){ + this.http.get("/api/Posts").subscribe( (data:any) =>{ + console.log(123,data) + 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) + } + }); + }) } - companyName:any; //企业单位名称 - companyPhone:any; //企业电话 - companyUsci:any; //企业统一社会信用代码 - //提交表单 + //提交创建表单 onSubmit (e) { - this.http.put(`/api/CompanyUsers/${this.data.name}`,{ - name:this.data.name, - phone:e.tel, - enabled:this.data.enabled, - creationTime:this.data.creationTime, - usci:e.creditcode, - companyId:this.data.companyId, - companyName:e.unitname - }).subscribe(data=>{ - this.dialogRef.close('success') + 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/Users/${this.data.name}`,body).subscribe(data => { + this.dialogRef.close("修改成功"); }) } - - } diff --git a/src/app/ui/enterpriseuser/seeenterpriseuser.html b/src/app/ui/enterpriseuser/seeenterpriseuser.html index a5e8a1c..e69de29 100644 --- a/src/app/ui/enterpriseuser/seeenterpriseuser.html +++ b/src/app/ui/enterpriseuser/seeenterpriseuser.html @@ -1,29 +0,0 @@ -查看企业用户 - -
- - 登录账号: - {{data.name}} - - 单位名称: - {{data.companyName}} - - 联系电话: - {{data.phone}} - - 统一社会信用代码: - {{data.usci}} - - 创建时间: - {{data.creationTime|date:'yyyy-MM-dd'}} - - 是否禁用: - - - - -
- -
- -
\ No newline at end of file diff --git a/src/app/ui/my-paginator.ts b/src/app/ui/my-paginator.ts new file mode 100644 index 0000000..c4e41c5 --- /dev/null +++ b/src/app/ui/my-paginator.ts @@ -0,0 +1,27 @@ +import { MatPaginatorIntl } from '@angular/material/paginator'; +const dutchRangeLabel = (page: number, pageSize: number, length: number) => { + if (length === 0 || pageSize === 0) { return `0 到 ${length}`; } + length = Math.max(length, 0); + const startIndex = page * pageSize; + const endIndex = startIndex < length ? + Math.min(startIndex + pageSize, length) : + startIndex + pageSize; + return `${startIndex + 1} - ${endIndex} 到 ${length}条`; + + } + + export function myPaginator() { + + const paginatorIntl = new MatPaginatorIntl(); + + paginatorIntl.itemsPerPageLabel = '每页条数:'; + + paginatorIntl.nextPageLabel = '下一页:'; + + paginatorIntl.previousPageLabel = '上一页:'; + + paginatorIntl.getRangeLabel = dutchRangeLabel; + + return paginatorIntl; + + } \ No newline at end of file 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..2531639 --- /dev/null +++ b/src/app/ui/teacherManagement/addenterpriseuser.component.ts @@ -0,0 +1,62 @@ +import { Component, OnInit, Inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import {MatDialogRef} from '@angular/material/dialog'; +import {FormControl} from '@angular/forms'; + + +@Component({ + selector: 'addenterpriseuser', + templateUrl: './addenterpriseuser.component.html', + styleUrls: ['./enterpriseuser.component.scss'] + }) +export class AddTeacher { + + toppings = new FormControl(); + constructor(private http: HttpClient,public dialogRef: MatDialogRef) {} + 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); + }) + + } + +} \ 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..3d6eb06 --- /dev/null +++ b/src/app/ui/teacherManagement/enterpriseuser.component.html @@ -0,0 +1,68 @@ +
+
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
姓名{{element.realName}}帐号{{element.name}}职务 + + {{item.name}} + + 操作 + assessment查看学习记录 + cached重置密码 + edit修改 + remove_circle禁用 + remove_circle禁用 + delete删除 +
+ + + diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.scss b/src/app/ui/teacherManagement/enterpriseuser.component.scss new file mode 100644 index 0000000..e54613b --- /dev/null +++ b/src/app/ui/teacherManagement/enterpriseuser.component.scss @@ -0,0 +1,63 @@ +table { + width: 100%; + text-align: center; + .cdk-header-cell { + text-align: center; + } + } +.maginleft { + margin-left: 5px; +} + + + +.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 15px; + font-size: 14px; + input { + width: 280px; + height: 22px; + line-height: 22px; + // border-radius: 3px; + } + } + .btnbox{ + float: right; + } + + } //queryBox +} + +.operationSpan{ + margin: 0 5px; + .spanbtn:hover{ + text-decoration: underline; + cursor: pointer; + } + .blue{ + color:rgb(24, 144, 255) ; + } + .red{ + color: rgb(245, 34, 45); + } + .gray{ + color: gray; + } +} +.icon{ + font-size: 18px; + vertical-align: top; +} diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.ts b/src/app/ui/teacherManagement/enterpriseuser.component.ts new file mode 100644 index 0000000..2a49270 --- /dev/null +++ b/src/app/ui/teacherManagement/enterpriseuser.component.ts @@ -0,0 +1,299 @@ +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[] = ['name', 'identitycard', 'post', 'operation',]; + dataSource:any; //所有企业用户 + + userLogin:string; //搜索账号 + userName:string; //搜索名称 + creditcode:string//统一社会信用代码 + + name:any //姓名 + identityCard: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/Users',{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/Users',{params:data}).subscribe((data:any)=>{ + console.log(666,data) + 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/Users',{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/Users/${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); + }) + } + + //查看企业信息 + see (e) { + // this.http.get(`/api/CompanyUsers/${e.name}`).subscribe( + // data=> { + // let dialogRef = this.dialog.open(seeTeacher, {data}); + // dialogRef.afterClosed().subscribe(); + // } + // ) + } + + //启用 + 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/Users/${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/Users/${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/Users/${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) + }) + this.getAllPosts() + } + + //获得所有职务 + getAllPosts(){ + this.http.get("/api/Posts").subscribe( (data:any) =>{ + console.log(123,data) + 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 : this.data.name, + realName : e.realName, + roleType : 2, + enabled : this.data.enabled, + creationTime : date, + posts : postsObj + } + this.http.put(`/api/Users/${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 535cdab..eb06364 100644 --- a/src/app/ui/ui-routing.module.ts +++ b/src/app/ui/ui-routing.module.ts @@ -2,9 +2,11 @@ import { Routes, RouterModule } from '@angular/router'; import { NgModule } from '@angular/core'; import { AllFileComponent } from './all-file/all-file.component'; import { EnterpriseuserComponent } from './enterpriseuser/enterpriseuser.component'; +import { TeacherManagementComponent } from './teacherManagement/enterpriseuser.component'; const routes: Routes = [ { path: '', component:AllFileComponent }, - { path: 'userManagement', component:EnterpriseuserComponent } + { path: 'userManagement', component:EnterpriseuserComponent }, + { path: 'teacherManagement', component:TeacherManagementComponent } ]; @NgModule({ diff --git a/src/app/ui/ui.module.ts b/src/app/ui/ui.module.ts index 3f1a2c4..ba63d57 100644 --- a/src/app/ui/ui.module.ts +++ b/src/app/ui/ui.module.ts @@ -57,9 +57,11 @@ import { IsLoginService } from '../is-login.service'; import { UploadFilesComponent } from './upload-files/upload-files.component'; import {AddEnterpriserUser} from './enterpriseuser/addenterpriseuser.component'; import {EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser} from './enterpriseuser/enterpriseuser.component' - +import { myPaginator } from "./my-paginator" +import { TeacherManagementComponent, editTeacher, seeTeacher } from './teacherManagement/enterpriseuser.component'; +import { AddTeacher } from './teacherManagement/addenterpriseuser.component'; @NgModule({ - declarations: [FolderDialog,ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser], + declarations: [FolderDialog,ViewDetails,PersonaldataComponent, ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, LoginComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,TeacherManagementComponent,editTeacher,AddTeacher,seeTeacher], imports: [ CommonModule, @@ -113,7 +115,8 @@ import {EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser} from './en ], exports: [ AllFileComponent - ] + ], + providers: [ { provide: MatPaginatorIntl, useValue: myPaginator() } ] }) export class UiModule { } diff --git a/src/styles.scss b/src/styles.scss index 4ce1feb..43476c1 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -78,5 +78,8 @@ table td.mat-footer-cell:last-of-type{ } .mat-tab-body-content{ overflow: hidden!important; - // text-align: center; -} \ No newline at end of file +} +.mat-select-panel { + width: 210px; + font-size: 13px!important; +}