From 759d2a289ecf8e5d589a9b8b8cdac3826f03718e Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 18 六月 2024 17:32:19 +0800
Subject: [PATCH] 修改高德地图key,并添加密钥
---
src/views/realtimemode/RealtimeMode.vue | 133 ++++++++++++++++++++++++++++++++++++++++----
1 files changed, 120 insertions(+), 13 deletions(-)
diff --git a/src/views/realtimemode/RealtimeMode.vue b/src/views/realtimemode/RealtimeMode.vue
index f1e9bf0..c4de517 100644
--- a/src/views/realtimemode/RealtimeMode.vue
+++ b/src/views/realtimemode/RealtimeMode.vue
@@ -1,6 +1,8 @@
<template>
<div class="p-events-none m-t-2">
- <el-row justify="center" align="middle" class="top-wrap"> </el-row>
+ <el-row justify="center" align="middle" class="top-wrap">
+ <DeviceChange @change="onDeviceChange"></DeviceChange>
+ </el-row>
<el-row class="m-t-2">
<FactorRadio
:device-type="deviceType"
@@ -13,9 +15,12 @@
:factor="factorDatas.factor[factorType]"
></FactorLegend>
</el-row>
- <el-row class="m-t-2" justify="start">
- <DashBoard :factor-datas="factorDatas"></DashBoard>
- </el-row>
+ <DashBoard class="dash-board" :factor-datas="factorDatas"></DashBoard>
+ <RealTimeTrend
+ class="real-time-trend"
+ :factor-datas="factorDatas"
+ :device-type="deviceType"
+ ></RealTimeTrend>
</div>
</template>
@@ -25,9 +30,14 @@
import { FactorDatas } from '@/model/FactorDatas';
import monitorDataApi from '@/api/monitorDataApi';
import DashBoard from './component/DashBoard.vue';
+import RealTimeTrend from './component/RealTimeTrend.vue';
+import DeviceChange from './component/DeviceChange.vue';
+import { realTimeMapAnimation } from '@/utils/map/animation';
+
+// const mapAnimation = new MapAnimation();
export default {
- components: { DashBoard },
+ components: { DashBoard, RealTimeTrend, DeviceChange },
setup() {
const { loading, fetchData } = useFetchData(10000);
return { loading, fetchData };
@@ -36,19 +46,50 @@
return {
// 鐩戞祴璁惧绫诲瀷
deviceType: TYPE0,
+ deviceCode: '0a0000000001',
// 鐩戞祴鍥犲瓙鐨勭被鍨嬬紪鍙�
factorType: '1',
- // 鐩戞祴鏁版嵁
- factorDatas: new FactorDatas()
+ // 鏂拌幏鍙栫殑鐩戞祴鏁版嵁
+ factorDatas: new FactorDatas(),
+ // 鍏ㄩ儴鐩戞祴鏁版嵁
+ allFactorDatas: new FactorDatas()
};
},
+ watch: {
+ factorType(nV, oV) {
+ if (nV != oV) {
+ realTimeMapAnimation.setFactorType(nV);
+ }
+ }
+ },
+ computed: {
+ latestTime() {
+ if (this.factorDatas.times.length == 0) {
+ return '';
+ } else {
+ return this.factorDatas.times[this.factorDatas.times.length - 1];
+ }
+ }
+ },
methods: {
- onFetchData(type, data) {
- // todo 鏍规嵁璁惧绫诲瀷鍒囨崲鍦板浘鐩戞祴鍥犲瓙灞曠ず鍗曢�夋銆佹姌绾垮浘澶嶉�夋銆佹暟鎹〃鏍煎閫夋鐨勫洜瀛愮被鍨�
+ onDeviceChange({ type, deviceCode }) {
this.deviceType = type;
- this.factorDatas.setData(data, this.drawMode, () => {
- this.factorDatas.refreshHeight(this.factorType);
+ this.deviceCode = deviceCode;
+ this.clearFetchingTask();
+ realTimeMapAnimation.stop();
+ this.allFactorDatas.clearData();
+ this.factorDatas.clearData();
+ this.notFirstFetch = false;
+ this.fetchRealTimeData();
+ },
+ onFetchData(data) {
+ // todo 鏍规嵁璁惧绫诲瀷鍒囨崲鍦板浘鐩戞祴鍥犲瓙灞曠ず鍗曢�夋銆佹姌绾垮浘澶嶉�夋銆佹暟鎹〃鏍煎閫夋鐨勫洜瀛愮被鍨�
+ // this.deviceType = type;
+ const fDatas = new FactorDatas();
+ fDatas.setData(data, this.drawMode, () => {
+ fDatas.refreshHeight(this.factorType);
// this.draw();
+ this.factorDatas = fDatas;
});
},
fetchRealTimeData() {
@@ -56,18 +97,84 @@
this.fetchData((page) => {
return monitorDataApi
.fetchHistroyData({
- deviceCode: '0a0000000001',
+ deviceCode: this.deviceCode,
+ // startTime: '2021-11-04 09:53:35',
page,
perPage: 100
})
.then((res) => {
- this.onFetchData(TYPE0, res.data);
+ this.onFetchData(res.data);
+ this.onMapData(res.data);
+ this.fetchNextData();
});
+ });
+ },
+ clearFetchingTask() {
+ if (this.fetchingTask) {
+ clearInterval(this.fetchingTask);
+ this.fetchingTask = undefined;
+ }
+ },
+ fetchNextData() {
+ this.clearFetchingTask();
+ this.fetchingTask = setInterval(() => {
+ if (this.isFetching) {
+ return;
+ }
+
+ this.isFetching = true;
+ this.fetchData(() => {
+ return monitorDataApi
+ .fetchNextData({
+ deviceCode: this.deviceCode,
+ updateTime: this.latestTime,
+ perPage: 10
+ })
+ .then((res) => {
+ this.onFetchData(res.data);
+ this.onMapData(res.data);
+ })
+ .finally(() => (this.isFetching = false));
+ });
+ }, 10000);
+ },
+ onMapData(dataList) {
+ let startIndex = this.allFactorDatas.length() - 1;
+ if (!this.notFirstFetch) {
+ startIndex = dataList.length - 2;
+ this.notFirstFetch = true;
+ }
+ startIndex = startIndex < 0 ? 0 : startIndex;
+ return new Promise((resolve, reject) => {
+ this.allFactorDatas.addData(dataList, this.drawMode, () => {
+ realTimeMapAnimation.moveAnimation(
+ this.allFactorDatas,
+ this.factorType,
+ startIndex
+ );
+ });
});
}
},
mounted() {
this.fetchRealTimeData();
+ },
+ unmounted() {
+ this.clearFetchingTask();
+ realTimeMapAnimation.stop();
+ console.log('clear');
}
};
</script>
+<style scoped>
+.dash-board {
+ position: absolute;
+ left: 0;
+ bottom: 2px;
+}
+.real-time-trend {
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+</style>
--
Gitblit v1.9.3