You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
272 lines
7.2 KiB
272 lines
7.2 KiB
4 years ago
|
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() {}
|
||
|
|
||
|
}
|