管道基础大数据平台系统开发-【前端】-新系統界面
王旭
2023-05-10 7a0c7de021aebbef3ec137f2f94ff73ab41014d7
src/components/mapsdk.vue
@@ -1,5 +1,10 @@
<template>
  <div class="mapBox">
  <div
    class="mapBox"
    v-loading="loading"
    :element-loading-text="loadingText"
    element-loading-background="rgba(0, 0, 0, 0.8)"
  >
    <div id="mapdiv">
      <div
        class="menu_Top box_divm"
@@ -75,16 +80,16 @@
            <el-form
              ref="form"
              :model="coordFrom"
              label-width="50px"
            >
              <el-form-item label="经度:">
                <el-input v-model="coordFrom.lon"></el-input>
                <el-input v-model="coordFrom.lon" placeholder="请输入经度"></el-input>
              </el-form-item>
              <el-form-item label="纬度:">
                <el-input v-model="coordFrom.lat"></el-input>
                <el-input v-model="coordFrom.lat" placeholder="请输入维度"></el-input>
              </el-form-item>
              <el-form-item label="高度:">
                <el-input v-model="coordFrom.height"></el-input>
                <el-input v-model="coordFrom.height" placeholder="请输入高度"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
@@ -409,6 +414,20 @@
                </div>
              </td>
            </tr>
            <tr>
              <td>淤泥质土</td>
              <td>
                <div style="width:100px;height:20px;background:rgba(75,74,78,1)">
                </div>
              </td>
            </tr>
            <tr>
              <td>其他</td>
              <td>
                <div style="width:100px;height:20px;background:rgba(225,225,225,1)">
                </div>
              </td>
            </tr>
          </table>
        </el-card>
      </div>
@@ -493,6 +512,7 @@
      <div
        class="propertiesPop"
        style="right:22%"
        v-if="$store.state.propertiesFlag == '2'"
      >
        <el-card class="box-card">
@@ -631,6 +651,72 @@
        </div>
      </el-dialog>
      <el-dialog
        title="瓦片下载"
        :append-to-body="false"
        :visible.sync="downTitleFlag"
        :close-on-click-modal="false"
        :show-close="false"
        width="30%"
      >
        <el-form
          :model="ruleForm"
          status-icon
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item
            label="名称"
            prop="title"
          >
            <el-input
              v-model="ruleForm.title"
              size="small"
              placeholder="请输入数据名称..."
            ></el-input>
          </el-form-item>
          <el-form-item
            label="密码"
            prop="pass"
          >
            <el-input
              show-password
              type="password"
              v-model="ruleForm.pass"
              autocomplete="off"
              size="small"
              placeholder="请输入密码..."
            ></el-input>
          </el-form-item>
          <el-form-item
            label="确认密码"
            prop="checkPass"
          >
            <el-input
              show-password
              type="password"
              v-model="ruleForm.checkPass"
              autocomplete="off"
              size="small"
              placeholder="确认密码..."
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              size="small"
              @click='submitTitleDown("ruleForm")'
            >提交</el-button>
            <el-button
              size="small"
              @click='cannelTitleDown("ruleForm")'
            >取消</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
      <!--      <div-->
      <!--        @click="changeMenulayer"-->
      <!--        class="center CenDiv"-->
@@ -644,6 +730,11 @@
    </div>
    <model-property ref='modelProperty'></model-property>
    <iframe
      id="downFrame"
      src=""
      style="display: none; border: 0; padding: 0; height: 0; width: 0"
    ></iframe>
  </div>
</template>
@@ -656,7 +747,10 @@
  select_Comprehensive_ByPageAndCount,
  select_Comprehensive_SelectWktById,
  comprehensive_selectRoute,
  dataLib_selectFiles, dataQuery_selectFields, dataQuery_selectDomains, dataQuery_selectByPage
  dataLib_selectFiles, dataQuery_selectFields, dataQuery_selectDomains,
  dataQuery_selectByPage,
  comprehensive_selectPubById, comprehensive_selectModelByGuid, decr,
  encr, inquiry_downloadTiles, sign_getPublicKey
} from '../api/api'
import { getToken } from '@/utils/auth'
@@ -684,6 +778,35 @@
            }
          }
        }
        callback();
      }
    };
    var checkAge = (rule, value, callback) => {
      if (!value) {
        return callback(new Error('数据名称不能为空'));
      }
      callback();
    };
    var validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'));
      } else {
        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();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.ruleForm.pass) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
@@ -716,14 +839,23 @@
            message: "坐标点经纬度错误,坐标应在[116.xxx, 39.yyy]范围",
          },
        ],
        pass: [
          { validator: validatePass, trigger: 'blur' }
        ],
        checkPass: [
          { validator: validatePass2, trigger: 'blur' }
        ],
        title: [
          { validator: checkAge, trigger: 'blur' }
        ]
      },
      bufFrom: {
        val: 50,
      },
      coordFrom: {
        lon: 116.3911,
        lat: 39.9115,
        height: 100000,
        lon: "",
        lat:"",
        height: "",
      },
      listData: {
        name: null,
@@ -769,6 +901,15 @@
      valueX: 0,
      valueY: 0,
      terrainflag: false,
      downTitleFlag: false,
      downTitleData: null,
      ruleForm: {
        pass: '',
        checkPass: '',
        title: ''
      },
      loadingText: '',
      loading: false,
    };
  },
  mounted() {
@@ -795,13 +936,72 @@
    });
    //模型捕捉
    this.catchmodel()
    this.$bus.$on("titleDown", res => {
      this.setDownLoadTitle(res);
    })
    window.localStorage.setItem('slider_x', this.valueX);
    window.localStorage.setItem('slider_y', this.valueY);
    window.localStorage.setItem('slider_z', this.valueZ);
  },
  methods: {
    setDownLoadTitle(res) {
      this.signGetPublicKey()
      this.downTitleFlag = true;
      this.downTitleData = res;
    },
    async signGetPublicKey() {
      const res = await sign_getPublicKey()
      if (res && res.code == 200) {
        window.encrypt = new JSEncrypt()
        encrypt.setPublicKey(res.result)
      }
    },
    submitTitleDown(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.downTitleData.title = this.ruleForm.title
          // this.downTitleData.pwd = encr(this.ruleForm.pass)
          this.downTitleData.pwd = encrypt.encrypt(this.ruleForm.pass)
          this.getDownLoadTile(this.downTitleData);
          this.cannelTitleDown();
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    async getDownLoadTile(res) {
      this.loading = true;
      this.loadingText = "数据下载中,请稍等..."
      $.ajax({
        url: BASE_URL + "/inquiry/downloadTiles?token=" + getToken(),
        type: "POST",
        data: JSON.stringify(res),
        dataType: 'json', // html、json、jsonp、script、text
        contentType: "application/json", // "application/x-www-form-urlencoded"
        success: (data) => {
          var token = getToken()
          var url = BASE_URL + "/dataLib/downloadFile?token=" + token + "&guid=" + data.result + "&pwd=" + res.pwd;
          $("#downFrame").attr("src", url).click();
          this.loading = false;
          this.loadingText = ""
        },
        error: function (e) {
        }
      });
    },
    cannelTitleDown(formName) {
      this.downTitleFlag = false;
      // this.$refs[formName].resetFields();
      this.ruleForm = {
        pass: '',
        checkPass: '',
        title: ''
      }
    },
    catchmodel() {
      var that = this;
      window.pickedFeature;
@@ -817,18 +1017,61 @@
              window.pickedFeature.color = Cesium.Color.RED.withAlpha(0.3);
              // this.$store.state.catModel = true;
              that.$store.state.catModelInfo = {
                id: pickedFeature.getProperty("id"),
                name: pickedFeature.getProperty("name"),
                layerId: pickedFeature.primitive.layerId,
                layerName: pickedFeature.primitive.id
              };
              that.$refs && that.$refs.modelProperty && that.$refs.modelProperty.open();
              that.setModelInfoData(window.pickedFeature);
            }
          }
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
    },
    async setModelInfoData(result) {
      var modelKey = 'id'
      if (result.tileset.pubid > 0) {
        const data = await comprehensive_selectPubById({ id: result.tileset.pubid })
        if (data.code != 200) {
          return
        } else {
          modelKey = JSON.parse(data.result.json).modelid
        }
        if (!modelKey) {
          return this.$message('没有模型主键ID,无法查询数据');
        }
      }
      var that = this
      var obj = {
        layerid: pickedFeature.primitive.layerId,
        modelid: pickedFeature.getProperty(modelKey)
      }
      const data1 = await comprehensive_selectModelByGuid(obj);
      if (data1.code != 200) {
        return;
      }
      var name = null;
      var bak = null;
      var type = null;
      if (data1.result) {
        name = data1.result.name;
        bak = data1.result.bak;
        type = data1.result.type;
      }
      that.$store.state.catModelInfo = {
        id: pickedFeature.getProperty(modelKey),
        name: name,
        type: type,
        bak: bak,
        layerId: pickedFeature.primitive.layerId,
        layerName: pickedFeature.primitive.id
      };
      that.$refs && that.$refs.modelProperty && that.$refs.modelProperty.open();
    },
    drawTerrainLevel() {
      this.clearTerrainLevel()
      var deep = parseFloat(this.terrainFrom.height)
@@ -858,8 +1101,13 @@
        licenseServer: window.sceneConfig.licenseServer,
      });
      window.Viewer = window.sgworld._Viewer;
      if (is_production) {
        Viewer.imageryLayers.removeAll();
      }
      //定位
      // sgworld.Navigate.jumpTo({
      //   //跳转视角
@@ -883,12 +1131,31 @@
      //显示fps
      Viewer.scene.debugShowFramesPerSecond = false;
      //导航控件
      window.sgworld.navControl("nav", false);
      // window.sgworld.navControl("nav", false);
      //比例尺
      window.sgworld.navControl("scale", false);
      // window.sgworld.navControl("scale", false);
      //开启深度检测
      // sgworld.Analysis.depthTestAgainstTerrain(true)
      Viewer.scene.globe.depthTestAgainstTerrain = true;
      if (is_production) {
        var base_ulr = window.sceneConfig.baseUrl;
        if (base_ulr.indexOf('{host}') > -1) {
          base_ulr = base_ulr.replace("{host}", iisHost)
        }
        Viewer.imageryLayers.addImageryProvider(
          new Cesium.UrlTemplateImageryProvider({
            url: base_ulr,
            maximumLevel: 9
          })
        );
        window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(
          new Cesium.UrlTemplateImageryProvider({
            url: base_ulr,
          })
        );
      }
      var option = {
        url: window.sceneConfig.SGUrl,
@@ -1449,7 +1716,7 @@
        return
      }
      if (res.result.length <= 0) {
        this.$message.error('暂无附件');
        this.$message('暂无附件');
        return
      }
@@ -1459,7 +1726,21 @@
    //是否显示查看按钮
    showAttachDetailBtn(row) {
      var name = row.name;
      if (name.indexOf('.pdf') != -1 || name.indexOf('.jpg') != -1 || name.indexOf('.gif') != -1 || name.indexOf('.png') != -1 || name.indexOf('.jpeg') != -1) {
      if (
        name.indexOf('.pdf') != -1
        || name.indexOf('.jpg') != -1
        || name.indexOf('.gif') != -1
        || name.indexOf('.png') != -1
        || name.indexOf('.jpeg') != -1
        || name.indexOf('.PDF') != -1
        || name.indexOf('.JPG') != -1
        || name.indexOf('.GIF') != -1
        || name.indexOf('.PNG') != -1
        || name.indexOf('.JPEG') != -1
        || name.indexOf('.BMP') != -1
        || name.indexOf('.bmp') != -1
      ) {
        return true;
      }
      return false;
@@ -1475,13 +1756,24 @@
    showAttachDetail(row) {
      this.refreshAttatchDetail();
      var name = row.name;
      if (name.indexOf('.pdf') != -1) {
      if (name.indexOf('.pdf') != -1 || name.indexOf('.PDF') != -1) {
        this.dialog.dialogVisible = true;
        this.dialog.isPdf = true;
        var url = BASE_URL + "/comprehensive/downloadForView?guid=" + row.guid + "&token=" + getToken();
        this.dialog.src = url
      }
      else if (name.indexOf('.jpg') != -1 || name.indexOf('.gif') != -1 || name.indexOf('.png') != -1 || name.indexOf('.jpeg') != -1) {
      else if (
        name.indexOf('.jpg') != -1
        || name.indexOf('.gif') != -1
        || name.indexOf('.png') != -1
        || name.indexOf('.jpeg') != -1
        || name.indexOf('.JPG') != -1
        || name.indexOf('.GIF') != -1
        || name.indexOf('.PNG') != -1
        || name.indexOf('.JPEG') != -1
        || name.indexOf('.BMP') != -1
        || name.indexOf('.bmp') != -1
      ) {
        this.dialog.dialogVisible = true;
        this.dialog.isJpg = true;
        var url = BASE_URL + "/comprehensive/downloadForView?guid=" + row.guid + "&token=" + getToken();
@@ -1651,7 +1943,7 @@
      z-index: 40;
      position: absolute;
      right: 8%;
      bottom: 1%;
      bottom: 10%;
    }
    .propertiesPop {
      width: 350px;