Browse Source

fix: 修改地图交互

sy-water-data-board-ui
panyuyi 6 months ago
parent
commit
811c23a44e
  1. 16
      src/api/reservoir/index.js
  2. 7
      src/utils/index.js
  3. 2
      src/views/reservoir/safeOperation/components/ProjectDetail.vue
  4. 108
      src/views/reservoir/safeOperation/components/RealTimeMonitor.vue
  5. 34
      src/views/reservoir/safeOperation/index.vue
  6. 2
      vue.config.js

16
src/api/reservoir/index.js

@ -42,3 +42,19 @@ export const getReservoirRsppDetailData = (id) =>{
method: 'get' method: 'get'
}) })
} }
// 水库实时监测--监测站树数据
export const getReservoirMonitorTreeData = (id) =>{
return request({
url: `/sk/??`,
method: 'get'
})
}
// 水库实时监测--降雨量等详情
export const getReservoirRainDetailData = (id) =>{
return request({
url: `/sk/??`,
method: 'get'
})
}

7
src/utils/index.js

@ -466,3 +466,10 @@ export function loadScript(url) {
document.head.appendChild(script) document.head.appendChild(script)
}) })
} }
// 开发时候生效
export function devRun(cb){
if(process.env.NODE_ENV === 'development'){
if(cb) cb()
}
}

2
src/views/reservoir/safeOperation/components/ProjectDetail.vue

@ -27,7 +27,7 @@ export default {
methods: { methods: {
initData(code) { initData(code) {
this.$refs.baseInfoRef.initData(code); this.$refs.baseInfoRef.initData(code);
this.$refs.realTimeMonitor.initData(code); // this.$refs.realTimeMonitor.initData(code);
}, },
}, },
}; };

108
src/views/reservoir/safeOperation/components/RealTimeMonitor.vue

@ -9,6 +9,9 @@
<el-date-picker <el-date-picker
v-model="paramsData.startDate" v-model="paramsData.startDate"
type="date" type="date"
:picker-options="{
disabledDate: filterStartDate,
}"
placeholder="选择日期" placeholder="选择日期"
> >
</el-date-picker> </el-date-picker>
@ -18,6 +21,9 @@
<el-date-picker <el-date-picker
v-model="paramsData.endDate" v-model="paramsData.endDate"
type="date" type="date"
:picker-options="{
disabledDate: filterEndDate,
}"
placeholder="选择日期" placeholder="选择日期"
> >
</el-date-picker> </el-date-picker>
@ -55,9 +61,15 @@
<script> <script>
import * as echarts from "echarts"; import * as echarts from "echarts";
import { initReverseLineOptions, doubleYAxisOptions } from "../js/initEcharts"; import { initReverseLineOptions, doubleYAxisOptions } from "../js/initEcharts";
import {
getReservoirMonitorTreeData,
getReservoirRainDetailData,
} from "@/api/reservoir";
export default { export default {
data() { data() {
return { return {
resCode: null, //
activeName: "1", activeName: "1",
filterText: "", filterText: "",
myChart: null, myChart: null,
@ -104,50 +116,82 @@ export default {
methods: { methods: {
initData(code) { initData(code) {
console.log("请求数据 >>>>>> ", code); console.log("请求数据 >>>>>> ", code);
this.resCode = code;
getReservoirMonitorTreeData(code).then((res) => {
this.treeData = res.data;
});
}, },
filterStartDate(date) {
if (this.paramsData.endDate) {
return (
(date && date.valueOf() > this.paramsData.endDate) ||
date.valueOf() > Date.now()
);
}
return date && date.valueOf() > Date.now();
},
filterEndDate(date) {
if (this.paramsData.startDate) {
return (
(date && date.valueOf() < this.paramsData.startDate) ||
date.valueOf() > Date.now()
);
}
return date && date.valueOf() > Date.now();
},
filterNode(value, data) { filterNode(value, data) {
if (!value) return true; if (!value) return true;
return data.label.indexOf(value) !== -1; return data.label.indexOf(value) !== -1;
}, },
handleSearch() {}, initChart(data, type) {
// echarts
switch (type) {
case "1":
// echarts
if (!this.$refs.echartsRef) {
return;
}
if (this.myChart) {
this.myChart.dispose();
}
let options = initReverseLineOptions(data);
this.myChart = echarts.init(this.$refs.echartsRef);
options && this.myChart.setOption(options);
break;
case "2":
// echarts
if (!this.$refs.echartsRef) {
return;
}
if (this.myChart) {
this.myChart.dispose();
}
let options2 = doubleYAxisOptions(data);
this.myChart = echarts.init(this.$refs.echartsRef);
options2 && this.myChart.setOption(options2);
break;
default:
break;
}
},
//
handleSearch() {
this.initData();
},
handleReset() { handleReset() {
this.paramsData.startDate = ""; this.paramsData.startDate = "";
this.paramsData.endDate = ""; this.paramsData.endDate = "";
}, },
handleClickTreeNode(data, node) { handleClickTreeNode(data, node) {
console.log("handleClickTreeNode >>>>> ", data, node);
if (node.isLeaf && data.type) { if (node.isLeaf && data.type) {
// echarts getReservoirRainDetailData({
switch (data.type) { resCode: this.resCode,
case "1": id: data.id,
// echarts }).then((res) => {
if (!this.$refs.echartsRef) { this.initChart(res.data, data.type);
return; });
}
if (this.myChart) {
this.myChart.dispose();
}
let options = initReverseLineOptions();
this.myChart = echarts.init(this.$refs.echartsRef);
options && this.myChart.setOption(options);
break;
case "2":
// echarts
if (!this.$refs.echartsRef) {
return;
}
if (this.myChart) {
this.myChart.dispose();
}
let options2 = doubleYAxisOptions();
this.myChart = echarts.init(this.$refs.echartsRef);
options2 && this.myChart.setOption(options2);
break;
default:
break;
}
} }
}, },
}, },

34
src/views/reservoir/safeOperation/index.vue

@ -20,7 +20,9 @@
<div class="btn mb-10 cursor-pointer" @click="showTreeBox = !showTreeBox"> <div class="btn mb-10 cursor-pointer" @click="showTreeBox = !showTreeBox">
图层管理 图层管理
</div> </div>
<div class="btn cursor-pointer">二维地图</div> <div class="btn cursor-pointer" @click="handleChangeMode">
{{ mapSceneType === 3 ? "三" : "二" }}维地图
</div>
</div> </div>
<!-- 树结构浮窗 --> <!-- 树结构浮窗 -->
@ -78,6 +80,7 @@ import {
import { queryLayersByPos } from "./js/mapUtils"; import { queryLayersByPos } from "./js/mapUtils";
import { throttle } from "lodash-es"; import { throttle } from "lodash-es";
import { devRun } from "@/utils";
const emitter = mitt(); const emitter = mitt();
@ -92,7 +95,7 @@ export default {
data() { data() {
return { return {
showDialog: false, showDialog: false,
mapType: "2D", // 3D mapSceneType: 2, // 2: 2D, 3: 3D
showTreeBox: false, showTreeBox: false,
defaultProps: { defaultProps: {
children: "layers", children: "layers",
@ -115,13 +118,26 @@ export default {
}).then((res) => { }).then((res) => {
let id = res.records?.[0]?.id; let id = res.records?.[0]?.id;
getLayerData(id).then((res) => { getLayerData(id).then((res) => {
console.log("res >>>>> ", res);
this.treeData = res.data.children; this.treeData = res.data.children;
}); });
}); });
}, },
handleChangeMode() {
this.mapSceneType = this.mapSceneType === 3 ? 2 : 3;
viewer?.changeSceneMode(this.mapSceneType);
let position = new sycim.Position(113.27, 23.13, 600000, 0, -90, 0);
viewer?.flyToPosition(
position,
() => {
console.log("移动结束 >>>>> ");
},
1
);
},
initMap() { initMap() {
viewer = new sycim.Viewer("reservoir-map-container"); viewer = new sycim.Viewer("reservoir-map-container", {
sceneMode: this.mapSceneType, // 2: 2D, 3: 3D
});
window.viewer = viewer; window.viewer = viewer;
let baseLayer = sycim.ImageryLayerFactory.createImageryLayer( let baseLayer = sycim.ImageryLayerFactory.createImageryLayer(
sycim.ImageryType.ARCGIS, sycim.ImageryType.ARCGIS,
@ -206,6 +222,9 @@ export default {
window.viewer.on( window.viewer.on(
sycim.MouseEventType.MOUSE_MOVE, sycim.MouseEventType.MOUSE_MOVE,
throttle((e) => { throttle((e) => {
if (!e.wgs84SurfacePosition) {
return;
}
queryLayersByPos(e.wgs84SurfacePosition, this.layerList, (res) => { queryLayersByPos(e.wgs84SurfacePosition, this.layerList, (res) => {
if (res) { if (res) {
this.handleAddHtmlLayer(e.wgs84SurfacePosition, res); this.handleAddHtmlLayer(e.wgs84SurfacePosition, res);
@ -220,10 +239,13 @@ export default {
openDialog(e) { openDialog(e) {
console.log("openDialog >>>>> ", e); console.log("openDialog >>>>> ", e);
let code = e;
this.showDialog = true; this.showDialog = true;
this.$nextTick(() => { this.$nextTick(() => {
// this.$refs.detailRef.initData(e); devRun(() => {
this.$refs.detailRef.initData("440111000034"); code = "440111000034";
});
this.$refs.detailRef.initData(code);
}); });
}, },
// layer // layer

2
vue.config.js

@ -23,7 +23,7 @@ module.exports = {
outputDir: 'dist', outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: 'static', assetsDir: 'static',
// 是否开启eslint保存检测,有效值:ture | false | 'error' // 是否开启eslint保存检测,有效值:true | false | 'error'
lintOnSave: process.env.NODE_ENV === 'development', lintOnSave: process.env.NODE_ENV === 'development',
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false, productionSourceMap: false,

Loading…
Cancel
Save