Browse Source

[修改]用同步方式实现异步获取服务层数据

zhuzhou
chenjingyu 4 years ago
parent
commit
1abc07e169
  1. 17
      src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts
  2. 25
      src/app/statistic-analysis/addUnit/add-unit-three-bar-details/add-unit-three-bar-details.component.ts
  3. 6
      src/app/statistic-analysis/addUnit/add-unit-three-line-details/add-unit-three-line-details.component.ts
  4. 6
      src/app/statistic-analysis/addUnit/add-unit-two-time/add-unit-two-time.component.ts
  5. 29
      src/app/statistic-analysis/addUnit/add-unit-two-type-statistics/add-unit-two-type-statistics.component.ts
  6. 12
      src/app/statistic-analysis/buildingType/building-type-one/building-type-one.component.ts
  7. 25
      src/app/statistic-analysis/buildingType/building-type-three-details/building-type-three-details.component.ts
  8. 25
      src/app/statistic-analysis/buildingType/building-type-two-reverse/building-type-two-reverse.component.ts
  9. 2
      src/app/statistic-analysis/compang-info/compang-info.component.ts
  10. 15
      src/app/statistic-analysis/echarts-data.service.ts

17
src/app/statistic-analysis/addUnit/add-unit-one/add-unit-one.component.ts

@ -21,13 +21,10 @@ export class AddUnitOneComponent implements OnInit {
}
/* this.buildData.push(this.echartsData.getData(null,`/api/StatisticsAnalysis/BuildingTypes`))
this.orData=this.echartsData.getData(null,`/api/StatisticsAnalysis/Companies`) */
this.echartsData.getData(null,`/api/StatisticsAnalysis/Companies`)
this.setTimeoutObj = window.setTimeout(()=>{
this.tabledata=JSON.parse(JSON.stringify(this.echartsData.allDate))
//console.log(this.tabledata)
this.initCharts("pieone")
this.initCharts("pietwo")
},1000)
this.getechartsdata()
})
this.echartsData.eventEmit.subscribe((value: any) => {
if (value == 'echarts') {
setTimeout(() => {
@ -41,6 +38,14 @@ export class AddUnitOneComponent implements OnInit {
updateEcharts(){
this.indexBzt.resize()
}
//获取服务层数据
async getechartsdata(){
await this.echartsData.getData(null,`/api/StatisticsAnalysis/Companies`)
this.tabledata=JSON.parse(JSON.stringify(this.echartsData.allDate))
//console.log(this.tabledata)
this.initCharts("pieone")
this.initCharts("pietwo")
}
//组件销毁时
ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj);

25
src/app/statistic-analysis/addUnit/add-unit-three-bar-details/add-unit-three-bar-details.component.ts

@ -35,13 +35,24 @@ export class AddUnitThreeBarDetailsComponent implements OnInit {
this.buildId=params['id']
this.orId=params['zhuid']
});
let paramsdata={
this.setTimeoutObj = window.setTimeout(()=>{
this.getechartsData()
})
}
ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj);
this.detailPlanEchart.clear()
this.detailPlanEchart.dispose()
}
//获取服务层数据
async getechartsData(){
let paramsdata={
//id:this.buildId,
organizationId:this.orId
}
this.serviceData.getData(paramsdata,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildId}`)
this.setTimeoutObj = window.setTimeout(()=>{
this.tabledata=JSON.parse(JSON.stringify(this.serviceData.allDate))
await this.serviceData.getData(paramsdata,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildId}`)
this.tabledata=JSON.parse(JSON.stringify(this.serviceData.allDate))
//console.log(this.tabledata)
for(var i=0;i<this.tabledata[0].organizations.length;i++){
this.zhiNameData.push(this.tabledata[0].organizations[i].organizationName)
@ -50,12 +61,6 @@ export class AddUnitThreeBarDetailsComponent implements OnInit {
}
this.tiaoshiPao=this.serviceData.qipao(this.tiaoshiPao,this.zhiNumData,this.zhiNameData)
this.detailEcharts()
},1000)
}
ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj);
this.detailPlanEchart.clear()
this.detailPlanEchart.dispose()
}
selectType:string = 'month'; //选择当前的 查询类型 按月/年

6
src/app/statistic-analysis/addUnit/add-unit-three-line-details/add-unit-three-line-details.component.ts

@ -43,7 +43,7 @@ export class AddUnitThreeLineDetailsComponent implements OnInit {
}
tabledata
zongcount=0
getdata(){
async getdata(){
let parzhi={
BuildingTypeId:this.lastId,
TrendType:this.serviceData.selectType,
@ -54,7 +54,7 @@ export class AddUnitThreeLineDetailsComponent implements OnInit {
TrendType:this.serviceData.selectType,
//TrendYear:this.year||''
}
this.serviceData.getData(this.serviceData.zuzhiorBuilding=='zhi'?parbuild:parzhi,`/api/StatisticsAnalysis`)
await this.serviceData.getData(this.serviceData.zuzhiorBuilding=='zhi'?parbuild:parzhi,`/api/StatisticsAnalysis`)
this.setTimeoutObj = window.setTimeout(() => {
this.tabledata=JSON.parse(JSON.stringify(this.serviceData.allDate))
//console.log(this.tabledata)
@ -70,7 +70,7 @@ export class AddUnitThreeLineDetailsComponent implements OnInit {
//this.oneInit (this.date,this.dateNum)
this.qopao=this.serviceData.qipao(this.qopao,this.dateNum,this.zhiNameData)
this.detailEcharts()
}, 1000);
});
}
selectType:string = 'month'; //选择当前的 查询类型 按月/年

6
src/app/statistic-analysis/addUnit/add-unit-two-time/add-unit-two-time.component.ts

@ -39,7 +39,7 @@ export class AddUnitTwoTimeComponent implements OnInit {
}
//获取数据
yeardatee
getdata(){
async getdata(){
let parzhi={
BuildingTypeId:this.lastId,
TrendType:this.serviceData.selectType,
@ -50,7 +50,7 @@ export class AddUnitTwoTimeComponent implements OnInit {
TrendType:this.serviceData.selectType,
TrendYear:this.yeardatee||''
}
this.serviceData.getData(this.serviceData.zuzhiorBuilding=='zhi'?parbuild:parzhi,`/api/StatisticsAnalysis`)
await this.serviceData.getData(this.serviceData.zuzhiorBuilding=='zhi'?parbuild:parzhi,`/api/StatisticsAnalysis`)
this.setTimeoutObj = window.setTimeout(() => {
this.tabledata=JSON.parse(JSON.stringify(this.serviceData.allDate))
//console.log(this.tabledata)
@ -66,7 +66,7 @@ export class AddUnitTwoTimeComponent implements OnInit {
//this.oneInit (this.date,this.dateNum)
this.tiaoshiPao=this.serviceData.qipao(this.tiaoshiPao,this.dateNum,this.date)
this.twoInit (this.date,this.dateNum,'month')
}, 1000);
});
}
forward(){
this.router.navigate(['/statisticanalysis/addUnit_one/addUnit_two_type'],{queryParams:{'level':this.headname,'id':this.lastId,'type':this.zhiorbuild=='zhi'?'zhi':'build'}})

29
src/app/statistic-analysis/addUnit/add-unit-two-type-statistics/add-unit-two-type-statistics.component.ts

@ -34,13 +34,27 @@ export class AddUnitTwoTypeStatisticsComponent implements OnInit {
this.lastId=param.id
this.zhiorbuild=param.type
});
this.setTimeoutObj = window.setTimeout(()=>{
this.getechartsData()
})
}
ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj);
this.forArr.forEach(item => {
item.echart.clear()
item.echart.dispose()
})
}
//获取服务层数据
async getechartsData(){
let paramsdata:any = {
id:this.lastId,
//organizationId:'1'
}
this.data.getData(this.zhiorbuild=="zhi"?paramsdata:null,this.zhiorbuild=="zhi"?`/api/StatisticsAnalysis/Companies/Organizations/${this.lastId}`:`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.lastId}`)
this.setTimeoutObj = window.setTimeout(()=>{
this.tabledata=JSON.parse(JSON.stringify(this.data.allDate))
await this.data.getData(this.zhiorbuild=="zhi"?paramsdata:null,this.zhiorbuild=="zhi"?`/api/StatisticsAnalysis/Companies/Organizations/${this.lastId}`:`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.lastId}`)
this.tabledata=JSON.parse(JSON.stringify(this.data.allDate))
//console.log(this.tabledata)
if(this.zhiorbuild=="zhi"){
for(var i=0;i<this.tabledata[0].buildingTypes.length;i++){
@ -59,15 +73,6 @@ export class AddUnitTwoTypeStatisticsComponent implements OnInit {
this.tiaoshiPao=this.data.qipao(this.tiaoshiPao,this.zhiorbuild=="zhi"?this.buildnumData:this.zhiNumData,this.zhiorbuild=="zhi"?this.buildingData:this.zhiNameData)
//this.initCharts()
this.barEcharts()
},1000)
}
ngOnDestroy(){
window.clearTimeout(this.setTimeoutObj);
this.forArr.forEach(item => {
item.echart.clear()
item.echart.dispose()
})
}
axisLabel = {

12
src/app/statistic-analysis/buildingType/building-type-one/building-type-one.component.ts

@ -20,15 +20,19 @@ export class BuildingTypeOneComponent implements OnInit {
}else{
this.padHw=false
}
this.echartsData.getData(null,`/api/StatisticsAnalysis/BuildingTypes`)
window.setTimeout(()=>{
this.initCharts()
},500)
this.getechartsdata()
})
}
ngOnDestroy(): void {
this.indexBzt.clear()
this.indexBzt.dispose()
}
async getechartsdata(){
await this.echartsData.getData(null,`/api/StatisticsAnalysis/BuildingTypes`)
this.initCharts()
}
/* 首页饼状图 */
indexBzt
padHw
@ -42,7 +46,7 @@ export class BuildingTypeOneComponent implements OnInit {
location.reload();
}
this.tabledata=JSON.parse(JSON.stringify(this.echartsData.allDate))
//console.log(this.tabledata)
console.log(this.tabledata)
for(var i=0;i<this.tabledata[0].buildingTypes.length;i++){
this.lengthdata.push(this.tabledata[0].buildingTypes[i].buildingTypeName)
this.count=this.count+this.tabledata[0].buildingTypes[i].count

25
src/app/statistic-analysis/buildingType/building-type-three-details/building-type-three-details.component.ts

@ -49,13 +49,24 @@ export class BuildingTypeThreeDetailsComponent implements OnInit {
this.listorganizationId=params['organizationId'];
this.buildingTypeId=params['buildId'];
});
window.setTimeout(()=>{
this.getechartsdata()
})
}
ngOnDestroy(): void {
this.detailPlanEchart.clear()
this.detailPlanEchart.dispose()
}
async getechartsdata(){
let paramsdata={
//id:this.buildingTypeId,
organizationId:this.listorganizationId
}
this.echartsData.getData(paramsdata,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildingTypeId}`)
window.setTimeout(()=>{
this.tabledata=JSON.parse(JSON.stringify(this.echartsData.allDate))
await this.echartsData.getData(paramsdata,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildingTypeId}`)
this.tabledata=JSON.parse(JSON.stringify(this.echartsData.allDate))
//console.log(this.tabledata)
for(var i=0;i<this.tabledata[0].organizations.length;i++){
this.zhongNameData.push(this.tabledata[0].organizations[i].organizationName)
@ -64,14 +75,6 @@ export class BuildingTypeThreeDetailsComponent implements OnInit {
}
this.tiaoshiPao=this.echartsData.qipao(this.tiaoshiPao,this.zhongNumData,this.zhongNameData)
this.detailEcharts()
},500)
}
ngOnDestroy(): void {
this.detailPlanEchart.clear()
this.detailPlanEchart.dispose()
}
topTextlabel = {
show: true, // 开启显示

25
src/app/statistic-analysis/buildingType/building-type-two-reverse/building-type-two-reverse.component.ts

@ -40,18 +40,10 @@ export class BuildingTypeTwoReverseComponent implements OnInit {
id:this.buildId,
//organizationId:'1'
}
this.data.getData(null,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildId}`)
window.setTimeout(()=>{
this.tabledata=JSON.parse(JSON.stringify(this.data.allDate))
for(var i=0;i<this.tabledata[0].organizations.length;i++){
this.zhiNameData.push(this.tabledata[0].organizations[i].organizationName)
this.zhiNumData.push(this.tabledata[0].organizations[i].count)
this.organizationId.push(this.tabledata[0].organizations[i].organizationId)
}
this.tiaoshiPao=this.data.qipao(this.tiaoshiPao,this.zhiNumData,this.zhiNameData)
this.barEcharts()
},500);
this.getechartsdata()
});
}
ngOnDestroy(): void {
@ -62,6 +54,17 @@ export class BuildingTypeTwoReverseComponent implements OnInit {
item.echart.dispose()
})
}
async getechartsdata(){
await this.data.getData(null,`/api/StatisticsAnalysis/Companies/BuildingTypes/${this.buildId}`)
this.tabledata=JSON.parse(JSON.stringify(this.data.allDate))
for(var i=0;i<this.tabledata[0].organizations.length;i++){
this.zhiNameData.push(this.tabledata[0].organizations[i].organizationName)
this.zhiNumData.push(this.tabledata[0].organizations[i].count)
this.organizationId.push(this.tabledata[0].organizations[i].organizationId)
}
this.tiaoshiPao=this.data.qipao(this.tiaoshiPao,this.zhiNumData,this.zhiNameData)
this.barEcharts()
}
axisLabel = {
interval: 0,
textStyle:{

2
src/app/statistic-analysis/compang-info/compang-info.component.ts

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2021-03-05 15:57:08
* @LastEditors: sueRimn
* @LastEditTime: 2021-03-25 10:34:49
* @LastEditTime: 2021-03-30 10:39:08
*/
import { Component, OnInit, ViewChild, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'

15
src/app/statistic-analysis/echarts-data.service.ts

@ -1,6 +1,8 @@
import { Injectable, EventEmitter} from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';
import { HttpClient } from '@angular/common/http'
import { promise } from 'selenium-webdriver';
import { resolve } from 'dns';
@Injectable({
providedIn: 'root'
})
@ -607,12 +609,15 @@ export class EchartsDataService {
async getData(paramsdata,api){
this.allDate=[]
this.obdata=null
this.http.get(api,{params:paramsdata}).subscribe((data:any)=>{
this.allDate.push(data)
this.obdata=JSON.parse(JSON.stringify(this.allDate))
console.log(this.obdata)
return this.allDate
let result = await new Promise((resolve, reject)=>{
this.http.get(api,{params:paramsdata}).subscribe((data:any)=>{
resolve(data)
})
})
this.allDate.push(result)
this.obdata=JSON.parse(JSON.stringify(this.allDate))
console.log(this.obdata)
}
selectType=0//选择年月
selectOneYear

Loading…
Cancel
Save