diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index daf1a39..d26ec6f 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -392,6 +392,14 @@ export class CollectionToolsComponent implements OnInit { this.canvas.on("deselect",obj=>{ this.isShowProperty = false }) + // 监听canvas组件新增素材事件 + this.canvas.on("createIcon",obj=>{ + this.renovateTreeData(false) + }) + // 监听canvas组件删除素材事件 + this.canvas.on("deleteIcon",obj=>{ + this.renovateTreeData(false) + }) } copyAssetData:any //存储用于复制的素材 @@ -740,11 +748,11 @@ export class CollectionToolsComponent implements OnInit { } //封装 刷新 tree 数据 - renovateTreeData () { - this.canvas.refresh() - this.canvasData.isChange = false //服务中 数据是否改动 改为false - this.isShowProperty = true - this.isShowAttribute = true + renovateTreeData (isRefresh:boolean = true) { + isRefresh? this.canvas.refresh() : null + isRefresh? this.canvasData.isChange = false : null //服务中 数据是否改动 改为false + isRefresh? this.isShowProperty = true : null + isRefresh? this.isShowAttribute = true : null this.allFireElements[this.allFireElements.length-1].children = [] let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id @@ -905,9 +913,19 @@ export class CollectionToolsComponent implements OnInit { if (this.canvasData.isChange) { //true 数据被改动 let isTrue = confirm('是否保存当前编辑数据') - if (isTrue) { //保存一遍数据, 再刷新数据 - - } else { + if (isTrue) { //先保存数据 在切换 + let isSuccess = this.saveSite()//true的时候 先保存数据 + if (isSuccess != false) { + this.selectingSitePlan = item + this.selectSitePlanIndex = index + 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 //服务中 存一份数据 @@ -917,6 +935,7 @@ export class CollectionToolsComponent implements OnInit { this.getBuildingStorey(item) //获取 建筑 楼层数据 } } + } else { //false 数据没被改动 this.selectingSitePlan = item this.selectSitePlanIndex = index diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 7e8044c..3fb243e 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -280,8 +280,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * 版本检查 */ public versionChecking(): void { - const floorData = this.canvasData.originaleveryStoreyData; - const buildingData = this.canvasData.originalcompanyBuildingData; + let floorData = this.canvasData.originaleveryStoreyData; + let buildingData = this.canvasData.originalcompanyBuildingData; if (floorData.version && floorData.version === '1.0') { floorData.version = '2.0'; Object.keys(floorData.data).forEach(item => {