管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-01-16 3c0bcd367dbc9aff25202d1a8ec2eb143f3e8261
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"
@@ -9,36 +13,43 @@
        >
          <el-option
            :value="menuTopFrom.queryLayer"
            style="overflow: auto; height: 100%"
            style="height: 100%"
          >
            <el-tree
              :data="layerData"
              show-checkbox
              node-key="id"
              ref="tree"
              accordion
              highlight-current
              :props="defaultProps"
            >
            </el-tree>
            <div style="margin-top: 5px">
              <el-button size="mini" plain @click="getCheckedNodes"
                >确认</el-button
            <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="mini"
                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>
      </el-form-item>
      <el-form-item>
        <el-select v-model="menuTopFrom.queryType" placeholder="请选择...">
        <el-select
          @change="changeValue($event)"
          v-model="menuTopFrom.queryType"
          placeholder="请选择..."
        >
          <el-option
            v-for="item in queryOption"
            :key="item.value"
@@ -52,30 +63,41 @@
        <input
          :accept="'.shp, .shx, .dbf, .prj'"
          style="display: none"
          ref="pathClear"
          type="file"
          name="file"
          id="getMenuTopFile"
          multiple="multiple"
          @change="setMenuTopFile()"
        />
        <el-link @click="getMenuTopFile" :underline="false"
        <!-- <el-link @click="getMenuTopFile" :underline="false"
          >导入选择范围</el-link
        >
        > -->
      </el-form-item>
      <el-form-item>
        <el-button plain @click="getAttributeQuery">查询</el-button>
        <el-button type="info" 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>
    <queryinfo ref="queryinfo" />
  </div>
</template>
<script>
import queryinfo from "../../views/Tools/queryinfo.vue"
import $ from 'jquery';
import { inquiry_SelectTabs, inquiry_uploadShp, encr } from '../../api/api.js';
import { getToken } from '@/utils/auth';
import * as turf from '@turf/turf';
export default {
  components: { queryinfo },
  data() {
    return {
      menuTopFrom: {
@@ -85,12 +107,14 @@
      layerData: [
        {
          id: 1,
          label: '基础数据',
          tabDesc: '基础数据',
          value: 'BD',
          children: [],
        },
        {
          id: 2,
          label: '业务数据',
          tabDesc: '业务数据',
          value: 'BS',
          children: [],
@@ -118,10 +142,14 @@
          value: 'polygon',
          label: '多边形',
        },
        {
          value: 'inputFile',
          label: '导入选择范围',
        },
      ],
      defaultProps: {
        children: 'children',
        label: 'tabDesc',
        label: 'label',
      },
      graphicLayer: null,
    };
@@ -134,6 +162,15 @@
    this.getAllTable();
  },
  methods: {
    changeValue(value) {
      // var obj = {};
      // obj = this.queryOption.find(function (item) {
      //   return item.value === value;
      // });
      // if (obj.value == 'inputFile') {
      //   this.getMenuTopFile();
      // }
    },
    async getAllTable() {
      const data = await inquiry_SelectTabs();
      if (data.code != 200) {
@@ -144,6 +181,7 @@
      for (var i in option) {
        var val_Data = option[i];
        val_Data.id = '1' + i;
        val_Data.label = val_Data.tabDesc + '(' + val_Data.tab + ')';
        if (option[i].ns == 'bd') {
          this.layerData[0].children.push(val_Data);
        } else {
@@ -198,6 +236,7 @@
            return this.$message.error('用户角色请求错误');
          }
          this.$store.state.mapMenuShpFile = rs.result;
          this.showMapMenuPop();
        },
        error: (e) => {
          console.log(e);
@@ -212,17 +251,25 @@
      //清空标绘
      sgworld.Creator.SimpleGraphic.edit(false, { editProp: false });
      sgworld.Creator.SimpleGraphic.clear();
      var val = document.getElementById('getMenuTopFile').files;
      if (!val || !val.length) {
      if (this.treeChange.length == 0) {
        this.$message.error('请选择要查询的数据');
        return;
      }
      if (this.menuTopFrom.queryType != 'inputFile') {
        sgworld.Creator.createSimpleGraphic(
          this.menuTopFrom.queryType,
          {},
          {
            color: '#00FF0060',
            outlineColor: '#0f0',
            outlineWidth: 5,
          },
          (entity) => {
            this.setTurfGeometry(entity);
          }
        );
      } else {
        this.showMapMenuPop();
        this.getMenuTopFile();
      }
    },
    setTurfGeometry(res) {
@@ -277,7 +324,6 @@
      if (type == 'polyline') {
        var line = turf.lineString(std, { name: 'polyline' });
        restVal = turf.buffer(line, 10, { units: 'miles' });
        console.log('line', restVal);
      } else if (type == 'rectangle') {
        var ste = this.setCartesianToEightFour(res[0]);
        std.push([ste.lng, ste.lat]);
@@ -291,24 +337,44 @@
    },
    setJonToWKT(res) {
      console.log(res.geometry)
      var jsonToWkt = this.$wkt.convert(res.geometry);
      this.$store.state.mapMenuShpFile = encr(jsonToWkt);
      this.showMapMenuPop();
    },
    showMapMenuPop() {
      console.log(this.treeChange);
      this.$store.state.mapSpaceQueryLayer = this.treeChange;
      if (
        this.$store.state.mapPopBoolean != true &&
        this.$store.state.mapPopBoxFlag != '1'
      ) {
        this.$store.state.mapPopBoolean = true;
        this.$store.state.mapPopBoxFlag = '1';
      }
      this.$store.state.mapPopBoxFlag = '1';
      // this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close();
      this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.open("空间查询", null, {
        close: () => {
         if (this.$store.state.primitLayer != null) {
            sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
            this.$store.state.primitLayer = null;
          }
          if (window.Viewer.scene.primitives.length != 0) {
            window.Viewer.scene.primitives.removeAll()
          }
        }
      });
      this.$bus.$emit('changeMapMenuTop', 'true');
      sgworld.Creator.SimpleGraphic.edit(false, { editProp: false });
      sgworld.Creator.SimpleGraphic.clear();
      //清空inputFile
      var file = document.getElementById('getMenuTopFile');
      file.outerHTML = file.outerHTML;
      // var file = document.getElementById('getMenuTopFile');
      // file.outerHTML = file.outerHTML;
      this.$refs.pathClear.value = '';
    },
    clearQuery() {
      this.$refs.pathClear.value = '';
      this.treeChange = [];
      this.menuTopFrom.queryLayer = null;
      this.menuTopFrom.queryType = 'rectangle';
      this.$refs.tree.setCheckedKeys([]);
      sgworld.Creator.SimpleGraphic.clear();
    },
    setCartesianToEightFour(res) {
      var std = {};
@@ -323,7 +389,7 @@
};
</script>
<style lang="less">
<style lang="less" scoped>
.menuBox {
  width: 98%;
  height: 100%;
@@ -338,4 +404,12 @@
  padding: 4px 20px;
  font-weight: 400;
}
/deep/.el-input__inner {
  background-color: transparent !important ;
  color: #fff;
  border: 1px solid;
}
/deep/ .el-select .el-input__inner {
  border-color: #fff !important;
}
</style>