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

Loading…
Cancel
Save