Browse Source

[完善] 考生,考官管理完善, 阅卷BUG修正

master
陈鹏飞 4 years ago
parent
commit
e0d98bff4d
  1. 7
      src/app/examiner/review-files/review-files.component.ts
  2. 4
      src/app/tabbar/tabbar.component.html
  3. 9
      src/app/ui/collection-tools-examinee/collection-tools.component.html
  4. 10
      src/app/ui/collection-tools-read/collection-tools.component.html
  5. 6
      src/app/ui/collection-tools/collection-tools.component.html
  6. 44
      src/app/ui/enterpriseuser/addenterpriseuser.component.html
  7. 90
      src/app/ui/enterpriseuser/addenterpriseuser.component.ts
  8. 39
      src/app/ui/enterpriseuser/editenterpriseuser.html
  9. 23
      src/app/ui/enterpriseuser/enterpriseuser.component.html
  10. 30
      src/app/ui/enterpriseuser/enterpriseuser.component.scss
  11. 217
      src/app/ui/enterpriseuser/enterpriseuser.component.ts
  12. 44
      src/app/ui/teacherManagement/addenterpriseuser.component.html
  13. 91
      src/app/ui/teacherManagement/addenterpriseuser.component.ts
  14. 41
      src/app/ui/teacherManagement/editenterpriseuser.html
  15. 21
      src/app/ui/teacherManagement/enterpriseuser.component.html
  16. 30
      src/app/ui/teacherManagement/enterpriseuser.component.scss
  17. 200
      src/app/ui/teacherManagement/enterpriseuser.component.ts

7
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.facilityItemScore = data.paperInfo.paperDataInfo[index].facilityItemScore //消防设施单项分
element.functionalDivisionItemSocre = data.paperInfo.paperDataInfo[index].functionalDivisionItemSocre //功能分区单选分 element.functionalDivisionItemSocre = data.paperInfo.paperDataInfo[index].functionalDivisionItemSocre //功能分区单选分
element.importLocationItemScore = data.paperInfo.paperDataInfo[index].importLocationItemScore //重点部位单项分 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 element.score = element.adjoinScore + element.basicInfoScore + element.facilityScore + element.functionalDivisionScore + element.importLocationScore
}); });
this.paperCompanyData = JSON.parse( JSON.stringify(data.examinationDataInfo) ) //具体考卷 this.paperCompanyData = JSON.parse( JSON.stringify(data.examinationDataInfo) ) //具体考卷

4
src/app/tabbar/tabbar.component.html

@ -15,7 +15,9 @@
<!-- <button mat-icon-button class="login"> <!-- <button mat-icon-button class="login">
<mat-icon>account_circle</mat-icon> <mat-icon>account_circle</mat-icon>
</button> --> </button> -->
<span style="position: absolute;right:80px;color: #1E2323;font-size: 16px;">{{realName}}<mat-icon [matMenuTriggerFor]="appMenu" style="color: #1E2323;position: relative;top: 8px;cursor: pointer;">keyboard_arrow_down</mat-icon></span> <span style="position: absolute;right:80px;color: #1E2323;font-size: 16px;cursor: pointer;" [matMenuTriggerFor]="appMenu" >
{{realName}}<mat-icon style="color: #1E2323;position: relative;top: 8px;cursor: pointer;">keyboard_arrow_down</mat-icon>
</span>
<mat-menu #appMenu="matMenu"> <mat-menu #appMenu="matMenu">
<!-- <button mat-menu-item (click)='changeUserData()'> <!-- <button mat-menu-item (click)='changeUserData()'>
<mat-icon>perm_identity</mat-icon> <mat-icon>perm_identity</mat-icon>

9
src/app/ui/collection-tools-examinee/collection-tools.component.html

@ -23,9 +23,8 @@
<app-working-area #canvas [init]='this'></app-working-area> <app-working-area #canvas [init]='this'></app-working-area>
<!-- H5Canvas --> <!-- H5Canvas -->
<!-- 拖拽窗口 --> <!-- 拖拽窗口 -->
<div class="centerBuildingDiv" style="user-select: none;" cdkDrag> <div (mousewheel)="$event.stopPropagation()" class="centerBuildingDiv" style="user-select: none;" cdkDrag>
<div class="centerTotal"> <div class="centerTotal">
<div class="centerTotalHeader overflowText"> <div class="centerTotalHeader overflowText">
<mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon> <mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon>
@ -49,9 +48,7 @@
</div> </div>
</div> </div>
<div (mousewheel)="$event.stopPropagation()" id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;">
<div id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;">
<!-- 处置预案 --> <!-- 处置预案 -->
<div class="handlePlan"> <div class="handlePlan">
@ -157,7 +154,7 @@
</div> </div>
<div id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;"> <div (mousewheel)="$event.stopPropagation()" id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;">
<!-- 右侧div鼠标拖动div --> <!-- 右侧div鼠标拖动div -->
<div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div> <div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div>
<!-- 属性 --> <!-- 属性 -->

10
src/app/ui/collection-tools-read/collection-tools.component.html

@ -28,9 +28,8 @@
<app-working-area #canvas [init]='this'></app-working-area> <app-working-area #canvas [init]='this'></app-working-area>
<!-- H5Canvas --> <!-- H5Canvas -->
<!-- 拖拽窗口 --> <!-- 拖拽窗口 -->
<div class="centerBuildingDiv" style="user-select: none;" cdkDrag> <div (mousewheel)="$event.stopPropagation()" class="centerBuildingDiv" style="user-select: none;" cdkDrag>
<div class="centerTotal"> <div class="centerTotal">
<div class="centerTotalHeader overflowText"> <div class="centerTotalHeader overflowText">
<mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon> <mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon>
@ -55,7 +54,7 @@
</div> </div>
<!-- 查看答案拖拽窗口 --> <!-- 查看答案拖拽窗口 -->
<div class="answerDivDrag" style="user-select: none;" cdkDrag *ngIf="answerDivDrag"> <div (mousewheel)="$event.stopPropagation()" class="answerDivDrag" style="user-select: none;" cdkDrag *ngIf="answerDivDrag">
<div> <div>
<nz-tree *ngIf="answertreeData.length != 0" nzExpandAll #nzTreeComponent [nzData]="answertreeData" nzBlockNode [nzTreeTemplate]="nzTreeTemplate"></nz-tree> <nz-tree *ngIf="answertreeData.length != 0" nzExpandAll #nzTreeComponent [nzData]="answertreeData" nzBlockNode [nzTreeTemplate]="nzTreeTemplate"></nz-tree>
@ -67,8 +66,7 @@
</div> </div>
</div> </div>
<div (mousewheel)="$event.stopPropagation()" id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;">
<div id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;">
<!-- 处置预案 --> <!-- 处置预案 -->
<div class="handlePlan"> <div class="handlePlan">
@ -133,7 +131,7 @@
</div> </div>
<div id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;"> <div (mousewheel)="$event.stopPropagation()" id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;">
<!-- 右侧div鼠标拖动div --> <!-- 右侧div鼠标拖动div -->
<div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div> <div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div>
<!-- 属性 --> <!-- 属性 -->

6
src/app/ui/collection-tools/collection-tools.component.html

@ -16,7 +16,7 @@
<!-- H5Canvas --> <!-- H5Canvas -->
<app-working-area #canvas [init]='this'></app-working-area> <app-working-area #canvas [init]='this'></app-working-area>
<!-- H5Canvas --> <!-- H5Canvas -->
<div class="centerBuildingDiv" style="user-select: none;" cdkDrag> <div (mousewheel)="$event.stopPropagation()" class="centerBuildingDiv" style="user-select: none;" cdkDrag>
<div class="centerTotal"> <div class="centerTotal">
<div class="centerTotalHeader overflowText"> <div class="centerTotalHeader overflowText">
<mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon> <mat-icon cdkDragHandle matTooltip="可移动窗口" matTooltipPosition="above" class="above">open_with</mat-icon>
@ -39,7 +39,7 @@
</div> </div>
</div> </div>
</div> </div>
<div id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;"> <div (mousewheel)="$event.stopPropagation()" id="leftDiv" class='functionalDomainLeft publicCss scenarioAssignment' [ngClass]="{'togglePanel': toggleExpandPanel==true}" style="user-select: none;">
<!-- 处置预案 --> <!-- 处置预案 -->
<div class="handlePlan"> <div class="handlePlan">
@ -142,7 +142,7 @@
</div> </div>
<div id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;"> <div (mousewheel)="$event.stopPropagation()" id="rightDiv" class="functionalDomainRight publicCss " [ngClass]="{'togglePanel2': toggleExpandPanelRight==true}" style="user-select: none;">
<!-- 右侧div鼠标拖动div --> <!-- 右侧div鼠标拖动div -->
<div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div> <div style="width: 3px;height: 100%;position: absolute;left: 0;cursor: e-resize;z-index: 1000;" (mousedown)="rightDivMouseDown($event)"></div>
<!-- 属性 --> <!-- 属性 -->

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

@ -1,48 +1,50 @@
<h2 mat-dialog-title>创建用户</h2> <h2 mat-dialog-title>新增用户</h2>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="idNumber" name="idNumber" <input matInput id="realName" name="realName" required ngModel placeholder="用户姓名" autocomplete="off">
required ngModel placeholder="请输入身份证号" autocomplete="off" pattern="^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$">
<mat-error>
<strong>请输入正确身份证号</strong>
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="realName" name="realName" <input matInput id="identityCard" name="identityCard" required ngModel placeholder="身份证号" autocomplete="off" pattern="^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$">
maxlength="100"
required ngModel placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required> <input matInput id="phone" name="phone" required ngModel placeholder="手机号" type="number" autocomplete="off" pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[0-35-9]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|6[2567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$">
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div style="margin-bottom: 10px;">
<p style="font-size: 14px;">消防救援站: <label style="margin-left: 10px;">{{organizationName}}</label></p>
</div>
<div class="treeDiv">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div mat-dialog-content *ngIf="errmsg"> <div mat-dialog-content *ngIf="errmsg">
<p style="font-size: 14px; color: red;">{{errmsg}}</p> <p style="font-size: 14px; color: red;">{{errmsg}}</p>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid || toppings.value == null">确定</button> <button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button>
<button mat-raised-button mat-dialog-close>取消</button> <button mat-raised-button mat-dialog-close>取消</button>
</div> </div>

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

@ -1,8 +1,10 @@
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; 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 {FormControl} from '@angular/forms';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { FlatTreeControl } from '@angular/cdk/tree';
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
@Component({ @Component({
selector: 'addenterpriseuser', selector: 'addenterpriseuser',
@ -11,57 +13,59 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
}) })
export class AddEnterpriserUser { export class AddEnterpriserUser {
toppings = new FormControl(); constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddEnterpriserUser>,public snackBar: MatSnackBar,@Inject(MAT_DIALOG_DATA) public data) {}
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddEnterpriserUser>,public snackBar: MatSnackBar) {}
errmsg:any; //捕获错误信息 ngOnInit(): void { this.dataSource.data = this.data }
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表 errmsg:string = null;
RescueStationPosts: any = []//救援站职务列表
ngOnInit(): void { organizationId:string = null;
this.getAllPosts() organizationName:string = null;
}
//获得所有职务 private _transformer = (node, level: number) => { //初始化tree
getAllPosts(){ return {
this.http.get("/api/Posts").subscribe( (data:any) =>{ expandable: !!node.children && node.children.length > 0,
data.forEach(item => { name: node.name,
if(item.name.indexOf("支队级") != -1){ level: level,
this.detachmentPosts.push(item) id: node.id,
}else if(item.name.indexOf("大队级") != -1){ parentId: node.parentId,
this.brigadePosts.push(item) children: node.children
}else{ };
this.RescueStationPosts.push(item)
}
});
})
} }
treeControl = new FlatTreeControl<any>(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) { onSubmit (e) {
let date = new Date() if (this.organizationId && this.organizationName) {
let postsArr = this.toppings.value e.phone = String(e.phone)
let postsObj = [] e.roleType = 2
postsArr.forEach((item) => { e.enabled = true
postsObj.push({id:item, name:""}) e.creationTime = new Date()
}) e.organizationId = this.organizationId
let body = { e.organizationName = this.organizationName
name : e.idNumber, this.http.post("/api/ExamUsers",e).subscribe(data => {
realName : e.realName, this.dialogRef.close(data);
roleType : 2, },err => {
enabled : true, const config = new MatSnackBarConfig();
creationTime : date, config.verticalPosition = 'top';
posts : postsObj config.duration = 3000
} this.snackBar.open(err,'确定',config);
this.http.post("/api/Users",body).subscribe( data => { })
this.dialogRef.close(data); } else {
},err => {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open(err,'确定',config); this.snackBar.open('请选择消防救援站','确定',config);
}) }
} }
} }

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

@ -4,42 +4,47 @@
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="idNumber" name="idNumber" <input matInput id="realName" name="realName" [(ngModel)]="realName" required placeholder="用户姓名" autocomplete="off">
required [(ngModel)]="IdNumber" placeholder="请输入身份证号" autocomplete="off" disabled pattern="^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="realName" name="realName" <input matInput id="identityCard" name="identityCard" [(ngModel)]="identityCard" required placeholder="身份证号" autocomplete="off" pattern="^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$">
maxlength="100"
required [(ngModel)]="realName" placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required> <input matInput id="phone" name="phone" [(ngModel)]="phone" required placeholder="手机号" type="number" autocomplete="off" pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[0-35-9]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|6[2567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$">
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div style="margin-bottom: 10px;">
<p style="font-size: 14px;">消防救援站: <label style="margin-left: 10px;">{{organizationName}}</label></p>
</div>
<div class="treeDiv">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div mat-dialog-content *ngIf="errmsg"> <div mat-dialog-content *ngIf="errmsg">
<p style="font-size: 14px; color: red;">{{errmsg}}</p> <p style="font-size: 14px; color: red;">{{errmsg}}</p>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid || toppings.value == null">确定</button> <button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button>
<button mat-raised-button mat-dialog-close>取消</button> <button mat-raised-button mat-dialog-close>取消</button>
</div> </div>

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

@ -11,9 +11,24 @@
<label style="margin-right: 10px;">身份证号:</label> <label style="margin-right: 10px;">身份证号:</label>
<input type="text" [(ngModel)]="identityCard" name="identityCard" autocomplete="off" placeholder="请输入身份证号"> <input type="text" [(ngModel)]="identityCard" name="identityCard" autocomplete="off" placeholder="请输入身份证号">
</div> </div>
<div class="queryField"> <div class="queryField" style="position: relative;">
<label style="margin-right: 10px;">消防救援站:</label> <label style="margin-right: 10px;">消防救援站:</label>
<input type="text" [(ngModel)]="fireTeam" name="fireTeam" autocomplete="off" placeholder="请选择消防救援站"> <input type="text" [(ngModel)]="organizationName" name="organizationName" readonly autocomplete="off" placeholder="请选择消防救援站" (click)='showTree()'>
<mat-icon class="closeTree" *ngIf="isShowTree" (click)='hideTree()'>highlight_off</mat-icon>
<div class="treeDiv searchTree" *ngIf="isShowTree">
<mat-tree [dataSource]="dataSources" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
</div> </div>
<div class="queryField"> <div class="queryField">
<button mat-raised-button (click)='initData()' style="background-color: #07CDCF;">查询</button> <button mat-raised-button (click)='initData()' style="background-color: #07CDCF;">查询</button>
@ -36,7 +51,7 @@
<ng-container matColumnDef="identitycard"> <ng-container matColumnDef="identitycard">
<th mat-header-cell *matHeaderCellDef>身份证号</th> <th mat-header-cell *matHeaderCellDef>身份证号</th>
<td mat-cell *matCellDef="let element">{{element.name}}</td> <td mat-cell *matCellDef="let element">{{element.identityCard}}</td>
</ng-container> </ng-container>
<ng-container matColumnDef="post"> <ng-container matColumnDef="post">
@ -60,7 +75,7 @@
<span class="operationSpan"><span class="spanbtn green" (click)="reset(element)">重置密码</span></span> <span class="operationSpan"><span class="spanbtn green" (click)="reset(element)">重置密码</span></span>
<span class="operationSpan"><span class="spanbtn green" (click)="edit(element)">编辑</span></span> <span class="operationSpan"><span class="spanbtn green" (click)="edit(element)">编辑</span></span>
<span *ngIf="element.enabled" class="operationSpan"><span class="spanbtn red" (click)="noEnabled(element)">禁用</span></span> <span *ngIf="element.enabled" class="operationSpan"><span class="spanbtn red" (click)="noEnabled(element)">禁用</span></span>
<span *ngIf="!element.enabled" class="operationSpan"><span class="spanbtn gray" (click)="enabled(element)"></span></span> <span *ngIf="!element.enabled" class="operationSpan"><span class="spanbtn gray" (click)="enabled(element)"></span></span>
<span class="operationSpan"><span class="spanbtn red" (click)="delete(element)">删除</span></span> <span class="operationSpan"><span class="spanbtn red" (click)="delete(element)">删除</span></span>
</td> </td>
</ng-container> </ng-container>

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

@ -52,3 +52,33 @@ table {
.red{ color: #FF8678 } .red{ color: #FF8678 }
.gray{ color: gray; } .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;
}

217
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 { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FormControl} from '@angular/forms'; import {FormControl} from '@angular/forms';
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
import { FlatTreeControl } from '@angular/cdk/tree';
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
@Component({ @Component({
selector: 'app-enterpriseuser', selector: 'app-enterpriseuser',
@ -20,6 +22,53 @@ export class EnterpriseuserComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.initData() 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<any>(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',]; displayedColumns: string[] = [ 'name','identitycard', 'post', 'tel', 'time', 'operation',];
@ -27,7 +76,6 @@ export class EnterpriseuserComponent implements OnInit {
name:any //姓名 name:any //姓名
identityCard:any //身份证 identityCard:any //身份证
fireTeam:any; //消防救援站
//分页 //分页
@ViewChild(MatPaginator, {static: true}) @ViewChild(MatPaginator, {static: true})
@ -42,8 +90,9 @@ export class EnterpriseuserComponent implements OnInit {
chagePage (e) { chagePage (e) {
this.pageNumber = e.pageIndex+1 this.pageNumber = e.pageIndex+1
let data= { let data= {
Name: this.identityCard || '',
RealName: this.name || '', RealName: this.name || '',
IdentityCard: this.identityCard || '',
OrganizationId: this.organizationId || '',
RoleType: '2', RoleType: '2',
PageNumber: String(this.pageNumber), PageNumber: String(this.pageNumber),
} }
@ -57,8 +106,9 @@ export class EnterpriseuserComponent implements OnInit {
//页面初始化 + 查询 + 重置 //页面初始化 + 查询 + 重置
initData () { initData () {
let data= { let data= {
Name: this.identityCard || '',
RealName: this.name || '', RealName: this.name || '',
IdentityCard: this.identityCard || '',
OrganizationId: this.organizationId || '',
RoleType: '2', RoleType: '2',
} }
this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{ this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{
@ -72,8 +122,9 @@ export class EnterpriseuserComponent implements OnInit {
//更新当前页数据 //更新当前页数据
getAllUsers () { getAllUsers () {
let data= { let data= {
Name: this.identityCard || '',
RealName: this.name || '', RealName: this.name || '',
IdentityCard: this.identityCard || '',
OrganizationId: this.organizationId || '',
RoleType: '2', RoleType: '2',
PageNumber: String(this.pageNumber), PageNumber: String(this.pageNumber),
} }
@ -86,16 +137,17 @@ export class EnterpriseuserComponent implements OnInit {
//清空搜索 //清空搜索
empty () { empty () {
this.identityCard = '' this.name = '',
this.name = '' this.identityCard = '',
this.organizationId = '',
this.organizationName = '',
this.initData() this.initData()
} }
//创建用户 //创建用户
open(){ open(){
let dialogRef = this.dialog.open(AddEnterpriserUser, {//调用open方法打开对话框并且携带参数过去 let data = this.treeData
width: '250px', let dialogRef = this.dialog.open(AddEnterpriserUser,{data});
});
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data=>{
if (data) { if (data) {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
@ -109,10 +161,8 @@ export class EnterpriseuserComponent implements OnInit {
//编辑企业用户 //编辑企业用户
edit (e) { edit (e) {
let dialogRef = this.dialog.open(editenterpriseuser,{ let data = {treeData: this.treeData, userData: e}
width: '250px', let dialogRef = this.dialog.open(editenterpriseuser,{data});
data:e
});
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data=>{
if (data) { if (data) {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
@ -126,32 +176,34 @@ export class EnterpriseuserComponent implements OnInit {
//重置密码 //重置密码
reset (e) { reset (e) {
this.http.put(`/api/ExamUsers/${e.name}/ResetPassword`,{}).subscribe( this.http.put(`/api/ExamUsers/${e.id}/ResetPassword`,{}).subscribe(data=>{
data=>{ const config = new MatSnackBarConfig();
const config = new MatSnackBarConfig(); config.verticalPosition = 'top';
config.verticalPosition = 'top'; config.duration = 3000
config.duration = 3000 this.snackBar.open('重置密码成功!','确定',config);
this.snackBar.open('重置密码成功!','确定',config); },err=>{
},err=>{ const config = new MatSnackBarConfig();
const config = new MatSnackBarConfig(); config.verticalPosition = 'top';
config.verticalPosition = 'top'; config.duration = 3000
config.duration = 3000 this.snackBar.open('重置密码失败!','确定',config);
this.snackBar.open('重置密码失败!','确定',config); })
})
} }
//启用 //启用
enabled (e) { enabled (e) {
let date = new Date()
let body = { let body = {
creationTime: new Date(),
enabled: true,
id: e.id,
identityCard: e.identityCard,
name : e.name, name : e.name,
organizationId: e.organizationId,
organizationName: e.organizationName,
phone: e.phone,
realName : e.realName, realName : e.realName,
roleType : e.roleType, 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(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000; config.duration = 3000;
@ -162,16 +214,19 @@ export class EnterpriseuserComponent implements OnInit {
//禁用 //禁用
noEnabled (e) { noEnabled (e) {
let date = new Date()
let body = { let body = {
creationTime: new Date(),
enabled: false,
id: e.id,
identityCard: e.identityCard,
name : e.name, name : e.name,
organizationId: e.organizationId,
organizationName: e.organizationName,
phone: e.phone,
realName : e.realName, realName : e.realName,
roleType : e.roleType, 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(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000; config.duration = 3000;
@ -184,7 +239,7 @@ export class EnterpriseuserComponent implements OnInit {
delete (e) { delete (e) {
let isTrue = confirm('您确定要删除吗') let isTrue = confirm('您确定要删除吗')
if (isTrue) { if (isTrue) {
this.http.delete(`/api/ExamUsers/${e.name}`).subscribe(data=>{ this.http.delete(`/api/ExamUsers/${e.id}`).subscribe(data=>{
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
@ -208,49 +263,71 @@ export class EnterpriseuserComponent implements OnInit {
}) })
export class editenterpriseuser { export class editenterpriseuser {
toppings:any = new FormControl(); constructor(private http: HttpClient,public dialogRef: MatDialogRef<editenterpriseuser>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar,) {}
constructor(private http: HttpClient,public dialogRef: MatDialogRef<editenterpriseuser>,@Inject(MAT_DIALOG_DATA) public data) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
IdNumber:any //身份证号
realName:any //真实姓名
ngOnInit(): void { ngOnInit(): void {
this.toppings.value = [] this.dataSource.data = this.data.treeData
this.IdNumber = this.data.name this.realName = JSON.parse(JSON.stringify(this.data.userData.realName))
this.realName = this.data.realName this.identityCard = JSON.parse(JSON.stringify(this.data.userData.identityCard))
this.data.posts.forEach((item) => { this.phone = JSON.parse(JSON.stringify(this.data.userData.phone))
this.toppings.value.push(item.id) this.organizationId = JSON.parse(JSON.stringify(this.data.userData.organizationId))
}) this.organizationName = JSON.parse(JSON.stringify(this.data.userData.organizationName))
} }
//获得所有职务 errmsg:string = null; //捕获错误信息
getAllPosts(){
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<any>(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) { onSubmit (e) {
let date = new Date() if (this.organizationId && this.organizationName) {
let postsArr = this.toppings.value e.phone = String(e.phone)
let postsObj = [] e.roleType = 2
postsArr.forEach((item) => { e.name = this.data.userData.name
postsObj.push({id:item, name:""}) e.id = this.data.userData.id
}) e.enabled = this.data.userData.enabled
let body = { e.creationTime = new Date()
name : this.data.name, e.organizationId = this.organizationId
realName : e.realName, e.organizationName = this.organizationName
roleType : 2, this.http.put(`/api/ExamUsers/${this.data.userData.id}`,e).subscribe(data => {
enabled : this.data.enabled, this.dialogRef.close('success');
creationTime : date, },err => {
posts : postsObj 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("修改成功");
})
} }
} }

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

@ -1,48 +1,44 @@
<h2 mat-dialog-title>创建教员</h2> <h2 mat-dialog-title>新增用户</h2>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="idNumber" name="idNumber" <input matInput id="name" name="name" required ngModel placeholder="登录账号" autocomplete="off" pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$">
required ngModel placeholder="请输入帐号" autocomplete="off" pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$">
<mat-error>
<strong>帐号格式为字母+数字</strong>
</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="realName" name="realName" <input matInput id="realName" name="realName" required ngModel placeholder="用户姓名" autocomplete="off">
maxlength="100"
required ngModel placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div style="margin-bottom: 10px;">
<mat-form-field> <p style="font-size: 14px;">消防救援站: <label style="margin-left: 10px;">{{organizationName}}</label></p>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</div> </div>
<div class="treeDiv">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div mat-dialog-content *ngIf="errmsg"> <div mat-dialog-content *ngIf="errmsg">
<p style="font-size: 14px; color: red;">{{errmsg}}</p> <p style="font-size: 14px; color: red;">{{errmsg}}</p>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid || toppings.value == null">确定</button> <button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button>
<button mat-raised-button mat-dialog-close>取消</button> <button mat-raised-button mat-dialog-close>取消</button>
</div> </div>

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

@ -1,8 +1,10 @@
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; 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 {FormControl} from '@angular/forms';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
import { FlatTreeControl } from '@angular/cdk/tree';
@Component({ @Component({
selector: 'addenterpriseuser', selector: 'addenterpriseuser',
@ -11,57 +13,60 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
}) })
export class AddTeacher { export class AddTeacher {
toppings = new FormControl(); constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddTeacher>,public snackBar: MatSnackBar,@Inject(MAT_DIALOG_DATA) public data) {}
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddTeacher>,public snackBar: MatSnackBar) {}
errmsg:any; //捕获错误信息 ngOnInit(): void { this.dataSource.data = this.data }
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表 errmsg:string = null;
RescueStationPosts: any = []//救援站职务列表
ngOnInit(): void { organizationId:string = null;
this.getAllPosts() organizationName:string = null;
}
//获得所有职务 private _transformer = (node, level: number) => { //初始化tree
getAllPosts(){ return {
this.http.get("/api/Posts").subscribe( (data:any) =>{ expandable: !!node.children && node.children.length > 0,
data.forEach(item => { name: node.name,
if(item.name.indexOf("支队级") != -1){ level: level,
this.detachmentPosts.push(item) id: node.id,
}else if(item.name.indexOf("大队级") != -1){ parentId: node.parentId,
this.brigadePosts.push(item) children: node.children
}else{ };
this.RescueStationPosts.push(item)
}
});
})
} }
treeControl = new FlatTreeControl<any>(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) { onSubmit (e) {
let date = new Date() if (this.organizationId && this.organizationName) {
let postsArr = this.toppings.value e.phone = null
let postsObj = [] e.identityCard = null
postsArr.forEach((item) => { e.roleType = 1
postsObj.push({id:item, name:""}) e.enabled = true
}) e.creationTime = new Date()
let body = { e.organizationId = this.organizationId
name : e.idNumber, e.organizationName = this.organizationName
realName : e.realName, this.http.post("/api/ExamUsers",e).subscribe(data => {
roleType : 1, this.dialogRef.close(data);
enabled : true, },err => {
creationTime : date, const config = new MatSnackBarConfig();
posts : postsObj config.verticalPosition = 'top';
} config.duration = 3000
this.http.post("/api/Users",body).subscribe( data => { this.snackBar.open(err,'确定',config);
this.dialogRef.close(data); })
},err=>{ } else {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open(err,'确定',config); this.snackBar.open('请选择消防救援站','确定',config);
}) }
} }
} }

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

@ -1,45 +1,44 @@
<h2 mat-dialog-title>编辑教员</h2> <h2 mat-dialog-title>编辑用户</h2>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container"> <form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="idNumber" name="idNumber" <input matInput id="name" name="name" [(ngModel)]="name" required readonly placeholder="登录账号" autocomplete="off">
required [(ngModel)]="IdNumber" placeholder="请输入帐号" autocomplete="off" disabled pattern="^[a-zA-Z][a-zA-Z0-9_]{4,19}$">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div>
<mat-form-field> <mat-form-field>
<input matInput id="realName" name="realName" <input matInput id="realName" name="realName" [(ngModel)]="realName" required placeholder="用户姓名" autocomplete="off">
maxlength="100"
required [(ngModel)]="realName" placeholder="请输入真实姓名" autocomplete="off">
</mat-form-field> </mat-form-field>
</div> </div>
<div> <div style="margin-bottom: 10px;">
<mat-form-field> <p style="font-size: 14px;">消防救援站: <label style="margin-left: 10px;">{{organizationName}}</label></p>
<mat-select placeholder="请选择职务" [formControl]="toppings" multiple required>
<div style="float: left;">
<mat-option *ngFor="let item of detachmentPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of brigadePosts" [value]="item.id">{{item.name}}</mat-option>
</div>
<div style="float: left;">
<mat-option *ngFor="let item of RescueStationPosts" [value]="item.id">{{item.name}}</mat-option>
</div>
</mat-select>
</mat-form-field>
</div> </div>
<div class="treeDiv">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div mat-dialog-content *ngIf="errmsg"> <div mat-dialog-content *ngIf="errmsg">
<p style="font-size: 14px; color: red;">{{errmsg}}</p> <p style="font-size: 14px; color: red;">{{errmsg}}</p>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid || toppings.value == null">确定</button> <button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">确定</button>
<button mat-raised-button mat-dialog-close>取消</button> <button mat-raised-button mat-dialog-close>取消</button>
</div> </div>

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

@ -11,9 +11,24 @@
<label style="margin-right: 10px;">用户姓名:</label> <label style="margin-right: 10px;">用户姓名:</label>
<input type="text" [(ngModel)]="name" name="name" autocomplete="off" placeholder="请输入用户姓名"> <input type="text" [(ngModel)]="name" name="name" autocomplete="off" placeholder="请输入用户姓名">
</div> </div>
<div class="queryField"> <div class="queryField" style="position: relative;">
<label style="margin-right: 10px;">消防救援站:</label> <label style="margin-right: 10px;">消防救援站:</label>
<input type="text" [(ngModel)]="fireTeam" name="fireTeam" autocomplete="off" placeholder="请选择消防救援站"> <input type="text" [(ngModel)]="organizationName" name="organizationName" readonly autocomplete="off" placeholder="请选择消防救援站" (click)='showTree()'>
<mat-icon class="closeTree" *ngIf="isShowTree" (click)='hideTree()'>highlight_off</mat-icon>
<div class="treeDiv searchTree" *ngIf="isShowTree">
<mat-tree [dataSource]="dataSources" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='selectTree(node)'>
<button type="button" mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon mat-icon class="mat-icon-rtl-mirror">{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
</div> </div>
<div class="queryField"> <div class="queryField">
<button mat-raised-button (click)='initData()' style="background-color: #07CDCF;">查询</button> <button mat-raised-button (click)='initData()' style="background-color: #07CDCF;">查询</button>
@ -55,7 +70,7 @@
<span class="operationSpan"><span class="spanbtn green" (click)="reset(element)">重置密码</span></span> <span class="operationSpan"><span class="spanbtn green" (click)="reset(element)">重置密码</span></span>
<span class="operationSpan"><span class="spanbtn green" (click)="edit(element)">编辑</span></span> <span class="operationSpan"><span class="spanbtn green" (click)="edit(element)">编辑</span></span>
<span *ngIf="element.enabled" class="operationSpan"><span class="spanbtn red" (click)="noEnabled(element)">禁用</span></span> <span *ngIf="element.enabled" class="operationSpan"><span class="spanbtn red" (click)="noEnabled(element)">禁用</span></span>
<span *ngIf="!element.enabled" class="operationSpan"><span class="spanbtn gray" (click)="enabled(element)"></span></span> <span *ngIf="!element.enabled" class="operationSpan"><span class="spanbtn gray" (click)="enabled(element)"></span></span>
<span class="operationSpan"><span class="spanbtn red" (click)="delete(element)">删除</span></span> <span class="operationSpan"><span class="spanbtn red" (click)="delete(element)">删除</span></span>
</td> </td>
</ng-container> </ng-container>

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

@ -52,3 +52,33 @@ table {
.red{ color: #FF8678 } .red{ color: #FF8678 }
.gray{ color: gray; } .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;
}

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

@ -7,6 +7,8 @@ import { PageEvent } from '@angular/material/paginator';
import { AddTeacher } from './addenterpriseuser.component' import { AddTeacher } from './addenterpriseuser.component'
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FormControl} from '@angular/forms'; import {FormControl} from '@angular/forms';
import { FlatTreeControl } from '@angular/cdk/tree';
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
@Component({ @Component({
selector: 'app-enterpriseuser', selector: 'app-enterpriseuser',
@ -19,6 +21,53 @@ export class TeacherManagementComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.initData() 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<any>(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',]; displayedColumns: string[] = ['identitycard', 'name', 'post', 'time', 'operation',];
@ -26,7 +75,6 @@ export class TeacherManagementComponent implements OnInit {
name:any //用户姓名 name:any //用户姓名
identityCard:any //用户账号 identityCard:any //用户账号
fireTeam:any; //消防救援站
//分页 //分页
@ViewChild(MatPaginator, {static: true}) @ViewChild(MatPaginator, {static: true})
@ -41,8 +89,9 @@ export class TeacherManagementComponent implements OnInit {
chagePage (e) { chagePage (e) {
this.pageNumber = e.pageIndex+1 this.pageNumber = e.pageIndex+1
let data= { let data= {
Name: this.identityCard || '', name: this.identityCard || '',
RealName: this.name || '', realName: this.name || '',
OrganizationId: this.organizationId || '',
RoleType: '1', RoleType: '1',
PageNumber: String(this.pageNumber), PageNumber: String(this.pageNumber),
} }
@ -56,8 +105,9 @@ export class TeacherManagementComponent implements OnInit {
//页面初始化 + 查询 + 重置 //页面初始化 + 查询 + 重置
initData () { initData () {
let data= { let data= {
Name: this.identityCard || '', name: this.identityCard || '',
RealName: this.name || '', realName: this.name || '',
OrganizationId: this.organizationId || '',
RoleType: '1', RoleType: '1',
} }
this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{ this.http.get('/api/ExamUsers',{params:data}).subscribe((data:any)=>{
@ -71,8 +121,9 @@ export class TeacherManagementComponent implements OnInit {
//更新当前页数据 //更新当前页数据
getAllUsers () { getAllUsers () {
let data= { let data= {
Name: this.identityCard || '', name: this.identityCard || '',
RealName: this.name || '', realName: this.name || '',
OrganizationId: this.organizationId || '',
RoleType: '1', RoleType: '1',
PageNumber: String(this.pageNumber), PageNumber: String(this.pageNumber),
} }
@ -85,16 +136,17 @@ export class TeacherManagementComponent implements OnInit {
//清空搜索 //清空搜索
empty () { empty () {
this.identityCard = '' this.name = '',
this.name = '' this.identityCard = '',
this.organizationId = '',
this.organizationName = '',
this.initData() this.initData()
} }
//创建教员 //创建教员
open(){ open(){
let dialogRef = this.dialog.open(AddTeacher, {//调用open方法打开对话框并且携带参数过去 let data = this.treeData
width: '250px', let dialogRef = this.dialog.open(AddTeacher,{data});
});
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data=>{
if (data) { if (data) {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
@ -108,10 +160,8 @@ export class TeacherManagementComponent implements OnInit {
//编辑企业用户 //编辑企业用户
edit (e) { edit (e) {
let dialogRef = this.dialog.open(editTeacher,{ let data = {treeData: this.treeData, userData: e}
width: '250px', let dialogRef = this.dialog.open(editTeacher,{data});
data:e
});
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data=>{
if (data) { if (data) {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
@ -125,7 +175,7 @@ export class TeacherManagementComponent implements OnInit {
//重置密码 //重置密码
reset (e) { reset (e) {
this.http.put(`/api/ExamUsers/${e.name}/ResetPassword`,{}).subscribe( this.http.put(`/api/ExamUsers/${e.id}/ResetPassword`,{}).subscribe(
data=>{ data=>{
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
@ -141,16 +191,9 @@ export class TeacherManagementComponent implements OnInit {
//启用 //启用
enabled (e) { enabled (e) {
let date = new Date() e.date = new Date()
let body = { e.enabled = true
name : e.name, this.http.put(`/api/ExamUsers/${e.id}`,e).subscribe(data => {
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(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000; config.duration = 3000;
@ -161,16 +204,9 @@ export class TeacherManagementComponent implements OnInit {
//禁用 //禁用
noEnabled (e) { noEnabled (e) {
let date = new Date() e.date = new Date()
let body = { e.enabled = false
name : e.name, this.http.put(`/api/ExamUsers/${e.id}`,e).subscribe(data => {
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(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000; config.duration = 3000;
@ -183,7 +219,7 @@ export class TeacherManagementComponent implements OnInit {
delete (e) { delete (e) {
let isTrue = confirm('您确定要删除吗') let isTrue = confirm('您确定要删除吗')
if (isTrue) { if (isTrue) {
this.http.delete(`/api/ExamUsers/${e.name}`).subscribe(data=>{ this.http.delete(`/api/ExamUsers/${e.id}`).subscribe(data=>{
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
@ -207,49 +243,69 @@ export class TeacherManagementComponent implements OnInit {
}) })
export class editTeacher { export class editTeacher {
toppings:any = new FormControl(); constructor(private http: HttpClient,public dialogRef: MatDialogRef<editTeacher>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar,) {}
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 { ngOnInit(): void {
this.toppings.value = [] this.dataSource.data = this.data.treeData
this.IdNumber = this.data.name this.name = JSON.parse(JSON.stringify(this.data.userData.name))
this.realName = this.data.realName this.realName = JSON.parse(JSON.stringify(this.data.userData.realName))
this.data.posts.forEach((item) => { this.organizationId = JSON.parse(JSON.stringify(this.data.userData.organizationId))
this.toppings.value.push(item.id) this.organizationName = JSON.parse(JSON.stringify(this.data.userData.organizationName))
})
} }
//获得所有职务 errmsg:string = null; //捕获错误信息
getAllPosts(){
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<any>(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) { onSubmit (e) {
let date = new Date() if (this.organizationId && this.organizationName) {
let postsArr = this.toppings.value e.phone = this.data.userData.phone
let postsObj = [] e.identityCard = this.data.userData.identityCard
postsArr.forEach((item) => { e.roleType = 1
postsObj.push({id:item, name:""}) e.id = this.data.userData.id
}) e.enabled = this.data.userData.enabled
let body = { e.creationTime = new Date()
name : this.data.name, e.organizationId = this.organizationId
realName : e.realName, e.organizationName = this.organizationName
roleType : 1, this.http.put(`/api/ExamUsers/${this.data.userData.id}`,e).subscribe(data => {
enabled : this.data.enabled, this.dialogRef.close('success');
creationTime : date, },err => {
posts : postsObj 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("修改成功");
})
} }
} }

Loading…
Cancel
Save