Browse Source

[完善]考试系统预案编辑功能

智慧矿山应急安全培训、考核、演练管理系统
邵佳豪 2 years ago
parent
commit
38dadbe23f
  1. 2
      src/app/examiner/create-test-score/create-test-score.component.html
  2. 2527
      src/app/examiner/create-test-score/create-test-score.component.ts
  3. 2793
      src/app/ui/collection-tools/collection-tools.component.ts
  4. 457
      src/app/ui/collection-tools/examinationQuestions.ts

2
src/app/examiner/create-test-score/create-test-score.component.html

@ -287,7 +287,7 @@
<input onchange="if(!value)value=0" (input)="planItemScore()" type="number" [(ngModel)]="item.score"> <input onchange="if(!value)value=0" (input)="planItemScore()" type="number" [(ngModel)]="item.score">
</td> </td>
<td *ngIf="!(pattern=='look')"> <td *ngIf="!(pattern=='look')">
<!-- <span style="color: #07CDCF;" (click)="edit(item)" >编辑</span> --> <span style="color: #07CDCF;" (click)="edit(item)" >编辑</span>
<span style="color: #FF8678;" (click)="deletePlan(item)">删除</span> <span style="color: #FF8678;" (click)="deletePlan(item)">删除</span>
</td> </td>
</tr> </tr>

2527
src/app/examiner/create-test-score/create-test-score.component.ts

File diff suppressed because it is too large Load Diff

2793
src/app/ui/collection-tools/collection-tools.component.ts

File diff suppressed because it is too large Load Diff

457
src/app/ui/collection-tools/examinationQuestions.ts

@ -1,217 +1,263 @@
import { Component, OnInit, Inject, ViewChild } from '@angular/core'; import { Component, OnInit, Inject, ViewChild } from "@angular/core";
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from "@angular/common/http";
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import {
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; MatDialog,
import { CanvasShareDataService, DisposalNodeData } from '../../canvas-share-data.service' //引入服务 MatDialogRef,
import { FlatTreeControl } from '@angular/cdk/tree'; MAT_DIALOG_DATA,
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; } from "@angular/material/dialog";
import { NzFormatBeforeDropEvent, NzFormatEmitEvent, NzTreeComponent } from 'ng-zorro-antd/tree'; import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar";
import { ActivatedRoute } from '@angular/router'; import {
CanvasShareDataService,
DisposalNodeData,
} from "../../canvas-share-data.service"; //引入服务
import { FlatTreeControl } from "@angular/cdk/tree";
import {
MatTreeFlatDataSource,
MatTreeFlattener,
} from "@angular/material/tree";
import {
NzFormatBeforeDropEvent,
NzFormatEmitEvent,
NzTreeComponent,
} from "ng-zorro-antd/tree";
import { ActivatedRoute } from "@angular/router";
@Component({ @Component({
selector: 'dialog-examination-questions', selector: "dialog-examination-questions",
templateUrl: './examinationQuestions.html', templateUrl: "./examinationQuestions.html",
styleUrls: ['./collection-tools.component.scss',] styleUrls: ["./collection-tools.component.scss"],
}) })
export class examinationQuestions { export class examinationQuestions {
constructor(
private http: HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data
) {}
constructor(private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, @ViewChild("nzTreeComponent3", { static: false })
@Inject(MAT_DIALOG_DATA) public data) { } nzTreeComponent!: NzTreeComponent;
@ViewChild('nzTreeComponent3', { static: false }) nzTreeComponent!: NzTreeComponent;
defaultCheckedKeys = []; //指定选中复选框的树节点 key值 defaultCheckedKeys = []; //指定选中复选框的树节点 key值
defaultExpandedKeys = []; //展开指定的树节点 key值 defaultExpandedKeys = []; //展开指定的树节点 key值
defaultSelectedKeys = []; //指定选中的树节点 key值 defaultSelectedKeys = []; //指定选中的树节点 key值
renderData: any renderData: any;
ngOnInit(): void { ngOnInit(): void {
this.renderData = this.data.treeData this.renderData = this.data.treeData;
if (JSON.parse(sessionStorage.getItem('tree型数据')) && JSON.parse(sessionStorage.getItem('tree型数据'))[this.data.buildFloorData.floorData.id]) { if (
this.defaultCheckedKeys = JSON.parse(sessionStorage.getItem('tree型数据'))[this.data.buildFloorData.floorData.id] JSON.parse(sessionStorage.getItem("tree型数据")) &&
JSON.parse(sessionStorage.getItem("tree型数据"))[
this.data.buildFloorData.floorData.id
]
) {
this.defaultCheckedKeys = JSON.parse(
sessionStorage.getItem("tree型数据")
)[this.data.buildFloorData.floorData.id];
} }
this.data.treeData.forEach(element => { this.data.treeData.forEach((element) => {
if (element.isTemplate) { if (element.isTemplate) {
element.isLeaf = false element.isLeaf = false;
} else { } else {
element.isLeaf = true element.isLeaf = true;
} }
if (element.children && element.children.length != 0) { if (element.children && element.children.length != 0) {
element.children.forEach(ele => { element.children.forEach((ele) => {
if (ele.isTemplate) { if (ele.isTemplate) {
ele.isLeaf = false ele.isLeaf = false;
} else { } else {
ele.isLeaf = true ele.isLeaf = true;
} }
if (ele.children && ele.children.length != 0) { if (ele.children && ele.children.length != 0) {
ele.children.forEach(item => { ele.children.forEach((item) => {
if (item.isTemplate) { if (item.isTemplate) {
item.isLeaf = false item.isLeaf = false;
} else { } else {
item.isLeaf = true item.isLeaf = true;
} }
}); });
} }
}) });
} }
}) });
//阻止 滚轮滚动事件穿透 //阻止 滚轮滚动事件穿透
window.setTimeout(()=>{ window.setTimeout(() => {
(document.getElementById('nodeTree') as any).onmousewheel = (e)=>{ (document.getElementById("nodeTree") as any).onmousewheel = (e) => {
e.stopPropagation(); e.stopPropagation();
} };
}, 0) }, 0);
} }
nzEvent($event) { nzEvent($event) {
console.log($event) console.log($event);
} }
//提交 //提交
submit() { submit() {
let oldTreeData = this.nzTreeComponent.getCheckedNodeList();
let oldTreeData = this.nzTreeComponent.getCheckedNodeList() let alltreedata = JSON.parse(sessionStorage.getItem("tree型数据"));
let keyArr = [];
oldTreeData.forEach((element) => {
// console.log(oldTreeData) keyArr.push(element.origin.key);
let alltreedata = JSON.parse(sessionStorage.getItem("tree型数据")) });
let keyArr = []
oldTreeData.forEach(element => {
keyArr.push(element.origin.key)
})
if (alltreedata) { if (alltreedata) {
//如果已经保存过当前楼层则替换 //如果已经保存过当前楼层则替换
alltreedata[this.data.buildFloorData.floorData.id] = keyArr alltreedata[this.data.buildFloorData.floorData.id] = keyArr;
sessionStorage.setItem('tree型数据', JSON.stringify(alltreedata)) sessionStorage.setItem("tree型数据", JSON.stringify(alltreedata));
} else { } else {
alltreedata = {} alltreedata = {};
alltreedata[this.data.buildFloorData.floorData.id] = keyArr alltreedata[this.data.buildFloorData.floorData.id] = keyArr;
sessionStorage.setItem('tree型数据', JSON.stringify(alltreedata)) sessionStorage.setItem("tree型数据", JSON.stringify(alltreedata));
} }
let checkList = []; //只存真实素材
let checkList = [] //只存真实素材
for (const key in this.data.oldRealData.data) { for (const key in this.data.oldRealData.data) {
let element = this.data.oldRealData.data[key] let element = this.data.oldRealData.data[key];
let isChecked = (this.nzTreeComponent.getTreeNodeByKey(key)).isChecked let isChecked = this.nzTreeComponent.getTreeNodeByKey(key).isChecked;
isChecked ? checkList.push(element) : null isChecked ? checkList.push(element) : null;
} }
//存储真实素材数据 //存储真实素材数据
let basicAssetsId = [] let basicAssetsId = [];
if (checkList && checkList.length != 0) { if (checkList && checkList.length != 0) {
checkList.forEach(item => { checkList.forEach((item) => {
basicAssetsId.push(item.TemplateId) basicAssetsId.push(item.TemplateId);
}) });
} }
basicAssetsId = Array.from(new Set(basicAssetsId)) basicAssetsId = Array.from(new Set(basicAssetsId));
console.log(123, this.data.buildFloorData) console.log(123, this.data.buildFloorData);
let obj = { let obj = {
name: this.data.buildFloorData.buildingData.name + '-' + this.data.buildFloorData.floorData.name, name:
this.data.buildFloorData.buildingData.name +
"-" +
this.data.buildFloorData.floorData.name,
key: this.data.buildFloorData.floorData.id, key: this.data.buildFloorData.floorData.id,
buildingId: this.data.buildFloorData.buildingData.id, buildingId: this.data.buildFloorData.buildingData.id,
children: checkList, children: checkList,
basicAssetsId: basicAssetsId basicAssetsId: basicAssetsId,
} };
let data = JSON.parse(sessionStorage.getItem("消防设施" + sessionStorage.getItem('paperId'))) let data = JSON.parse(
sessionStorage.getItem("消防设施" + sessionStorage.getItem("paperId"))
);
if (data && data.length != 0) { if (data && data.length != 0) {
console.log(1) console.log(1);
let ind = null let ind = null;
data.forEach((item, index) => { data.forEach((item, index) => {
if (item.key == obj.key) { if (item.key == obj.key) {
ind = index + 1 ind = index + 1;
} }
}) });
if (ind) { if (ind) {
if (checkList.length != 0) { if (checkList.length != 0) {
data[ind - 1].children = checkList data[ind - 1].children = checkList;
} else { } else {
data.splice(ind - 1, 1) data.splice(ind - 1, 1);
} }
} else { } else {
data.push(obj) data.push(obj);
} }
sessionStorage.setItem("消防设施" + sessionStorage.getItem('paperId'), JSON.stringify(data)) sessionStorage.setItem(
"消防设施" + sessionStorage.getItem("paperId"),
JSON.stringify(data)
);
} else { } else {
console.log(2) console.log(2);
data = [] data = [];
data[0] = obj data[0] = obj;
sessionStorage.setItem("消防设施" + sessionStorage.getItem('paperId'), JSON.stringify(data)) sessionStorage.setItem(
"消防设施" + sessionStorage.getItem("paperId"),
JSON.stringify(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);
this.dialogRef.close() this.dialogRef.close();
} }
} }
//上传按钮 //上传按钮
@Component({ @Component({
selector: 'dialog-upload-questions', selector: "dialog-upload-questions",
templateUrl: './uploadQuestions.html', templateUrl: "./uploadQuestions.html",
styleUrls: ['./collection-tools.component.scss',] styleUrls: ["./collection-tools.component.scss"],
}) })
export class uploadQuestions { export class uploadQuestions {
constructor(
constructor(private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, private http: HttpClient,
@Inject(MAT_DIALOG_DATA) public data, private route: ActivatedRoute) { } public dialog: MatDialog,
public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data,
private route: ActivatedRoute
) {}
defaultCheckedKeys = []; //指定选中复选框的树节点 key值 defaultCheckedKeys = []; //指定选中复选框的树节点 key值
defaultExpandedKeys = []; //展开指定的树节点 key值 defaultExpandedKeys = []; //展开指定的树节点 key值
defaultSelectedKeys = []; //指定选中的树节点 key值 defaultSelectedKeys = []; //指定选中的树节点 key值
renderData: any renderData: any;
ngOnInit(): void { ngOnInit(): void {
let data = JSON.parse(sessionStorage.getItem("消防设施" + sessionStorage.getItem('paperId'))) let data = JSON.parse(
data ? data.forEach(item => { sessionStorage.getItem("消防设施" + sessionStorage.getItem("paperId"))
let realData = item.children );
let allFireElements = JSON.parse(JSON.stringify(this.data.allFireElements))
item.children = this.processingData(allFireElements, realData) console.log(888, data);
}) : null
this.renderData = data data
this.getProfiles() ? data.forEach((item) => {
this.nodeInit() let realData = item.children;
let allFireElements = JSON.parse(
JSON.stringify(this.data.allFireElements)
);
item.children = this.processingData(allFireElements, realData);
})
: null;
this.renderData = data;
this.getProfiles();
this.nodeInit();
console.log('天气信息', this.data.weatherData) console.log("天气信息", this.data.weatherData);
} }
//处理数据 将消防要素模板与真实素材结合 //处理数据 将消防要素模板与真实素材结合
processingData(allFireElements, realData) { processingData(allFireElements, realData) {
allFireElements[allFireElements.length - 1].children = [] allFireElements[allFireElements.length - 1].children = [];
realData.forEach(item => { realData.forEach((item) => {
item.isLeaf = true item.isLeaf = true;
let noMatch = allFireElements.find(every => every.id === item.FireElementId) let noMatch = allFireElements.find(
(every) => every.id === item.FireElementId
);
if (!noMatch) { if (!noMatch) {
allFireElements[allFireElements.length - 1].children.push(item) allFireElements[allFireElements.length - 1].children.push(item);
} }
}) });
let treeData = [] //tree型 处理完成后的数据 let treeData = []; //tree型 处理完成后的数据
allFireElements.forEach(element => { allFireElements.forEach((element) => {
element.key = element.id element.key = element.id;
element.name != '其他' ? element.children = [] : null element.name != "其他" ? (element.children = []) : null;
if (realData) { if (realData) {
realData.forEach(item => { realData.forEach((item) => {
if (element.id == item.FireElementId) { if (element.id == item.FireElementId) {
element.children.push(item) element.children.push(item);
} }
}) });
} }
allFireElements.forEach(item => { if (item.parentId == element.id) { element.children.push(item) } }); allFireElements.forEach((item) => {
if (item.parentId == element.id) {
element.children.push(item);
}
});
}); });
allFireElements.forEach(element => { allFireElements.forEach((element) => {
if (!element.parentId) { treeData.push(element) } if (!element.parentId) {
treeData.push(element);
}
}); });
function recursionFilterEmpty(originalList, result) { function recursionFilterEmpty(originalList, result) {
for (let i = 0, length = originalList.length; i < length; i++) { for (let i = 0, length = originalList.length; i < length; i++) {
@ -228,7 +274,7 @@ export class uploadQuestions {
item.children = newChildren; item.children = newChildren;
// 子项有真实的数据,就保留这一项 // 子项有真实的数据,就保留这一项
result.push(item); result.push(item);
} // 如果没有这一项就会被删除 } // 如果没有这一项就会被删除
} }
} }
} }
@ -237,53 +283,55 @@ export class uploadQuestions {
recursionFilterEmpty(listData, result); recursionFilterEmpty(listData, result);
return result; return result;
} }
return filterEmpty(treeData) return filterEmpty(treeData);
} }
//获取登录账号的个人资料 //获取登录账号的个人资料
Profiles: any Profiles: any;
getProfiles() { getProfiles() {
this.http.get('/api/ExamAccounts/Profiles').subscribe(data => { this.http.get("/api/ExamAccounts/Profiles").subscribe((data) => {
this.Profiles = data this.Profiles = data;
}) });
} }
nodeTreeData: any = []; //处置节点tree nodeTreeData: any = []; //处置节点tree
//节点初始化 //节点初始化
nodeInit() { nodeInit() {
let treeData = [] let treeData = [];
this.data.node.forEach(element => { console.log(9999, this.data.node);
element.title = element.name //name this.data.node.forEach((element) => {
element.key = element.id //id element.title = element.name; //name
element.children = [] //children element.key = element.id; //id
if (element.sitePlanId || element.buildingAreaId) { //是数据节点 element.children = []; //children
element.isLeaf = true if (element.sitePlanId || element.buildingAreaId) {
element.isDataNode = true //是数据节点
} else { //不是数据节点 element.isLeaf = true;
element.isLeaf = false element.isDataNode = true;
element.isDataNode = false } else {
//不是数据节点
element.isLeaf = false;
element.isDataNode = false;
} }
this.data.node.forEach(item => { this.data.node.forEach((item) => {
item.parentId === element.id ? element.children.push(item) : null item.parentId === element.id ? element.children.push(item) : null;
}) });
});
this.data.node.forEach((element) => {
!element.parentId ? treeData.push(element) : null;
}); });
this.data.node.forEach(element => { this.nodeTreeData = [...treeData];
!element.parentId ? treeData.push(element) : null
})
this.nodeTreeData = [...treeData]
} }
nzEvent($event) { nzEvent($event) {
console.log($event) console.log($event);
} }
//上传 //上传
submit() { submit() {
console.log(this.data.question) console.log(this.data.question);
let body: any = { let body: any = {
id: this.route.snapshot.queryParams.paperplanId, id: this.route.snapshot.queryParams.paperplanId,
paperId: sessionStorage.getItem('paperId'), paperId: sessionStorage.getItem("paperId"),
planComponentId: sessionStorage.getItem('planId'), planComponentId: sessionStorage.getItem("planId"),
examPlanType: this.route.snapshot.queryParams.openType == 1 ? 0 : 1, examPlanType: this.route.snapshot.queryParams.openType == 1 ? 0 : 1,
creatorId: this.Profiles.id, creatorId: this.Profiles.id,
modifiedTime: new Date(), modifiedTime: new Date(),
@ -291,70 +339,87 @@ export class uploadQuestions {
title: this.route.snapshot.queryParams.planName, title: this.route.snapshot.queryParams.planName,
mainPoint: this.data.question.keynote, mainPoint: this.data.question.keynote,
score: 0, score: 0,
examFacilityAssetsData: sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) ? sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) : null, examFacilityAssetsData: sessionStorage.getItem(
examDisposalNodesData: sessionStorage.getItem('examNodeList') ? sessionStorage.getItem('examNodeList') : null, "消防设施" + sessionStorage.getItem("paperId")
companyId: sessionStorage.getItem('companyId'), )
weather: JSON.stringify(this.data.weatherData) ? sessionStorage.getItem("消防设施" + sessionStorage.getItem("paperId"))
} : null,
examDisposalNodesData: sessionStorage.getItem("examNodeList")
? sessionStorage.getItem("examNodeList")
this.http.put(`/api/PaperPlans/${this.route.snapshot.queryParams.paperplanId}`, body).subscribe(data => { : null,
companyId: sessionStorage.getItem("companyId"),
const config = new MatSnackBarConfig(); weather: JSON.stringify(this.data.weatherData),
config.verticalPosition = 'top'; };
config.duration = 3000
this.snackBar.open('设置完成,页面将于一秒后关闭', '确定', config); this.http
setTimeout(() => { .put(
window.close() `/api/PaperPlans/${this.route.snapshot.queryParams.paperplanId}`,
}, 1000); body
)
}) .subscribe(
(data) => {
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("设置完成,页面将于一秒后关闭", "确定", config);
setTimeout(() => {
window.close();
}, 1000);
},
(err) => {
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("保存失败", "确定", config);
}
);
} }
} }
//保存考的节点 //保存考的节点
@Component({ @Component({
selector: 'dialog-disposal-nodes', selector: "dialog-disposal-nodes",
templateUrl: './uploadDisposalNodes.html', templateUrl: "./uploadDisposalNodes.html",
styleUrls: ['./collection-tools.component.scss',] styleUrls: ["./collection-tools.component.scss"],
}) })
export class uploadDisposalNodes { export class uploadDisposalNodes {
constructor(
constructor(private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, private http: HttpClient,
@Inject(MAT_DIALOG_DATA) public data) { } public dialog: MatDialog,
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; public snackBar: MatSnackBar,
public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data
) {}
@ViewChild("nzTreeComponent", { static: false })
nzTreeComponent!: NzTreeComponent;
ngOnInit(): void { ngOnInit(): void {
this.treeData = [...this.data.treeData] this.treeData = [...this.data.treeData];
} }
treeData: any = []; //tree treeData: any = []; //tree
//提交 保存考试节点 //提交 保存考试节点
submit() { submit() {
let checkList = [] let checkList = [];
this.data.oldTreeData.forEach(element => { this.data.oldTreeData.forEach((element) => {
let isChecked = (this.nzTreeComponent.getTreeNodeByKey(element.id)).isChecked let isChecked = this.nzTreeComponent.getTreeNodeByKey(
isChecked ? checkList.push(element) : null element.id
).isChecked;
isChecked ? checkList.push(element) : null;
}); });
let galfList = this.nzTreeComponent.getHalfCheckedNodeList() let galfList = this.nzTreeComponent.getHalfCheckedNodeList();
this.data.oldTreeData.forEach(element => { this.data.oldTreeData.forEach((element) => {
galfList.forEach(elements => { galfList.forEach((elements) => {
element.id == elements.origin.id ? checkList.push(element) : null element.id == elements.origin.id ? checkList.push(element) : null;
}); });
}); });
if (checkList.length) { if (checkList.length) {
this.dialogRef.close(checkList); this.dialogRef.close(checkList);
} else { } else {
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);
} }
} }
}
}

Loading…
Cancel
Save