Browse Source

[修正] promise封装修正同步请求BUG

develop
陈鹏飞 4 years ago
parent
commit
28ff84b82f
  1. 150
      src/app/ui/collection-tools/collection-tools.component.ts

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

@ -643,7 +643,7 @@ export class CollectionToolsComponent implements OnInit {
data.forEach(element => {
element.isTemplate = true //添加模板标识
element.isLook = true //添加是否可见标识
element.name!='其他'? element.children = [] : element.children
element.name!='其他'? element.children = [] : null
if(storeyData){
for(let key in storeyData.data){
@ -824,9 +824,10 @@ export class CollectionToolsComponent implements OnInit {
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
this.selectSitePlanIndex = 0
if (fireData=='success' && planData=='success') {
Promise.all([fireData,planData]).then((res)=>{
this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据
}
})
})
}
@ -843,43 +844,46 @@ export class CollectionToolsComponent implements OnInit {
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
this.selectSitePlanIndex = 0
if (fireData=='success' && planData=='success') {
Promise.all([fireData,planData]).then((res)=>{
this.getBuildingStorey(this.selectingSitePlan) //获取 建筑 楼层数据
}
})
})
}
//根据单位类型获得所有的消防要素
getFireElements (e) {
getFireElements (e) {
let params = {ids:e}
let isTrue = this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{
this.allFireElements = data //所有消防要素
let other = {
children: [],
computed: true,
id: '',
name: '其他',
order: 999,
parentId: null,
tag: "INPUT",
isLookPattern : true
}
this.allFireElements.push(other)
return true
return new Promise ((resolve,reject)=>{
this.http.get('/api/Companies/FireElements',{params}).subscribe((data:any)=>{
this.allFireElements = data //所有消防要素
let other = {
children: [],
computed: true,
id: '',
name: '其他',
order: 999,
parentId: null,
tag: "INPUT",
isLookPattern : true
}
this.allFireElements.push(other)
resolve('success')
})
})
if (isTrue) { return 'success' }
}
//获取 单位 数据
getSitePlanCompanyData () {
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 = {}
this.canvasData.originalcompanyBuildingData.version? null : this.canvasData.originalcompanyBuildingData.version = "2.0"
this.canvasData.originalcompanyBuildingData.companyId? null : this.canvasData.originalcompanyBuildingData.companyId = sessionStorage.getItem('companyId')
return true
return new Promise ((resolve,reject)=>{
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 = {}
this.canvasData.originalcompanyBuildingData.version? null : this.canvasData.originalcompanyBuildingData.version = "2.0"
this.canvasData.originalcompanyBuildingData.companyId? null : this.canvasData.originalcompanyBuildingData.companyId = sessionStorage.getItem('companyId')
resolve('success')
})
})
if (isTrue) { return 'success' }
}
//获取 平面图 楼层数据
@ -896,14 +900,15 @@ export class CollectionToolsComponent implements OnInit {
//获取 建筑 数据
getBuildingData (e) {
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 = {}
this.canvasData.originalcompanyBuildingData.version? null : this.canvasData.originalcompanyBuildingData.version = "2.0"
this.canvasData.originalcompanyBuildingData.buildingId? null : this.canvasData.originalcompanyBuildingData.buildingId = e.buildingId
return true
return new Promise ((resolve,reject)=>{
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 = {}
this.canvasData.originalcompanyBuildingData.version? null : this.canvasData.originalcompanyBuildingData.version = "2.0"
this.canvasData.originalcompanyBuildingData.buildingId? null : this.canvasData.originalcompanyBuildingData.buildingId = e.buildingId
resolve('success')
})
})
if (isTrue) { return 'success' }
}
//获取 建筑 楼层数据
@ -1051,13 +1056,17 @@ 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=>{
const revolve = this.renovateSitePlan()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
})
})
} else { //楼层/区域
this.http.put(`/api/CompanyAccount/BuildingAreas/${item.id}`,item).subscribe(data=>{
const revolve = this.renovateBuilding()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
})
})
}
@ -1144,8 +1153,10 @@ 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=>{
const revolve = this.renovateSitePlan()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
let isSuccess = this.renovateSitePlan()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
@ -1153,8 +1164,10 @@ export class CollectionToolsComponent implements OnInit {
})
} else { //楼层/区域
this.http.put(`/api/CompanyAccount/BuildingAreas/${item.id}`,item).subscribe(data=>{
const revolve = this.renovateBuilding()
if (revolve=='renovate') { this.canvas.refreshBackgroundImage(); }
let isSuccess = this.renovateBuilding()
isSuccess.then(res=>{
this.canvas.refreshBackgroundImage()
})
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
@ -1163,25 +1176,21 @@ export class CollectionToolsComponent implements OnInit {
}
}
//封装 统一刷新 左侧菜单栏数据
// renovateLeftMenu () {
// }
//封装 刷新总平面图 数据
renovateSitePlan () {
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] //服务中 存一份数据
this.canvasData.originaleveryStoreyData.sitePlanId? null : this.canvasData.originaleveryStoreyData.sitePlanId = this.selectingSitePlan.id || null
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
return true
return new Promise ((resolve,reject)=>{
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
this.sitePlanData = data
this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex]
this.canvasData.selectStorey = this.sitePlanData[this.selectSitePlanIndex] //服务中 存一份数据
this.canvasData.originaleveryStoreyData.sitePlanId? null : this.canvasData.originaleveryStoreyData.sitePlanId = this.selectingSitePlan.id || null
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
resolve('success')
})
})
if (isTrue) { return 'renovate' }
}
//封装 刷新 楼层/区域 数据
@ -1189,18 +1198,19 @@ export class CollectionToolsComponent implements OnInit {
let params = {
buildingId: this.beforeOneCheckedBuilding.id
}
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] //服务中 存一份数据
this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = this.selectingSitePlan.id || null
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
return true
return new Promise ((resolve,reject)=>{
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] //服务中 存一份数据
this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = this.selectingSitePlan.id || null
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
resolve('success')
})
})
if (isTrue) { return 'renovate' }
}
allLibrary:any = []; //所有素材库 + 素材

Loading…
Cancel
Save