@ -1,4 +1,4 @@
import { Component , OnInit , Inject , ViewChild , ElementRef , Renderer2 , ViewContainerRef } from '@angular/core' ;
import { Component , OnInit , Inject , ViewChild , ElementRef , Renderer2 , ViewContainerRef , ɵ Console } 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 { MatDialog , MatDialogRef , MAT_DIALOG_DATA } from '@angular/material/dialog' ;
import { MatSnackBar , MatSnackBarConfig } from '@angular/material/snack-bar' ;
import { MatSnackBar , MatSnackBarConfig } from '@angular/material/snack-bar' ;
@ -18,7 +18,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { examinationQuestionsExaminee , uploadDisposalNodesExaminee , uploadQuestionsExaminee } from './examinationQuestions'
import { examinationQuestionsExaminee , uploadDisposalNodesExaminee , uploadQuestionsExaminee } from './examinationQuestions'
@Component ( {
@Component ( {
selector : 'app-collection-tools' ,
selector : 'app-collection-tools' ,
templateUrl : './collection-tools.component.html' ,
templateUrl : './collection-tools.component.html' ,
@ -29,7 +28,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
@ViewChild ( 'canvas' , { static : true } ) canvas :WorkingAreaComponent ; //父组件中获得子组件的引用
@ViewChild ( 'canvas' , { static : true } ) canvas :WorkingAreaComponent ; //父组件中获得子组件的引用
constructor ( private http :HttpClient , public dialog : MatDialog , public snackBar : MatSnackBar , private element : ElementRef , public canvasData : CanvasShareDataService , private router :Router , private route :ActivatedRoute ) { }
constructor ( private http :HttpClient , public dialog : MatDialog , public snackBar : MatSnackBar , private element : ElementRef , public canvasData : CanvasShareDataService , private router :Router , private route :ActivatedRoute ) { }
@ViewChild ( 'nzTreeComponent' , { static : false } ) nzTreeComponent ! : NzTreeComponent ;
@ViewChild ( 'nzTreeComponent2 ' , { static : false } ) nzTreeComponent ! : NzTreeComponent ;
// tree配置
// tree配置
private _transformer = ( node , level : number ) = > { //要给渲染节点传那些属性参数
private _transformer = ( node , level : number ) = > { //要给渲染节点传那些属性参数
return {
return {
@ -151,191 +150,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
pattern :boolean = false //默认为基本信息编辑
pattern :boolean = false //默认为基本信息编辑
//基本信息编辑模式
baseInfo ( ) {
if ( ! this . pattern ) {
this . basicInfo = true
this . canvas . setNameVisible ( this . basicInfo , 1 )
this . pattern = true
this . canvasData . gameMode = GameMode . BasicInformation
this . canvasData . selectPanelPoint = new DisposalNodeData ( ) ;
this . mateDeleteCustomize ( )
this . getAllLibrary ( )
this . checkedBuildingIndex = - 1
this . getSitePlan ( ) //总平面图一层
}
}
//想定作业编辑模式
wantWork ( ) {
if ( this . pattern ) {
//让基本信息图标显示
this . basicInfo = false
this . canvas . setNameVisible ( this . basicInfo , 0 )
this . pattern = false
this . canvasData . gameMode = GameMode . Assignment
this . getAllLibrary ( 'plan' )
this . getDisposalNode ( )
}
}
//ngzorro tree 拖拽
nzEvent ( event : NzFormatEmitEvent ) : void {
if ( this . isDrag ) {
let parentId
if ( this . pos == 0 ) {
parentId = event . node . key
} else {
if ( event . node . level == 0 ) {
parentId = null
} else {
parentId = event . node . origin . parentId
}
}
let orders = { }
let originalData = JSON . parse ( JSON . stringify ( this . canvasData . allDisposalNode || [ ] ) ) //tree原始数据
let targetNodeData = [ ] //拖动移入节点的数据,用于遍历求出放在该数组的第几位
//找到需要重新排序的数组
if ( this . pos == 0 ) {
originalData . forEach ( item = > {
if ( item . parentId == event . node . key ) {
targetNodeData . push ( item )
}
} )
} else {
if ( event . node . origin . parentId ) { //如果拖动目标为非一级节点
originalData . forEach ( item = > {
if ( item . parentId == event . node . origin . parentId ) {
targetNodeData . push ( item )
}
} )
} else { //如果拖动目标为一级节点
originalData . forEach ( item = > {
if ( ! item . parentId ) {
targetNodeData . push ( item )
}
} )
}
}
let idArr = [ ]
targetNodeData . forEach ( i = > {
idArr . push ( i . id )
} )
console . log ( 6666666666666 , event ) ;
if ( this . pos == 0 && event . node . origin . children . length == 1 ) {
console . log ( "移入,没有兄弟" )
let key = event . dragNode . key
orders [ key ] = 0
parentId = event . node . key
} else {
console . log ( "移入,多个兄弟" )
let array = [ ]
targetNodeData . forEach ( item = > {
if ( item . id != event . dragNode . key ) { //将拖动项先移除掉
array . push ( item )
}
} )
if ( event . dragNode . isEnd [ event . dragNode . isEnd . length - 1 ] ) { //如果移入到最后一个
console . log ( "最后" )
array . push ( event . dragNode . origin )
} else if ( event . dragNode . isStart [ event . dragNode . isStart . length - 1 ] ) { //如果移入到第一个
console . log ( "第一" )
array . unshift ( event . dragNode . origin )
} else { //如果移入中间位置
console . log ( "中间" )
array . splice ( event . node . origin . order , 0 , event . dragNode . origin )
}
array . forEach ( ( item , key ) = > {
orders [ item . id ] = key
} )
}
let obj = {
id : event.dragNode.origin.id ,
parentId : parentId ,
orders : orders
}
this . http . put ( "/api/DisposalNodes/Sort" , obj ) . subscribe ( data = > {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '排序成功' , '确定' , config )
this . refurbishTreeData ( )
} )
}
}
isDrag //是否可以拖动
pos //放置位置
beforeDrop = ( arg : NzFormatBeforeDropEvent ) = > {
if ( arg . dragNode . origin . isDataNode && arg . node . level === 0 ) { //如果为数据节点则不允许拖到一级节点
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '数据节点不允许拖拽到一级节点' , '确定' , config )
this . isDrag = false
return of ( false ) ;
} else if ( ! arg . dragNode . origin . isDataNode && arg . node . level === 2 ) {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '处置节点不允许拖拽到三级节点' , '确定' , config )
this . isDrag = false
return of ( false ) ;
} else {
this . isDrag = true
this . pos = arg . pos
return of ( true )
}
}
//ngzorro tree 拖拽
//天气栏目
weatherBtn = true
weatherBtnShow ( ) {
this . weatherBtn = ! this . weatherBtn
}
weatherBtnHidden ( ) {
this . weatherBtn = ! this . weatherBtn
}
//底部切换按钮div
detailsAndattentBtn = true
//节点详情
details ( ) {
this . detailsAndattentBtn = true
}
//注意事项
attent ( ) {
this . detailsAndattentBtn = false
}
//消防要素div边框高度调节
firecategoriesDivMouseDown ( e ) {
document . onmousemove = ( ev ) = > {
let bodyHeight = document . body . clientHeight //网页宽度
let maxHeight = this . element . nativeElement . querySelector ( '#rightDiv' ) . clientHeight - 35 //最大宽度
if ( bodyHeight - ev . clientY >= maxHeight ) {
this . element . nativeElement . querySelector ( '#firecategories' ) . style . height = maxHeight + 'px'
this . element . nativeElement . querySelector ( '#property' ) . style . height = 35 + 'px'
} else {
this . element . nativeElement . querySelector ( '#firecategories' ) . style . height = ( bodyHeight - ev . clientY ) + 'px' ;
this . element . nativeElement . querySelector ( '#property' ) . style . height = ( this . element . nativeElement . querySelector ( '#rightDiv' ) . clientHeight - this . element . nativeElement . querySelector ( '#firecategories' ) . clientHeight ) + 'px'
}
}
document . onmouseup = ( ) = > {
document . onmousemove = null ;
document . onmouseup = null ;
}
}
//左侧div边框宽度调节
//左侧div边框宽度调节
leftDivMouseDown ( e ) {
leftDivMouseDown ( e ) {
@ -354,22 +169,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
}
}
//底部div高度调节
bottomDivMouseDown ( e ) {
document . onmousemove = ( ev ) = > {
let bodyHeight = document . body . clientHeight //网页高度
let maxHeight = this . element . nativeElement . querySelector ( '#rightDiv' ) . clientHeight //最大高度
if ( bodyHeight - ev . clientY >= maxHeight ) {
this . element . nativeElement . querySelector ( '#bottomDiv' ) . style . height = maxHeight + 'px'
} else {
this . element . nativeElement . querySelector ( '#bottomDiv' ) . style . height = ( bodyHeight - ev . clientY ) + 'px' ;
}
}
document . onmouseup = ( ) = > {
document . onmousemove = null ;
document . onmouseup = null ;
}
}
//右侧div边框宽度调节
//右侧div边框宽度调节
rightDivMouseDown ( e ) {
rightDivMouseDown ( e ) {
@ -625,15 +424,15 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
ngOnInit ( ) : void {
ngOnInit ( ) : void {
this . getAllLibrary ( 'plan' ) //获取素材库
this . getAllLibrary ( 'plan' ) //获取素材库
this . getAllBuildings ( ) //获取所有建筑
this . getAllBuildings ( ) //获取所有建筑
this . getAllFirePlan ( ) //获取当前单位灾情
this . getAllFirePlan ( ) //获取当前单位灾情
this . getPaperPlanData ( ) //获得当前考题题目
let that = this
let that = this
window . setTimeout ( ( ) = > {
window . setTimeout ( ( ) = > {
document . getElementById ( "functionalDomainContent" ) . oncontextmenu = function ( event ) {
document . getElementById ( "functionalDomainContent" ) . oncontextmenu = function ( event ) {
// that.canvas.cancelPaint()
that . selectImageIndex = - 1
that . selectImageIndex = - 1
event . preventDefault ( ) ;
event . preventDefault ( ) ;
} ;
} ;
@ -646,15 +445,76 @@ export class CollectionToolsExamineeComponent implements OnInit {
} )
} )
}
}
paperId :any = this . route . snapshot . queryParams . paperId
planData :any //当前考题题目
Facilities :any //当前预案考题所有楼层要考的基本信息素材
//获得单位预案设定
getPaperPlanData ( ) {
let params = {
paperId : this.paperId
}
this . http . get ( ` /api/PaperPlans ` , { params :params } ) . subscribe ( ( data :any ) = > {
console . log ( 456 , data )
data . forEach ( item = > {
item . id == this . route . snapshot . queryParams . paperplanId ?
this . planData = item : null
} )
let questions = JSON . parse ( this . planData . examDisposalNodesData )
this . handleHybridTree ( questions , '题目' )
this . Facilities = JSON . parse ( this . planData . examFacilityAssetsData )
} )
}
//获得所有素材库
basicAssetLibraries :any = [ ] //基本信息素材库
getAllAssetLibraries ( Facilitiesitem ) {
this . canvasData . hiddenBasicInfoFacilities = Facilitiesitem . children
console . log ( 1314 , this . canvasData . hiddenBasicInfoFacilities )
this . basicAssetLibraries = [ ]
this . http . get ( '/api/AssetLibraries' ) . subscribe ( async ( data :any ) = > {
console . log ( '素材库' , data )
for ( let index = 0 ; index < data . length ; index ++ ) {
const element = data [ index ] ;
let params = {
libraryId :element.id ,
assetIds : Facilitiesitem.basicAssetsId
}
await new Promise ( ( resolve , reject ) = > {
this . http . get ( '/api/Assets' , { params :params } )
. subscribe ( ( data :any ) = > {
console . log ( index , data )
if ( data && data . length != 0 ) {
data . forEach ( item = > {
item . tag = 1
} )
element . images = data
this . basicAssetLibraries . push (
element
)
}
resolve ( )
} )
} )
}
// console.log(55555,this.basicAssetLibraries)
this . allLibrary = [ . . . this . originalallLibrary , . . . this . basicAssetLibraries ]
} )
}
ngAfterViewInit ( ) : void {
ngAfterViewInit ( ) : void {
this . getSitePlan ( ) //获取总平面图/楼层
this . getSitePlan ( ) //获取总平面图/楼层
// 监听canvas组件选中素材事件
// 监听canvas组件选中素材事件
this . canvas . on ( "select" , obj = > {
this . canvas . on ( "select" , obj = > {
//选中素材属性注入函数
//选中素材属性注入函数
this . setAssetsProperty ( obj . assetData )
this . setAssetsProperty ( obj . assetData )
} )
} )
// 监听canvas组件取消选中素材事件
// 监听canvas组件取消选中素材事件
this . canvas . on ( "deselect" , obj = > {
this . canvas . on ( "deselect" , obj = > {
@ -662,27 +522,19 @@ export class CollectionToolsExamineeComponent implements OnInit {
} )
} )
// 监听canvas组件新增素材事件
// 监听canvas组件新增素材事件
this . canvas . on ( "createIcon" , obj = > {
this . canvas . on ( "createIcon" , obj = > {
this . renovateTreeData ( false )
console . log ( obj . assetData )
// this.renovateTreeData(false)
} )
} )
// 监听canvas组件删除素材事件
// 监听canvas组件删除素材事件
this . canvas . on ( "deleteIcon" , obj = > {
this . canvas . on ( "deleteIcon" , obj = > {
this . renovateTreeData ( false )
// this.renovateTreeData(false)
} )
} )
}
}
copyAssetData :any //存储用于复制的素材
copyAssetData :any //存储用于复制的素材
//复制素材
copyAsset ( ) {
this . canvas . copy ( )
}
//粘贴素材
pasteAsset ( ) {
let companyId = sessionStorage . getItem ( "companyId" )
let buildingId = this . beforeOneCheckedBuilding . id
let floorId = this . selectingSitePlan . id
this . canvas . paste ( companyId , buildingId , floorId )
}
basicInfo :boolean = true //基本信息名称显隐
basicInfo :boolean = true //基本信息名称显隐
wantToWork :boolean = true //想定作业名称显隐
wantToWork :boolean = true //想定作业名称显隐
@ -721,7 +573,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
saveNum :any = [ ]
saveNum :any = [ ]
saveSite ( ) {
saveSite ( ) {
if ( this . selectingSitePlan && this . selectingSitePlan . id ) {
if ( this . selectingSitePlan && this . selectingSitePlan . id ) {
this . saveNum = [ ]
let SitePlanData = JSON . parse ( JSON . stringify ( this . canvasData . originaleveryStoreyData ) ) ;
let SitePlanData = JSON . parse ( JSON . stringify ( this . canvasData . originaleveryStoreyData ) ) ;
SitePlanData . data = JSON . stringify ( SitePlanData . data )
SitePlanData . data = JSON . stringify ( SitePlanData . data )
let CompanyData = JSON . parse ( JSON . stringify ( this . canvasData . originalcompanyBuildingData ) ) ;
let CompanyData = JSON . parse ( JSON . stringify ( this . canvasData . originalcompanyBuildingData ) ) ;
@ -731,21 +582,114 @@ export class CollectionToolsExamineeComponent implements OnInit {
let adjoinArr = [ ] //毗邻数组
let adjoinArr = [ ] //毗邻数组
if ( this . pattern ) { //如果是基本信息编辑模式
if ( this . pattern ) { //如果是基本信息编辑模式
//如果是单位 总平面图
if ( this . checkedBuildingIndex == - 1 ) {
//保存平面图数据
this . http . post ( "/api/SitePlanData" , SitePlanData , {
params : {
companyId :this.params.companyId
}
} ) . subscribe ( data = > {
if ( this . saveNum . length == 5 ) {
this . canvasData . isChange = false
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '保存成功' , '确定' , config ) ;
}
} , err = > {
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . canvasData . isChange = true
this . snackBar . open ( '平面图数据保存失败' , '确定' , config ) ;
} )
//保存建筑数据
this . http . post ( "/api/CompanyData" , CompanyData , {
params : {
companyId :this.params.companyId
}
} ) . subscribe ( data = > {
if ( this . saveNum . length == 5 ) {
this . canvasData . isChange = false
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '保存成功' , '确定' , config ) ;
}
} , err = > {
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . canvasData . isChange = true
this . snackBar . open ( '单位数据保存失败' , '确定' , config ) ;
} )
} else { //如果是建筑
//建筑平面图数据
this . http . post ( "/api/BuildingAreaData" , SitePlanData , {
params : {
companyId :this.params.companyId
}
} ) . subscribe ( data = > {
if ( this . saveNum . length == 5 ) {
this . canvasData . isChange = false
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '保存成功' , '确定' , config ) ;
}
} , err = > {
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . canvasData . isChange = true
this . snackBar . open ( '平面图数据保存失败' , '确定' , config ) ;
} )
//建筑数据
this . http . post ( "/api/BuildingData" , CompanyData , {
params : {
companyId :this.params.companyId
}
} ) . subscribe ( data = > {
if ( this . saveNum . length == 5 ) {
this . canvasData . isChange = false
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '保存成功' , '确定' , config ) ;
}
} , err = > {
let config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . canvasData . isChange = true
this . snackBar . open ( '单位数据保存失败' , '确定' , config ) ;
} )
}
return true
return true
} else { //如果是想定作业编辑模式
} else { //如果是想定作业编辑模式
const dialogRef = this . dialog . open ( saveOneDialogExaminee , {
console . log ( SitePlanData )
data : {
// const dialogRef = this.dialog.open(saveOneDialogExaminee, {
allDisposalNode : this.canvasData.allDisposalNode ,
// data: {
selectedBuildingData :this.beforeOneCheckedBuilding ,
// allDisposalNode: this.canvasData.allDisposalNode,
selectedSiteData :this.selectingSitePlan ,
// selectedBuildingData:this.beforeOneCheckedBuilding,
siteOrbuilding :this.checkedBuildingIndex ,
// selectedSiteData:this.selectingSitePlan,
disasterId : this.allFirePlan [ 0 ] . id || ''
// siteOrbuilding:this.checkedBuildingIndex,
}
// disasterId: this.allFirePlan[0].id || ''
} ) ;
// }
// });
dialogRef . afterClosed ( ) . subscribe ( result = > {
// dialogRef.afterClosed().subscribe(result => {
console . log ( 'The dialog was closed' ) ;
// console.log('The dialog was closed');
} ) ;
// });
}
}
} else { //if
} else { //if
@ -771,79 +715,17 @@ export class CollectionToolsExamineeComponent implements OnInit {
//选择建筑
//选择建筑
checkedBuilding ( item , index ) {
checkedBuilding ( item , index ) {
if ( this . checkedBuildingIndex != index ) {
if ( this . checkedBuildingIndex != index ) {
this . beforeOneCheckedBuilding = item
if ( this . canvasData . isChange ) { //true 数据被改动
this . checkedBuildingIndex = index
let isTrue = confirm ( '是否保存当前编辑数据' )
if ( index == - 1 ) { //总平面图数据
if ( isTrue ) { //先保存数据 在切换
this . getSitePlan ( )
let isSuccess = this . saveSite ( ) //true的时候 先保存数据
} else { //建筑楼层/区域数据
if ( isSuccess != false ) {
this . getBuildingSitePlan ( item )
this . beforeOneCheckedBuilding = item
}
this . checkedBuildingIndex = index
if ( index == - 1 ) { //总平面图数据
this . getSitePlan ( )
} else { //建筑楼层/区域数据
this . getBuildingSitePlan ( item )
}
}
} else {
this . beforeOneCheckedBuilding = item
this . checkedBuildingIndex = index
if ( index == - 1 ) { //总平面图数据
this . getSitePlan ( )
} else { //建筑楼层/区域数据
this . getBuildingSitePlan ( item )
}
}
} else { //flase 数据未被改动
this . beforeOneCheckedBuilding = item
this . checkedBuildingIndex = index
if ( index == - 1 ) { //总平面图数据
this . getSitePlan ( )
} else { //建筑楼层/区域数据
this . getBuildingSitePlan ( item )
}
} //if
} //if
} //if
}
}
//删除建筑
deleteBuilding ( e , item ) {
e . stopPropagation ( ) ;
if ( confirm ( "是否删除该建筑" ) == true ) {
let isHave = this . canvasData . allDisposalNode . find ( items = > { return items . buildingId === item . id } )
if ( isHave == undefined ) {
this . http . delete ( ` /api/Buildings/ ${ item . id } ` ) . subscribe ( data = > {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '删除成功' , '确定' , config ) ;
this . http . get ( "/api/Buildings" , {
params : {
companyId :this.params.companyId
}
} ) . subscribe ( data = > {
this . allBuildings = data
this . beforeOneCheckedBuilding = { name : "总平面图" }
this . checkedBuildingIndex = - 1
this . getSitePlan ( )
} )
} , err = > {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '删除失败' , '确定' , config ) ;
this . getAllBuildings ( )
} )
} else { //建筑 含有数据节点时
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '含有数据节点的建筑不允许删除' , '确定' , config ) ;
}
}
}
storeyData //将建筑素材和当前楼层素材合二为一
storeyData //将建筑素材和当前楼层素材合二为一
@ -852,9 +734,8 @@ export class CollectionToolsExamineeComponent implements OnInit {
//storeyData为当前楼层拥有的消防设施
//storeyData为当前楼层拥有的消防设施
this . storeyData = storeyData
this . storeyData = storeyData
let data = JSON . parse ( JSON . stringify ( this . allFireElements ) ) //所有消防要素模板
let data = JSON . parse ( JSON . stringify ( this . allFireElements ) ) //所有消防要素模板
console . log ( data )
let treeData = [ ] //tree型 处理完成后的数据
let treeData = [ ] //tree型 处理完成后的数据
data . forEach ( element = > {
this . allFireElements . forEach ( element = > {
element . key = element . id
element . key = element . id
element . isTemplate = true //添加模板标识
element . isTemplate = true //添加模板标识
element . isLook = true //添加是否可见标识
element . isLook = true //添加是否可见标识
@ -881,9 +762,9 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
}
}
}
}
data . forEach ( item = > { if ( item . parentId == element . id ) { element . children . push ( item ) } } ) ;
this . allFireElements . forEach ( item = > { if ( item . parentId == element . id ) { element . children . push ( item ) } } ) ;
} ) ;
} ) ;
data . forEach ( element = > {
this . allFireElements . forEach ( element = > {
if ( ! element . parentId ) { treeData . push ( element ) }
if ( ! element . parentId ) { treeData . push ( element ) }
} ) ;
} ) ;
@ -913,8 +794,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
return result ;
return result ;
}
}
// console.log(filterEmpty(treeData))
this . dataSource . data = filterEmpty ( treeData )
this . dataSource . data = filterEmpty ( treeData )
this . treeControl . expandAll ( )
this . treeControl . expandAll ( )
@ -953,7 +832,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击树节点的显示隐藏icon
//点击树节点的显示隐藏icon
clickLookItem ( node ) {
clickLookItem ( node ) {
//修改真实素材islook属性
//修改真实素材islook属性
for ( let key in this . storeyData . data ) {
for ( let key in this . storeyData . data ) {
if ( key == node . id ) {
if ( key == node . id ) {
@ -976,8 +855,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
} )
} )
}
}
//子节点跟随父节点的islook变化
//子节点跟随父节点的islook变化
if ( node . children && node . children . length != 0 ) {
if ( node . children && node . children . length != 0 ) {
node . children . forEach ( item = > {
node . children . forEach ( item = > {
@ -1024,10 +901,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
} else {
} else {
iconVisibleArr . push ( node . id )
iconVisibleArr . push ( node . id )
}
}
console . log ( 1 , iconVisibleArr )
console . log ( 2 , node . isLook )
this . canvas . setIconVisible ( iconVisibleArr , ! node . isLook )
this . canvas . setIconVisible ( iconVisibleArr , ! node . isLook )
}
}
//打开消防设施考题设定
//打开消防设施考题设定
@ -1070,13 +944,11 @@ export class CollectionToolsExamineeComponent implements OnInit {
let beforeOneId = this . selectingSitePlan . id || '' //当前 选中 平面图 楼层/区域 id
let beforeOneId = this . selectingSitePlan . id || '' //当前 选中 平面图 楼层/区域 id
let companyBuildingData = JSON . parse ( JSON . stringify ( this . canvasData . originalcompanyBuildingData || { } ) ) // 当前 单位/建筑 数据
let companyBuildingData = JSON . parse ( JSON . stringify ( this . canvasData . originalcompanyBuildingData || { } ) ) // 当前 单位/建筑 数据
let storeyData = JSON . parse ( JSON . stringify ( this . canvasData . originaleveryStoreyData || { } ) ) //当前 楼层 数据
let storeyData = JSON . parse ( JSON . stringify ( this . canvasData . originaleveryStoreyData || { } ) ) //当前 楼层 数据
this . Facilities . forEach ( item = > {
// for(let key in companyBuildingData.data){
item . key == this . selectingSitePlan . id ?
// if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下
this . getAllAssetLibraries ( item ) :
// storeyData.data[key] = companyBuildingData.data[key]
null
// }
} )
// }
console . log ( 566 , storeyData . data )
for ( let key in storeyData . data ) { //筛选数据
for ( let key in storeyData . data ) { //筛选数据
storeyData . data [ key ] . key = storeyData . data [ key ] . Id
storeyData . data [ key ] . key = storeyData . data [ key ] . Id
let noMatch = this . allFireElements . find ( every = > every . id === storeyData . data [ key ] . FireElementId )
let noMatch = this . allFireElements . find ( every = > every . id === storeyData . data [ key ] . FireElementId )
@ -1138,7 +1010,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
this . selectingSitePlan = this . sitePlanData [ 0 ] || { }
this . selectingSitePlan = this . sitePlanData [ 0 ] || { }
this . canvasData . selectStorey = this . sitePlanData [ 0 ] || { } //服务中 存一份数据
this . canvasData . selectStorey = this . sitePlanData [ 0 ] || { } //服务中 存一份数据
this . selectSitePlanIndex = 0
this . selectSitePlanIndex = 0
Promise . all ( [ fireData , planData ] ) . then ( ( res ) = > {
Promise . all ( [ fireData , planData ] ) . then ( ( res ) = > {
this . getSitePlanStorey ( this . selectingSitePlan ) //获取 平面图 楼层数据
this . getSitePlanStorey ( this . selectingSitePlan ) //获取 平面图 楼层数据
} )
} )
@ -1207,10 +1079,44 @@ export class CollectionToolsExamineeComponent implements OnInit {
this . canvasData . originaleveryStoreyData . data ? this . canvasData . originaleveryStoreyData . data = JSON . parse ( this . canvasData . originaleveryStoreyData . data ) : this . canvasData . originaleveryStoreyData . data = { }
this . canvasData . originaleveryStoreyData . data ? this . canvasData . originaleveryStoreyData . data = JSON . parse ( this . canvasData . originaleveryStoreyData . data ) : this . canvasData . originaleveryStoreyData . data = { }
this . canvasData . originaleveryStoreyData . version ? null : this . canvasData . originaleveryStoreyData . version = "2.0"
this . canvasData . originaleveryStoreyData . version ? null : this . canvasData . originaleveryStoreyData . version = "2.0"
this . canvasData . originaleveryStoreyData . sitePlanId ? null : this . canvasData . originaleveryStoreyData . sitePlanId = e . id || null
this . canvasData . originaleveryStoreyData . sitePlanId ? null : this . canvasData . originaleveryStoreyData . sitePlanId = e . id || null
this . renovateTreeData ( )
let examParams = {
sitePlanId : e.id ,
examinationId : this.route.snapshot.queryParams.examId ,
planComponentId : this.route.snapshot.queryParams.planComponentId
}
this . http . get ( '/api/ExamSitePlanData' , { params :examParams } ) . subscribe ( ( data :any ) = > {
this . canvasData . examOriginaleveryStoreyData = data || { } // 楼层原数据
this . canvasData . examOriginaleveryStoreyData . data ? this . canvasData . examOriginaleveryStoreyData . data = JSON . parse ( this . canvasData . examOriginaleveryStoreyData . data ) : this . canvasData . examOriginaleveryStoreyData . data = { }
this . canvasData . examOriginaleveryStoreyData . version ? null : this . canvasData . examOriginaleveryStoreyData . version = "2.0"
this . canvasData . examOriginaleveryStoreyData . buildingAreaId ? null : this . canvasData . examOriginaleveryStoreyData . buildingAreaId = e . id || null
this . renovateTreeData ( )
} )
} )
}
//获取 建筑 楼层数据
getBuildingStorey ( e ) {
let params = { buildingAreaId : e.id }
this . http . get ( ` /api/BuildingAreaData ` , { params } ) . subscribe ( ( data :any ) = > {
this . canvasData . originaleveryStoreyData = data || { } // 楼层原数据
this . canvasData . originaleveryStoreyData . data ? this . canvasData . originaleveryStoreyData . data = JSON . parse ( this . canvasData . originaleveryStoreyData . data ) : this . canvasData . originaleveryStoreyData . data = { }
this . canvasData . originaleveryStoreyData . version ? null : this . canvasData . originaleveryStoreyData . version = "2.0"
this . canvasData . originaleveryStoreyData . buildingAreaId ? null : this . canvasData . originaleveryStoreyData . buildingAreaId = e . id || null
let examParams = {
buildingAreaId : e.id ,
examinationId : this.route.snapshot.queryParams.examId ,
planComponentId : this.route.snapshot.queryParams.planComponentId
}
this . http . get ( '/api/ExamBuildingAreaData' , { params :examParams } ) . subscribe ( ( data :any ) = > {
this . canvasData . examOriginaleveryStoreyData = data || { } // 楼层原数据
this . canvasData . examOriginaleveryStoreyData . data ? this . canvasData . examOriginaleveryStoreyData . data = JSON . parse ( this . canvasData . examOriginaleveryStoreyData . data ) : this . canvasData . examOriginaleveryStoreyData . data = { }
this . canvasData . examOriginaleveryStoreyData . version ? null : this . canvasData . examOriginaleveryStoreyData . version = "2.0"
this . canvasData . examOriginaleveryStoreyData . buildingAreaId ? null : this . canvasData . examOriginaleveryStoreyData . buildingAreaId = e . id || null
this . renovateTreeData ( )
} )
} )
} )
}
}
//获取 建筑 数据
//获取 建筑 数据
getBuildingData ( e ) {
getBuildingData ( e ) {
return new Promise ( ( resolve , reject ) = > {
return new Promise ( ( resolve , reject ) = > {
@ -1224,62 +1130,21 @@ export class CollectionToolsExamineeComponent implements OnInit {
} )
} )
}
}
//获取 建筑 楼层数据
getBuildingStorey ( e ) {
let params = { buildingAreaId : e.id }
this . http . get ( ` /api/BuildingAreaData ` , { params } ) . subscribe ( ( data :any ) = > {
this . canvasData . originaleveryStoreyData = data || { } // 楼层原数据
this . canvasData . originaleveryStoreyData . data ? this . canvasData . originaleveryStoreyData . data = JSON . parse ( this . canvasData . originaleveryStoreyData . data ) : this . canvasData . originaleveryStoreyData . data = { }
this . canvasData . originaleveryStoreyData . version ? null : this . canvasData . originaleveryStoreyData . version = "2.0"
this . canvasData . originaleveryStoreyData . buildingAreaId ? null : this . canvasData . originaleveryStoreyData . buildingAreaId = e . id || null
this . renovateTreeData ( )
} )
}
//点击选中 平面图 楼层/区域 时
//点击选中 平面图 楼层/区域 时
selectSitePlan ( item , index ) {
selectSitePlan ( item , index ) {
if ( this . selectSitePlanIndex != index ) {
if ( this . selectSitePlanIndex != index ) {
this . canvasData . selectPanelPoint = new DisposalNodeData ( ) ;
this . canvasData . selectPanelPoint = new DisposalNodeData ( ) ;
if ( this . canvasData . isChange ) { //true 数据被改动
this . selectingSitePlan = item
let isTrue = confirm ( '是否保存当前编辑数据' )
this . selectSitePlanIndex = index
if ( isTrue ) { //先保存数据 在切换
this . canvasData . selectStorey = item //服务中 存一份数据
let isSuccess = this . saveSite ( ) //true的时候 先保存数据
if ( this . checkedBuildingIndex == - 1 ) { //总平面图时
if ( isSuccess != false ) {
this . getSitePlanStorey ( item ) //获取 平面图 楼层数据
this . selectingSitePlan = item
} else { //楼层/区域时
this . selectSitePlanIndex = index
this . getBuildingStorey ( item ) //获取 建筑 楼层数据
this . canvasData . selectStorey = item //服务中 存一份数据
}
if ( this . checkedBuildingIndex == - 1 ) { //总平面图时
this . getSitePlanStorey ( item ) //获取 平面图 楼层数据
} else { //楼层/区域时
this . getBuildingStorey ( item ) //获取 建筑 楼层数据
}
}
} else { //不保存数据 直接切换
this . selectingSitePlan = item
this . selectSitePlanIndex = index
this . canvasData . selectStorey = item //服务中 存一份数据
if ( this . checkedBuildingIndex == - 1 ) { //总平面图时
this . getSitePlanStorey ( item ) //获取 平面图 楼层数据
this . getSitePlanCompanyData ( )
} else { //楼层/区域时
this . getBuildingStorey ( item ) //获取 建筑 楼层数据
let params = { buildingId : this.beforeOneCheckedBuilding.id }
this . getBuildingData ( params )
}
}
} else { //false 数据没被改动
this . selectingSitePlan = item
this . selectSitePlanIndex = index
this . canvasData . selectStorey = item //服务中 存一份数据
if ( this . checkedBuildingIndex == - 1 ) { //总平面图时
this . getSitePlanStorey ( item ) //获取 平面图 楼层数据
} else { //楼层/区域时
this . getBuildingStorey ( item ) //获取 建筑 楼层数据
}
} //if
}
}
}
}
@ -1542,6 +1407,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
allLibrary :any = [ ] ; //所有素材库 + 素材
allLibrary :any = [ ] ; //所有素材库 + 素材
originalallLibrary = [ ] ; //原始所有素材库 + 素材 备份
selectLibrary :any ; //选中的素材库
selectLibrary :any ; //选中的素材库
selectImage :any ; //选中的素材库图片
selectImage :any ; //选中的素材库图片
selectImageIndex :number ; //选中的素材库图片index
selectImageIndex :number ; //选中的素材库图片index
@ -1552,8 +1418,10 @@ export class CollectionToolsExamineeComponent implements OnInit {
data . forEach ( element = > {
data . forEach ( element = > {
element . images = [ ]
element . images = [ ]
} ) ;
} ) ;
this . originalallLibrary = data
this . allLibrary = data
this . allLibrary = data
this . selectImageIndex = - 1
this . selectImageIndex = - 1
console . log ( 654 , this . allLibrary )
// this.canvas.cancelPaint()
// this.canvas.cancelPaint()
} )
} )
}
}
@ -1569,6 +1437,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击选中素材库图片时
//点击选中素材库图片时
selectImg ( item , items , index ) {
selectImg ( item , items , index ) {
console . log ( 66666666 , items )
this . selectLibrary = item . name
this . selectLibrary = item . name
this . selectImage = items
this . selectImage = items
this . selectImageIndex = index
this . selectImageIndex = index
@ -1579,7 +1448,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//处置预案
//处置预案
examType = this . route . snapshot . queryParams . openType // 预案类型 1=已存在/2=自定义
examType = Number ( this . route . snapshot . queryParams . openType ) // 预案类型 1=已存在/2=自定义
allFirePlan :any = [ ] ; //所有灾情
allFirePlan :any = [ ] ; //所有灾情
selectDisposalNode :string = '' ; //当前点击tree节点 css选中样式
selectDisposalNode :string = '' ; //当前点击tree节点 css选中样式
@ -1587,7 +1456,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
getAllFirePlan ( ) {
getAllFirePlan ( ) {
let api
let api
this . examType == 1 ? api = '/api/Disasters' : api = '/api/ExamDisasters'
this . examType == 1 ? api = '/api/Disasters' : api = '/api/ExamDisasters'
let params = { componentId : sessionStorage.getItem ( 'planId' ) }
let params = { componentId : this.route.snapshot.queryParams.planComponentId }
this . http . get ( api , { params :params } ) . subscribe ( ( data :any ) = > {
this . http . get ( api , { params :params } ) . subscribe ( ( data :any ) = > {
if ( ! data . length ) { //该 单位没有灾情时
if ( ! data . length ) { //该 单位没有灾情时
let msg = {
let msg = {
@ -1609,25 +1478,27 @@ export class CollectionToolsExamineeComponent implements OnInit {
//获取所有处置节点
//获取所有处置节点
getDisposalNode ( ) {
getDisposalNode ( ) {
let api
let api
this . examType == 1 ? api = '/api/DisposalNodes' : api = '/api/ExamDisposalNodes'
console . log ( 4444 , this . examType )
api = '/api/ExamDisposalNodes'
this . selectDisposalNode = ''
this . selectDisposalNode = ''
let params
let params
this . examType == 1 ? params = { disasterId : this.allFirePlan [ 0 ] . id || '' } : params = { examDisasterId : this.allFirePlan [ 0 ] . id || '' }
params = { examDisasterId : this.allFirePlan [ 0 ] . id || '' , disposalNodeType :1 , examinationId :this.route.snapshot.queryParams.examId }
this . http . get ( api , { params :params } ) . subscribe ( data = > { //处置节点
this . http . get ( api , { params :params } ) . subscribe ( data = > { //处置节点
this . canvasData . allDisposalNode = data
this . canvasData . allDisposalNode = data
this . handleHybridTree ( )
this . handleHybridTree ( this . canvasData . allDisposalNode , '答案' )
} )
} )
}
}
treeData :any = [ ] ; //渲染tree处理完成数据
treeData :any = [ ] ; //渲染tree处理完成数据
questionstreeData :any = [ ] ; //渲染tree处理完成数据(题目)
defaultExpandedKeys :any = [ ] ; //首次渲染 tree展开状态
defaultExpandedKeys :any = [ ] ; //首次渲染 tree展开状态
//处理 节点 Tree数据
//处理 节点 Tree数据
handleHybridTree ( ) {
handleHybridTree ( disposalNodedata , type ) {
this . defaultExpandedKeys = [ ]
// this.defaultExpandedKeys = []
let treeData = [ ]
let treeData = [ ]
let data = JSON . parse ( JSON . stringify ( this . canvasData . allDisposalNode || [ ] ) )
let data = JSON . parse ( JSON . stringify ( disposalNodedata || [ ] ) )
data . forEach ( element = > {
data . forEach ( element = > {
this . defaultExpandedKeys . push ( element . id )
element . title = element . name //name
element . title = element . name //name
element . key = element . id //id
element . key = element . id //id
element . children = [ ] //children
element . children = [ ] //children
@ -1645,23 +1516,25 @@ export class CollectionToolsExamineeComponent implements OnInit {
data . forEach ( element = > {
data . forEach ( element = > {
! element . parentId ? treeData . push ( element ) : null
! element . parentId ? treeData . push ( element ) : null
} )
} )
this . treeData = [ . . . treeData ]
type == '题目' ? this . questionstreeData = [ . . . treeData ] : this . treeData = [ . . . treeData ]
this . defaultExpandedKeys = [ . . . this . defaultExpandedKeys ]
}
}
//刷新 treeData 保存已展开节点
//刷新 treeData 保存已展开节点
refurbishTreeData ( ) {
refurbishTreeData ( ) {
let api
let api
this . examType == 1 ? api = '/api/DisposalNodes' : api = '/api/ExamDisposalNodes'
api = '/api/ExamDisposalNodes'
this . defaultExpandedKeys = [ ]
this . defaultExpandedKeys = [ ]
let params
let params
this . examType == 1 ? params = { d isasterId : this.allFirePlan [ 0 ] . id || '' } : params = { examDisasterId : this.allFirePlan [ 0 ] . id || '' }
params = { examD isasterId : this.allFirePlan [ 0 ] . id , disposalNodeType :1 , examinationId :this.route.snapshot.queryParams.examId }
this . http . get ( api , { params :params } ) . subscribe ( nodeData = > { //处置节点
this . http . get ( api , { params :params } ) . subscribe ( nodeData = > { //处置节点
this . canvasData . allDisposalNode = nodeData
this . canvasData . allDisposalNode = nodeData
let oldTreeData = this . nzTreeComponent . getExpandedNodeList ( )
let oldTreeData = this . nzTreeComponent . getExpandedNodeList ( )
oldTreeData . forEach ( item = > {
oldTreeData . forEach ( item = > {
this . defaultExpandedKeys . push ( item . key )
this . defaultExpandedKeys . push ( item . key )
} )
} )
console . log ( 1 , oldTreeData )
console . log ( 2 , this . defaultExpandedKeys )
let treeData = [ ]
let treeData = [ ]
let data = JSON . parse ( JSON . stringify ( this . canvasData . allDisposalNode || [ ] ) )
let data = JSON . parse ( JSON . stringify ( this . canvasData . allDisposalNode || [ ] ) )
data . forEach ( element = > {
data . forEach ( element = > {
@ -1812,6 +1685,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击 处置Tree节点
//点击 处置Tree节点
selectanelPoint ( e ) {
selectanelPoint ( e ) {
console . log ( 12111 , e )
if ( ! e . buildingAreaId && ! e . sitePlanId ) { //当前节点 不是 数据节点 时
if ( ! e . buildingAreaId && ! e . sitePlanId ) { //当前节点 不是 数据节点 时
let msg = this . canvasData . findDisposalNode ( e . id )
let msg = this . canvasData . findDisposalNode ( e . id )
this . canvasData . selectPanelPointBaseData = msg
this . canvasData . selectPanelPointBaseData = msg
@ -1824,7 +1698,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
if ( this . canvasData . selectPanelPoint . DisposalNodeId != e . id ) { //选择节点 不是当前节点时
if ( this . canvasData . selectPanelPoint . DisposalNodeId != e . id ) { //选择节点 不是当前节点时
let api
let api
this . examType == 1 ? api = '/api/DisposalNodeData' : api = '/api/ExamDisposalNodeData'
api = '/api/ExamDisposalNodeData'
let params = { nodeId : e.id }
let params = { nodeId : e.id }
let parameter = { //查询 节点 对应 建筑/楼层 index,id
let parameter = { //查询 节点 对应 建筑/楼层 index,id
buildingIndex : e.sitePlanId? - 1 : this.allBuildings.findIndex ( item = > { return item . id === e . buildingId } ) , //总平面图/建筑 index
buildingIndex : e.sitePlanId? - 1 : this.allBuildings.findIndex ( item = > { return item . id === e . buildingId } ) , //总平面图/建筑 index