管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2022-12-26 82fe506bd7ab485bb590ff8b5ee5401cbcaa0759
src/components/MapView/mapMenuPop.vue
@@ -1,6 +1,17 @@
<template>
  <div class="menuPop">
    <div class="leftBox">
      <div
        class="leftDown"
        v-if="$store.state.download"
      >
        <div @click="getDownloadDep">
          <el-link
            style="color:white"
            icon="el-icon-download"
          > </el-link>
        </div>
      </div>
      <ul>
        <li
          v-for="(item, index) in option"
@@ -12,7 +23,6 @@
      </ul>
    </div>
    <div class="rightBox">
      <div class="tableBox">
        <el-table
          :data="tableData"
@@ -26,7 +36,11 @@
            label="序号"
            width="50"
          />
          <el-table-column label="定位" width="100" align="center">
          <el-table-column
            label="定位"
            width="100"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                icon="el-icon-map-location"
@@ -73,14 +87,20 @@
        label-width="100px"
        class="codeForm"
      >
        <el-form-item :label="$t('common.passworld')" prop="password">
        <el-form-item
          :label="$t('common.passworld')"
          prop="password"
        >
          <el-input
            type="password"
            v-model="codeForm.password"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item :label="$t('common.SPassword')" prop="repassword">
        <el-form-item
          :label="$t('common.SPassword')"
          prop="repassword"
        >
          <el-input
            type="password"
            v-model="codeForm.repassword"
@@ -92,13 +112,82 @@
            class="primary"
            size="small"
            @click="download('codeForm')"
            >{{ $t('common.confirm') }}</el-button
          >
          <el-button type="info" size="small" @click="closeDown('codeForm')">{{
            $t('common.cancel')
          >{{ $t("common.confirm") }}</el-button>
          <el-button
            type="info"
            size="small"
            @click="closeDown('codeForm')"
          >{{
            $t("common.cancel")
          }}</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog
      title="数据申请"
      :visible.sync="dialogInsertVisible"
      width="30%"
      top="35vh"
      :modal="false"
      :before-close="handleInsertClose"
    >
      <div style="width:100%; max-height:450px;overflow-y:auto">
        <el-form
          ref="form"
          :model="ruleForm"
          label-width="100px"
        >
          <el-form-item label="审核单位">
            <div>
              <ul>
                <li v-for="item in ruleForm.depname">
                  {{item.name}}
                </li>
              </ul>
            </div>
          </el-form-item>
          <el-form-item label="表名">
            <div>
              <ul>
                <li v-for="item in ruleForm.tabs">
                  {{item.tabDesc}}
                </li>
              </ul>
            </div>
          </el-form-item>
          <el-form-item label="条件">
            <el-input
              :title="ruleForm.wkt"
              v-model=" ruleForm.wkt"
              disabled
            ></el-input>
          </el-form-item>
          <el-form-item label="描述">
            <el-input
              type="textarea"
              placeholder="请输入内容"
              v-model="ruleForm.descr"
              maxlength="50"
              show-word-limit
            >
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              class="primary"
              size="small"
              @click="getInsertDown"
            >{{ $t("common.confirm") }}</el-button>
            <el-button
              type="info"
              size="small"
              @click="closeInsertDown"
            >{{
            $t("common.cancel")
          }}</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
    <iframe
      id="Iframe1"
@@ -116,17 +205,20 @@
  dataQuerySelectWktById,
  sign_getPublicKey,
  dataLib_selectDownloadFile,
  decr,
} from '../../api/api.js';
import { getToken } from '@/utils/auth';
import $ from 'jquery';
  dataQuery_selectDbOverflowDep,
  apply_insertApply,
  decr, encr,
} from "../../api/api.js";
import { getToken } from "@/utils/auth";
import $ from "jquery";
import { View } from "ol";
export default {
  data() {
    var repasswordValidator = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.codeForm.password) {
        callback(new Error('两次输入密码不一致!'));
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
@@ -135,26 +227,45 @@
      var passwordreg =
        /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![a-z0-9]+$)(?![a-z\W!@#$%^&*`~()\\-_+=,.?;<>]+$)(?![0-9\W!@#$%^&*`~()\\-_+=,.?;<>]+$)[a-zA-Z0-9\W!@#$%^&*`~()\\-_+=,.?;<>]{12,20}$/;
      if (!passwordreg.test(value)) {
        callback(new Error('密码必须由数字、字母、特殊字符组合,请输入13-20位'));
        callback(new Error("密码必须由数字、字母、特殊字符组合,请输入13-20位"));
      } else {
        callback();
      }
    };
    return {
      ruleForm: {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      },
      dialogVisible: false,
      dialogInsertVisible: false,
      insertFlag: null,
      codeForm: {
        password: '',
        repassword: '',
        password: "",
        repassword: "",
      },
      rules: {
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { validator: passwordValidator, trigger: 'blur' },
          { required: true, message: "请输入密码", trigger: "blur" },
          { validator: passwordValidator, trigger: "blur" },
        ],
        repassword: [
          { required: true, message: '请输入确认密码', trigger: 'blur' },
          { validator: repasswordValidator, trigger: 'blur' },
          { required: true, message: "请输入确认密码", trigger: "blur" },
          { validator: repasswordValidator, trigger: "blur" },
        ],
      },
      insertOption: {
        ids: [],
        pwd: null,
        tabs: [],
        entity: [],
        wkt: null,
        descr: null,
      },
      listPage: {
        pageSize: 10,
@@ -178,9 +289,68 @@
      domainsLayer: [],
      optionx: [],
      imagePoint: null,
      Layerprimit: null,
    };
  },
  methods: {
    getInsertDown() {
      this.dialogInsertVisible = false;
      this.dialogVisible = true;
    },
    handleInsertClose() {
      this.$confirm('确认关闭?')
        .then(_ => {
          this.closeInsertDown();
        })
        .catch(_ => { });
    },
    closeInsertDown() {
      this.ruleForm = {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      }
      this.dialogInsertVisible = false
    },
    async getDownloadDep() {
      var std = [];
      for (var i in this.option) {
        std.push(this.option[i].entity
        )
      }
      var obj = {
        entities: std,
        wkt: this.listdata.wkt
      }
      const data = await dataQuery_selectDbOverflowDep(JSON.stringify(obj))
      if (data.code != 200) {
        this.$message.error("数据请求失败");
        return;
      }
      if (data.result.length == 0 || data.result == null) {
        this.insertFlag = 1;
        this.dialogVisible = true;
      } else {
        this.insertFlag = 2;
        var std = [];
        this.insertOption.ids = data.result;
        for (var i in data.result) {
          std.push({
            name: data.result[i]
          })
        }
        this.ruleForm.depname = std;
        this.ruleForm.wkt = decr(this.listdata.wkt)
        this.ruleForm.tabs = this.option;
        this.dialogInsertVisible = true;
      }
    },
    async signGetPublicKey() {
      const res = await sign_getPublicKey();
      if (res && res.code == 200) {
@@ -188,32 +358,62 @@
        encrypt.setPublicKey(res.result);
      }
    },
    download() {
      if (this.codeForm.password == '') return;
      var obj = {
        pwd: encrypt.encrypt(this.codeForm.password),
        entities: [],
        wkt: this.listdata.wkt,
      };
      for (var i in this.option) {
        obj.entities.push(this.option[i].entity);
    async download() {
      if (this.codeForm.password == "") return;
      if (this.insertFlag == 1) {
        var obj = {
          pwd: encrypt.encrypt(this.codeForm.password),
          entities: [],
          wkt: this.listdata.wkt,
        };
        for (var i in this.option) {
          obj.entities.push(this.option[i].entity);
        }
        var token = getToken();
        var that = this;
        $.ajax(BASE_URL + "/dataLib/downloadDbReq?token=" + token, {
          type: "post",
          data: JSON.stringify(obj),
          async: true,
          cache: false,
          processData: false,
          contentType: false,
          success: (res) => {
            if (res.code != 200) {
              return;
            }
            this.selectDownloadFile(res.result, obj.pwd);
          },
        });
      } else if (this.insertFlag == 2) {
        var std = [];
        var std1 = [];
        for (var i in this.option) {
          std.push(this.option[i].tabDesc)
          std1.push(this.option[i].entity)
        }
        var obj = {
          ids: this.insertOption.ids,
          pwd: encr(this.codeForm.password),
          tabs: std,
          entities: std1,
          wkt: this.listdata.wkt,
          descr: this.ruleForm.descr,
        }
        const data1 = await apply_insertApply(JSON.stringify(obj))
        if (data1.code != 200) {
          this.$message.error("数据申请失败");
          return
        }
        this.$message({
          message: '数据申请成功',
          type: 'success'
        });
        this.closeDown();
      }
      var token = getToken();
      var that = this;
      $.ajax(BASE_URL + '/dataLib/downloadDbReq?token=' + token, {
        type: 'post',
        data: JSON.stringify(obj),
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: (res) => {
          if (res.code != 200) {
            return;
          }
          this.selectDownloadFile(res.result, obj.pwd);
        },
      });
    },
    async selectDownloadFile(rsid, rspwd) {
      var downObj = {
@@ -222,32 +422,33 @@
      };
      const data = await dataLib_selectDownloadFile(downObj);
      if (data.code != 200) {
        this.$message.error('下载请求失败');
        this.$message.error("下载请求失败");
        return;
      }
      this.closeDown();
      var token = getToken();
      var url =
        BASE_URL +
        '/dataLib/downloadFile?token=' +
        "/dataLib/downloadFile?token=" +
        token +
        '&guid=' +
        "&guid=" +
        rsid +
        '&pwd=' +
        "&pwd=" +
        encodeURIComponent(rspwd);
      $('#Iframe1').attr('src', url).click();
      $("#Iframe1").attr("src", url).click();
    },
    handleCloseDown() {
      this.$confirm('确认关闭?')
      this.$confirm("确认关闭?")
        .then((_) => {
          this.closeDown();
        })
        .catch((_) => {});
        .catch((_) => { });
    },
    closeDown() {
      this.dialogVisible = false;
      this.codeForm.password = '';
      this.codeForm.repassword = '';
      this.codeForm.password = "";
      this.codeForm.repassword = "";
      this.closeInsertDown();
    },
    startTableMssage() {
      this.listdata.pageIndex = 1;
@@ -260,7 +461,14 @@
      this.startTableMssage();
      this.listdata.wkt = this.$store.state.mapMenuShpFile;
      this.querylayer = this.$store.state.mapSpaceQueryLayer;
      this.option = this.$store.state.mapSpaceQueryLayer;
      //  = this.$store.state.mapSpaceQueryLayer;
      var arr = this.$store.state.mapSpaceQueryLayer;
      var obj = {};
      arr = arr.reduce(function (item, next) {
        obj[next.label] ? "" : (obj[next.label] = true && item.push(next));
        return item;
      }, []);
      this.option = arr;
      this.listdata.name = this.option[0].entity;
      this.getTableDateHidder();
@@ -268,11 +476,11 @@
    async getTableDateHidder() {
      const data = await inquiry_selectFields({ name: this.listdata.name });
      if (data.code != 200) {
        this.$message.error('列表调用失败');
        this.$message.error("列表调用失败");
      }
      const data1 = await inquiry_selectDomains({ name: this.listdata.name });
      if (data1.code != 200) {
        this.$message.error('列表调用失败');
        this.$message.error("列表调用失败");
      }
      this.optionx = [];
      this.attributeData = [];
@@ -304,7 +512,7 @@
      };
      const data = await dataQuerySelectWktById(param);
      if (data.code != 200) {
        this.$message.error('列表调用失败');
        this.$message.error("列表调用失败");
      }
      var val1 = decr(data.result);
@@ -319,19 +527,53 @@
    },
    setMapLoaction(res) {
      var coord = res.coordinates;
      if (res.type == 'Point') {
        this.imagePoint = sgworld.Creator.CreateLabel(
          { X: coord[0], Y: coord[1], Altitude: 2000 },
          '',
          SmartEarthRootUrl + 'Workers/image/mark.png',
          {
            disableDepthTestDistance: Infinity,
            scale: 0.8,
      if (this.Layerprimit != null) {
        window.Viewer.scene.primitives.remove(this.Layerprimit);
        this.Layerprimit = null;
      }
      if (res.type == "Point") {
        Viewer.camera.flyTo({
          destination: Cesium.Cartesian3.fromDegrees(coord[0], coord[1], 2000),
          orientation: {
            heading: Cesium.Math.toRadians(0), // 水平偏角,默认正北 0
            pitch: Cesium.Math.toRadians(-90), // 俯视角,默认-90,垂直向下
            roll: 0, // 旋转角
          },
        });
      } else if (res.type == "MultiPolygon") {
        var val = res.coordinates[0][0];
        var std = [];
        for (var i in val) {
          std.push({ x: val[i][0], y: val[i][1], z: 1000 });
        }
        this.$store.state.primitLayer = sgworld.Creator.createPolygon(
          std,
          {
            fillColor: "#ffff00",
            outlineColor: "#fff",
            outlineWidth: 2,
          },
          1,
          0,
          '巡检点'
          "面"
        );
        sgworld.Navigate.flyToObj(this.imagePoint.item);
        sgworld.Navigate.flyToObj(this.$store.state.primitLayer.item);
      } else if (res.type == "MultiLineString") {
        var line = res.coordinates[0];
        var std = [];
        for (var i in line) {
          std.push({ x: line[i][0], y: line[i][1], z: 1000 });
        }
        this.$store.state.primitLayer = sgworld.Creator.createPolyline(
          std,
          "#ffff00",
          1,
          0,
          "线"
        );
        sgworld.Navigate.flyToObj(this.$store.state.primitLayer.item);
      }
    },
    setTableChange(res) {
@@ -354,7 +596,7 @@
      const data = await dataQuery_selectByPage(this.listdata);
      if (data.code != 200) {
        this.$message.error('列表调用失败');
        this.$message.error("列表调用失败");
      }
      var val_Data = data.result;
@@ -372,7 +614,107 @@
      this.pageCount = data.count;
      this.tableData = data.result;
      this.$refs.dialogPayChannel.doLayout();
      this.showAllImage(data.result);
    },
    async showAllImage(res) {
      if (window.Viewer.scene.primitives.length != null) {
        window.Viewer.scene.primitives.removeAll();
      }
      if (this.$store.state.primitLayer != null) {
        sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
        this.$store.state.primitLayer = null;
      }
      for (var i in res) {
        var param = {
          gid: res[i].gid,
          name: this.listdata.name,
        };
        const data = await dataQuerySelectWktById(param);
        if (data.code != 200) {
          this.$message.error("列表调用失败");
        }
        var val1 = decr(data.result);
        if (val1) {
          var wkt = this.$wkt.parse(val1);
          this.getprimitiLayer(wkt);
          this.primitivesAddLayer(wkt);
        }
      }
    },
    getprimitiLayer(res) {
      switch (res.type) {
        case "Point":
          this.$store.state.primitLayer = window.Viewer.scene.primitives.add(
            new Cesium.BillboardCollection()
          );
          break;
      }
    },
    primitivesAddLayer(res) {
      switch (res.type) {
        case "Point":
          var val = Cesium.Cartesian3.fromDegrees(
            res.coordinates[0],
            res.coordinates[1],
            1000
          );
          this.$store.state.primitLayer.add({
            position: val,
            image: SmartEarthRootUrl + "Workers/image/mark.png",
          });
          break;
        case "MultiLineString":
          var line = res.coordinates[0];
          var std = [];
          for (var i in line) {
            std.push(line[i][0], line[i][1]);
          }
          var instance = new Cesium.GeometryInstance({
            geometry: new Cesium.GroundPolylineGeometry({
              positions: Cesium.Cartesian3.fromDegreesArray(std),
              width: 4.0,
            }),
            attributes: {
              color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                new Cesium.Color(1.0, 0.0, 0.0, 0.3)
              ),
            },
          });
          window.Viewer.scene.primitives.add(
            new Cesium.GroundPolylinePrimitive({
              geometryInstances: instance,
              appearance: new Cesium.PolylineColorAppearance(),
            })
          );
          break;
        case "MultiPolygon":
          var val = res.coordinates[0][0];
          var std = [];
          for (var i in val) {
            std.push(val[i][0], val[i][1]);
          }
          var primitive = new Cesium.GroundPrimitive({
            //贴地的primitive
            geometryInstances: new Cesium.GeometryInstance({
              geometry: new Cesium.PolygonGeometry({
                //支持CircleGeometry,CorridorGeometry,EllipseGeometry,RectangleGeometry
                polygonHierarchy: new Cesium.PolygonHierarchy(
                  Cesium.Cartesian3.fromDegreesArray(std)
                ),
              }),
              attributes: {
                color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                  new Cesium.Color(1.0, 0.0, 0.0, 0.3)
                ),
              },
            }),
            appearance: Cesium.EllipsoidSurfaceAppearance(),
          });
          window.Viewer.scene.primitives.add(primitive);
          break;
      }
    },
    closeMenuBox() {
      if (this.imagePoint != null) {
        sgworld.Creator.DeleteObject(this.imagePoint);
@@ -387,8 +729,8 @@
    this.setTableAll();
  },
  mounted() {
    this.$bus.$on('changeMapMenuTop', (res) => {
      if (res == 'true') {
    this.$bus.$on("changeMapMenuTop", (res) => {
      if (res == "true") {
        this.setTableAll();
      }
    });
@@ -421,6 +763,12 @@
    li:hover {
      color: #409eff;
      background: rgba(128, 128, 128, 0.2);
    }
    .leftDown {
      width: 94%;
      padding: 3%;
      display: flex;
      justify-content: flex-end;
    }
  }
@@ -541,6 +889,15 @@
    }
  }
}
li {
  color: white;
  line-height: 20px;
  border-bottom: 1px solid white;
  padding: 5px;
}
/deep/.el-textarea .el-input__count {
  background: transparent;
}
</style>
<style lang="less"></style>
<style scoped lang="less"></style>