Browse Source

[完善] 优化异步请求函数顺序, 实时更新界面

develop
陈鹏飞 4 years ago
parent
commit
c0d225da31
  1. 48
      src/app/ui/collection-tools/collection-tools.component.ts
  2. 2
      src/app/ui/collection-tools/panel.scss

48
src/app/ui/collection-tools/collection-tools.component.ts

@ -775,15 +775,17 @@ export class CollectionToolsComponent implements OnInit {
//获取总平面图
getSitePlan () {
this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素
this.getSitePlanCompanyData() //获取 单位 数据
let fireData = this.getFireElements(sessionStorage.getItem('buildingTypeId')) //获取单位下 消防要素
let planData = this.getSitePlanCompanyData() //获取 单位 数据
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
this.sitePlanData = data
this.selectingSitePlan = this.sitePlanData[0] || {}
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
this.selectSitePlanIndex = 0
this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据
if (fireData=='success' && planData=='success') {
this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据
}
})
}
@ -792,32 +794,38 @@ export class CollectionToolsComponent implements OnInit {
let params = {
buildingId: item.id
}
this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素
this.getBuildingData(params) //获取 建筑 数据
let fireData = this.getFireElements(item.buildingTypes[0].id || '') //获取建筑下 消防要素
let planData = this.getBuildingData(params) //获取 建筑 数据
this.http.get('/api/CompanyAccount/BuildingAreas',{params}).subscribe(data=>{
this.sitePlanData = data
this.selectingSitePlan = this.sitePlanData[0] || {}
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
this.selectSitePlanIndex = 0
this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据
if (fireData=='success' && planData=='success') {
this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据
}
})
}
//根据单位类型获得所有的消防要素
getFireElements (e) {
let params = {ids:e}
this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{
let isTrue = this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{
this.allFireElements = data //所有消防要素
return true
})
if (isTrue) { return 'success' }
}
//获取 单位 数据
getSitePlanCompanyData () {
this.http.get('/api/CompanyAccount/CompanyData').subscribe((data:any)=>{
let isTrue = this.http.get('/api/CompanyAccount/CompanyData').subscribe((data:any)=>{
this.canvasData.originalcompanyBuildingData = data || {} // 单位原数据
this.canvasData.originalcompanyBuildingData.data? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {}
return true
})
if (isTrue) { return 'success' }
}
//获取 平面图 楼层数据
@ -832,10 +840,12 @@ export class CollectionToolsComponent implements OnInit {
//获取 建筑 数据
getBuildingData (e) {
this.http.get(`/api/CompanyAccount/BuildingData`,{params:e}).subscribe((data:any)=>{
let isTrue = this.http.get(`/api/CompanyAccount/BuildingData`,{params:e}).subscribe((data:any)=>{
this.canvasData.originalcompanyBuildingData = data || {} // 建筑原数据
this.canvasData.originalcompanyBuildingData.data? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {}
return true
})
if (isTrue) { return 'success' }
}
//获取 建筑 楼层数据
@ -952,11 +962,13 @@ export class CollectionToolsComponent implements OnInit {
item.imageAngle==270? item.imageAngle = 0 : item.imageAngle = item.imageAngle+90
if (this.checkedBuildingIndex==-1) { //总平面图
this.http.put(`/api/CompanyAccount/SitePlans/${item.id}`,item).subscribe(data=>{
this.renovateSitePlan()
const revolve = this.renovateSitePlan()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
})
} else { //楼层/区域
this.http.put(`/api/CompanyAccount/BuildingAreas/${item.id}`,item).subscribe(data=>{
this.renovateBuilding()
const revolve = this.renovateBuilding()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
})
}
@ -1043,7 +1055,8 @@ export class CollectionToolsComponent implements OnInit {
item.imageUrl = '/api/Objects/WebPlan2D/' + e
if (this.checkedBuildingIndex ==-1) { //总平面图
this.http.put(`/api/CompanyAccount/SitePlans/${item.id}`,item).subscribe(data=>{
this.renovateSitePlan()
const revolve = this.renovateSitePlan()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
@ -1051,7 +1064,8 @@ export class CollectionToolsComponent implements OnInit {
})
} else { //楼层/区域
this.http.put(`/api/CompanyAccount/BuildingAreas/${item.id}`,item).subscribe(data=>{
this.renovateBuilding()
const revolve = this.renovateBuilding()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
@ -1067,7 +1081,7 @@ export class CollectionToolsComponent implements OnInit {
//封装 刷新总平面图 数据
renovateSitePlan () {
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
let isTrue = this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
this.sitePlanData = data
this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex]
this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据
@ -1075,7 +1089,9 @@ export class CollectionToolsComponent implements OnInit {
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
return true
})
if (isTrue) { return 'renovate' }
}
//封装 刷新 楼层/区域 数据
@ -1083,7 +1099,7 @@ export class CollectionToolsComponent implements OnInit {
let params = {
buildingId: this.beforeOneCheckedBuilding.id
}
this.http.get('/api/CompanyAccount/BuildingAreas',{params}).subscribe(data=>{
let isTrue = this.http.get('/api/CompanyAccount/BuildingAreas',{params}).subscribe(data=>{
this.sitePlanData = data
this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex]
this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据
@ -1091,7 +1107,9 @@ export class CollectionToolsComponent implements OnInit {
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
return true
})
if (isTrue) { return 'renovate' }
}
allLibrary:any = []; //所有素材库 + 素材

2
src/app/ui/collection-tools/panel.scss

@ -112,7 +112,7 @@
height: 100px;
position: absolute;
top: -32px;
right: -51px;
right: -50.5px;
border-radius: 0 100px 100px 0;
background-color: #cdced1;
// #F0F4F7

Loading…
Cancel
Save