|
|
|
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',]
|
|
|
|
})
|
|
|
|
export class examinationQuestions {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
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.data.treeData.forEach(element => {
|
|
|
|
if(element.isTemplate){
|
|
|
|
element.isLeaf = false
|
|
|
|
}else{
|
|
|
|
element.isLeaf = true
|
|
|
|
}
|
|
|
|
if(element.children && element.children.length != 0){
|
|
|
|
element.children.forEach(ele => {
|
|
|
|
if(ele.isTemplate){
|
|
|
|
ele.isLeaf = false
|
|
|
|
}else{
|
|
|
|
ele.isLeaf = true
|
|
|
|
}
|
|
|
|
if(ele.children && ele.children.length != 0){
|
|
|
|
ele.children.forEach(item => {
|
|
|
|
if(item.isTemplate){
|
|
|
|
item.isLeaf = false
|
|
|
|
}else{
|
|
|
|
item.isLeaf = true
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
nzEvent($event){
|
|
|
|
console.log($event)
|
|
|
|
}
|
|
|
|
//提交
|
|
|
|
submit () {
|
|
|
|
|
|
|
|
let oldTreeData = this.nzTreeComponent.getCheckedNodeList()
|
|
|
|
|
|
|
|
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))
|
|
|
|
}else{
|
|
|
|
alltreedata = {}
|
|
|
|
alltreedata[this.data.buildFloorData.floorData.id] = keyArr
|
|
|
|
sessionStorage.setItem('tree型数据',JSON.stringify(alltreedata))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 basicAssetsId = []
|
|
|
|
if(checkList && checkList.length != 0){
|
|
|
|
checkList.forEach(item => {
|
|
|
|
basicAssetsId.push(item.TemplateId)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
key:this.data.buildFloorData.floorData.id,
|
|
|
|
buildingId:this.data.buildFloorData.buildingData.id,
|
|
|
|
children:checkList,
|
|
|
|
basicAssetsId:basicAssetsId
|
|
|
|
}
|
|
|
|
|
|
|
|
let data = JSON.parse(sessionStorage.getItem("消防设施"+sessionStorage.getItem('paperId')))
|
|
|
|
|
|
|
|
if(data && data.length != 0){
|
|
|
|
console.log(1)
|
|
|
|
let ind = null
|
|
|
|
data.forEach((item,index) => {
|
|
|
|
if(item.key == obj.key){
|
|
|
|
ind = index + 1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(ind){
|
|
|
|
if(checkList.length != 0){
|
|
|
|
data[ind - 1].children = checkList
|
|
|
|
}else{
|
|
|
|
data.splice(ind - 1,1)
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
data.push(obj)
|
|
|
|
}
|
|
|
|
sessionStorage.setItem("消防设施"+sessionStorage.getItem('paperId'),JSON.stringify(data))
|
|
|
|
|
|
|
|
}else{
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//上传按钮
|
|
|
|
@Component({
|
|
|
|
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) {}
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
renderData:any
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
let data = JSON.parse(sessionStorage.getItem("消防设施"+sessionStorage.getItem('paperId')))
|
|
|
|
data ? data.forEach(item => {
|
|
|
|
item.children.forEach(i => {
|
|
|
|
i.isLeaf = true
|
|
|
|
})
|
|
|
|
}) :null
|
|
|
|
this.renderData = data
|
|
|
|
this.getProfiles()
|
|
|
|
this.nodeInit()
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取登录账号的个人资料
|
|
|
|
Profiles:any
|
|
|
|
getProfiles(){
|
|
|
|
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
|
|
|
|
}
|
|
|
|
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.nodeTreeData = [...treeData]
|
|
|
|
}
|
|
|
|
|
|
|
|
nzEvent($event){
|
|
|
|
console.log($event)
|
|
|
|
}
|
|
|
|
//上传
|
|
|
|
submit () {
|
|
|
|
console.log(this.data.question)
|
|
|
|
let body:any = {
|
|
|
|
id: null,
|
|
|
|
paperId: sessionStorage.getItem('paperId'),
|
|
|
|
planComponentId: sessionStorage.getItem('planId'),
|
|
|
|
examPlanType: this.route.snapshot.queryParams.openType == 1 ? 0 : 1,
|
|
|
|
creatorId: this.Profiles.id,
|
|
|
|
modifiedTime: new Date(),
|
|
|
|
isPublic: true,
|
|
|
|
title: this.route.snapshot.queryParams.planName,
|
|
|
|
mainPoint: this.data.question.keynote,
|
|
|
|
score: null,
|
|
|
|
examFacilityAssetsData: sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) ? sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) : null,
|
|
|
|
examDisposalNodesData: sessionStorage.getItem('examNodeList') ? sessionStorage.getItem('examNodeList') : null
|
|
|
|
}
|
|
|
|
let params:any = {
|
|
|
|
paperId:sessionStorage.getItem('paperId'),
|
|
|
|
examPlanType:this.route.snapshot.queryParams.openType == 1 ? 0 : 1
|
|
|
|
}
|
|
|
|
this.http.post("/api/PaperPlans",body,{params:params}).subscribe(data => {
|
|
|
|
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('设置完成,页面将于一秒后关闭','确定',config);
|
|
|
|
setTimeout(() => {
|
|
|
|
window.close()
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存考的节点
|
|
|
|
@Component({
|
|
|
|
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;
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
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 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|