Selaa lähdekoodia

优化环路添加途经点时候方便点的选择,默认加一个小旗子在换热站的地址上,让改地址居中,方便找位置。并优化新增时候切换换热站时更新这个小旗子的地址

yanglzh 2 vuotta sitten
vanhempi
sitoutus
49198b1adc
2 muutettua tiedostoa jossa 30 lisäystä ja 1 poistoa
  1. 1 0
      public/imgs/flag.svg
  2. 29 1
      src/views/heating/heatStation/loop/component/edit.vue

+ 1 - 0
public/imgs/flag.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1669819581058" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7858" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M815.55392 597.333333H187.07392V0h628.48a64 64 0 0 1 58.453333 89.173333l-82.346666 192.853334a42.666667 42.666667 0 0 0 0 33.706666l82.773333 192.853334A64 64 0 0 1 815.55392 597.333333z" fill="#FC284F" p-id="7859"></path><path d="M791.660587 315.306667a42.666667 42.666667 0 0 1-3.413334-16.64H187.07392v298.666666h628.48a64 64 0 0 0 58.88-89.173333z" fill="#C4264F" p-id="7860"></path><path d="M187.07392 1024a42.666667 42.666667 0 0 1-42.666667-42.666667V42.666667a42.666667 42.666667 0 0 1 85.333334 0v938.666666a42.666667 42.666667 0 0 1-42.666667 42.666667z" fill="#5E3841" p-id="7861"></path></svg>

+ 29 - 1
src/views/heating/heatStation/loop/component/edit.vue

@@ -9,7 +9,7 @@
 					<el-input v-model="ruleForm.code" placeholder="请输入环路编号" />
 				</el-form-item> -->
         <el-form-item label="所属换热站" prop="stationId">
-          <el-tree-select v-model="ruleForm.stationId" :data="treeData" :props="{
+          <el-tree-select v-model="ruleForm.stationId" :data="treeData" @change="stationChange" :props="{
 							label: 'name',
 							children: 'children'
 						}" node-key="id" :clearable="true" filterable check-strictly style="width: 100%;" :render-after-expand="true" />
@@ -106,6 +106,7 @@ import { reactive, toRefs, defineComponent, ref, unref, nextTick } from 'vue';
 import api from '/@/api/heatStation';
 import datahubApi from '/@/api/datahub';
 import { ElMessage } from 'element-plus';
+import { number } from 'echarts';
 interface Point {
   sort?: number;
   lnt: number;
@@ -134,6 +135,7 @@ export default defineComponent({
     let BMapGL: any = null
     let polyline: any = null
     let startDraw = false
+    let stationInfo: any = null
 
     const formRef = ref<HTMLElement | null>(null);
     const state = reactive({
@@ -240,11 +242,27 @@ export default defineComponent({
             lng: item.lnt,
           }))
 
+          // 绘制换热站
+          stationInfo = res.stationInfo
+          setStationMarker()
+
           // 绘制点线
           state.pointList.forEach((point: any) => map.addOverlay(new BMapGL.Marker(point)))
           setLine(state.pointList)
+
         })
     }
+
+    function setStationMarker() {
+      map.clearOverlays()
+      const { lnt: lng, lat } = stationInfo
+      map.centerAndZoom({ lng, lat }, 18);
+      map.addOverlay(new BMapGL.Marker({ lng, lat }, {
+        icon: new BMapGL.Icon("/imgs/flag.svg", new BMapGL.Size(40, 40), {
+          anchor: new BMapGL.Size(10, 40)   // 设置图片偏移  
+        }),
+      }));
+    }
     // 新增
     const onSubmit = () => {
       const formWrap = unref(formRef) as any
@@ -292,6 +310,7 @@ export default defineComponent({
       startDraw = true
       state.pointList = []
       map.clearOverlays();
+      setStationMarker()
 
       // if (state.pointList.find((item: any) => item.editFalg)) {
       //   ElMessage.warning('请先保存途经点')
@@ -370,7 +389,16 @@ export default defineComponent({
     //   state.pointIndex = index
     // }
 
+    function stationChange(id: number) {
+
+      api.heatStation.detail(id).then((res: any) => {
+        stationInfo = res
+        setStationMarker()
+      })
+    }
+
     return {
+      stationChange,
       openDialog,
       closeDialog,
       onCancel,