| | |
| | | <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" |
| | |
| | | :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" |
| | |
| | | import monitorDataApi from '@/api/monitorDataApi'; |
| | | import DashBoard from './component/DashBoard.vue'; |
| | | import RealTimeTrend from './component/RealTimeTrend.vue'; |
| | | import { MapAnimation } from '@/utils/map/animation'; |
| | | import DeviceChange from './component/DeviceChange.vue'; |
| | | import { realTimeMapAnimation } from '@/utils/map/animation'; |
| | | |
| | | const mapAnimation = new MapAnimation(); |
| | | // const mapAnimation = new MapAnimation(); |
| | | |
| | | export default { |
| | | components: { DashBoard, RealTimeTrend }, |
| | | components: { DashBoard, RealTimeTrend, DeviceChange }, |
| | | setup() { |
| | | const { loading, fetchData } = useFetchData(10000); |
| | | return { loading, fetchData }; |
| | |
| | | allFactorDatas: new FactorDatas() |
| | | }; |
| | | }, |
| | | watch: { |
| | | factorType(nV, oV) { |
| | | if (nV != oV) { |
| | | realTimeMapAnimation.setFactorType(nV); |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | latestTime() { |
| | | if (this.factorDatas.times.length == 0) { |
| | | return '----/--/-- --:--:--'; |
| | | return ''; |
| | | } else { |
| | | return this.factorDatas.times[this.factorDatas.times.length - 1]; |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | onDeviceChange({ type, deviceCode }) { |
| | | this.deviceType = type; |
| | | this.deviceCode = deviceCode; |
| | | this.clearFetchingTask(); |
| | | realTimeMapAnimation.stop(); |
| | | this.allFactorDatas.clearData(); |
| | | this.factorDatas.clearData(); |
| | | this.notFirstFetch = false; |
| | | this.fetchRealTimeData(); |
| | | }, |
| | | onFetchData(data) { |
| | | // todo 根据设备类型切换地图监测因子展示单选框、折线图复选框、数据表格复选框的因子类型 |
| | | // this.deviceType = type; |
| | |
| | | return monitorDataApi |
| | | .fetchHistroyData({ |
| | | deviceCode: this.deviceCode, |
| | | startTime: '2021-11-04 09:53:35', |
| | | // startTime: '2021-11-04 09:53:35', |
| | | page, |
| | | perPage: 100 |
| | | }) |
| | |
| | | clearFetchingTask() { |
| | | if (this.fetchingTask) { |
| | | clearInterval(this.fetchingTask); |
| | | this.fetchingTask = undefined; |
| | | } |
| | | }, |
| | | fetchNextData() { |
| | |
| | | .fetchNextData({ |
| | | deviceCode: this.deviceCode, |
| | | updateTime: this.latestTime, |
| | | perPage: 2 |
| | | perPage: 10 |
| | | }) |
| | | .then((res) => { |
| | | this.onFetchData(res.data); |
| | |
| | | this.notFirstFetch = true; |
| | | } |
| | | startIndex = startIndex < 0 ? 0 : startIndex; |
| | | this.allFactorDatas.addData(dataList, this.drawMode, () => { |
| | | mapAnimation.moveAnimation( |
| | | this.allFactorDatas, |
| | | this.factorType, |
| | | startIndex |
| | | ); |
| | | return new Promise((resolve, reject) => { |
| | | this.allFactorDatas.addData(dataList, this.drawMode, () => { |
| | | realTimeMapAnimation.moveAnimation( |
| | | this.allFactorDatas, |
| | | this.factorType, |
| | | startIndex |
| | | ); |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | |
| | | }, |
| | | unmounted() { |
| | | this.clearFetchingTask(); |
| | | mapAnimation.stop(); |
| | | realTimeMapAnimation.stop(); |
| | | } |
| | | }; |
| | | </script> |
| | | <style scoped> |
| | | .dash-board { |
| | | position: absolute; |
| | | left: 0; |
| | | bottom: 2px; |
| | | } |
| | | .real-time-trend { |
| | | position: absolute; |
| | | right: 0; |