|
|
@@ -7,7 +7,7 @@
|
|
|
<view class="font-16 title">设备名称:{{deviceInfo.equip_name}}</view>
|
|
|
<view class="text">设备ID:{{deviceInfo.equip_name}}</view>
|
|
|
<view class="text text-ellipsis">地址:{{deviceInfo.equip_name}}</view>
|
|
|
- <view class="text">最新上报时间:{{deviceInfo.uptime | timeFrom('yyyy-mm-dd hh:MM:ss')}}</view>
|
|
|
+ <view class="text">最新上报时间:{{deviceInfo.uptime | timeFrom}}</view>
|
|
|
</view>
|
|
|
<view class="font-12 state">{{deviceInfo.is_online?'在线':'离线'}}</view>
|
|
|
</view>
|
|
|
@@ -21,7 +21,7 @@
|
|
|
<!-- 数据列表 -->
|
|
|
<view class="latest-list">
|
|
|
<block v-for="(item,index) in latestList" :key="index">
|
|
|
- <view class="ui-card latest-item" @click="openLatestChart(item)">
|
|
|
+ <view class="ui-card latest-item" @click="openLatestChart(item.el,item.text)">
|
|
|
<view class="icon"></view>
|
|
|
<view class="column-between text-info font-12">
|
|
|
<view class="text">{{item.text}}</view>
|
|
|
@@ -32,15 +32,23 @@
|
|
|
</view>
|
|
|
<!-- 数据列表end -->
|
|
|
<!-- 统计图24小时数据 -->
|
|
|
- <uni-popup ref="chartsPopup" type="dialog" background-color="#fff">
|
|
|
- <!-- <view class="charts-popup" v-if="chartshow">
|
|
|
- <lineCharts :chartData="chartShowData"></lineCharts>
|
|
|
- </view> -->
|
|
|
- <view class="charts-popup">
|
|
|
+ <uni-popup ref="chartsPopup" type="dialog" :mask-click="false">
|
|
|
+
|
|
|
+ <view class="charts-popup" v-if="dayData">
|
|
|
+ <uni-icons type="clear" size="50" color="#999999" class="charts-icon" @click="closeChartsPopup"></uni-icons>
|
|
|
<view class="charts-title">
|
|
|
24小时数据
|
|
|
</view>
|
|
|
- <lineCharts :chartData="chartShowData"></lineCharts>
|
|
|
+ <view class="charts-box">
|
|
|
+ <lineCharts :chartData="chartShowData" :width="200" :height="200"></lineCharts>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="charts-text">
|
|
|
+ 当天最大值:{{dayData.max}} {{dayData.maxtime | timeFrom}}
|
|
|
+ </view>
|
|
|
+ <view class="charts-text">
|
|
|
+ 当天最小值:{{dayData.min}} {{dayData.mintime | timeFrom}}
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</uni-popup>
|
|
|
</view>
|
|
|
@@ -49,23 +57,26 @@
|
|
|
<script>
|
|
|
import {
|
|
|
getWeatherDeviceDetail,
|
|
|
- getWeatherDayData
|
|
|
+ getWeatherDayData,
|
|
|
+ getWeatherChart
|
|
|
} from '@/api/weather.js'
|
|
|
import lineCharts from './components/w-line-charts.vue' // 折线图
|
|
|
// 设备详情
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- deviceId: '', // 设备id
|
|
|
deviceInfo: {}, // 设备信息
|
|
|
// 实时数据列表 { icon:'图标', text:'标题',valu7e:'值'}
|
|
|
latestList: [],
|
|
|
+ dayData: null, //当天24小时数据
|
|
|
+ dayDatas: [], // 24小时数据列表
|
|
|
// 统计图24小时数据
|
|
|
chartShowData: {
|
|
|
categories: [],
|
|
|
series: [],
|
|
|
},
|
|
|
-
|
|
|
+ // 统计图储存数据 格式 {通道号:数据列表}
|
|
|
+ chartData: null,
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
@@ -73,8 +84,9 @@
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.deviceInfo = JSON.parse(options.params);
|
|
|
- this.getLatestList();
|
|
|
- this.getWeatherDayData();
|
|
|
+ this.getLatestList(); // 获取实时列表
|
|
|
+ this.getWeatherDayData(); // 获取24小时数据
|
|
|
+ this.getWeatherChart(); // 获取设备24小时折线图数据
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取实时数据列表
|
|
|
@@ -85,13 +97,48 @@
|
|
|
},
|
|
|
// 获取24小时实时数据
|
|
|
async getWeatherDayData() {
|
|
|
- let res = await getWeatherDayData({
|
|
|
+ const {
|
|
|
+ data
|
|
|
+ } = await getWeatherDayData({
|
|
|
device_id: this.deviceInfo.equip_id
|
|
|
});
|
|
|
+ this.dayDatas = data ?? [];
|
|
|
},
|
|
|
- // 实时数据折线图信息
|
|
|
- openLatestChart() {
|
|
|
+ /**
|
|
|
+ * 根据通道号 字段el 获取实时数据折线图信息
|
|
|
+ * @param {string} el 通道号
|
|
|
+ * @param {string} name 标识名称
|
|
|
+ */
|
|
|
+ openLatestChart(el,name) {
|
|
|
+ if(!this.chartData){
|
|
|
+ return this.$api.msg('数据加载中,请稍后');
|
|
|
+ }
|
|
|
+ this.dayData=this.dayDatas.find(item=>item.ekey==el);
|
|
|
+ this.chartShowData.series = [{
|
|
|
+ name:name,
|
|
|
+ data: this.chartData[el] ?? []
|
|
|
+ }]
|
|
|
this.$refs['chartsPopup'].open();
|
|
|
+ },
|
|
|
+ // 关闭弹框
|
|
|
+ closeChartsPopup(){
|
|
|
+ this.dayData=null;
|
|
|
+ this.$refs['chartsPopup'].close();
|
|
|
+ },
|
|
|
+ // 获取气象统计数据
|
|
|
+ async getWeatherChart() {
|
|
|
+ const {
|
|
|
+ times,
|
|
|
+ charts
|
|
|
+ } = await getWeatherChart({
|
|
|
+ device_id: this.deviceInfo.equip_id,
|
|
|
+ begin: this.$util.timeFrame('start'),
|
|
|
+ end: this.$util.timeFrame('end'),
|
|
|
+ });
|
|
|
+ this.chartData = charts; // 统计数据集合
|
|
|
+ console.log(this.chartData);
|
|
|
+ // 统计图显示数据
|
|
|
+ this.chartShowData.categories = times;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -100,14 +147,33 @@
|
|
|
|
|
|
<style lang="scss">
|
|
|
.charts-popup {
|
|
|
- width: 500rpx;
|
|
|
- height: 500rpx;
|
|
|
+ position: relative;
|
|
|
+ width: 600rpx;
|
|
|
+ height: 620rpx;
|
|
|
+ padding: 24rpx;
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ }
|
|
|
+ .charts-icon{
|
|
|
+ position: absolute;
|
|
|
+ right: -20rpx;
|
|
|
+ top: -50rpx;
|
|
|
+ }
|
|
|
+ .charts-box{
|
|
|
+ width: 100%;
|
|
|
+ height: 450rpx;
|
|
|
+ overflow: hidden;
|
|
|
}
|
|
|
-
|
|
|
.charts-title {
|
|
|
font-size: $font-size-title;
|
|
|
color: $color-title;
|
|
|
line-height: $line-height-title;
|
|
|
text-align: center;
|
|
|
}
|
|
|
+
|
|
|
+ .charts-text {
|
|
|
+ font-size:24rpx;
|
|
|
+ color: $color-subtitle;
|
|
|
+ line-height: $line-height-subtitle;
|
|
|
+ }
|
|
|
</style>
|