管道基础大数据平台系统开发-【前端】-新系統界面
13693261870
2023-06-09 df1b2a901ef28e3168e2a0f7b3cbe6709a022509
src/components/preview_map.vue
@@ -1,66 +1,139 @@
<template>
  <div
    id="mapdiv"
    class="previewBox"
  >
    <div
      v-if="modelLayer"
      class="modelLayer box_divm"
    >
      <el-tree
        :data="treeData"
        show-checkbox
        node-key="id"
        ref="tree"
        :default-expanded-keys="[2, 3]"
        :default-checked-keys="[5]"
        :props="defaultProps"
        @node-click="handleNodeClick"
        @check="handleCheckChange"
      >
      </el-tree>
  <div id="mapdiv"
       class="previewBox">
    <div v-if="modelLayer"
         class="modelLayer box_divm">
      <div class="modelBox">
        <div style="float:right"
             :title="$t('synthesis.undergroundMode')"
             @click="setUndergroundMode">
          <i class="el-icon-sunrise "></i>
        </div>
      </div>
      <div class="modelBox">
        <el-tree :data="treeData"
                 show-checkbox
                 node-key="id"
                 ref="tree"
                 :default-expanded-keys="[1]"
                 :props="defaultProps"
                 @node-click="handleNodeClick"
                 @check="handleCheckChange">
        </el-tree>
      </div>
    </div>
    <div v-if="editModelFlag"
         class="modelLayer box_divm">
      <el-form ref="form"
               :model="modelForm"
               label-width="80px">
        <el-form-item>
          <el-button size="small"
                     @click="locateTo">定位</el-button>
          <el-button size="small"
                     @click="showTileset">显隐</el-button>
          <el-button size="small"
                     @click="underground">地下</el-button>
          <el-button v-if="$store.state.previewLayer.type  != '3dml'"
                     size="small"
                     @click="pickupCoords">拾取</el-button>
          <el-button v-if="$store.state.previewLayer.type  != '3dml'"
                     size="small"
                     @click="reload">
            重载
          </el-button>
          <el-button v-if="modelForm.modelid == null && $store.state.previewLayer.type  != '3dml'"
                     size="small"
                     @click="getModeKeyId">模型主键</el-button>
          <el-button v-if="$store.state.previewLayer.type  != '3dml'"
                     size="small"
                     @click="resave">保存</el-button>
        </el-form-item>
        <el-form-item label="经度:"
                      v-if="$store.state.previewLayer.type  != '3dml'">
          <el-input size="small"
                    v-model="modelForm.lon"
                    @input="update"></el-input>
          <el-slider v-model="modelForm.lon"
                     @input="update"
                     :min="73"
                     :step="0.001"
                     :max="135"></el-slider>
        </el-form-item>
        <el-form-item label="纬度:"
                      v-if="$store.state.previewLayer.type  != '3dml'">
          <el-input size="small"
                    v-model="modelForm.lat"
                    @input="update"></el-input>
          <el-slider v-model="modelForm.lat"
                     @input="update"
                     :min="3"
                     :step="0.001"
                     :max="54"></el-slider>
        </el-form-item>
        <el-form-item label="高度:"
                      v-if="$store.state.previewLayer.type  != '3dml'">
          <el-input size="small"
                    v-model="modelForm.height"
                    @input="update"></el-input>
          <el-slider v-model="modelForm.height"
                     :min="-800"
                     :step="1"
                     @input="update"
                     :max="8800"></el-slider>
        </el-form-item>
        <el-form-item label="角度:"
                      v-if="$store.state.previewLayer.type  != '3dml'">
          <el-input size="small"
                    v-model="modelForm.yaw"
                    @input="update"></el-input>
          <el-slider v-model="modelForm.yaw"
                     :min="0"
                     @input="update"
                     :step="0.1"
                     :max="360"></el-slider>
        </el-form-item>
        <el-form-item label="透明度:">
          <el-input size="small"
                    v-model="modelForm.alpha"
                    @input="update"></el-input>
          <el-slider v-model="modelForm.alpha"
                     @input="update"
                     :min="0"
                     :step="0.01"
                     :max="1"></el-slider>
        </el-form-item>
      </el-form>
    </div>
    <el-dialog
      :title="formInline.title"
      :visible.sync="dialogVisible"
      :modal="false"
      :modal-append-to-body="false"
      :close-on-click-modal="false"
      :before-close="handleClose"
      width="30%"
    >
    <el-dialog :title="formInline.title"
               :visible.sync="dialogVisible"
               :modal="false"
               :modal-append-to-body="false"
               :close-on-click-modal="false"
               :before-close="handleClose"
               width="30%">
      <div style="height:63vh">
        <el-tabs
          v-model="activeName"
          @tab-click="handleClick"
        >
          <el-tab-pane
            label="属性"
            name="first"
          >
            <el-form
              ref="form"
              :model="formInline"
              label-width="80px"
            >
        <el-tabs v-model="activeName"
                 @tab-click="handleClick">
          <el-tab-pane label="属性"
                       name="first">
            <el-form ref="form"
                     :model="formInline"
                     label-width="80px">
              <el-form-item :label="$t('common.name')">
                <el-input v-model="formInline.name"></el-input>
              </el-form-item>
              <el-form-item :label="$t('common.type')">
                <el-select
                  v-model="formInline.type"
                  style="width:100%"
                >
                  <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                <el-select v-model="formInline.type"
                           style="width:100%">
                  <el-option v-for="item in options"
                             :key="item.value"
                             :label="item.label"
                             :value="item.value">
                  </el-option>
                </el-select>
@@ -71,110 +144,78 @@
              </el-form-item>
              <el-form-item>
                <el-button
                  v-show="isShowModel"
                  type="success"
                  plain
                  size="small"
                  @click="InsertData"
                >{{$t('common.increase')}}</el-button>
                <el-button
                  v-show="!isShowModel"
                  type="info"
                  plain
                  size="small"
                  @click="EditData"
                >{{$t('common.update')}}</el-button>
                <el-button v-show="isShowModel"
                           type="success"
                           plain
                           size="small"
                           @click="InsertData">{{$t('common.increase')}}</el-button>
                <el-button v-show="!isShowModel"
                           type="info"
                           plain
                           size="small"
                           @click="EditData">{{$t('common.update')}}</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane
            label="附件"
            name="second"
          >
            <el-form
              :model="fromfile"
              class="demo-form-inline"
            >
          <el-tab-pane label="附件"
                       name="second">
            <el-form :model="fromfile"
                     class="demo-form-inline">
              <el-form-item>
                <el-input
                  v-model="fromfile.file"
                  style="width: 300px; margin-right: 20px"
                  :placeholder="$t('common.choose')"
                  disabled
                ></el-input>
                <input
                  name="file1"
                  type="file"
                  id="insertFile"
                  multiple="multiple"
                  style="display: none"
                  @change="insertFile( )"
                />
                <el-link
                  @click="getInsertFile( )"
                  :underline="false"
                ><i class="el-icon-folder-opened"></i></el-link>
                <el-input v-model="fromfile.file"
                          style="width: 300px; margin-right: 20px"
                          :placeholder="$t('common.choose')"
                          disabled></el-input>
                <input name="file1"
                       type="file"
                       id="insertFile"
                       multiple="multiple"
                       style="display: none"
                       @change="insertFile( )" />
                <el-link @click="getInsertFile( )"
                         :underline="false"><i class="el-icon-folder-opened"></i></el-link>
              </el-form-item>
              <el-form-item>
                <el-row>
                  <el-col :span="3">
                    <el-link
                      class="elLink"
                      :underline="false"
                      @click="setAttachInsert"
                    >{{$t('common.append')}}</el-link>
                    <el-link class="elLink"
                             :underline="false"
                             @click="setAttachInsert">{{$t('common.append')}}</el-link>
                  </el-col>
                  <el-col :span="3">
                    <el-link
                      class="elLink"
                      :underline="false"
                      @click="setAttachDel"
                    >{{$t('common.delete')}}</el-link>
                    <el-link class="elLink"
                             :underline="false"
                             @click="setAttachDel">{{$t('common.delete')}}</el-link>
                  </el-col>
                </el-row>
              </el-form-item>
            </el-form>
            <el-table
              :data="tableData"
              ref="filterTable"
              height="calc(100% - 130px)"
              border
              style="width: 100%"
              @selection-change="handleAttatchChange"
            >
              <el-table-column
                type="selection"
                width="70"
              />
              <el-table-column
                width="60"
                type="index"
                :label="$t('common.index')"
              />
              <el-table-column
                prop="name"
                :label="$t('common.name')"
              />
            <el-table :data="tableData"
                      ref="filterTable"
                      height="calc(100% - 130px)"
                      border
                      style="width: 100%"
                      @selection-change="handleAttatchChange">
              <el-table-column type="selection"
                               width="70" />
              <el-table-column width="60"
                               type="index"
                               :label="$t('common.index')" />
              <el-table-column prop="name"
                               :label="$t('common.name')" />
              <el-table-column
                prop="sizes"
                :label="$t('common.size')"
                :formatter="statSizeChange"
              />
              <el-table-column
                align="center"
                :label="$t('common.operate')"
                min-width="100"
              >
              <el-table-column prop="sizes"
                               :label="$t('common.size')"
                               :formatter="statSizeChange" />
              <el-table-column align="center"
                               :label="$t('common.operate')"
                               min-width="100">
                <template slot-scope="scope">
                  <el-link
                    v-if="matchState(scope, /[]/)"
                    @click="setAttatchDetail(scope.$index, scope.row)"
                    class="elLink"
                  >{{ $t('common.see') }}</el-link>
                  <el-link v-if="matchState(scope, /[]/)"
                           @click="setAttatchDetail(scope.$index, scope.row)"
                           class="elLink">{{ $t('common.see') }}</el-link>
                </template>
              </el-table-column>
@@ -186,9 +227,66 @@
      </div>
    </el-dialog>
    <!-- <el-dialog
      :title=" $t('synthesis.rangequery')"
      :visible.sync="dialogMapVisible"
      width="90%"
      top="10vh"
      :before-close="handleMapClose"
    >
      <div style="height:700px">
        <map-sdk v-if='showMapVisible'></map-sdk>
      </div>
    </el-dialog> -->
    <el-dialog title="预览"
               :append-to-body="false"
               :visible.sync="dialog.dialogVisible"
               width="70%"
               :close-on-click-modal="false">
      <div v-if="dialog.isPdf"
           class="pdfClass">
        <iframe :src="dialog.src"
                type="application/x-google-chrome-pdf"
                width="100%"
                height="100%">
        </iframe>
      </div>
      <div v-if="dialog.isJpg"
           class="pdfClass">
        <el-image style="width:100%; height:100%"
                  :src="dialog.src"
                  :preview-src-list="[dialog.src]">
        </el-image>
      </div>
    </el-dialog>
    <div v-show="modelKeyFlag"
         class="modelLayer box_divm"
         v-drag>
      <el-form ref="form"
               :model="modelForm"
               label-width="80px">
        <el-form-item label="主键ID">
          <el-select v-model="modelLayerId">
            <el-option v-for="item in optionKey"
                       :key="item.value"
                       :label="item.label"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     size="small"
                     @click="setSureKeyModelKey">{{$t('common.confirm')}}</el-button>
        </el-form-item>
      </el-form>
    </div>
    <undergroundModel ref="undergroundModel" />
  </div>
</template>
<script>
import {
  perms_selectLayers,
@@ -196,11 +294,18 @@
  comprehensive_insertModel,
  comprehensive_updateModel,
  comprehensive_selectFiles,
  dataQuery_deletes
  dataQuery_deletes,
  publish_update,
  comprehensive_selectPubById
} from '../api/api.js';
import { getToken } from '@/utils/auth';
import undergroundModel from '../views/Tools/undergroundModel.vue'
export default {
  data() {
  components: {
    undergroundModel
  },
  data () {
    return {
      levelArray: [
        0, 40000000, 20000000, 10000000, 5000000, 2000000, 1000000, 500000,
@@ -258,35 +363,76 @@
        isJpg: false,
        src: ''
      },
      modelType: ['ifc', 'fbx', 'rvt', '3dml', 'cpt'],
      editModelFlag: false,
      modelForm: {
        lon: 119,
        lat: 39,
        height: 0,
        yaw: 0,
        alpha: 1,
        modelid: null,
      },
      app: {
        tileset: null,
        isBusy: false,
        under: false,
        handler: null
      },
      modelLayerId: null,
      optionKey: [],
      modelKeyFlag: false,
    }
  },
  mounted() {
  mounted () {
    this.init3DMap();
  },
  methods: {
    refreshAttatchDetail() {
    setUndergroundMode () {
      if (window.UndergroundMode) {
        this.$refs &&
          this.$refs.undergroundModel &&
          this.$refs.undergroundModel.close();
      } else {
        this.$refs &&
          this.$refs.undergroundModel &&
          this.$refs.undergroundModel.open("地下模式", null,);
      }
    },
    refreshAttatchDetail () {
      this.dialog.src = "";
      this.dialog.dialogVisible = false;
      this.dialog.isPdf = false;
      this.dialog.isJpg = false;
    },
    //附件查看
    setAttatchDetail(index, row) {
    setAttatchDetail (index, 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();
        this.dialog.src = url
      }
    },
    async setAttachDel() {
    async setAttachDel () {
      var std = [];
      for (var i in this.attacgSelection) {
        std.push(this.attacgSelection[i].id);
@@ -297,7 +443,7 @@
      }
      this.getAttacthFlieList();
    },
    setAttachInsert() {
    setAttachInsert () {
      var token = getToken();
      var fs = document.getElementById("insertFile");
      if (fs.files.length == 0) {
@@ -341,27 +487,40 @@
      );
    },
    //附件=>文件选择
    getInsertFile() {
    getInsertFile () {
      $('#insertFile').click();
    },
    insertFile() {
    insertFile () {
      var val = document.getElementById('insertFile').files;
      if (!val || !val.length) return;
      this.fromfile.file = val[0].name;
    },
    matchState(state = "", reg) {
    matchState (state = "", reg) {
      var row = state.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('.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
        || name.indexOf('.pdf') != -1
        || name.indexOf('.PDF') != -1
      ) {
        return true;
      }
      return false;
    },
    statSizeChange(row, column) {
    statSizeChange (row, column) {
      return this.stateFormatSizes(row.sizes)
    },
    stateFormatSizes(res) {
    stateFormatSizes (res) {
      if (res >= 1024) {
        const val = parseFloat(res / 1024).toFixed(3);
        return val + ' GB';
@@ -370,12 +529,11 @@
      }
    },
    // 附件=>表格选择
    handleAttatchChange(val) {
    handleAttatchChange (val) {
      this.attacgSelection = val;
    },
    //附件列表查询
    async getAttacthFlieList() {
      debugger
    async getAttacthFlieList () {
      var obj = {
        eventid: this.layerID,
        tabName: "lf.sys_style"
@@ -387,24 +545,34 @@
      }
      this.tableData = res.result;
    },
    handleClick() {
    handleClick () {
      if (this.activeName == "second") {
        this.getAttacthFlieList();
      }
    },
    async EditData() {
    async EditData () {
      const data = await comprehensive_updateModel(this.formInline)
      if (data.code != 200) {
        this.$message.error('修改失败');
      } else {
        this.$message({
          message: '修改成功',
          type: 'success'
        });
        return
      }
      this.$message({
        message: '修改成功',
        type: 'success'
      });
      var that = this;
      that.dialogVisible = false;
      this.formInline.title = this.formInline.name
      that.dialogVisible = true;
      this.startModelData();
    },
    async InsertData() {
    async InsertData () {
      var std = {
        "bak": this.formInline.bak,
        "guid": this.formInline.Id,
@@ -416,16 +584,22 @@
      const data = await comprehensive_insertModel(std)
      if (data.code != 200) {
        this.$message.error('添加失败');
      } else {
        this.$message({
          message: '添加成功',
          type: 'success'
        });
      }
      this.$message({
        message: '添加成功',
        type: 'success'
      });
      var that = this;
      that.dialogVisible = false;
      this.formInline.title = this.formInline.name
      that.dialogVisible = true;
      this.startModelData();
    },
    handleClose() {
    handleClose () {
      this.dialogVisible = false;
      this.formInline = {
        title: '',
@@ -437,20 +611,50 @@
        bak: '',
        Id: ''
      }
      this.activeName = "first"
    },
    setShowModelInfo(result) {
    async setShowModelInfo (result) {
      var modelKey = 'id';
      this.formInline.title = result.getProperty("name")
      this.formInline.Id = result.getProperty("id");
      this.layerID = result.getProperty("id");
      if (result.tileset) {
        if (result.tileset.pubid && parseInt(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,无法查询数据');
          }
          this.formInline.Id = result.getProperty(modelKey);
          this.layerID = result.getProperty(modelKey);
        }
      } else {
        var id = '3dml' + result.primitive.id;
        this.formInline.Id = id;
        this.layerID = id;
      }
      this.formInline.layerId = result.primitive.layerId;
      this.formInline.layerName = result.primitive.id;
      // this.formInline.title = result.getProperty("name")
      if (!this.formInline.Id) {
        this.formInline.Id = "noAuto_" + this.formInline.layerId;
      }
      if (!this.layerID) {
        this.layerID = "noAuto_" + this.formInline.layerId;
      }
      this.startModelData();
      this.dialogVisible = true;
    },
    async startModelData() {
    async startModelData () {
      var obj = {
        layerid: this.formInline.layerId,
        modelid: this.formInline.Id
@@ -459,19 +663,16 @@
      if (data.code != 200) {
        return;
      }
      if (data.result == null) {
        this.isShowModel = true;
        this.formInline.name = this.formInline.title;
      } else {
        this.isShowModel = false;
        this.formInline = data.result;
        this.formInline.title = this.formInline.name;
      }
    },
    setChangeTileset(result) {
    setChangeTileset (result) {
      var value = this.$refs.tree.getCheckedNodes();
      var std = [];
      for (var i in value) {
@@ -490,17 +691,19 @@
        }
      }
    },
    setAddLayers(res) {
      if (res.serveType == "Tileset") {
    setAddLayers (rs) {
      if (rs.serveType == "Tileset" || rs.serveType == "3DML") {
        var url;
        if (res.url.indexOf("{host}") != -1) {
          url = res.url.replace("{host}", iisHost);
        if (rs.url.indexOf("{host}") != -1) {
          url = rs.url.replace("{host}", iisHost);
        } else {
          url = modelUrl + "/" + res.url
          url = modelUrl + "/" + rs.url
        }
        var tileset = Viewer.scene.primitives.add(
          new Cesium.Cesium3DTileset({
            name: res.cnName,
            name: rs.cnName,
            url: url, //192.168.20.106,to4
            maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
            maximumMemoryUsage: 768, // 最大内存:512
@@ -508,15 +711,69 @@
            skipLevelOfDetail: true, // 在遍历时候跳过详情:false
          })
        );
        var that = this;
        tileset.readyPromise.then((tileset) => {
          tileset.id = res.cnName;
          tileset.layerId = res.id;
          this.tileSet(tileset, parseFloat(res.elev))
          Viewer.flyTo(tileset);
          tileset.id = rs.cnName;
          tileset.layerId = rs.id;
          tileset.pubid = rs.pubid;
          if (rs.serveType != '3DML') {
            that.getArgsTileset(tileset, rs);
          }
        });
      }
    },
    handleCheckChange(data, checked, indeterminate) {
    async getArgsTileset (tileset, rs) {
      if (rs.pubid > 0) {
        const data = await comprehensive_selectPubById({ id: rs.pubid })
        if (data.code != 200) {
        } else {
          if (rs.serveType == '3DML') {
            this.tileSet(tileset, parseFloat(rs.elev))
          } else {
            this.reloadTile(tileset, data.result.json)
          }
        }
      } else {
        this.tileSet(tileset, parseFloat(rs.elev))
      }
    },
    tileSet (tileset, height) {
      //3dtile模型的边界球体
      var boundingSphere = tileset.boundingSphere;
      //迪卡尔空间直角坐标=>地理坐标(弧度制)
      var cartographic_original = Cesium.Cartographic.fromCartesian(boundingSphere.center);
      //地理坐标(弧度制)=>迪卡尔空间直角坐标
      var Cartesian3_original = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, cartographic_original.height);
      var Cartesian3_offset = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, height);
      //获得地面和offset的转换
      var translation = Cesium.Cartesian3.subtract(Cartesian3_offset, Cartesian3_original, new Cesium.Cartesian3());
      //修改模型矩阵
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
      // Viewer.flyTo(tileset);
    },
    reloadTile (tileset, res) {
      var vm = JSON.parse(res)
      var pos = Cesium.Cartesian3.fromDegrees(vm.lon, vm.lat, vm.height);
      var converter = Cesium.Transforms.eastNorthUpToFixedFrame;
      var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(vm.yaw), 0, 0);
      var matrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr, Cesium.Ellipsoid.WGS84, converter);
      tileset._root.transform = matrix;
      Viewer.flyTo(tileset);
    },
    handleCheckChange (data, checked, indeterminate) {
      if (data.type == 1) {
        this.getchilds(data);
        this.setChangeTileset(this.childOption, checked);
@@ -524,7 +781,7 @@
        this.setChangeTileset([data], checked);
      }
    },
    handleNodeClick(data) {
    handleNodeClick (data) {
      if (data.type == 2) {
        this.currentData = data;
        for (var j in Viewer.scene.primitives._primitives) {
@@ -534,7 +791,7 @@
        }
      }
    },
    getchilds(source) {
    getchilds (source) {
      if (source.children) {
        var child = source.children
        for (var i in child) {
@@ -548,20 +805,19 @@
        this.childOption.push(source)
      }
    },
    init3DMap() {
    init3DMap () {
      //地图初始化
      window.sgworld = new SmartEarth.SGWorld("mapdiv", {
        licenseServer: window.sceneConfig.licenseServer,
      });
      window.Viewer = window.sgworld._Viewer;
      // Viewer.camera.flyTo({
      //   destination: Cesium.Cartesian3.fromDegrees(110, 33, 8000000),
      // });
      if (is_production) {
        Viewer.imageryLayers.removeAll();
      }
      Viewer._enableInfoOrSelection = false;
      //显示fps
      Viewer.scene.debugShowFramesPerSecond = false;
@@ -571,16 +827,67 @@
      // window.sgworld.navControl("scale", false);
      //开启深度检测
      // sg.Analysis.depthTestAgainstTerrain(true)
      if (is_production) {
        var base_ulr = window.sceneConfig.baseUrl;
        if (base_ulr.indexOf('{host}') > -1) {
          base_ulr = base_ulr.replace("{host}", iisHost)
        }
        window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(
          new Cesium.UrlTemplateImageryProvider({
            url: base_ulr,
          })
        );
      }
      Viewer.scene.globe.depthTestAgainstTerrain = true;
      // window.elevationTool = new SmartEarth.ElevationTool(window.sg);
      // elevationTool.setContourColor("#F1D487");
      var option = {
        url: window.sceneConfig.SGUrl,
        layerName: window.sceneConfig.mptName,
        requestVertexNormals: true,
      };
      window.terrainLayer = sgworld.Creator.sfsterrainprovider("", option, "", true, "");
      // window.terrainLayer = new Cesium.CesiumTerrainProvider({
      //   url: demLayer
      // });
      // Viewer.terrainProvider = window.terrainLayer
      if (this.$store.state.previewLayer) {
        var res = this.$store.state.previewLayer;
        var type = res.type;
        res.ulr = res.url.replace("{host}", iisHost);
        if (type == 'DEM') {
          window.terrainLayer.deleteObject();
          // Viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider();
          // window.terrainLayer = null;
        if (res.url.indexOf('.png') != -1) {
          window.terrainLayer = new Cesium.CesiumTerrainProvider({
            url: res.url
          });
          Viewer.terrainProvider = window.terrainLayer
          /*Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(113.229279, 31.215949, 1000),
            orientation: {
              heading: 6.08434611923462,
              pitch: Cesium.Math.toRadians(-45.0),
              roll: 0.0
            }
          });*/
          var wkt = this.$wkt.parse(res.geom);
          var height = this.getHeight(wkt.coordinates[2]);
          Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], height),
          });
        } else if (type == 'DOM') {
          var wkt = this.$wkt.parse(res.geom);
          var height = this.getHeight(wkt.coordinates[2])
          window.BaseMapLayer = Viewer.imageryLayers.addImageryProvider(
@@ -588,55 +895,315 @@
              url: res.url,
              maximumLevel: 18
            })
          );
          Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], height),
          });
        } else if (res.url.indexOf('.json') != -1) {
          var tileset = Viewer.scene.primitives.add(
            new Cesium.Cesium3DTileset({
              url: res.url, //192.168.20.106,to4
              maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
              maximumMemoryUsage: 768, // 最大内存:512
              dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
              skipLevelOfDetail: true, // 在遍历时候跳过详情:false
            })
          );
          tileset.readyPromise.then((tileset) => {
            tileset.id = res.cnName;
            tileset.layerId = res.id;
            this.tileSet(tileset, 50)
            Viewer.flyTo(tileset);
          });
        } else if (res.url.indexOf('.mpt') != -1) {
        } else if (type == '3dml' || type == 'fbx' || type == 'ifc' || type == 'rvt' || type == 'cpt') {
          if (this.app.tileset) viewer.scene.primitives.remove(this.app.tileset);
          this.app.tileset = this.createTileset(res);
          var that = this;
          Viewer.scene.primitives.add(this.app.tileset).readyPromise.then(function (ts) {
            that.setModleLocatin()
            Viewer.flyTo(ts);
          });
        } else if (res.url.indexOf('.mpt') != -1) {
          Viewer.imageryLayers.removeAll();
          var url = res.url.split(';')
          sgworld.Creator.createImageryProvider('mpt影像', "wms", {
            url: url[0],
            layers: url[1]
          }, "0", undefined, true, "");
        } else if (res.url.indexOf('menuLayer') != -1) {
          this.setShowModelLayer();
        }
      }
    },
    async setShowModelLayer() {
    getModeKeyId () {
      window.ModeKeyIdHandler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
      window.ModeKeyIdHandler.setInputAction((event) => {
        window.pickedFeature = sgworld.Viewer.scene.pick(event.position);
        if (Cesium.defined(window.pickedFeature)) {
          if (window.pickedFeature.primitive instanceof Cesium.Cesium3DTileset) {
            if (window.pickedFeature && window.pickedFeature.getProperty) {
              this.setModeLayerID(pickedFeature);
            } else {
              this.modelForm.modelid = 'id3dml'
              window.ModeKeyIdHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //移除事件
            }
          }
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
    },
    async resave () {
      if (!this.modelForm.modelid) {
        return this.$message('未选择模型主键ID');
      }
      this.$store.state.previewLayer.json = JSON.stringify(this.modelForm);
      if (this.$store.state.previewLayer.url) {
        var url = this.$store.state.previewLayer.url;
        this.$store.state.previewLayer.url = url.replace(iisHost, "{host}");
      }
      const data = await publish_update(this.$store.state.previewLayer);
      if (data.code != 200) {
        this.$message.error('数据保存失败');
      } else {
        this.$message({
          message: '数据保存成功',
          type: 'success'
        });
      }
      this.reload();
    },
    reload () {
      var json = JSON.stringify(this.modelForm);
      var url = this.$store.state.previewLayer.url.replace("{host}", iisHost);
      if (!url) return;
      if (this.app.tileset) Viewer.scene.primitives.remove(this.app.tileset);
      this.app.isBusy = true;
      this.app.tileset = this.createTileset(this.$store.state.previewLayer);
      var that = this;
      Viewer.scene.primitives.add(this.app.tileset).readyPromise.then(function (ts) {
        that.modelForm = JSON.parse(json);
        var pos = Cesium.Cartesian3.fromDegrees(parseFloat(that.modelForm.lon), parseFloat(that.modelForm.lat), parseFloat(that.modelForm.height));
        var converter = Cesium.Transforms.eastNorthUpToFixedFrame;
        var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(parseFloat(that.modelForm.yaw)), 0, 0);
        var matrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr, Cesium.Ellipsoid.WGS84, converter);
        that.app.tileset._root.transform = matrix;
        Viewer.flyTo(ts);
        that.app.isBusy = false;
      });
    },
    //拾取
    pickupCoords () {
      if (this.app.handler) {
        this.app.handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
        this.app.handler = undefined;
        return;
      }
      var that = this;
      this.app.handler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
      this.app.handler.setInputAction(function (event) {
        var ray = Viewer.camera.getPickRay(event.position);
        var cartesian = Viewer.scene.globe.pick(ray, Viewer.scene);
        var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
        var x = that.toFixed(Cesium.Math.toDegrees(cartographic.longitude), 7);
        var y = that.toFixed(Cesium.Math.toDegrees(cartographic.latitude), 7);
        var z = that.toFixed(cartographic.height, 3);
        that.modelForm.lon = x;
        that.modelForm.lat = y;
        that.modelForm.height = z;
        that.pickupCoords();
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },
    // 保留小数位
    toFixed (d, n) {
      var p = Math.pow(10, n);
      return Math.round(d * p) / p;
    },
    update () {
      if (!this.modelForm.lon || isNaN(this.modelForm.lon)) {
        var args = this.getEditTilesetArgs();
        this.modelForm.lon = args.lon == null ? 0 : args.height;
        return
      }
      if (!this.modelForm.lat || isNaN(this.modelForm.lat)) {
        var args = this.getEditTilesetArgs();
        this.modelForm.lat = args.lat == null ? 0 : args.height;
        return
      }
      if (!this.modelForm.height || isNaN(this.modelForm.height)) {
        var args = this.getEditTilesetArgs();
        this.modelForm.height = args.height == null ? 0 : args.height;
        return
      }
      if (!this.modelForm.yaw || isNaN(this.modelForm.yaw)) {
        this.modelForm.yaw = 0;
        return
      }
      // if (!this.modelForm.alpha || isNaN(this.modelForm.alpha)) {
      //   if (this.app.under) {
      //
      //     this.modelForm.alpha = sgworld._Analysis._UndergroundMode._alpha;
      //   } else {
      //     this.modelForm.alpha = 1
      //   }
      //   return
      // }
      this.setTilesetArgs(this.modelForm);
      sgworld.Analysis.UndergroundMode(this.app.under, this.modelForm.alpha)
    },
    setTilesetArgs (f) {
      if (!this.app.tileset || this.app.isBusy) return;
      var pos = Cesium.Cartesian3.fromDegrees(parseFloat(f.lon), parseFloat(f.lat), parseFloat(f.height));
      var converter = Cesium.Transforms.eastNorthUpToFixedFrame;
      var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(parseFloat(f.yaw)), 0, 0);
      var matrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr, Cesium.Ellipsoid.WGS84, converter);
      var model = this.app.tileset
      model._root.transform = matrix;
    },
    //地下
    underground () {
      this.app.under = !this.app.under;
      sgworld.Analysis.UndergroundMode(this.app.under, this.modelForm.alpha)
    },
    //显隐
    showTileset () {
      if (!this.app.tileset) return;
      this.app.tileset.show = !this.app.tileset.show;
    },
    //定位
    locateTo () {
      if (!this.app.tileset) return;
      Viewer.flyTo(this.app.tileset);
    },
    createTileset (res) {
      res.url = res.url.replace('{host}', iisHost)
      return new Cesium.Cesium3DTileset({
        url: res.url,
        name: 'tsTest',
        skipLevelOfDetail: true, // 在遍历时候跳过详情:false
        baseScreenSpaceError: 1024,
        maximumScreenSpaceError: 64, // 最大屏幕空间错误:16,数值加大能让最终成像变模糊
        skipScreenSpaceErrorFactor: 16,
        skipLevels: 1,
        immediatelyLoadDesiredLevelOfDetail: false,
        loadSiblings: true, // 自动从中心开始超清化模型:false
        cullWithChildrenBounds: true, // 使用子项边界体积的并集来剔除图块:true
        cullRequestsWhileMoving: true,
        cullRequestsWhileMovingMultiplier: 10, // 值越小能够更快的剔除:60
        preloadWhenHidden: true,
        preferLeaves: true, // 预装子节点:false
        maximumMemoryUsage: 256, // 内存分配变小有利于内存回收,提升性能体验
        progressiveResolutionHeightFraction: 0.5, // 数值偏于0能够让初始加载变得模糊
        dynamicScreenSpaceErrorDensity: 0.5, // 数值加大,能让周边加载变快
        dynamicScreenSpaceErrorFactor: 2, // 动态屏幕空间误差的系数
        dynamicScreenSpaceError: true // 减少离相机较远的屏幕空间错误:false,全屏加载完之后才清晰化房屋
      });
    },
    setEditModelLayer (res) {
      this.editModelFlag = true;
      if (res.json) {
        var json = JSON.parse(res.json)
        this.modelForm = json;
        this.reload();
      } else {
        this.getTilesetArgs();
      }
    },
    setModleLocatin () {
      var res = this.$store.state.previewLayer;
      var type = res.type;
      if (this.modelType.indexOf(type) != -1) {
        if (type != '3dml') {
          this.setEditModelLayer(res)
        } else {
          this.editModelFlag = true;
        }
      }
    },
    setModeLayerID (res) {
      var value = res.getPropertyNames();
      var std = [];
      for (var i in value) {
        std.push({
          value: value[i],
          label: value[i]
        })
      }
      this.optionKey = std;
      this.modelLayerId = this.optionKey[0].label;
      this.modelKeyFlag = true;
    },
    setSureKeyModelKey () {
      this.modelKeyFlag = false;
      this.modelForm.modelid = this.modelLayerId
      window.ModeKeyIdHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //移除事件
    },
    getTilesetArgs () {
      this.app.isBusy = true;
      var cm = this.app.tileset._root.transform;
      var cartesian = new Cesium.Cartesian3(cm[12], cm[13], cm[14]);
      var carto = Cesium.Cartographic.fromCartesian(cartesian);
      if (carto) {
        this.modelForm.lon = Cesium.Math.toDegrees(carto.longitude).toFixed(7);
        this.modelForm.lat = Cesium.Math.toDegrees(carto.latitude).toFixed(7);
        this.modelForm.height = carto.height.toFixed(3);
      }
      this.app.isBusy = false;
    },
    getEditTilesetArgs () {
      this.app.isBusy = true;
      var std = {
        lon: 0,
        lat: 0,
        height: 0,
      }
      if (!this.app.tileset._root) return std;
      var cm = this.app.tileset._root.transform;
      var cartesian = new Cesium.Cartesian3(cm[12], cm[13], cm[14]);
      var carto = Cesium.Cartographic.fromCartesian(cartesian);
      if (carto) {
        std.lon = Cesium.Math.toDegrees(carto.longitude).toFixed(7);
        std.lat = Cesium.Math.toDegrees(carto.latitude).toFixed(7);
        std.height = carto.height.toFixed(3);
      }
      this.app.isBusy = false;
      return std
    },
    async setShowModelLayer () {
      const data = await perms_selectLayers();
      if (data.code != 200) {
      } else {
        var std = data.result
        var val = std.filter((str) => {
        var val = [];
        std.filter((str) => {
          // if (str.type == 1 && str.pid == 1) {
          //   return str;
          // }
          // if (str.id == 1 && str.pid == 0) {
          //   return str;
          // }
          if (str.type == 1) {
            return str;
            val.push(str);
          }
          if (str.url != null && str.type == 2) {
            return str;
          if (str.url != null && str.type == 2 && str.serveType == 'Tileset') {
            val.push(str);
          }
          if (str.url != null && str.type == 2 && str.serveType == '3DML') {
            val.push(str);
          }
        });
@@ -644,32 +1211,27 @@
        this.treeData = res;
        this.modelLayer = true;
        var that = this;
        var pickedFeature, pickedColor;
        window.modeCatchHandler = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
        window.modeCatchHandler.setInputAction((event) => {
          window.pickedFeature && (window.pickedFeature.color = window.pickedColor);
          window.pickedFeature = sgworld.Viewer.scene.pick(event.position);
          if (Cesium.defined(window.pickedFeature)) {
            if (window.pickedFeature.primitive instanceof Cesium.Cesium3DTileset) {
              if (window.pickedFeature && window.pickedFeature.getProperty) {
                window.pickedColor = window.pickedFeature.color
                window.pickedFeature.color = Cesium.Color.RED.withAlpha(0.3);
          if (pickedColor) { pickedFeature && (pickedFeature.color = pickedColor); }
          pickedFeature = sgworld.Viewer.scene.pick(event.position);
          if (Cesium.defined(pickedFeature)) {
            if (pickedFeature.primitive instanceof Cesium.Cesium3DTileset) {
              if (pickedFeature) {
                pickedColor = pickedFeature.color
                pickedFeature.color = Cesium.Color.RED.withAlpha(0.3);
                that.setShowModelInfo(pickedFeature);
                // this.$store.state.catModel = true;
                // this.$store.state.catModelInfo = {
                //   id: pickedFeature.getProperty("id"),
                //   name: pickedFeature.getProperty("name"),
                //   layerId: pickedFeature.primitive.layerId,
                //   layerName: pickedFeature.primitive.id
                // };
              }
            }
          }
        }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
      }
    },
    setTreeData(source) {
    setTreeData (source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
@@ -677,23 +1239,23 @@
        branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
        // 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c , 那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
        // 由此循环多次后,就能形成相应的树形数据结构
        return father.pid == 430; // 返回一级菜单
        return father.pid == 0; // 返回一级菜单
      });
    },
    tileSet(tileset, height) {
      //3dtile模型的边界球体
      var boundingSphere = tileset.boundingSphere;
      //迪卡尔空间直角坐标=>地理坐标(弧度制)
      var cartographic_original = Cesium.Cartographic.fromCartesian(boundingSphere.center);
      //地理坐标(弧度制)=>迪卡尔空间直角坐标
      var Cartesian3_original = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, cartographic_original.height);
      var Cartesian3_offset = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, height);
      //获得地面和offset的转换
      var translation = Cesium.Cartesian3.subtract(Cartesian3_offset, Cartesian3_original, new Cesium.Cartesian3());
      //修改模型矩阵
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    },
    getHeight(level) {
    // tileSet(tileset, height) {
    //   //3dtile模型的边界球体
    //   var boundingSphere = tileset.boundingSphere;
    //   //迪卡尔空间直角坐标=>地理坐标(弧度制)
    //   var cartographic_original = Cesium.Cartographic.fromCartesian(boundingSphere.center);
    //   //地理坐标(弧度制)=>迪卡尔空间直角坐标
    //   var Cartesian3_original = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, cartographic_original.height);
    //   var Cartesian3_offset = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, height);
    //   //获得地面和offset的转换
    //   var translation = Cesium.Cartesian3.subtract(Cartesian3_offset, Cartesian3_original, new Cesium.Cartesian3());
    //   //修改模型矩阵
    //   tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    // },
    getHeight (level) {
      if (level > 0 && level < 23) {
        return this.levelArray[level]
      }
@@ -704,7 +1266,7 @@
}
</script>
<style lang="less" scoped>
.previewBox {
  width: 100%;
@@ -716,8 +1278,27 @@
    border: 1px solid #409eff;
    margin: 10px;
    max-height: 300px;
    max-height: 600px;
    overflow: auto;
    .modelBox {
      width: 100%;
      min-height: 24px;
    }
  }
  .pdfClass {
    height: 70vh;
    width: 100%;
    position: relative;
  }
  .el-icon-sunrise {
    background: url("../assets/img/synthesis/images/3白底_157.png") center
      center no-repeat;
    background-size: 24px;
  }
  .el-icon-sunrise:before {
    content: "11";
    visibility: hidden;
  }
}
</style>
</style>