|
|
|
|
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 examinationQuestionsRead {
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
renderData:any
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
let data = JSON.parse(JSON.stringify(this.data.Facilities))
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
//处理数据 将消防要素模板与真实素材结合
|
|
|
|
|
processingData(allFireElements,realData){
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let treeData = [] //tree型 处理完成后的数据
|
|
|
|
|
allFireElements.forEach(element => {
|
|
|
|
|
element.key = element.id
|
|
|
|
|
element.name != '其他' ? element.children = [] : null
|
|
|
|
|
if(realData && realData.length != 0){
|
|
|
|
|
realData.forEach(item => {
|
|
|
|
|
if(element.id == item.FireElementId){
|
|
|
|
|
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) }
|
|
|
|
|
});
|
|
|
|
|
function recursionFilterEmpty(originalList, result) {
|
|
|
|
|
for(let i = 0, length = originalList.length; i < length; i++) {
|
|
|
|
|
const item = originalList[i];
|
|
|
|
|
if (item.PropertyInfos) {
|
|
|
|
|
// 最内层
|
|
|
|
|
result.push(item);
|
|
|
|
|
} else if (item.children && item.children.length) {
|
|
|
|
|
const newChildren = [];
|
|
|
|
|
// 递归调用,底层的真实数据会全部 push 进 newChildren 中
|
|
|
|
|
recursionFilterEmpty(item.children, newChildren);
|
|
|
|
|
if (newChildren.length) {
|
|
|
|
|
// 替换原始数据
|
|
|
|
|
item.children = newChildren;
|
|
|
|
|
// 子项有真实的数据,就保留这一项
|
|
|
|
|
result.push(item);
|
|
|
|
|
} // 如果没有这一项就会被删除
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function filterEmpty(listData) {
|
|
|
|
|
const result = [];
|
|
|
|
|
recursionFilterEmpty(listData, result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return filterEmpty(treeData)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nzEvent($event){
|
|
|
|
|
console.log($event)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上传按钮
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'dialog-upload-questions',
|
|
|
|
|
templateUrl: './uploadQuestions.html',
|
|
|
|
|
styleUrls: ['./collection-tools.component.scss',]
|
|
|
|
|
})
|
|
|
|
|
export class uploadQuestionsRead {
|
|
|
|
|
|
|
|
|
|
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>,
|
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data,private route:ActivatedRoute) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderData:any
|
|
|
|
|
labeledOfBasicIcon:any //当前页面各建筑各楼层已标注的基本信息集合
|
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
|
|
let params = {
|
|
|
|
|
examinationId : this.route.snapshot.queryParams.examId,
|
|
|
|
|
planComponentId : this.route.snapshot.queryParams.planComponentId
|
|
|
|
|
}
|
|
|
|
|
let SitePlanData
|
|
|
|
|
let BuildingPlanData
|
|
|
|
|
await new Promise((resolve,reject) => {
|
|
|
|
|
this.http.get('/api/ExamSitePlanData/ExamData',{params}).subscribe(data => {
|
|
|
|
|
SitePlanData = data
|
|
|
|
|
resolve(1)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
await new Promise((resolve,reject) => {
|
|
|
|
|
this.http.get('/api/ExamBuildingAreaData/ExamData',{params}).subscribe(data => {
|
|
|
|
|
BuildingPlanData = data
|
|
|
|
|
resolve(2)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.labeledOfBasicIcon = [...SitePlanData,...BuildingPlanData]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data = JSON.parse(JSON.stringify(this.data.Facilities))
|
|
|
|
|
console.log('一共有哪几层需要标注',data)
|
|
|
|
|
data ? data.forEach(item => {
|
|
|
|
|
let realData = item.children
|
|
|
|
|
let allFireElements = JSON.parse(JSON.stringify(this.data.allFireElements))
|
|
|
|
|
item.children = this.processingData(allFireElements,realData,item.key)
|
|
|
|
|
}) :null
|
|
|
|
|
|
|
|
|
|
this.renderData = data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理数据 将消防要素模板与真实素材结合
|
|
|
|
|
processingData(allFireElements,realData,key){
|
|
|
|
|
|
|
|
|
|
//key为当前处理数据的层id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allFireElements[allFireElements.length-1].children = []
|
|
|
|
|
|
|
|
|
|
//数组根据某个属性去重 (一类素材只保留一个)
|
|
|
|
|
const res = new Map();
|
|
|
|
|
realData = realData.filter((a) => !res.has(a.TemplateId) && res.set(a.TemplateId, 1))
|
|
|
|
|
console.log('当层需要标记的',realData)
|
|
|
|
|
this.labeledOfBasicIcon.forEach(item => {
|
|
|
|
|
if(item.sitePlanId == key || item.buildingAreaId == key ){
|
|
|
|
|
let data = JSON.parse(item.data)
|
|
|
|
|
console.log('当层已经标记的',data)
|
|
|
|
|
let arr = []
|
|
|
|
|
for (const key in data) {
|
|
|
|
|
arr.push(data[key])
|
|
|
|
|
}
|
|
|
|
|
realData.forEach(i => {
|
|
|
|
|
let isexist = arr.some((ele)=>{
|
|
|
|
|
return ele.TemplateId == i.TemplateId
|
|
|
|
|
})
|
|
|
|
|
isexist ? i.xxx = true : null
|
|
|
|
|
console.log(666,isexist)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
realData.forEach(item => {
|
|
|
|
|
item.isLeaf = true
|
|
|
|
|
let noMatch = allFireElements.find( every=> every.id === item.FireElementId)
|
|
|
|
|
if (!noMatch) {
|
|
|
|
|
allFireElements[allFireElements.length-1].children.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let treeData = [] //tree型 处理完成后的数据
|
|
|
|
|
allFireElements.forEach(element => {
|
|
|
|
|
element.key = element.id
|
|
|
|
|
element.name != '其他' ? element.children = [] : null
|
|
|
|
|
if(realData && realData.length != 0){
|
|
|
|
|
realData.forEach(item => {
|
|
|
|
|
if(element.id == item.FireElementId){
|
|
|
|
|
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) }
|
|
|
|
|
});
|
|
|
|
|
function recursionFilterEmpty(originalList, result) {
|
|
|
|
|
for(let i = 0, length = originalList.length; i < length; i++) {
|
|
|
|
|
const item = originalList[i];
|
|
|
|
|
if (item.PropertyInfos) {
|
|
|
|
|
// 最内层
|
|
|
|
|
result.push(item);
|
|
|
|
|
} else if (item.children && item.children.length) {
|
|
|
|
|
const newChildren = [];
|
|
|
|
|
// 递归调用,底层的真实数据会全部 push 进 newChildren 中
|
|
|
|
|
recursionFilterEmpty(item.children, newChildren);
|
|
|
|
|
if (newChildren.length) {
|
|
|
|
|
// 替换原始数据
|
|
|
|
|
item.children = newChildren;
|
|
|
|
|
// 子项有真实的数据,就保留这一项
|
|
|
|
|
result.push(item);
|
|
|
|
|
} // 如果没有这一项就会被删除
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function filterEmpty(listData) {
|
|
|
|
|
const result = [];
|
|
|
|
|
recursionFilterEmpty(listData, result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
return filterEmpty(treeData)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nzEvent($event){
|
|
|
|
|
console.log($event)
|
|
|
|
|
}
|
|
|
|
|
//上传
|
|
|
|
|
submit () {
|
|
|
|
|
// this.dialogRef.close();
|
|
|
|
|
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 uploadDisposalNodesRead {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|