管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-04-11 78ab9cd3f487cc271ea5b3a10cb9d2491b78767e
src/components/MapView/mapMenuTop.vue
@@ -1,6 +1,10 @@
<template>
  <div class="menuBox">
    <el-form :inline="true" :model="menuTopFrom" class="demo-form-inline">
    <el-form
      :inline="true"
      :model="menuTopFrom"
      class="demo-form-inline"
    >
      <el-form-item>
        <el-select
          v-model="menuTopFrom.queryLayer"
@@ -8,30 +12,33 @@
          placeholder="请选择..."
          :popper-append-to-body="false"
        >
          <el-option :value="menuTopFrom.queryLayer" style="height: 100%">
          <el-option
            :value="menuTopFrom.queryLayer"
            style="height: 100%"
          >
            <div style="height: 200px; overflow: auto">
              <el-tree
                :data="layerData"
                show-checkbox
                node-key="id"
                ref="tree"
                accordion
                highlight-current
                :props="defaultProps"
              >
              </el-tree>
            </div>
            <div style="margin-top: 5px">
              <el-button size="small" plain @click="getCheckedNodes"
                >确认</el-button
              >
              <el-button
                size="small"
                plain
                @click="getCheckedNodes"
              >确认</el-button>
              <el-button
                size="small"
                type="info"
                plain
                @click="resetCheckedNodes"
                >重置</el-button
              >
              >重置</el-button>
            </div>
          </el-option>
        </el-select>
@@ -70,12 +77,17 @@
      </el-form-item>
      <el-form-item>
        <el-button plain size="small" @click="getAttributeQuery"
          >查询</el-button
        >
        <el-button type="info" size="small" @click="clearQuery" plain
          >重置</el-button
        >
        <el-button
          plain
          size="small"
          @click="getAttributeQuery"
        >查询</el-button>
        <el-button
          type="info"
          size="small"
          @click="clearQuery"
          plain
        >重置</el-button>
      </el-form-item>
      <!-- <el-form-item>
        <el-button
@@ -93,15 +105,21 @@
    <queryinfo ref="queryinfo" />
    <!-- <div class="buffer-container" ></div> -->
    <el-dialog
      v-dialogDrag
      custom-class="buffer-dialog"
      top="40vh"
      title="管道中心线查询"
      :visible.sync="dialogFormVisible"
      :modal="false"
      :lock-scroll="false"
      :close-on-click-modal="false"
      width="25%"
      @opened="dialogOpend"
    >
      <el-form :model="menuTopFrom" label-width="150px">
      <el-form
        :model="menuTopFrom"
        label-width="150px"
      >
        <el-form-item label="管道中心线">
          <el-select
            @change="changeSelect2"
@@ -136,14 +154,23 @@
          <el-input-number
            v-model="menuTopFrom.bufferSize"
            placeholder=""
            @change="handleBufferChange"
            :step="500"
          ></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="genBuffer">确 定</el-button>
        <el-button
          type="primary"
          @click="changeBufferData"
        >确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
@@ -153,41 +180,43 @@
import {
  inquiry_SelectTabs,
  inquiry_uploadShp,
  decr,
  encr,
  dataLib_selectTabs,
  pipelines_selectSegNames,
  dataLib_selectTabed
} from "../../api/api.js"
import { selectPipelines } from "@/api/screen.js"
import { getToken } from "@/utils/auth"
import * as turf from "@turf/turf"
import { wktToGeoJSON } from "@terraformer/wkt"
export default {
  components: { queryinfo },
  data() {
    return {
      selectTree: "",
      menuTopFrom: {
        queryType: "",
        pipeline: "",
        segName: "",
        bufferSize: 10,
        bufferSize: 5000,
      },
      treeChange: [],
      layerData: [
        {
          id: 1,
          label: "基础数据",
          tabDesc: "基础数据",
          value: "BD",
          children: [],
        },
        {
          id: 2,
          label: "业务数据",
          tabDesc: "业务数据",
          value: "BS",
          children: [],
        },
        // {
        //   id: 1,
        //   label: "基础数据",
        //   tabDesc: "基础数据",
        //   value: "BD",
        //   children: [],
        // },
        // {
        //   id: 2,
        //   label: "业务数据",
        //   tabDesc: "业务数据",
        //   value: "BS",
        //   children: [],
        // },
      ],
      queryOption: [
@@ -232,6 +261,10 @@
      featureLayer: [],
      analyGid: null,
      dialogFormVisible: false,
      bufferLinePosition: [],
      dialogExtentVisible: false,
      setExtent: 10,
      wktExtent: null,
    }
  },
@@ -239,8 +272,67 @@
    this.menuTopFrom.queryType = "rectangle"
    this.getAllTable()
    this.getPipelineData()
    this.$bus.$on("setExtentBUff", res => {
      this.setExtentBuffer(res);
    })
  },
  watch: {
    analyGid(newVal, oldVal) {
      if (newVal !== oldVal && this.dialogFormVisible) {
        this.genBuffer()
      }
    },
  },
  methods: {
    setExtentBuffer(res) {
      // var wkt = this.$wkt.parse(this.wktExtent)
      // var wkt = encr(this.wktExtent)
      var wkt1 = decr(this.wktExtent)
      var wkt = this.$wkt.parse(wkt1)
      var restVal = turf.buffer(wkt, res, { units: "meters", steps: 64 })
      var options = { precision: 6, coordinates: 2 };
      var truncated = turf.truncate(restVal, options);
      var options1 = { tolerance: 0.01, highQuality: false };
      var simplified = turf.simplify(truncated, options1);
      var wkt2 = this.$wkt.convert(simplified.geometry)
      var wkt3 = encr(wkt2)
      this.$store.state.mapMenuShpFile = wkt3
      var points = simplified.geometry.coordinates[0]
      var degreesArray = this.pointsToDegreesArray(points)
      let array = Cesium.Cartesian3.fromDegreesArray(degreesArray)
      const hierarchy = new Cesium.PolygonHierarchy(array)
      const bufferPolygon = sgworld.Viewer.entities.add({
        polygon: {
          hierarchy: hierarchy,
          material: Cesium.Color.RED.withAlpha(0.5),
          classificationType: Cesium.ClassificationType.BOTH,
        },
      })
      this.bufferEntities.push(bufferPolygon)
      sgworld.Navigate.flyToObj(bufferPolygon)
      this.showMapMenuPop()
    },
    getDownLoadExtent(res) {
      this.wktExtent = res.result.wkt
      this.$bus.$emit('showExtentLayer', true);
      // this.dialogExtentVisible = true
      //           this.$store.state.mapMenuShpFile = rs.result.wkt
      //
    },
    changeValue(value) {
      var obj = {}
      obj = this.queryOption.find(function (item) {
@@ -249,50 +341,75 @@
      if (obj.value == "inputFile") {
        this.getMenuTopFile()
      } else if (obj.value == "buffer") {
        this.handleBuffer()
        this.dialogFormVisible = true
      }
    },
    async getAllTable() {
      const data = await dataLib_selectTabs({
        pageIndex: 1,
        pageSize: 500,
      const data = await dataLib_selectTabed({
        hasGeom: "true",
        name: null,
      })
      if (data.code != 200) {
        this.$message.error("列表调用失败")
      }
      var option = data.result.filter(res => {
        if (res.rows != 0) {
          return res
        }
      })
      for (var i in option) {
        var val_Data = option[i]
        val_Data.id = "1" + i
        val_Data.label = val_Data.tabDesc
        if (option[i].ns == "bd") {
          this.layerData[0].children.push(val_Data)
        } else {
          this.layerData[1].children.push(val_Data)
        }
      }
      var val = data.result
      // var std = [];
      // val.filter((item) => {
      //   if (std.indexOf(item.bak) == -1) {
      //     std.push(item.bak);
      //     this.layerData.push(
      //       {
      //         val: item.bak,
      //         label: item.bak,
      //         children: [],
      //       }
      //     )
      //   }
      // });
      // for (var i in this.layerData) {
      //   var item = this.layerData[i];
      //   for (var j in val) {
      //     var res = val[j];
      //     if (item.val === res.bak) {
      //       res.label = res.tabDesc
      //       this.layerData[i].children.push(res)
      //     }
      //   }
      // }
    },
    //获取选择树的节点
    getCheckedNodes() {
      var valTree = this.$refs.tree.getCheckedNodes()
      if (valTree.length == 0) return
      this.menuTopFrom.queryLayer = valTree[0].tabDesc
      this.menuTopFrom.queryLayer = null;
      this.$store.state.propertiesName = valTree[0];
      this.treeChange = [];
      for (var i = 0; i < valTree.length; i++) {
        if (valTree[i].entity) {
          if (!this.menuTopFrom.queryLayer) {
            this.menuTopFrom.queryLayer = valTree[i].tabDesc;
          }
          this.treeChange.push(valTree[i])
        }
      }
    },
    //清空树选中的节点
    resetCheckedNodes() {
      this.layerData = []
      this.getAllTable()
      this.$refs.tree.setCheckedKeys([]);
      this.treeChange = []
      this.menuTopFrom.queryLayer = null
      this.$refs.tree.setCheckedKeys([])
    },
    //导入shp文件
    async setMenuTopFile() {
@@ -317,6 +434,7 @@
        })
        return
      }
      var that = this;
      $.ajax(BASE_URL + "/inquiry/uploadShp?token=" + getToken(), {
        type: "post",
        data: formData,
@@ -326,11 +444,11 @@
        contentType: false,
        success: rs => {
          if (rs.code !== 200) {
            return this.$message.error("用户角色请求错误")
            return this.$message.error("数据解析失败")
          }
          this.$store.state.mapMenuShpFile = rs.result.wkt
          this.showMapMenuPop()
          that.getDownLoadExtent(rs);
        },
        error: e => {
          console.log(e)
@@ -356,6 +474,10 @@
        sgworld.Creator.DeleteObject(this.$store.state.primitLayer)
        this.$store.state.primitLayer = null
      }
      if (this.treeChange.length == 0) {
        this.$message.error("请选择要查询的数据")
        return
@@ -490,6 +612,8 @@
    },
    clearQuery() {
      // 清楚buffer
      this.layerData = [];
      this.getAllTable();
      this.clearBufferEntities()
      this.$refs.pathClear.value = ""
      this.treeChange = []
@@ -523,7 +647,6 @@
      std.alt = cartographic.height
      return std
    },
    handleBuffer() {},
    async getPipelineData() {
      const data = await pipelines_selectSegNames()
      if (data.code != 200) {
@@ -556,27 +679,21 @@
        if (item && wkt) {
          const line = wktToGeoJSON(wkt)
          // const line2 = wktToGeoJSON(wkt2)
          const position = line.coordinates
          // const position2 = line2.coordinates
          let position = line.coordinates
          if (wkt.includes("MULTILINESTRING")) {
            this.createBuffer(position.flat())
          } else {
            this.createBuffer(position)
            position = line.coordinates.flat()
          }
          this.bufferLinePosition = position
          if (this.dialogFormVisible) {
            this.createBuffer()
          }
        }
      }
      this.dialogFormVisible = false
      let wkt =
        "LINESTRING(114.82181424692999 33.697046488105,115.06065563205186 32.2808276171009,114.69405780892077 31.527280108790023)"
      let wkt2 =
        "MULTILINESTRING((115.35696516720873 33.51877172773311,117.76217256980829 32.44801812803422,118.69492094774364 32.31899881794112))"
      // console.log("line1", position)
      // console.log("line2", position2)
    },
    createBuffer(position) {
    createBuffer() {
      this.clearBufferEntities()
      const position = this.bufferLinePosition
      const buffRadius = this.menuTopFrom.bufferSize
      var polylineF = turf.lineString(position)
      var bufferd = turf.buffer(polylineF, buffRadius, { units: "meters" })
@@ -596,6 +713,12 @@
      })
      this.bufferEntities.push(bufferPolygon)
      let res = hierarchy.positions
      sgworld.Navigate.flyToObj(bufferPolygon)
      this.flyEntity = res
    },
    changeBufferData() {
      this.dialogFormVisible = false
      let res = this.flyEntity
      let restVal,
        std = []
      for (let i in res) {
@@ -604,13 +727,12 @@
      }
      restVal = turf.polygon([std], { name: "polygon" })
      this.flyEntity = res
      sgworld.Navigate.flyToObj(bufferPolygon)
      console.log("bufferPolygon", res)
      console.log("bufferPolygon", restVal)
      this.setJonToWKT(restVal)
    },
    pointsToDegreesArray(points) {
      let degreesArray = []
      points.forEach(item => {
@@ -623,6 +745,7 @@
      this.bufferEntities.forEach(entity => {
        sgworld.Viewer.entities.remove(entity)
      })
      this.flyEntity = null
    },
    changeSelect2(res) {
      var value = this.featureLayer
@@ -633,8 +756,9 @@
        }
      }
      this.segNameOption = option
      this.menuTopFrom.segName = option[0].segName || '<空>'
      this.menuTopFrom.segName = option[0].segName || "<空>"
      this.analyGid = option[0].gid
      this.genBuffer()
    },
    selectChangeGid(res) {
      this.analyGid = res
@@ -652,6 +776,12 @@
      })
      return restVal
    },
    handleBufferChange(val, oldVal) {
      this.createBuffer()
    },
    dialogOpend() {
      this.createBuffer()
    }
  },
}
</script>
@@ -685,25 +815,33 @@
<style lang="less">
.menuBox {
  .buffer-dialog {
    background-color: rgba(244, 248, 255, 0.85) !important;
    border: 1px solid rgba(32, 160, 255, 0.6);
    color: #202020;
    .el-dialog__header {
      padding: 10px 20px;
      border-bottom: 1px solid rgba(32, 160, 255, 0.6);
  .el-dialog__wrapper {
    pointer-events: none;
    .buffer-dialog {
      top: 355px;
      background-color: rgba(244, 248, 255, 0.85) !important;
      border: 1px solid rgba(32, 160, 255, 0.6);
      color: #202020;
      .el-dialog__body,
      .el-dialog__header,
      .el-dialog__footer {
        pointer-events: auto;
      }
      .el-dialog__header {
        padding: 10px 20px;
        border-bottom: 1px solid rgba(32, 160, 255, 0.6);
      .el-dialog__headerbtn {
        top: 10px;
        font-size: 18px;
        .el-dialog__headerbtn {
          top: 10px;
          font-size: 18px;
        }
      }
      .el-form-item {
        .el-input-number {
          width: 202px;
        }
      }
    }
    .el-form-item {
      .el-input-number {
        width: 202px;
      }
    }
  }
}
</style>