diff --git a/src/app/examiner/review-files/review-files.component.ts b/src/app/examiner/review-files/review-files.component.ts index deb2a1d..2009c48 100644 --- a/src/app/examiner/review-files/review-files.component.ts +++ b/src/app/examiner/review-files/review-files.component.ts @@ -46,6 +46,13 @@ export class ReviewFilesComponent implements OnInit { element.facilityItemScore = data.paperInfo.paperDataInfo[index].facilityItemScore //消防设施单项分 element.functionalDivisionItemSocre = data.paperInfo.paperDataInfo[index].functionalDivisionItemSocre //功能分区单选分 element.importLocationItemScore = data.paperInfo.paperDataInfo[index].importLocationItemScore //重点部位单项分 + if (this.paperType == 1) { //阅卷 + element.adjoinScore = data.paperInfo.paperDataInfo[index].adjoinScore //四周毗邻 总分 + element.basicInfoScore = data.paperInfo.paperDataInfo[index].basicInfoScore //基本信息 总分 + element.facilityScore = data.paperInfo.paperDataInfo[index].facilityScore //消防设施 总分 + element.functionalDivisionScore = data.paperInfo.paperDataInfo[index].functionalDivisionScore //功能分区 总分 + element.importLocationScore = data.paperInfo.paperDataInfo[index].importLocationScore //重点部位 总分 + } element.score = element.adjoinScore + element.basicInfoScore + element.facilityScore + element.functionalDivisionScore + element.importLocationScore }); this.paperCompanyData = JSON.parse( JSON.stringify(data.examinationDataInfo) ) //具体考卷 diff --git a/src/app/tabbar/tabbar.component.html b/src/app/tabbar/tabbar.component.html index 265f213..ecefc0f 100644 --- a/src/app/tabbar/tabbar.component.html +++ b/src/app/tabbar/tabbar.component.html @@ -15,7 +15,9 @@ - {{realName}}keyboard_arrow_down + + {{realName}}keyboard_arrow_down + - -
+
open_with @@ -49,9 +48,7 @@
- - -
+
@@ -157,7 +154,7 @@
-
+
diff --git a/src/app/ui/collection-tools-read/collection-tools.component.html b/src/app/ui/collection-tools-read/collection-tools.component.html index 065b1e8..8e566b4 100644 --- a/src/app/ui/collection-tools-read/collection-tools.component.html +++ b/src/app/ui/collection-tools-read/collection-tools.component.html @@ -28,9 +28,8 @@ - -
+
open_with @@ -55,7 +54,7 @@
-
+
@@ -67,8 +66,7 @@
- -
+
@@ -133,7 +131,7 @@
-
+
diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index ec5cdfe..3730757 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -16,7 +16,7 @@ -
+
open_with @@ -39,7 +39,7 @@
-
+
@@ -142,7 +142,7 @@
-
+
diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.html b/src/app/ui/enterpriseuser/addenterpriseuser.component.html index 3c624ef..cc2f159 100644 --- a/src/app/ui/enterpriseuser/addenterpriseuser.component.html +++ b/src/app/ui/enterpriseuser/addenterpriseuser.component.html @@ -1,48 +1,50 @@ -

创建用户

+

新增用户

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

消防救援站:

+
+ +
+ + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    +
    +

    {{errmsg}}

    - +
    diff --git a/src/app/ui/enterpriseuser/addenterpriseuser.component.ts b/src/app/ui/enterpriseuser/addenterpriseuser.component.ts index e7aab20..feaf5df 100644 --- a/src/app/ui/enterpriseuser/addenterpriseuser.component.ts +++ b/src/app/ui/enterpriseuser/addenterpriseuser.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import {MatDialogRef} from '@angular/material/dialog'; +import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import {FormControl} from '@angular/forms'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; +import { FlatTreeControl } from '@angular/cdk/tree'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; @Component({ selector: 'addenterpriseuser', @@ -11,57 +13,59 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; }) 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() - } + constructor(private http: HttpClient,public dialogRef: MatDialogRef,public snackBar: MatSnackBar,@Inject(MAT_DIALOG_DATA) public data) {} + + ngOnInit(): void { this.dataSource.data = this.data } + + errmsg:string = null; + + organizationId:string = null; + organizationName:string = null; - //获得所有职务 - 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) - } - }); - }) + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name + } //提交创建表单 onSubmit (e) { - 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 => { + if (this.organizationId && this.organizationName) { + e.phone = String(e.phone) + e.roleType = 2 + e.enabled = true + e.creationTime = new Date() + e.organizationId = this.organizationId + e.organizationName = this.organizationName + this.http.post("/api/ExamUsers",e).subscribe(data => { + this.dialogRef.close(data); + },err => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open(err,'确定',config); + }) + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open(err,'确定',config); - }) - + this.snackBar.open('请选择消防救援站','确定',config); + } } } \ No newline at end of file diff --git a/src/app/ui/enterpriseuser/editenterpriseuser.html b/src/app/ui/enterpriseuser/editenterpriseuser.html index 964e833..410e6aa 100644 --- a/src/app/ui/enterpriseuser/editenterpriseuser.html +++ b/src/app/ui/enterpriseuser/editenterpriseuser.html @@ -4,42 +4,47 @@
    - +
    - +
    - -
    - {{item.name}} -
    -
    - {{item.name}} -
    -
    - {{item.name}} -
    -
    +
    +
    +

    消防救援站:

    +
    + +
    + + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    +

    {{errmsg}}

    - +
    diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.html b/src/app/ui/enterpriseuser/enterpriseuser.component.html index ca37553..47ee53d 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.html +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.html @@ -11,9 +11,24 @@
    -
    +
    - + + highlight_off +
    + + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    +
    @@ -26,7 +41,7 @@
    - + @@ -36,7 +51,7 @@ - + @@ -60,7 +75,7 @@ 重置密码 编辑 禁用 - 禁用 + 启用 删除 diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.scss b/src/app/ui/enterpriseuser/enterpriseuser.component.scss index 71c0551..85b628b 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.scss +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.scss @@ -52,3 +52,33 @@ table { .red{ color: #FF8678 } .gray{ color: gray; } } + +//tree +.treeDiv { + max-height: 300px; + overflow-y: auto; + .mat-icon-button { + width: 20px; + height: 20px; + line-height: 20px; + } + li { cursor: pointer; } + .mat-tree-node:hover { background-color: rgb(240, 236, 236); } +} + +.closeTree { + cursor: pointer; + position: absolute; + top: 40px; + right: -95px; + z-index: 100; +} +.searchTree { + .mat-tree-node button .mat-icon { color: #000; } + border: 1px solid rgb(207, 204, 204); + width: 350px; + max-height: 150px; + position: absolute; + top: 40px; + left: 0; +} diff --git a/src/app/ui/enterpriseuser/enterpriseuser.component.ts b/src/app/ui/enterpriseuser/enterpriseuser.component.ts index 6967c81..601d987 100644 --- a/src/app/ui/enterpriseuser/enterpriseuser.component.ts +++ b/src/app/ui/enterpriseuser/enterpriseuser.component.ts @@ -8,6 +8,8 @@ import { AddEnterpriserUser } from './addenterpriseuser.component' import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import {FormControl} from '@angular/forms'; import { Router,ActivatedRoute } from '@angular/router' +import { FlatTreeControl } from '@angular/cdk/tree'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; @Component({ selector: 'app-enterpriseuser', @@ -20,6 +22,53 @@ export class EnterpriseuserComponent implements OnInit { ngOnInit() { this.initData() + this.getOrganizations() + } + + allOrganizations:any; //所有组织机构 + treeData:any = []; //tree型 data + isShowTree:boolean = false; //树形结构是否展示 + showTree () { this.isShowTree = true } + hideTree () { this.isShowTree = false } + + //获取所有组织机构 + getOrganizations () { + this.http.get('/api/Organizations').subscribe((data:any)=>{ + this.allOrganizations = data + data.forEach(element => { + element.children = [] + data.forEach(item => { item.parentId === element.id? element.children.push(item) : null }); + }); + data.forEach(element => { + !element.parentId? this.treeData.push(element) : null + }); + this.dataSources.data = this.treeData + }) //http + } + + organizationId:string = null; + organizationName:string = null; + + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSources = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name + this.isShowTree = false } displayedColumns: string[] = [ 'name','identitycard', 'post', 'tel', 'time', 'operation',]; @@ -27,7 +76,6 @@ export class EnterpriseuserComponent implements OnInit { name:any //姓名 identityCard:any //身份证 - fireTeam:any; //消防救援站 //分页 @ViewChild(MatPaginator, {static: true}) @@ -42,8 +90,9 @@ export class EnterpriseuserComponent implements OnInit { chagePage (e) { this.pageNumber = e.pageIndex+1 let data= { - Name: this.identityCard || '', RealName: this.name || '', + IdentityCard: this.identityCard || '', + OrganizationId: this.organizationId || '', RoleType: '2', PageNumber: String(this.pageNumber), } @@ -57,8 +106,9 @@ export class EnterpriseuserComponent implements OnInit { //页面初始化 + 查询 + 重置 initData () { let data= { - Name: this.identityCard || '', RealName: this.name || '', + IdentityCard: this.identityCard || '', + OrganizationId: this.organizationId || '', RoleType: '2', } this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{ @@ -72,8 +122,9 @@ export class EnterpriseuserComponent implements OnInit { //更新当前页数据 getAllUsers () { let data= { - Name: this.identityCard || '', RealName: this.name || '', + IdentityCard: this.identityCard || '', + OrganizationId: this.organizationId || '', RoleType: '2', PageNumber: String(this.pageNumber), } @@ -86,16 +137,17 @@ export class EnterpriseuserComponent implements OnInit { //清空搜索 empty () { - this.identityCard = '' - this.name = '' + this.name = '', + this.identityCard = '', + this.organizationId = '', + this.organizationName = '', this.initData() } //创建用户 open(){ - let dialogRef = this.dialog.open(AddEnterpriserUser, {//调用open方法打开对话框并且携带参数过去 - width: '250px', - }); + let data = this.treeData + let dialogRef = this.dialog.open(AddEnterpriserUser,{data}); dialogRef.afterClosed().subscribe(data=>{ if (data) { const config = new MatSnackBarConfig(); @@ -109,10 +161,8 @@ export class EnterpriseuserComponent implements OnInit { //编辑企业用户 edit (e) { - let dialogRef = this.dialog.open(editenterpriseuser,{ - width: '250px', - data:e - }); + let data = {treeData: this.treeData, userData: e} + let dialogRef = this.dialog.open(editenterpriseuser,{data}); dialogRef.afterClosed().subscribe(data=>{ if (data) { const config = new MatSnackBarConfig(); @@ -126,32 +176,34 @@ export class EnterpriseuserComponent implements OnInit { //重置密码 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); - }) + this.http.put(`/api/ExamUsers/${e.id}/ResetPassword`,{}).subscribe(data=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('重置密码成功!','确定',config); + },err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('重置密码失败!','确定',config); + }) } //启用 enabled (e) { - let date = new Date() let body = { + creationTime: new Date(), + enabled: true, + id: e.id, + identityCard: e.identityCard, name : e.name, + organizationId: e.organizationId, + organizationName: e.organizationName, + phone: e.phone, realName : e.realName, roleType : e.roleType, - enabled : true, - creationTime : date, - posts : e.posts } - this.http.put(`/api/ExamUsers/${e.name}`,body).subscribe(data => { + this.http.put(`/api/ExamUsers/${e.id}`,body).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000; @@ -162,16 +214,19 @@ export class EnterpriseuserComponent implements OnInit { //禁用 noEnabled (e) { - let date = new Date() let body = { + creationTime: new Date(), + enabled: false, + id: e.id, + identityCard: e.identityCard, name : e.name, + organizationId: e.organizationId, + organizationName: e.organizationName, + phone: e.phone, realName : e.realName, roleType : e.roleType, - enabled : false, - creationTime : date, - posts : e.posts } - this.http.put(`/api/ExamUsers/${e.name}`,body).subscribe(data => { + this.http.put(`/api/ExamUsers/${e.id}`,body).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000; @@ -184,7 +239,7 @@ export class EnterpriseuserComponent implements OnInit { delete (e) { let isTrue = confirm('您确定要删除吗') if (isTrue) { - this.http.delete(`/api/ExamUsers/${e.name}`).subscribe(data=>{ + this.http.delete(`/api/ExamUsers/${e.id}`).subscribe(data=>{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 @@ -208,49 +263,71 @@ export class EnterpriseuserComponent implements OnInit { }) 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 = []//救援站职务列表 + constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar,) {} - 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.dataSource.data = this.data.treeData + this.realName = JSON.parse(JSON.stringify(this.data.userData.realName)) + this.identityCard = JSON.parse(JSON.stringify(this.data.userData.identityCard)) + this.phone = JSON.parse(JSON.stringify(this.data.userData.phone)) + this.organizationId = JSON.parse(JSON.stringify(this.data.userData.organizationId)) + this.organizationName = JSON.parse(JSON.stringify(this.data.userData.organizationName)) } - //获得所有职务 - getAllPosts(){ - + errmsg:string = null; //捕获错误信息 + + realName:string = null; + identityCard:string = null; + phone:number = null; + organizationId:string = null; + organizationName:string = null; + + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name } - //提交创建表单 onSubmit (e) { - 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 + if (this.organizationId && this.organizationName) { + e.phone = String(e.phone) + e.roleType = 2 + e.name = this.data.userData.name + e.id = this.data.userData.id + e.enabled = this.data.userData.enabled + e.creationTime = new Date() + e.organizationId = this.organizationId + e.organizationName = this.organizationName + this.http.put(`/api/ExamUsers/${this.data.userData.id}`,e).subscribe(data => { + this.dialogRef.close('success'); + },err => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open(err,'确定',config); + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请选择消防救援站','确定',config); } - this.http.put(`/api/ExamUsers/${this.data.name}`,body).subscribe(data => { - this.dialogRef.close("修改成功"); - }) } } diff --git a/src/app/ui/teacherManagement/addenterpriseuser.component.html b/src/app/ui/teacherManagement/addenterpriseuser.component.html index 36be501..11c2847 100644 --- a/src/app/ui/teacherManagement/addenterpriseuser.component.html +++ b/src/app/ui/teacherManagement/addenterpriseuser.component.html @@ -1,48 +1,44 @@ -

    创建教员

    +

    新增用户

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

    消防救援站:

    +
    + +
    + + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    -

    {{errmsg}}

    - +
    diff --git a/src/app/ui/teacherManagement/addenterpriseuser.component.ts b/src/app/ui/teacherManagement/addenterpriseuser.component.ts index c4d6c72..22a0749 100644 --- a/src/app/ui/teacherManagement/addenterpriseuser.component.ts +++ b/src/app/ui/teacherManagement/addenterpriseuser.component.ts @@ -1,8 +1,10 @@ import { Component, OnInit, Inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import {MatDialogRef} from '@angular/material/dialog'; +import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import {FormControl} from '@angular/forms'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; +import { FlatTreeControl } from '@angular/cdk/tree'; @Component({ selector: 'addenterpriseuser', @@ -11,57 +13,60 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; }) 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() - } + constructor(private http: HttpClient,public dialogRef: MatDialogRef,public snackBar: MatSnackBar,@Inject(MAT_DIALOG_DATA) public data) {} + + ngOnInit(): void { this.dataSource.data = this.data } + + errmsg:string = null; + + organizationId:string = null; + organizationName:string = null; - //获得所有职务 - 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) - } - }); - }) + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name + } //提交创建表单 onSubmit (e) { - 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=>{ + if (this.organizationId && this.organizationName) { + e.phone = null + e.identityCard = null + e.roleType = 1 + e.enabled = true + e.creationTime = new Date() + e.organizationId = this.organizationId + e.organizationName = this.organizationName + this.http.post("/api/ExamUsers",e).subscribe(data => { + this.dialogRef.close(data); + },err => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open(err,'确定',config); + }) + } else { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open(err,'确定',config); - }) - + this.snackBar.open('请选择消防救援站','确定',config); + } } } \ No newline at end of file diff --git a/src/app/ui/teacherManagement/editenterpriseuser.html b/src/app/ui/teacherManagement/editenterpriseuser.html index 013cd42..b01e9d2 100644 --- a/src/app/ui/teacherManagement/editenterpriseuser.html +++ b/src/app/ui/teacherManagement/editenterpriseuser.html @@ -1,45 +1,44 @@ -

    编辑教员

    +

    编辑用户

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

    消防救援站:

    +
    + + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    +

    {{errmsg}}

    - +
    diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.html b/src/app/ui/teacherManagement/enterpriseuser.component.html index b2f662d..cf317d7 100644 --- a/src/app/ui/teacherManagement/enterpriseuser.component.html +++ b/src/app/ui/teacherManagement/enterpriseuser.component.html @@ -11,9 +11,24 @@
    -
    +
    - + + highlight_off +
    + + + +
  • {{node.name}}
  • +
    + + +
  • {{node.name}}
  • +
    +
    +
    @@ -55,7 +70,7 @@ 重置密码 编辑 禁用 - 禁用 + 启用 删除 diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.scss b/src/app/ui/teacherManagement/enterpriseuser.component.scss index 71c0551..85b628b 100644 --- a/src/app/ui/teacherManagement/enterpriseuser.component.scss +++ b/src/app/ui/teacherManagement/enterpriseuser.component.scss @@ -52,3 +52,33 @@ table { .red{ color: #FF8678 } .gray{ color: gray; } } + +//tree +.treeDiv { + max-height: 300px; + overflow-y: auto; + .mat-icon-button { + width: 20px; + height: 20px; + line-height: 20px; + } + li { cursor: pointer; } + .mat-tree-node:hover { background-color: rgb(240, 236, 236); } +} + +.closeTree { + cursor: pointer; + position: absolute; + top: 40px; + right: -95px; + z-index: 100; +} +.searchTree { + .mat-tree-node button .mat-icon { color: #000; } + border: 1px solid rgb(207, 204, 204); + width: 350px; + max-height: 150px; + position: absolute; + top: 40px; + left: 0; +} diff --git a/src/app/ui/teacherManagement/enterpriseuser.component.ts b/src/app/ui/teacherManagement/enterpriseuser.component.ts index 1da79e2..7795479 100644 --- a/src/app/ui/teacherManagement/enterpriseuser.component.ts +++ b/src/app/ui/teacherManagement/enterpriseuser.component.ts @@ -7,6 +7,8 @@ import { PageEvent } from '@angular/material/paginator'; import { AddTeacher } from './addenterpriseuser.component' import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import {FormControl} from '@angular/forms'; +import { FlatTreeControl } from '@angular/cdk/tree'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; @Component({ selector: 'app-enterpriseuser', @@ -19,6 +21,53 @@ export class TeacherManagementComponent implements OnInit { ngOnInit() { this.initData() + this.getOrganizations() + } + + allOrganizations:any; //所有组织机构 + treeData:any = []; //tree型 data + isShowTree:boolean = false; //树形结构是否展示 + showTree () { this.isShowTree = true } + hideTree () { this.isShowTree = false } + + //获取所有组织机构 + getOrganizations () { + this.http.get('/api/Organizations').subscribe((data:any)=>{ + this.allOrganizations = data + data.forEach(element => { + element.children = [] + data.forEach(item => { item.parentId === element.id? element.children.push(item) : null }); + }); + data.forEach(element => { + !element.parentId? this.treeData.push(element) : null + }); + this.dataSources.data = this.treeData + }) //http + } + + organizationId:string = null; + organizationName:string = null; + + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSources = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name + this.isShowTree = false } displayedColumns: string[] = ['identitycard', 'name', 'post', 'time', 'operation',]; @@ -26,7 +75,6 @@ export class TeacherManagementComponent implements OnInit { name:any //用户姓名 identityCard:any //用户账号 - fireTeam:any; //消防救援站 //分页 @ViewChild(MatPaginator, {static: true}) @@ -41,8 +89,9 @@ export class TeacherManagementComponent implements OnInit { chagePage (e) { this.pageNumber = e.pageIndex+1 let data= { - Name: this.identityCard || '', - RealName: this.name || '', + name: this.identityCard || '', + realName: this.name || '', + OrganizationId: this.organizationId || '', RoleType: '1', PageNumber: String(this.pageNumber), } @@ -56,8 +105,9 @@ export class TeacherManagementComponent implements OnInit { //页面初始化 + 查询 + 重置 initData () { let data= { - Name: this.identityCard || '', - RealName: this.name || '', + name: this.identityCard || '', + realName: this.name || '', + OrganizationId: this.organizationId || '', RoleType: '1', } this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{ @@ -71,8 +121,9 @@ export class TeacherManagementComponent implements OnInit { //更新当前页数据 getAllUsers () { let data= { - Name: this.identityCard || '', - RealName: this.name || '', + name: this.identityCard || '', + realName: this.name || '', + OrganizationId: this.organizationId || '', RoleType: '1', PageNumber: String(this.pageNumber), } @@ -85,16 +136,17 @@ export class TeacherManagementComponent implements OnInit { //清空搜索 empty () { - this.identityCard = '' - this.name = '' + this.name = '', + this.identityCard = '', + this.organizationId = '', + this.organizationName = '', this.initData() } //创建教员 open(){ - let dialogRef = this.dialog.open(AddTeacher, {//调用open方法打开对话框并且携带参数过去 - width: '250px', - }); + let data = this.treeData + let dialogRef = this.dialog.open(AddTeacher,{data}); dialogRef.afterClosed().subscribe(data=>{ if (data) { const config = new MatSnackBarConfig(); @@ -108,10 +160,8 @@ export class TeacherManagementComponent implements OnInit { //编辑企业用户 edit (e) { - let dialogRef = this.dialog.open(editTeacher,{ - width: '250px', - data:e - }); + let data = {treeData: this.treeData, userData: e} + let dialogRef = this.dialog.open(editTeacher,{data}); dialogRef.afterClosed().subscribe(data=>{ if (data) { const config = new MatSnackBarConfig(); @@ -125,7 +175,7 @@ export class TeacherManagementComponent implements OnInit { //重置密码 reset (e) { - this.http.put(`/api/ExamUsers/${e.name}/ResetPassword`,{}).subscribe( + this.http.put(`/api/ExamUsers/${e.id}/ResetPassword`,{}).subscribe( data=>{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; @@ -141,16 +191,9 @@ export class TeacherManagementComponent implements OnInit { //启用 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 => { + e.date = new Date() + e.enabled = true + this.http.put(`/api/ExamUsers/${e.id}`,e).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000; @@ -161,16 +204,9 @@ export class TeacherManagementComponent implements OnInit { //禁用 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 => { + e.date = new Date() + e.enabled = false + this.http.put(`/api/ExamUsers/${e.id}`,e).subscribe(data => { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000; @@ -183,7 +219,7 @@ export class TeacherManagementComponent implements OnInit { delete (e) { let isTrue = confirm('您确定要删除吗') if (isTrue) { - this.http.delete(`/api/ExamUsers/${e.name}`).subscribe(data=>{ + this.http.delete(`/api/ExamUsers/${e.id}`).subscribe(data=>{ const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 @@ -207,49 +243,69 @@ export class TeacherManagementComponent implements OnInit { }) 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 = []//救援站职务列表 + constructor(private http: HttpClient,public dialogRef: MatDialogRef,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar,) {} - 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.dataSource.data = this.data.treeData + this.name = JSON.parse(JSON.stringify(this.data.userData.name)) + this.realName = JSON.parse(JSON.stringify(this.data.userData.realName)) + this.organizationId = JSON.parse(JSON.stringify(this.data.userData.organizationId)) + this.organizationName = JSON.parse(JSON.stringify(this.data.userData.organizationName)) } - //获得所有职务 - getAllPosts(){ - + errmsg:string = null; //捕获错误信息 + + name:string = null; + realName:string = null; + organizationId:string = null; + organizationName:string = null; + + private _transformer = (node, level: number) => { //初始化tree + return { + expandable: !!node.children && node.children.length > 0, + name: node.name, + level: level, + id: node.id, + parentId: node.parentId, + children: node.children + }; + } + treeControl = new FlatTreeControl(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + //选择tree节点 + selectTree (e) { + this.organizationId = e.id + this.organizationName = e.name } - //提交创建表单 onSubmit (e) { - 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 + if (this.organizationId && this.organizationName) { + e.phone = this.data.userData.phone + e.identityCard = this.data.userData.identityCard + e.roleType = 1 + e.id = this.data.userData.id + e.enabled = this.data.userData.enabled + e.creationTime = new Date() + e.organizationId = this.organizationId + e.organizationName = this.organizationName + this.http.put(`/api/ExamUsers/${this.data.userData.id}`,e).subscribe(data => { + this.dialogRef.close('success'); + },err => { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open(err,'确定',config); + }) + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请选择消防救援站','确定',config); } - this.http.put(`/api/ExamUsers/${this.data.name}`,body).subscribe(data => { - this.dialogRef.close("修改成功"); - }) } }
    身份证号{{element.name}}{{element.identityCard}}