فهرست منبع

修改历史曲线

tengmingxue 2 سال پیش
والد
کامیت
c7d48d5585

+ 27 - 3
src/views/shiYuan/common/MonitorCurve/index.vue

@@ -5,6 +5,7 @@
       v-dialogDrag
       title="历史监测信息"
       :visible.sync="dialogVisible"
+      v-if="dialogVisible"
       :modal="false"
       :append-to-body="true"
       width="1200px"
@@ -266,7 +267,11 @@ export default {
       timeType: 1,
     };
   },
-  mounted() {},
+  created() {
+  },
+  mounted() {
+
+  },
   watch: {
     radio(val, oldVal) {
       // if (val == 3) this.form['date'] = this.getSevenDate()
@@ -276,6 +281,20 @@ export default {
     },
   },
   methods: {
+    initDate() {
+      let start =new Date(new Date() - 24*60*60*1000);
+      const end = new Date();
+      const sYear = start.getFullYear()
+      const sMonth = (start.getMonth() + 1) > 9 ? start.getMonth() + 1 : '0' + (start.getMonth() + 1)
+      const sDay = start.getDate() > 9 ? start.getDate() : '0' + start.getDate()
+      let sTime = sYear + '-' + sMonth + '-' + sDay + ''
+      const eYear = end.getFullYear()
+      const eMonth = (end.getMonth() + 1) > 9 ? end.getMonth() + 1 : '0' + (end.getMonth() + 1)
+      const eDay = end.getDate() > 9 ? end.getDate() : '0' + end.getDate()
+      let eTime = eYear + '-' + eMonth + '-' + eDay + ''
+      return [sTime,eTime]
+    },
+
     show(siteId = null) {
       Object.assign(this.$data, this.$options.data());
       this.getSites(siteId);
@@ -321,9 +340,13 @@ export default {
      * 曲线
      */
     getCurve() {
+      let date = this.initDate()
+      if(this.form.date.length == 0) this.form.date = date
       let params = {
         code: this.form.displayCode,
         deviceIds: this.form.siteId,
+        start:(this.form.date.length == 0 ? date[0]:this.form.date[0]) + ' 00:00:00',
+        end:(this.form.date.length == 0 ? date[1]:this.form.date[1]) + ' 23:59:59',
         size: 10000,
         current: 1,
       };
@@ -541,8 +564,9 @@ export default {
      * 查询
      */
     query() {
-      let params = this.readyParams();
-      this.getHistoryCurve(params);
+      //let params = this.readyParams();
+      //this.getHistoryCurve(params);
+      this.getCurve()
     },
     getSeries(seriesList) {
       let list = [];

+ 92 - 5
src/views/shiYuan/monitoringCenter/partitionManage/components/dmaSettingDialog/index.vue

@@ -619,12 +619,8 @@
   </div>
 </template>
 <script>
-import proj4 from "@/components/proj4/index.js";
-import GeoJSON from "ol/format/GeoJSON";
 import { esriConfig, appconfig } from "staticPub/config";
 import request from "@/utils/request";
-import { getMaterialList, getAvgPress } from "@/api/DMA/zoningManage";
-import { queryDevice } from "@/api/scadaApi";
 import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer";
 import { OSM, XYZ, Vector as VectorSource } from "ol/source";
 import {
@@ -636,6 +632,7 @@ import {
   Stroke,
   Text,
 } from "ol/style";
+import { Select, Pointer, Draw, Modify } from "ol/interaction";
 import olMap from "@/views/components/olMap/index.vue";
 import { getArea, getLength } from "ol/sphere";
 import ol from "ol";
@@ -716,6 +713,10 @@ export default {
       geoservers: mapConfig.geoservers || [],
       vectorSource: null,
       vectorLayer: null,
+      editVectorSource:null,
+      editVectorLayer: null,
+      editSelect:null,
+      editModify:null
     };
   },
   watch: {
@@ -896,6 +897,10 @@ export default {
                   this.lineColor = geo.symbol.outline.color; //边线颜色
                   this.opacity = geo.symbol.opacity; //透明度
                   this.polygonColor = geo.symbol.color;
+                  this.polygon = null;
+                  const rings = geo.hasOwnProperty("rings") ? geo.rings : null;
+                  if (rings == null) return;
+                  this.polygon = new WKT().readFeature(rings);
                 } else {
                   this.deleteDraw();
                 }
@@ -1216,7 +1221,89 @@ export default {
       }
     },
 
-    editDraw() {},
+    /**
+     * 分区图形编辑
+     */
+    editDraw() {
+      if (this.polygon == null) return;
+      this.removeEditFeature();
+      this.removeEditVectorLayer();
+      let map = this.$refs.olmap.map;
+      this.editVectorSource = new VectorSource({ wrapX: false });
+      this.editVectorLayer = new VectorLayer({
+        source: this.editVectorSource,
+        style: new Style({
+          //边框样式
+          stroke: new Stroke({
+            color: "blue",
+            width: 3,
+          }),
+          //填充样式
+          fill: new Fill({
+            color: "rgba(0, 0, 255, 0.3)",
+          }),
+        }),
+      });
+      map.addLayer(this.editVectorLayer);
+      this.editVectorSource.addFeature(this.polygon);
+      // 先选择在修改.每次只编辑一个图形
+      this.editSelect = new Select({
+        layers: [this.editVectorLayer],
+        feature: this.editVectorSource.getFeatures(),
+      });
+      map.addInteraction(this.editSelect);
+      // 传入选中的图形
+      // 这样做之后,需要点击选中要素才可以进行编辑
+      this.editModify = new Modify({
+        features: this.editSelect.getFeatures(),
+      });
+
+      this.editModify.on('modifyend',(evt)=>{
+        let feature = evt.features.array_[0]
+        this.drawFeature = feature
+        if (this.drawFeature) {
+          this.isHavePolygon = true;
+          this.queryFeaturesByPolygon();
+          this.polygon = feature;
+        }
+      })
+      map.addInteraction(this.editModify);
+      this.editSelect.setActive(true);
+      this.editModify.setActive(true);  
+    },
+
+    /**
+     * 移除feature
+     */
+    removeEditFeature() {
+      let that = this;
+      if (this.editVectorLayer) {
+        that.editVectorLayer
+          .getSource()
+          .getFeatures()
+          .forEach((feature) => {
+            that.editVectorLayer.getSource().removeFeature(feature);
+          });
+      }
+    },
+
+    /**
+     * 移除VectorLayer
+     */
+    removeEditVectorLayer() {
+      if (this.editVectorLayer) {
+        let that = this;
+        let map = this.$refs.olmap.map;
+        that.editVectorLayer
+          .getSource()
+          .getFeatures()
+          .forEach((feature) => {
+            that.editVectorLayer.getSource().removeFeature(feature);
+          });
+        that.features = [];
+        map.removeLayer(that.editVectorLayer);
+      }
+    },
 
     editCancel() {},