|
@@ -4,26 +4,28 @@
|
|
|
style="width:80%;display: flex;align-items: center;margin:40rpx 0 20rpx 0">
|
|
|
<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
|
|
|
</uni-section>
|
|
|
- <view v-for="item in echartsData" :key="item.id" style="padding-right:20rpx">
|
|
|
- <view v-if="item.chartType==='pie'">
|
|
|
- <view class="title" v-if="echartsData.length">
|
|
|
- {{item.chartName}}
|
|
|
+ <template v-if="clear">
|
|
|
+ <view v-for="item in echartsData" :key="item.id" style="padding-right:20rpx">
|
|
|
+ <view v-if="item.chartType==='pie'">
|
|
|
+ <view class="title" v-if="echartsData.length">
|
|
|
+ {{item.chartName}}
|
|
|
+ </view>
|
|
|
+ <pieEcharts :echartsData="item" @piePolling="piePolling" />
|
|
|
</view>
|
|
|
- <pieEcharts :echartsData="item" @piePolling="piePolling" />
|
|
|
- </view>
|
|
|
- <view v-if="item.chartType==='bar'">
|
|
|
- <view class="title" v-if="echartsData.length">
|
|
|
- {{item.chartName}}
|
|
|
+ <view v-if="item.chartType==='bar'">
|
|
|
+ <view class="title" v-if="echartsData.length">
|
|
|
+ {{item.chartName}}
|
|
|
+ </view>
|
|
|
+ <barEcharts :echartsData="item" @barPolling="barPolling" />
|
|
|
</view>
|
|
|
- <barEcharts :echartsData="item" @barPolling="barPolling" />
|
|
|
- </view>
|
|
|
- <view v-if="item.chartType==='line'">
|
|
|
- <view class="title" v-if="echartsData.length">
|
|
|
- {{item.chartName}}
|
|
|
+ <view v-if="item.chartType==='line'">
|
|
|
+ <view class="title" v-if="echartsData.length">
|
|
|
+ {{item.chartName}}
|
|
|
+ </view>
|
|
|
+ <lineEcharts :echartsData="item" @linePolling="linePolling" />
|
|
|
</view>
|
|
|
- <lineEcharts :echartsData="item" @linePolling="linePolling" />
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </template>
|
|
|
<u-empty text="暂无数据" icon="../../static/data.png" v-if="!echartsData.length"></u-empty>
|
|
|
</view>
|
|
|
</template>
|
|
@@ -65,20 +67,17 @@
|
|
|
text: "近一天"
|
|
|
},
|
|
|
],
|
|
|
- barTime: null,
|
|
|
- lineTime: null,
|
|
|
- pieTime: null
|
|
|
+ clear: true
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
+ this.clear = true
|
|
|
this.value = null
|
|
|
this.startTime = timeToDate(new Date().getTime() - 3600000)
|
|
|
this.temperature()
|
|
|
},
|
|
|
onHide() {
|
|
|
- clearInterval(this.barTime)
|
|
|
- clearInterval(this.lineTime)
|
|
|
- clearInterval(this.pieTime)
|
|
|
+ this.clear = false
|
|
|
},
|
|
|
methods: {
|
|
|
//用户图表数据
|
|
@@ -120,43 +119,6 @@
|
|
|
clearInterval(this.pieTime)
|
|
|
}
|
|
|
this.temperature()
|
|
|
- },
|
|
|
- //轮询
|
|
|
- barPolling(time, id) {
|
|
|
- this.barTime = setInterval(() => {
|
|
|
- let chartParams = {
|
|
|
- id: id,
|
|
|
- startTime: this.startTime,
|
|
|
- endTime: nowDate()
|
|
|
- }
|
|
|
- uni.$http.get('/chart/getChartById', chartParams).then(res => {
|
|
|
-
|
|
|
- })
|
|
|
- }, time)
|
|
|
- },
|
|
|
- linePolling(time, id) {
|
|
|
- this.lineTime = setInterval(() => {
|
|
|
- let chartParams = {
|
|
|
- id: id,
|
|
|
- startTime: this.startTime,
|
|
|
- endTime: nowDate()
|
|
|
- }
|
|
|
- uni.$http.get('/chart/getChartById', chartParams).then(res => {
|
|
|
-
|
|
|
- })
|
|
|
- }, time)
|
|
|
- },
|
|
|
- piePolling(time, id) {
|
|
|
- this.pieTime = setInterval(() => {
|
|
|
- let chartParams = {
|
|
|
- id: id,
|
|
|
- startTime: this.startTime,
|
|
|
- endTime: nowDate()
|
|
|
- }
|
|
|
- uni.$http.get('/chart/getChartById', chartParams).then(res => {
|
|
|
-
|
|
|
- })
|
|
|
- }, time)
|
|
|
}
|
|
|
}
|
|
|
};
|