管道基础大数据平台系统开发-【前端】-新系統界面
suerprisePlus
2024-05-30 05d9fb2ae038a5b3bf80eaaa864141bc278084a5
src/views/Synthesis/LeftMenu.vue
@@ -1,3204 +1,3289 @@
<template>
  <div class="menu_Box box_div">
    <div class="leftMen_div"
         @click="setChangeTwoMenu(item)"
         v-for="(item, index) in setListTwoMenu"
         :class="{ lefMenuDivActive: showTwoMenuFlag == item.id }">
      <div class="menuTwoImage"
           :class="item.css"></div>
      <div>{{ $t(item.label) }}</div>
    </div>
    <mapinfo ref="mapinfo" />
    <maplayer ref="maplayer" />
    <queryinfo ref="queryinfo" />
    <terrainDig ref="terrainDig" />
    <modelAttach ref="modelAttach" />
    <undergroundModel ref="undergroundModel" />
    <setPellucidity ref="setPellucidity" />
    <input type="file"
           accept=".kml"
           class="file"
           style="display: none" />
    <input :accept="'.shp, .shx, .dbf, .prj'"
           style="display: none"
           ref="pathClear"
           type="file"
           name="file"
           id="shpFile"
           multiple="multiple"
           @change="handleOpenShp()" />
    <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="预览"
                 :append-to-body="false"
                 :visible.sync="dialog.dialogVisible"
                 width="70%"
                 :modal="false"
                 :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 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-form-item :label="$t('common.name')">
                <!-- <el-input v-model="formInline.name"></el-input> -->
                {{formInline.name}}
              </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-option>
                </el-select> -->
                {{formInline.type}}
              </el-form-item>
              <el-form-item :label="$t('common.bak')">
                <!-- <el-input v-model="formInline.bak"></el-input> -->
                {{formInline.bak}}
              </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-form-item> -->
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="附件"
                       name="second">
            <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">
                <template slot-scope="scope">
                  <el-link v-if="matchState(scope, /[]/)"
                           @click="setAttatchDetail(scope.$index, scope.row)"
                           class="elLink">{{ $t('common.see') }}</el-link>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
    </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.depid">
                  {{ 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="getInsertDownz()">{{
              $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>
    <el-dialog :title="$t('common.passworld')"
               :visible.sync="dialogVisible1"
               width="30%"
               top="35vh"
               :modal="false"
               :before-close="handleCloseDown1">
      <el-form :model="codeForm"
               :rules="rules"
               ref="codeForm"
               label-width="100px"
               class="codeForm">
        <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-input type="password"
                    v-model="codeForm.repassword"
                    show-password></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="primary"
                     size="small"
                     @click="downloadx('codeForm')">{{ $t("common.confirm") }}</el-button>
          <el-button type="info"
                     size="small"
                     @click="closeDownx('codeForm')">{{
            $t("common.cancel")
          }}</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog title="范围"
               :visible.sync="dialogExtentVisible"
               width="30%"
               :before-close="handleExtentClose"
               :modal="false"
               :lock-scroll="false"
               :close-on-click-modal="false">
      <el-row :gutter="20">
        <el-col :span="16">
          <el-input v-model="setExtent"></el-input>
        </el-col>
        <el-col :span="6">
          <div>
            单位:(m)
          </div>
        </el-col>
      </el-row>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="handleExtentClose">取 消</el-button>
        <el-button @click="handleExtentinsert"
                   type="primary">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { transform } from "ol/proj";
import mapinfo from "../Tools/mapinfo.vue";
import maplayer from "../Tools/maplayer.vue";
import queryinfo from "../Tools/queryinfo.vue";
import terrainDig from "../Tools/terrainDig.vue";
import modelAttach from "../Tools/ModelAttach.vue";
import undergroundModel from "../Tools/undergroundModel.vue";
import setPellucidity from "../Tools/setPellucidity.vue";
import $ from "jquery";
import { getToken } from "@/utils/auth";
import ImageWMS from "ol/source/ImageWMS";
import Image from "ol/layer/Image";
import GeoJSON from "ol/format/GeoJSON.js";
import { Vector as VectorSource } from "ol/source";
import { Vector as VectorLayer } from "ol/layer";
import {
  perms_selectLayers,
  comprehensive_selectModelByGuid,
  comprehensive_selectFiles,
  comprehensive_deletes,
  comprehensive_selectModelByPageAndCount,
  comprehensive_insertModel,
  comprehensive_updateModel, selectByBuffer,
  dataQuery_selectTabByEntity,
  inquiry_selectDomains,
  inquiry_selectFields,
  dataQuery_selectByGid,
} from '../../api/api.js'
import {
  OverviewMap,
  defaults as defaultControls,
  FullScreen,
  ScaleLine,
  Rotate,
} from "ol/control.js";
import * as turf from "@turf/turf";
import { geometry } from "@turf/turf";
export default {
  components: { mapinfo, maplayer, queryinfo, terrainDig, modelAttach, undergroundModel, setPellucidity },
  data () {
    var repasswordValidator = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.codeForm.password) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
    var passwordValidator = (rule, value, callback) => {
      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位')
        );
      } else {
        callback();
      }
    };
    return {
      rules: {
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }, { validator: passwordValidator, trigger: 'blur' }],
        repassword: [
          { required: true, message: '请输入确认密码', trigger: 'blur' },
          { validator: repasswordValidator, trigger: 'blur' },
        ],
      },
      codeForm: {
        password: '',
        repassword: '',
      },
      showTwoMenuFlag: false,
      setListTwoMenu: [],
      setListTwoMenuAll: [
        [
          {
            id: "a1",
            label: "synthesis.layer",
            name: "图层管理",
            css: "twoMenu_imge11",
          },
          {
            id: "b1",
            label: "synthesis.split",
            name: "分屏",
            css: "twoMenu_imge21",
          },
          {
            id: "b9",
            label: "synthesis.undergroundMode",
            name: "地下模式",
            css: "twoMenu_imge29",
          },
          // {
          //   id: "b10",
          //   label: "synthesis.undergroundMode",
          //   name: "瓦片下载",
          //   css: "twoMenu_imge29",
          // },
        ],
        [
          {
            id: "b1",
            label: "synthesis.split",
            name: "分屏",
            css: "twoMenu_imge21",
          },
          {
            id: "b2",
            label: "synthesis.twod",
            name: "二维",
            css: "twoMenu_imge22",
          },
          {
            id: "b3",
            label: "synthesis.threed",
            name: "三维",
            css: "twoMenu_imge23",
          },
          {
            id: "b4",
            label: "synthesis.full",
            name: "全图",
            css: "twoMenu_imge24",
          },
          {
            id: "b5",
            label: "synthesis.zommin",
            name: "放大",
            css: "twoMenu_imge25",
          },
          {
            id: "b6",
            label: "synthesis.zoomout",
            name: "缩小",
            css: "twoMenu_imge26",
          },
          {
            id: "b7",
            label: "synthesis.rule",
            name: "比例尺",
            css: "twoMenu_imge27",
          },
          {
            id: "b8",
            label: "synthesis.compass",
            name: "指北针",
            css: "twoMenu_imge28",
          },
          {
            id: "b9",
            label: "synthesis.undergroundMode",
            name: "地下模式",
            css: "twoMenu_imge29",
          },
        ],
        [
          {
            id: "c1",
            label: "synthesis.someroaming",
            name: "点漫游",
            css: "twoMenu_imge31",
          },
          {
            id: "c2",
            label: "synthesis.lineroaming",
            name: "线路漫游",
            css: "twoMenu_imge32",
          },
          {
            id: "c3",
            label: "synthesis.mouseroaming",
            name: "鼠标漫游",
            css: "twoMenu_imge33",
          },
          {
            id: "c4",
            label: "synthesis.snapshot",
            name: "地图快照",
            css: "twoMenu_imge34",
          },
        ],
        [
          {
            id: "d1",
            label: "synthesis.contouranalysis",
            name: "等高线",
            css: "twoMenu_imge41",
          },
          {
            id: "d2",
            label: "synthesis.slopeanalysis",
            name: "坡度分析",
            css: "twoMenu_imge42",
          },
          {
            id: "d3",
            label: "synthesis.pathanalysis",
            name: "路径分析",
            css: "twoMenu_imge43",
          },
          {
            id: "d4",
            label: "synthesis.cuttinganalysis",
            name: "地形剖切",
            css: "twoMenu_imge44",
          },
          {
            id: "d5",
            label: "synthesis.floodanalysis",
            name: "淹没分析",
            css: "twoMenu_imge45",
          },
          {
            id: "d6",
            label: "synthesis.earthworkcalculation",
            name: "土方量计算",
            css: "twoMenu_imge46",
          },
          {
            id: "d7",
            label: "synthesis.crosssectionanalysis",
            name: "三维截面",
            css: "twoMenu_imge47",
          },
          {
            id: "d8",
            label: "synthesis.imagecontrast",
            name: "影像对比",
            css: "twoMenu_imge48",
          },
          {
            id: "d9",
            label: "synthesis.pipelineAnalysis",
            name: "管道分析",
            css: "twoMenu_imge49",
          },
          {
            id: "d10",
            label: "synthesis.flatterrain",
            name: "地形平整",
            css: "twoMenu_imge410",
          },
          {
            id: "d11",
            label: "synthesis.terrainexcavation",
            name: "地形开挖",
            css: "twoMenu_imge411",
          },
          {
            id: "d12",
            label: "synthesis.visibilityAnalysis",
            name: "通视分析",
            css: "twoMenu_imge412",
          },
          {
            id: "d13",
            label: "synthesis.viewAnalysis",
            name: "视域分析",
            css: "twoMenu_imge413",
          },
          {
            id: "d14",
            label: "synthesis.circularViewAnalysis",
            name: "圆形视域分析",
            css: "twoMenu_imge414",
          },
        ],
        [
          {
            id: "e1",
            label: "synthesis.attributequery",
            name: "属性查询",
            css: "twoMenu_imge51",
          },
          {
            id: "e2",
            label: "synthesis.rangequery",
            name: "空间查询",
            css: "twoMenu_imge52",
          },
        ],
        [
          {
            id: "f1",
            label: "synthesis.gpsrtk",
            name: "坐标定位",
            css: "twoMenu_imge61",
          },
          {
            id: "f2",
            label: "synthesis.placenamelocation",
            name: "地名定位",
            css: "twoMenu_imge62",
          },
        ],
        [
          {
            id: "j1",
            label: "synthesis.synthobj.m1",
            name: "表面距离",
            css: "twoMenu_imge71",
          },
          {
            id: "j2",
            label: "synthesis.synthobj.m4",
            name: "垂直高度",
            css: "twoMenu_imge72",
          },
          {
            id: "j3",
            label: "synthesis.synthobj.m6",
            name: "平面面积",
            css: "twoMenu_imge73",
          },
          {
            id: "j4",
            label: "synthesis.synthobj.m7",
            name: "体积",
            css: "twoMenu_imge74",
          },
          {
            id: "j5",
            label: "synthesis.synthobj.m5",
            name: "表面面积",
            css: "twoMenu_imge75",
          },
          {
            id: "j6",
            label: "synthesis.synthobj.m2",
            name: "空间距离",
            css: "twoMenu_imge76",
          },
          {
            id: "j7",
            label: "synthesis.synthobj.m9",
            name: "高程量测",
            css: "twoMenu_imge77",
          },
        ],
        [
          {
            id: "h1",
            label: "synthesis.point",
            name: "点",
            css: "twoMenu_imge81",
          },
          {
            id: "h8",
            label: "synthesis.addlabel",
            name: "文字",
            css: "twoMenu_imge88",
          },
          {
            id: "h2",
            label: "synthesis.line",
            name: "线",
            css: "twoMenu_imge82",
          },
          {
            id: "h3",
            label: "synthesis.rectangle",
            name: "矩形",
            css: "twoMenu_imge83",
          },
          {
            id: "h4",
            label: "synthesis.polygon",
            name: "多边形",
            css: "twoMenu_imge84",
          },
          {
            id: "h5",
            label: "synthesis.import",
            name: "导入KML",
            css: "twoMenu_imge85",
          },
          {
            id: "h6",
            label: "synthesis.export",
            name: "导出KML",
            css: "twoMenu_imge86",
          },
          {
            id: "h9",
            label: "synthesis.import1",
            name: "导入SHP",
            css: "twoMenu_imge85",
          },
          {
            id: "h10",
            label: "synthesis.export1",
            name: "导出SHP",
            css: "twoMenu_imge86",
          },
          {
            id: "h7",
            label: "synthesis.removepaint",
            name: "清除",
            css: "twoMenu_imge87",
          },
        ],
        [
          {
            id: "i1",
            name: "场景提取",
            label: "synthesis.sceneExtraction",
            css: "twoMenu_imge12",
          },
          {
            id: "i2",
            label: "synthesis.release",
            name: "场景发布",
            css: "twoMenu_imge13",
          },
          {
            id: "i3",
            label: "synthesis.tdisplay",
            name: "三维演示",
            css: "twoMenu_imge35",
          },
        ],
      ],
      isRuler: false,
      isNaviget: false,
      isolineFlag: false,
      isslopeFlag: false,
      isContrastFlag: false,
      UndergroundMode: false,
      scaleLine: null,
      Excavation: false,
      entityaLayers: [],
      isMenuFlag: null,
      isRouter: false, //路径分析
      isPiple: false, //管道分析
      DXZPState: null, //地形整平
      dialogVisible: false,
      formInline: {
        title: '',
        file: '',
        name: '',
        type: '',
        info: '',
        icon: '',
        bak: ''
      },
      tableData: [],
      dialog: {
        dialogVisible: false,
        isPdf: false,
        isJpg: false,
        src: ''
      },
      activeName: "first",
      isShowModel: false,
      options: [
        {
          value: '倾斜模型',
          label: '倾斜模型'
        }, {
          value: 'BIM模型',
          label: 'BIM模型'
        }, {
          value: '点云模型',
          label: '点云模型'
        }, {
          value: '地质设计模型',
          label: '地质设计模型'
        }, {
          value: '人工模型',
          label: '人工模型'
        }, {
          value: '其他模型',
          label: '其他模型'
        }],
      modelClip: false,
      showPickUp: false,
      dialogInsertVisible: false,
      dialogVisible1: false,
      ruleForm: {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      },
      dialogExtentVisible: false,
      setExtent: 10,
    };
  },
  methods: {
    //二級菜单点击切换
    setChangeTwoMenu (res) {
      var val = res.id[0];
      if (window.model != null) {
        // window.model.deleteObject();
        // window.model = null;
      }
      sgworld.Analysis.clearCurtainContrast();
      this.showPickUp = false;
      if (this.isMenuFlag == "d") {
        this.clearAllAnalsy();
      }
      this.$store.state.propertiesFlag = '';
      if (this.isMenuFlag != val) {
        if (res.id != "b9") {
          this.$store.state.mapMenuBoolean = false;
          this.$store.state.mapMenuBoxFlag = null;
          this.$store.state.mapPopBoolean = false;
          this.$store.state.mapPopBoxFlag = null;
          this.isMenuFlag = val;
          if (this.entityaLayers.length != 0) {
            for (var i in this.entityaLayers) {
              sgworld.Viewer.entities.remove(this.entityaLayers[i]);
            }
            this.entityaLayers = [];
          }
          for (var i in this.$store.state.queryInfo) {
            sgworld.Viewer.entities.remove(this.$store.state.queryInfo[i]);
          }
          this.$store.state.queryInfo = [];
          if (this.$store.state.primitLayer != null) {
            sgworld.Viewer.entities.remove(this.$store.state.primitLayer);
            sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
            this.$store.state.primitLayer = null;
          }
        }
      }
      this.showTwoMenuFlag = res.id;
      if (val != 'h' && res.id != "b9") {
        sgworld.Creator.SimpleGraphic.clear();
        Viewer.entities.removeAll();
      }
      switch (val) {
        case "a": //图层管理
          this.setCoverage(res.id);
          break;
        case "b":
          this.setViewport(res.id);
          break;
        case "c":
          this.setWander(res.id);
          break;
        case "d":
          this.setAnalsy(res.id);
          break;
        case "e":
          this.setIquery(res.id);
          break;
        case "f":
          this.setOrientation(res.id);
          break;
        case "j":
          this.setMeasurement(res.id);
          break;
        case "h":
          sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
          this.setPlot(res.id);
          break;
      }
    },
    setPlot (res) {
      switch (res) {
        case "h1":
          sgworld.Creator.createSimpleGraphic(
            "point",
            {},
            function (entity) { }
          );
          break;
        case "h2":
          sgworld.Creator.createSimpleGraphic(
            "polyline",
            {},
            function (entity) { }
          );
          break;
        case "h3":
          sgworld.Creator.createSimpleGraphic(
            "rectangle",
            {},
            function (entity) { }
          );
          break;
        case "h4":
          sgworld.Creator.createSimpleGraphic(
            "polygon",
            {},
            function (entity) { }
          );
          break;
        case "h5":
          this.handleOpenClick();
          break;
        case "h6":
          this.handleSaveClick();
          break;
        case "h9":
          // this.handleOpenShp();
          $("#shpFile").click();
          break;
        case "h10":
          this.handleSaveShp();
          break;
        case "h7":
          sgworld.Creator.SimpleGraphic.clear();
          for (var i in this.entityaLayers) {
            sgworld.Viewer.entities.remove(this.entityaLayers[i]);
          }
          this.entityaLayers = [];
          break;
        case "h8":
          sgworld.Creator.createSimpleGraphic(
            "label",
            {},
            function (entity) { }
          );
          break;
      }
    },
    handleSaveClick () {
      let funDownload = function (content, filename) {
        let eleLink = document.createElement("a");
        eleLink.download = filename;
        eleLink.style.display = "none";
        // 字符内容转变成blob地址
        let blob = new Blob([content]);
        eleLink.href = URL.createObjectURL(blob);
        // 触发点击
        document.body.appendChild(eleLink);
        eleLink.click();
        // 然后移除
        document.body.removeChild(eleLink);
      };
      let entities = new Cesium.EntityCollection();
      let dataSources = sgworld.Viewer.dataSources;
      for (let i = 0, j = dataSources.length; i < j; i++) {
        for (let v of dataSources.get(i).entities.values) {
          entities.add(v);
        }
      }
      for (let v of sgworld.Viewer.entities.values) {
        entities.add(v);
      }
      if (entities.values.length) {
        console.log(sgworld.Viewer.entities);
        let promise = Cesium.exportKml({ entities: sgworld.Viewer.entities });
        console.log(entities);
        // let promise = Cesium.exportKml({ entities: entities });
        promise.then(function (e) {
          funDownload(e.kml, new Date().getTime() + ".kml");
        });
      } else {
        alert("当前场景没有entities实体");
      }
    },
    handleSaveShp () {
      var entities = sgworld.Viewer.entities.values;
      if (entities.length == 0) {
        return;
      }
      var std = [];
      for (var i in entities) {
        var type, fillColor, alpha, wkt, name;
        var bak = {};
        if (entities[i].name) {
          name = entities[i].name;
        }
        if (entities[i].properties) {
          var properties = entities[i].properties.propertyNames;
          for (var j in properties) {
            bak[properties[j]] = entities[i].properties[properties[j]]._value;
          }
        } else {
          bak = {
            name: entities[i].name,
          };
        }
        if (entities[i].rectangle) {
          //矩形
          type = "rectangle";
          var east = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().east
          );
          var north = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().north
          );
          var west = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().west
          );
          var south = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().south
          );
          var line = turf.polygon([
            [
              [east, north],
              [west, north],
              [west, south],
              [east, south],
              [east, north],
            ],
          ]);
          wkt = this.$wkt.convert(line.geometry);
          var fill = entities[i].rectangle._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].point) {
          //点
          type = "point";
          let ellipsoid = Viewer.scene.globe.ellipsoid;
          let cartographic = ellipsoid.cartesianToCartographic(
            entities[i].position.getValue()
          );
          let lat = Cesium.Math.toDegrees(cartographic.latitude);
          let lng = Cesium.Math.toDegrees(cartographic.longitude);
          let alt = cartographic.height;
          let point = turf.point([lng, lat, alt]);
          wkt = this.$wkt.convert(point.geometry);
          var fill = entities[i].point._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].polygon) {
          type = "polygon";
          var fill = entities[i].polygon._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
          var geometry = entities[i].polygon.hierarchy.getValue().positions;
          var coordinates = [];
          for (var k in geometry) {
            coordinates.push(this.setCartesianToEightFour(geometry[k]));
          }
          if (coordinates[0] != coordinates[1]) {
            coordinates.push(coordinates[0]);
          }
          var polygon = turf.polygon([coordinates]);
          wkt = this.$wkt.convert(polygon.geometry);
        } else if (entities[i].polyline) {
          type = "polyline";
          var coordinates = [];
          var geometry = entities[i].polyline.positions.getValue();
          for (var k in geometry) {
            coordinates.push(this.setCartesianToEightFour(geometry[k]));
          }
          var polyline = turf.lineString(coordinates);
          wkt = this.$wkt.convert(polyline.geometry);
          var fill = entities[i].polyline._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].label) {
          type = "label";
          let ellipsoid = Viewer.scene.globe.ellipsoid;
          let cartographic = ellipsoid.cartesianToCartographic(
            entities[i].position.getValue()
          );
          let lat = Cesium.Math.toDegrees(cartographic.latitude);
          let lng = Cesium.Math.toDegrees(cartographic.longitude);
          let alt = cartographic.height;
          let point = turf.point([lng, lat, alt]);
          wkt = this.$wkt.convert(point.geometry);
          var fill = entities[i].label.backgroundColor._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        }
        std.push({
          id: parseInt(i) + 1,
          type: type,
          fillColor: fillColor,
          opacity: alpha,
          name: name,
          bak: JSON.stringify(bak),
          wkt: wkt,
        });
      }
      $.ajax({
        url: BASE_URL + "/comprehensive/downloadShp?token=" + getToken(),
        type: "POST",
        data: JSON.stringify(std),
        dataType: "json", // html、json、jsonp、script、text
        contentType: "application/json", // "application/x-www-form-urlencoded"
        success: (rs) => {
          if (rs && rs.code == 200) {
            var a = document.createElement("a"); // 创建一个a标签元素
            a.style.display = "none"; // 设置元素不可见
            a.href =
              BASE_URL +
              "/comprehensive/downloadFile?token=" +
              getToken() +
              "&guid=" +
              rs.result;
            document.body.appendChild(a); // 加入
            a.click(); // 触发点击,下载
            document.body.removeChild(a); // 释放
          }
        },
        error: function (e) { },
      });
    },
    handleOpenShp () {
      var formData = new FormData();
      var fs = document.getElementById("shpFile");
      var exts = [".shp", ".shx", ".dbf", ".prj"];
      var count = 0;
      for (var i = 0, c = fs.files.length; i < c; i++) {
        var name = fs.files[i].name.toLocaleLowerCase();
        var ext = name.substring(name.lastIndexOf("."));
        if (exts.indexOf(ext) > -1) {
          count++;
          formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
        }
      }
      if (count != 4) {
        alert("ShapeFile文件选择不全!");
        return;
      }
      var that = this;
      $.ajax(BASE_URL + "/comprehensive/uploadShp?token=" + getToken(), {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          if (rs.code == 200) {
            that.showShpEntity(rs.result);
          }
        },
        error: function (e) {
          console.error(e);
        },
      });
      document.getElementById("shpFile").value = "";
    },
    showShpEntity (res) {
      for (var i in res) {
        var wkt = this.$wkt.parse(res[i].wkt);
        var fillColor = res[i].fillColor.split(",");
        var color = new Cesium.Color(
          parseFloat(fillColor[0]),
          parseFloat(fillColor[1]),
          parseFloat(fillColor[2]),
          res[i].opacity
        );
        var name = res[i].name;
        switch (res[i].type) {
          case "rectangle":
          case "polygon":
            var std = [];
            var geo = wkt.coordinates[0];
            for (var i in geo) {
              std.push(geo[i][0]);
              std.push(geo[i][1]);
            }
            var entity = Viewer.entities.add({
              name: name,
              polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray(std),
                //height : 100000,
                material: color,
                outline: true,
                outlineColor: color,
              },
            });
            this.entityaLayers.push(entity);
            sgworld.Navigate.flyToObj(entity)
            break;
          case "point":
            let point = Viewer.entities.add({
              name: name,
              position: Cesium.Cartesian3.fromDegrees(
                wkt.coordinates[0],
                wkt.coordinates[1]
              ), //经纬度转世界坐标
              point: {
                show: true,
                color: color,
                pixelSize: 10,
                outlineColor: color,
                outlineWidth: 3,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            });
            this.entityaLayers.push(point);
            sgworld.Navigate.flyToObj(point)
            break;
          case "polyline":
            var std = [];
            var geo = wkt.coordinates;
            for (var i in geo) {
              std.push(geo[i][0]);
              std.push(geo[i][1]);
            }
            let line = Viewer.entities.add({
              name: name,
              polyline: {
                //经纬度数组转世界坐标,带高度的话是fromDegreesArrayHeights
                positions: Cesium.Cartesian3.fromDegreesArray(std),
                width: 10,
                material: color,
                clampToGround: true,
              },
            });
            this.entityaLayers.push(line);
            sgworld.Navigate.flyToObj(line)
            break;
          case "label":
            const label = Viewer.entities.add({
              position: Cesium.Cartesian3.fromDegrees(
                wkt.coordinates[0],
                wkt.coordinates[1]
              ),
              label: {
                text: name,
                fillColor: color,
                font: "28px",
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                verticalOrigin: Cesium.VerticalOrigin.TOP,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            });
            this.entityaLayers.push(label);
            sgworld.Navigate.flyToObj(label)
            break;
        }
      }
    },
    setCartesianToEightFour (res) {
      var std = [];
      let ellipsoid = Viewer.scene.globe.ellipsoid;
      let cartographic = ellipsoid.cartesianToCartographic(res);
      let lat = Cesium.Math.toDegrees(cartographic.latitude);
      let lng = Cesium.Math.toDegrees(cartographic.longitude);
      let alt = cartographic.height;
      std = [lng, lat, alt];
      return std;
    },
    handleOpenClick () {
      var that = this;
      sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
      let fileInput = document.querySelector(".file");
      fileInput.onchange = function (evt) {
        let files = evt.target.files;
        if (files.length > 0) {
          let file = evt.target.files[0];
          let fileReader = new FileReader();
          fileReader.readAsDataURL(file);
          fileReader.onload = () => {
            var kmlOptions = {
              camera: sgworld.Viewer.scene.camera,
              canvas: sgworld.Viewer.scene.canvas,
              clampToGround: true,
            };
            var geocachePromise = Cesium.KmlDataSource.load(
              fileReader.result,
              kmlOptions
            );
            sgworld.Navigate.flyToObj(geocachePromise)
            geocachePromise.then(function (dataSource) {
              var geocacheEntities = dataSource.entities.values;
              that.entityaLayers = geocacheEntities;
              for (var i = 0; i < geocacheEntities.length; i++) {
                var entity = geocacheEntities[i];
                sgworld.Viewer.entities.add(entity);
              }
            });
            // sgworld.Viewer.dataSources
            //   .add(
            //     Cesium.KmlDataSource.load(fileReader.result, {
            //       camera: sgworld.Viewer.scene.camera,
            //       canvas: sgworld.Viewer.scene.canvas,
            //     })
            //   )
            //   .then((KmlDataSource) => {
            //     console.log(KmlDataSource);
            //     // let entities = kmlDataSource.entities;
            //   });
          };
        }
        // fileInput.value = null;
      };
      fileInput.click();
    },
    setLayerScene () {
      var URL = window.location.href.split("#");
      this.openwindow({ url: URL[0] + "LfSKyline/index.html" });
    },
    openwindow (data) {
      var url = data.url; //转向网页的地址;
      var name = data.title || "选择要添加的页面"; //网页名称,可为空;
      var iWidth = window.screen.width; //弹出窗口的宽度;
      var iHeight = window.screen.height; //弹出窗口的高度;
      var iTop = 0; //获得窗口的垂直位置;
      var iLeft = 0; //获得窗口的水平位置;
      window.open(
        url,
        name,
        "height=" +
        iHeight +
        ",,innerHeight=" +
        iHeight +
        ",width=" +
        iWidth +
        ",innerWidth=" +
        iWidth +
        ",top=" +
        iTop +
        ",left=" +
        iLeft +
        ",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no"
      );
    },
    setMeasurement (res) {
      switch (res) {
        case "j1":
          var measure = window.sgworld.Command.execute(
            0,
            2,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("表面距离", data);
            }
          );
          break;
        case "j6":
          var measure = window.sgworld.Command.execute(
            0,
            10,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("空间距离", data);
            }
          );
          break;
        // case 'j3':
        //   var measure = window.sgworld.Command.execute(0, 3, this.colorAll, (data) => {
        //     data.id = window.sgworld.Core.getuid();
        //     this.measureData.set(data.id, measure);
        //     this.openMeasureResultInfo('平面面积', data);
        //   });
        //   break;
        case "j2":
          var measure = window.sgworld.Command.execute(
            0,
            5,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("垂直高度", data);
            }
          );
          break;
        case "j5":
          var measure = window.sgworld.Command.execute(
            0,
            8,
            {
              ...this.colorAll,
              tin: true, // 是否显示tin三角网
              onlyTerrain: false, // 是否只测量精细地形
            },
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("表面面积", data);
            }
          );
          break;
        case "j3":
          var measure = window.sgworld.Command.execute(
            0,
            3,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("平面面积", data);
            }
          );
          break;
        case "j4":
          var volumetricMeasurementTool =
            window.sgworld.Creator.createVolumetricMeasureTool();
          volumetricMeasurementTool.startDrawing(
            { ...this.colorAll, onlyTerrain: false },
            "auto",
            (data) => {
              if (volumetricMeasurementTool.popupData) {
                volumetricMeasurementTool.popupData.value = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
                  }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
              } else {
                data.id = window.sgworld.Core.getuid();
                this.measureData.set(data.id, volumetricMeasurementTool);
                let popupData = this.openMeasureResultInfo("体积方量", data);
                volumetricMeasurementTool.popupData = popupData;
              }
            }
          );
          break;
        case "j8":
          var measure = window.sgworld.Command.execute(
            0,
            12,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("角度", data);
            }
          );
          break;
        case "j7":
          var measure = window.sgworld.Command.execute(
            1,
            11,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("海拔高度", data);
            }
          );
          break;
      }
    },
    openMeasureResultInfo (name, data) {
      let info = "";
      switch (name) {
        case "表面距离":
        case "空间距离":
          info = "总长度:" + data.distance[data.distance.length - 1];
          break;
        case "海拔高度":
          info = "高度:" + data.height;
          break;
        case "垂直高度":
          info = `${data.gddistance}<br>${data.kjdistance}<br>${data.spdistance}`;
          break;
        case "表面面积":
        case "平面面积":
          info = data.mj;
          break;
        case "角度":
          data.labels.forEach((label) => {
            info += label.label.text.getValue() + "<br>";
          });
          break;
        case "体积方量":
          info = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
            }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
          break;
      }
      return (
        this.$refs &&
        this.$refs.mapinfo &&
        this.$refs.mapinfo.open(name, info, {
          close: () => {
            // 清除测量
            this.clearMeasure(data.id);
          },
        })
      );
    },
    clearMeasure (id) {
      if (id) {
        let data = this.measureData.get(id);
        data && data.deleteObject && data.deleteObject();
        // 体积方量
        data && data.cleanUp && data.cleanUp();
        this.measureData.delete(id);
      } else {
        this.measureData.forEach((data) => {
          data.deleteObject && data.deleteObject();
          // 体积方量
          data.cleanUp && data.cleanUp();
        });
        this.measureData.clear();
      }
    },
    setIquery (res) {
      switch (res) {
        case "e2":
          this.showPickUp = false;
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "1";
          break;
        case "e1":
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "2";
          this.showPickUp = false;
          break;
        //拾取功能
        case "e3":
          this.$store.state.mapMenuBoolean = false;
          this.showPickUp = !this.showPickUp;
          if (this.showPickUp) {
            let that = this;
            Viewer.screenSpaceEventHandler.setInputAction(function (event) {
              let p = sgworld.Navigate.getMouseDegrees(event);
              console.log(p);
              if (that.showPickUp) {
                that.getPickUpData(p);
              }
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
          } else {
            this.$refs.queryinfo.closeAll();
            Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          }
          break;
      }
    },
    clearAllAnalsy () {
      // switch (this.showTwoMenuFlag) {
      //   case 'd1':
      //     that.isolineFlag = false;
      //     elevationTool.tf = that.isolineFlag;
      //     elevationTool.render();
      //     break;
      //   case 'd2':
      //     that.isslopeFlag = false;
      //     elevationTool.type = 'none';
      //     elevationTool.render();
      //     break;
      // }
    },
    ClearDraw () {
      //console.log(sgworld);
      //   console.log(sgworld.drawObj.drawHandler);
      //   sgworld.drawObj.drawHandler.destroy();
      //   sgworld.drawObj.end()
    },
    setAnalsy (res) {
      //this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close("queryinfo");
      this.$bus.$emit("closeMenuPop", res);
      var that = this;
      switch (res) {
        case "d1": //等高线分析
          this.closePipelinePop();
          that.isolineFlag = !that.isolineFlag;
          elevationTool.tf = that.isolineFlag;
          elevationTool.render();
          break;
        case "d2": //坡度分析
          this.closePipelinePop();
          that.isslopeFlag = !that.isslopeFlag;
          var val = {
            name: "Lengend",
            id: res,
            vshow: that.isslopeFlag,
          };
          this.$bus.$emit("mapChangeBox", val);
          window.PDelevationTool = new SmartEarth.ElevationTool(sgworld); //全局变量
          if (that.isslopeFlag == true) {
            PDelevationTool.type = "slope";
            PDelevationTool.tf = this.checked;
          } else {
            PDelevationTool.type = "none";
          }
          PDelevationTool.render();
          break;
        case "d3": //路径分析
          this.closePipelinePop();
          this.isRouter = !this.isRouter;
          let value;
          if (this.isRouter) {
            value = {
              name: "Analysis",
              id: 3,
              show: true,
            };
          } else {
            value = {
              name: "Analysis",
              id: 3,
              show: false,
            };
          }
          this.$bus.$emit("mapChangeBox", value);
          break;
        case "d4": //剖面分析
          this.closePipelinePop();
          if (window.AnalysisDXPM) {
            window.AnalysisDXPM.end && window.AnalysisDXPM.end("cancel");
            this.clear(res);
          } else {
            this.addterrainSectionAnalysis();
          }
          break;
        case "d5": //洪水淹没分析
          this.closePipelinePop();
          if (window.AnalysisFlood) {
            this.clear(res);
          } else {
            this.addAnalysisFlood();
          }
          break;
        case "d6": //土方量分析
          this.closePipelinePop();
          if (window.TFvolumetricMeasurementTool) {
            TFvolumetricMeasurementTool.cleanUp();
            if (TFvolumetricMeasurementTool._mouseHandler) {
              TFvolumetricMeasurementTool._mouseHandler.destroy();
              TFvolumetricMeasurementTool = null;
              Viewer._container.style.cursor = "default";
              return;
            }
            TFvolumetricMeasurementTool = null;
            this.$refs.mapinfo && this.$refs.mapinfo.close();
          } else {
            var that = this;
            window.TFvolumetricMeasurementTool =
              sgworld.Creator.createVolumetricMeasureTool();
            TFvolumetricMeasurementTool.startDrawing(
              { ...this.colorAll, onlyTerrain: false },
              "auto",
              (data) => {
                if (TFvolumetricMeasurementTool.popupData) {
                  TFvolumetricMeasurementTool.popupData.value = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
                    }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
                } else {
                  data.id = sgworld.Core.getuid();
                  this.measureData.set(data.id, TFvolumetricMeasurementTool);
                  let popupData = that.openMeasureResultInfo("体积方量", data);
                  TFvolumetricMeasurementTool.popupData = popupData;
                }
              }
            );
          }
          break;
        case "d7": //三维截面分析
          this.closePipelinePop();
          // if(window.MXModel) {
          //   Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          //   window.MXModel=null;
          // } else {
          var that = this;
          that.modelClip = !that.modelClip;
          if (that.modelClip) {
            // that.$store.state.propertiesFlag = '3';
            if (window.model) {
              that.modelClipping();
            }
            else {
              var tileset = Viewer.scene.primitives.add(
                new Cesium.Cesium3DTileset({
                  name: res.cnName,
                  url: modelUrl + "/tileset/m/SN/tileset.json",
                  maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
                  maximumMemoryUsage: 768, // 最大内存:512
                  dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
                  skipLevelOfDetail: true, // 在遍历时候跳过详情:false
                })
              );
              tileset.readyPromise.then((tileset) => {
                tileset.id = res.cnName;
                tileset.layerId = res.id;
                Viewer.flyTo(tileset);
                that.modelClipping();
              });
              window.model = tileset
            }
          }
          else {
            // that.$store.state.propertiesFlag = '';
            Viewer.entities.removeAll();
          }
          // window.model = sgworld.Creator.create3DTilesets(
          //   "",
          //   modelUrl + "/tileset/m/SN/tileset.json",
          //   {},
          //   {},
          //   "0",
          //   true,
          //   (data) => {
          //     sgworld.Navigate.flyToObj(data);
          //     that.setclippingModel();
          //   }
          // );
          break;
        case "d9": //管道分析
          this.isPiple = !this.isPiple;
          if (this.isPiple) {
            this.$store.state.mapPopBoxFlag = "3";
            this.$refs &&
              this.$refs.queryinfo &&
              this.$refs.queryinfo.open("管道空间分析", null, {
                close: () => {
                  if (this.$store.state.pipelineEntity.length != 0) {
                    for (var i in this.$store.state.pipelineEntity) {
                      sgworld.Viewer.entities.remove(
                        this.$store.state.pipelineEntity[i]
                      );
                    }
                  }
                },
              });
          } else {
            this.$refs &&
              this.$refs.queryinfo &&
              this.$refs.queryinfo.close("queryinfo");
          }
          break;
        case "d8": //影像对比
          this.closePipelinePop();
          if (this.isContrastFlag == false) {
            this.isContrastFlag = true;
            var localUrl = 'http://{host}/LFData/2d/tiles/img/{z}/{x}/{y}.png'
            localUrl = localUrl.replace("{host}", iisHost)
            window.contRastLayer = Viewer.imageryLayers.addImageryProvider(
              new Cesium.UrlTemplateImageryProvider({
                url: localUrl,
                maximumLevel: 22,
              })
            );
            Viewer.imageryLayers.lowerToBottom(window.contRastLayer);//将图层移到最底层
            Viewer.imageryLayers.raise(window.contRastLayer);//将图层上移一层
            if (window.BaseMapLayer) {
              Viewer.imageryLayers.raise(window.contRastLayer);//将图层上移一层
              sgworld.Analysis.createCurtainContrast(1, 2);
            } else {
              sgworld.Analysis.createCurtainContrast(0, 1);
            }
          } else {
            this.isContrastFlag = false;
            sgworld.Analysis.clearCurtainContrast();
            if (window.contRastLayer) {
              window.Viewer.imageryLayers.remove(
                window.contRastLayer
              );
              window.contRastLayer = null;
            }
          }
          break;
        case "d10": //地面整平
          this.closePipelinePop();
          var val = {
            name: "Trrain",
            id: res,
          };
          this.$bus.$emit("mapChangeBox", val);
          // if (this.DXZPState != null) {
          //   this.DXZPState.drawHandler && this.DXZPState.drawHandler.destroy();
          //   Viewer._container.style.cursor = "default";
          //   this.DXZPState.tooltip && this.DXZPState.tooltip.show(false);
          //   if (window.DXTerrainFlattening != null) {
          //     DXTerrainFlattening.remove();
          //   }
          //   window.DXTerrainFlattening = null;
          //   this.DXZPState = null;
          // } else {
          //   this.DXZPState = sgworld.Creator.createSimpleGraphic(
          //     "polygon",
          //     {
          //       clampToGround: true,
          //     },
          //     function (entity) {
          //       let positions = entity.polygon.hierarchy.getValue().positions;
          //       sgworld.Creator.SimpleGraphic.remove(entity.id);
          //       window.DXTerrainFlattening =
          //         sgworld.Creator.createTerrainModifier(
          //           "地形压平",
          //           positions,
          //           10,
          //           {}
          //         );
          //     }
          //   );
          // }
          break;
        case "d11": //地形开挖
          this.closePipelinePop();
          // this.$refs &&
          //   this.$refs.terrainDig &&
          //   this.$refs.terrainDig.open("管道空间分析", null, {
          //     close: () => {
          //     },
          //   });
          if (window.Excavation) {
            window.Excavation.drawHandler &&
              window.Excavation.drawHandler.destroy();
            Viewer._container.style.cursor = "default";
            window.Excavation.tooltip && window.Excavation.tooltip.show(false);
            window.Excavation.clear();
            window.Excavation = null;
          } else {
            window.Excavation = sgworld.Analysis.TerrainExcavation(
              10,
              {},
              function () { }
            );
          }
          break;
        case "d12": //通视分析
          this.closePipelinePop();
          if (window.TSExcavation != null) {
            window.TSExcavation._SimpleGraphic.drawHandler &&
              window.TSExcavation._SimpleGraphic.drawHandler.destroy();
            Viewer._container.style.cursor = "default";
            window.TSExcavation._SimpleGraphic.tooltip &&
              window.TSExcavation._SimpleGraphic.tooltip.show(false);
            window.TSExcavation.deleteObject();
            window.TSExcavation = null;
          } else {
            window.TSExcavation = sgworld.Analysis.createSightLine({
              type: "default",
            });
          }
          break;
        case "d13": //视域分析
          this.closePipelinePop();
          if (window.SYExcavatio) {
            window.SYExcavatio.end && window.SYExcavatio.end();
            window.SYExcavatio.close();
            window.SYExcavatio = null;
          } else {
            var SYFX_visible_color = { r: 0.0, g: 1.0, b: 0.0 },
              SYFX_notVisible_color = { r: 1.0, g: 0.0, b: 0.0 };
            window.SYExcavatio = sgworld.Analysis.create3DViewshed({
              name: "Viewshed On Frederick",
              height: 1.8,
              color: {
                Back: SYFX_notVisible_color,
                Fore: SYFX_visible_color,
              },
              isSpherical: "",
            });
          }
          break;
        case "d14": //圆形时域分析
          this.closePipelinePop();
          if (window.YXSYExcavation) {
            window.YXSYExcavation.end && window.YXSYExcavation.end();
            window.YXSYExcavation.close();
            window.YXSYExcavation = null;
          } else {
            var SYFX_visible_color = { r: 0.0, g: 1.0, b: 0.0 },
              SYFX_notVisible_color = { r: 1.0, g: 0.0, b: 0.0 };
            window.YXSYExcavation = sgworld.Analysis.create3DViewshed({
              name: "Viewshed On Frederick",
              height: 1.8,
              color: {
                Back: SYFX_notVisible_color,
                Fore: SYFX_visible_color,
              },
              isSpherical: "spherical",
            });
          }
          break;
      }
    },
    //模型裁切
    modelClipping () {
      const scene = Viewer.scene;
      let targetY = 40.0;
      let planeEntities = [];
      let selectedPlane;
      let clippingPlanes = new Cesium.ClippingPlaneCollection({
        planes: [ // ClippingPlane对象数组集合
          new Cesium.ClippingPlane( // 裁切面
            new Cesium.Cartesian3(0.0, 0.0, -1.0), // 法线方向
            0// 原点到平面的最短距离,设置0就好
          ),
        ],
        enabled: true,
        edgeWidth: 1.0, // 模型被裁切部分的截面线宽
      });
      // let clippingPlanes = new Cesium.ClippingPlaneCollection({
      //   planes: [ // ClippingPlane对象数组集合
      //     //前后切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 1, 0), 0), //后
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, -1, 0), 0),  //前
      //     // 左右切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0), 0), //左
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0), 0),  //右
      //     // 上下切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, -1), 0),  //上→下
      //     // new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, 1), 0),  //下→上、
      //   ],
      //   enabled: true,
      //   edgeWidth: 1.0, // 模型被裁切部分的截面线宽
      //   unionClippingRegions: true, //true 才能多个切割
      // });
      let boundingSphere = window.model.boundingSphere;
      // 创建一个坐标轴,便于测试
      // var transform = Cesium.Transforms.eastNorthUpToFixedFrame(boundingSphere.center);
      // var modelMatrixPrimitive = Viewer.scene.primitives.add(new Cesium.DebugModelMatrixPrimitive({
      //   // modelMatrix: transform,
      //   length: 140.0
      // }));
      // // 创建添加裁剪平面
      for (let i = 0; i < clippingPlanes.length; ++i) {
        const plane = clippingPlanes.get(i);
        const planeEntity = Viewer.entities.add({
          position: boundingSphere.center,
          plane: {
            dimensions: new Cesium.Cartesian2(
              boundingSphere.radius * 1.5,
              boundingSphere.radius * 1.5
            ),//切面的长和宽
            material: Cesium.Color.WHITE.withAlpha(0.1),
            plane: new Cesium.CallbackProperty(
              // 添加绑定事件,不断调用
              createPlaneUpdateFunction(plane),
              false
            ),
            outline: true,
            outlineColor: Cesium.Color.WHITE,
          },
        });
        planeEntities.push(planeEntity);
      }
      // 创建添加裁剪平面
      // let m_box;
      // for (let i = 0; i < clippingPlanes.length; ++i) {
      //   let plane = clippingPlanes.get(i);
      //   let getPlaneType = getType4Plane(plane);
      //   let planeEntity = Viewer.entities.add({ //添加平面实体 直观裁切面
      //     id: 'ClipPlane' + i,
      //     position: boundingSphere.center,// 根据3dtiles同步调整裁切面高度
      //     plane: {
      //       dimensions: new Cesium.Cartesian2(80, 80),//切面的长和宽
      //       plane: new Cesium.CallbackProperty(createPlaneUpdateFunction_box(plane, getPlaneType, boundingSphere.center), false),
      //       material: Cesium.Color.WHITE.withAlpha(0.2),
      //       outline: false,
      //       outlineColor: Cesium.Color.WHITE,
      //     }
      //   });
      //   if (!m_box) {
      //     m_box = Viewer.entities.add({
      //       id: 'ClopBox',
      //       modelMatrixPrimitive: modelMatrixPrimitive,
      //       position: boundingSphere.center,
      //       box: {
      //         dimensions: new Cesium.Cartesian3(boundingSphere.radius * 1.2, boundingSphere.radius * 1.2, 40),
      //         material: Cesium.Color.WHITE.withAlpha(0.3),
      //       }
      //     })
      //   }
      // }
      window.model.clippingPlanes = clippingPlanes;
      if (window.modelHeight && window.modelHeight != 0) {
        // console.log("window.modelHeight---",window.modelHeight)
        window.model.clippingPlanes.modelMatrix = Cesium.Matrix4.fromTranslation(
          new Cesium.Cartesian3(0.0, 0.0, window.modelHeight)
        );
      }
      // 绑定上移动事件
      const downHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      downHandler.setInputAction(function (movement) {
        const pickedObject = scene.pick(movement.position);
        if (
          Cesium.defined(pickedObject) &&
          Cesium.defined(pickedObject.id.plane)
        ) {
          selectedPlane = pickedObject.id.plane;
          selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.05);
          selectedPlane.outlineColor = Cesium.Color.WHITE;
          scene.screenSpaceCameraController.enableInputs = false;
        }
      }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
      // 绑定下移动事件
      const upHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      upHandler.setInputAction(function () {
        if (Cesium.defined(selectedPlane)) {
          selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.1);
          selectedPlane.outlineColor = Cesium.Color.WHITE;
          selectedPlane = undefined;
        }
        scene.screenSpaceCameraController.enableInputs = true;
      }, Cesium.ScreenSpaceEventType.LEFT_UP);
      // Update plane on mouse move
      const moveHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      moveHandler.setInputAction(function (movement) {
        if (Cesium.defined(selectedPlane)) {
          const deltaY = movement.startPosition.y - movement.endPosition.y;
          targetY += deltaY;
          // console.log("targetY----",targetY)
        }
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      function createPlaneUpdateFunction (plane) {
        return function () {
          plane.distance = targetY;
          // console.log("targetY----",targetY)
          return plane;
        };
      }
      //获取切面的type // 上、下、左、右、前、后
      function getType4Plane (plane) {
        var m_type;
        var normal = plane._normal;
        var x = normal.x;
        var y = normal.y;
        var z = normal.z;
        if (x == 1 && y == 0 && z == 0) {
          m_type = 'left';
        }
        else if (x == -1 && y == 0 && z == 0) {
          m_type = 'right';
        }
        else if (x == 0 && y == 1 && z == 0) {
          m_type = 'behind';
        }
        else if (x == 0 && y == -1 && z == 0) {
          m_type = 'front';
        }
        else if (x == 0 && y == 0 && z == -1) {
          m_type = 'top';
        }
        return m_type;
      }
      function createPlaneUpdateFunction_box (plane, type, origin) {
        return function () {
          var num_x = window.localStorage.getItem('slider_x') / 100000;
          var num_y = window.localStorage.getItem('slider_y') / 100000;
          var num_z = window.localStorage.getItem('slider_z') / 1.5;//读取滑动条值
          var origin_degree = cartesian3ToDegrees(origin);
          var target_degree_x = [origin_degree[0] + num_x, origin_degree[1], +origin_degree[2]];
          var target_degree_y = [origin_degree[0], origin_degree[1] + num_y, +origin_degree[2]];
          var target_degree_z = [origin_degree[0], origin_degree[1], +origin_degree[2] + num_z];
          var m_dis_x = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_x[0], target_degree_x[1], target_degree_x[2]));
          var m_dis_y = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_y[0], target_degree_y[1], target_degree_y[2]));
          var m_dis_z = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_z[0], target_degree_z[1], target_degree_z[2]));
          createPlanePos(origin_degree, num_x, num_y, num_z);
          let distance = 140;
          if (type == 'left') {
            if (num_x < 0) {
              plane.distance = distance - (-m_dis_x);
              return plane;
            } else {
              plane.distance = distance - m_dis_x
              return plane;
            }
          }
          else if (type == 'behind') {
            if (num_y < 0) {
              plane.distance = distance - (-m_dis_y);
              return plane;
            } else {
              plane.distance = distance - m_dis_y;
              return plane;
            }
          }
          else if (type == 'right') {
            if (num_x < 0) {
              plane.distance = distance - m_dis_x;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_x);
              return plane;
            }
          }
          else if (type == 'front') {
            if (num_y < 0) {
              plane.distance = distance - m_dis_y;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_y);
              return plane;
            }
          }
          else if (type == 'top') {
            if (num_z < 0) {
              plane.distance = m_dis_z;
              // console.log('num_z=========',num_z)
              // console.log('m_dis_z=========',m_dis_z)
              // plane.distance = distance - m_dis_z;
              return plane;
            } else {
              // plane.distance = 100;
              plane.distance = distance - (-m_dis_z);
              return plane;
            }
          }
          return plane;
        };
      }
      function createPlanePos (origin, x, y, z) {
        var clipbox = Viewer.entities.getById('ClopBox');
        if (clipbox) {
          clipbox.position = new Cesium.CallbackProperty(function () {
            return Cesium.Cartesian3.fromDegrees(origin[0] + x, origin[1] + y, +origin[2] + z);//实时返回当前盒子的位置
          }, false);
        }
      }
      function cartesian3ToDegrees (cartesian3) {
        var ellipsoid = Viewer.scene.globe.ellipsoid;
        var cartographic = ellipsoid.cartesianToCartographic(cartesian3);
        var lat = Cesium.Math.toDegrees(cartographic.latitude);
        var lng = Cesium.Math.toDegrees(cartographic.longitude);
        var alt = cartographic.height;
        var pos = [lng, lat, alt];
        return pos;
      }
    },
    //关闭管道信息弹窗
    closePipelinePop () {
      this.$refs &&
        this.$refs.queryinfo &&
        this.$refs.queryinfo.close("queryinfo");
    },
    setclippingModel () {
      if (window.model) {
        setTimeout(() => {
          window.model.clippingModel({
            direction: "z",
          });
        }, 1000);
        // window.model.clippingModel({
        //   direction: 'z',
        // });
      }
    },
    clear (res) {
      switch (res) {
        case "d4":
          layer.close(this.dxpmIndex);
          this.dxpmIndex = undefined;
          if (window.AnalysisDXPM) {
            window.AnalysisDXPM.flyPoint &&
              Viewer.entities.remove(window.AnalysisDXPM.flyPoint);
            window.AnalysisDXPM && window.AnalysisDXPM.deleteObject();
            window.AnalysisDXPM = undefined;
          }
          break;
        case "d5":
          window.AnalysisFlood.endWater();
          window.AnalysisFlood = undefined;
          break;
      }
    },
    addAnalysisFlood () {
      var url = window.location.href;
      var testurl = "";
      if (url.indexOf("web") != -1) {
        testurl = "/web";
      }
      var method = {
        pointSelect: true,
        spood: 20,
        GroupID: 0,
        url: testurl + "/SmartEarthSDK/Workers/image/33.gif",
      };
      window.AnalysisFlood = sgworld.Command.execute(
        2,
        2,
        method,
        (value) => { }
      );
    },
    addterrainSectionAnalysis () {
      window.AnalysisDXPM = sgworld.Command.execute(
        2,
        6,
        { cyjj: 50, objid: 0 },
        (Distance) => {
          if (Distance.gcs && Distance.gcs.length) {
            var url = window.location.href;
            var testurl = "";
            if (url.indexOf("web") != -1) {
              testurl = "/web";
            }
            window.AnalysisDXPM.analyseData = Distance;
            this.dxpmIndex = layer.open({
              type: 2,
              title: "分析结果",
              shade: false,
              area: ["80%", "280px"],
              offset: "b",
              skin: "other-class",
              content:
                testurl + "/SmartEarthSDK/Workers/analysis/AnalysisDXPM.html",
              end: () => {
                this.dxpmIndex && this.clear("d4");
              },
            });
          } else {
            //剖面
            window.AnalysisDXPM && window.AnalysisDXPM.deleteObject();
          }
        }
      );
    },
    setWander (res) {
      switch (res) {
        case "c1":
          if (window.PointMY != null) {
            window.PointMY.drawHandler && window.PointMY.drawHandler.destroy();
            window.PointMY.end && window.PointMY.end();
            window.PointMY = null;
          } else {
            window.PointMY = window.sgworld.Analysis.setPointFly();
          }
          break;
        case "c2":
          var url = window.location.href;
          var testurl = "";
          if (url.indexOf("web") != -1) {
            testurl = "/web";
          }
          window.sgworld.Command.execute(2, 3, "", (data) => {
            data.showPoint = false;
            data.showLine = true;
            data.mode = 0;
            // 弹窗数据
            window.PathAnimationData = {
              flyData: data,
            };
            window.PathAnimationData.winIndex = layer.open({
              type: 2,
              title: "路径动画",
              shade: false,
              area: ["352px", "690px"],
              offset: "r",
              skin: "other-class",
              content: testurl + "/SmartEarthSDK/Workers/path/Path.html",
              end: function () {
                PathAnimationData.fly && PathAnimationData.fly.exit();
              },
            });
          });
          break;
        case "c3":
          sgworld.Analysis.createindoormode({ showHelp: true });
          break;
        case "c4":
          window.sgworld.Analysis.createScreenshot();
          break;
      }
    },
    setOrientation (res) {
      var resid;
      switch (res) {
        case "f1":
          resid = 1;
          break;
        case "f2":
          resid = 2;
          break;
      }
      var val = {
        name: "Coord",
        id: resid,
      };
      this.$bus.$emit("mapChangeBox", val);
    },
    setViewport (res) {
      switch (res) {
        case "b1": //分屏
          this.$bus.$emit("changemap", 1);
          break;
        case "b2": //二维
          this.$bus.$emit("changemap", 2);
          break;
        case "b3": //三维
          this.$bus.$emit("changemap", 3);
          break;
        case "b4": //全图
          window.sgworld.Navigate.jumpTo({
            //跳转视角
            destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000),
          });
          window.map
            .getView()
            .setCenter(transform([110, 32], "EPSG:4326", "EPSG:3857"));
          window.map.getView().setZoom(4);
          break;
        case "b5": //放大
          window.sgworld.Navigate.zoomIn();
          // 获取当前视图
          var zoom = window.map.getView().getZoom(); // 获取当前缩放级别
          window.map.getView().setZoom(zoom + 1); // 设置缩放级别
          break;
        case "b6": //缩小
          window.sgworld.Navigate.zoomOut();
          var zoom = window.map.getView().getZoom(); // 获取当前缩放级别
          window.map.getView().setZoom(zoom - 1); // 设置缩放级别
          break;
        case "b7": //比例尺
          this.isRuler = !this.isRuler;
          window.sgworld.navControl("scale", this.isRuler);
          if (this.isRuler == true) {
            this.scaleLine = new ScaleLine({
              units: "metric",
            });
            window.map.addControl(this.scaleLine);
          } else {
            window.map.removeControl(this.scaleLine);
            this.scaleLine = false;
          }
          break;
        case "b8": //指北针
          this.isNaviget = !this.isNaviget;
          window.sgworld.navControl("nav", this.isNaviget);
          this.$store.state.isNaviget = this.isNaviget;
          break;
        case "b9": //地下模式
          // this.UndergroundMode = !this.UndergroundMode;
          // window.sgworld.Analysis.UndergroundMode(this.UndergroundMode, 0.3);
          if (window.UndergroundMode) {
            this.$refs &&
              this.$refs.undergroundModel &&
              this.$refs.undergroundModel.close();
          } else {
            this.$refs &&
              this.$refs.undergroundModel &&
              this.$refs.undergroundModel.open("地下模式", null,);
          }
          break;
      }
    },
    setCoverage (res) {
      switch (res) {
        case "a1":
          if (this.$store.state.layerMnage == false) {
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.closeAll();
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.open();
            this.$store.state.layerMnage = true;
          } else if (this.$store.state.layerMnage == true) {
            this.$bus.$emit("treeDataCopy", "true");
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.closeAll();
            this.$store.state.layerMnage = false;
          }
          break;
      }
    },
    menuChange (res) {
      this.setListTwoMenu = this.setListTwoMenuAll[res];
    },
    async layersStart () {
      const data = await perms_selectLayers();
      if (data.code != 200) {
        return this.$message.error("图层列表查询失败");
      }
      var std = data.result;
      var that = this;
      var checkKey = [];
      let checkedLayers = [];
      this.$store.state.isProjectLayer = [];
      var val = std.filter((str) => {
        if (str.type == 1) {
          return str;
        }
        if (str.url != null && str.type == 2) {
          if (str.isShow == 1) {
            checkKey.push(str.id);
          }
          return str;
        }
      });
      var value = std.filter((str) => {
        if (str.url != null && str.type == 2 && str.isShow == 1) {
          return str;
        }
      })
      var layer = std.filter((str) => {
        if (str.isProject == 1 && str.type == 2) {
          this.$store.state.isProjectLayer.push(str);
        }
      })
      this.setAddLayers(value);
      var res = this.setTreeData(val);
      this.$store.state.pigCode = null;
      //存储选中图层
      // sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
      // for (var i in res) {
      //   res[i].children = res[i].children.filter((val) => {
      //     if (val.children != null) {
      //       return val;
      //     }
      //   });
      // }
      this.$store.state.oldTree = val;
      this.$store.state.treeData = res;
      this.$store.state.checkedKeys = checkKey;
    },
    setTreeData (source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
        if (branchArr.length > 0) {
          branchArr.sort(function (a, b) {
            return a.orderNum - b.orderNum
          })
        }
        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 == 0; // 返回一级菜单
      });
    },
    setAddLayers (res) {
      this.setClearWmsLayer()
      var std = [[]];
      for (var i in res) {
        switch (res[i].serveType) {
          case "WMS":
            std[0].push(res[i])
            break;
        }
      }
      if (std[0].length != 0) {
        if (this.$store.state.pigCode) {
          this.setPrjidWmsLayer(std[0])
        } else {
          this.setAddWmsLayer(std[0])
        }
      }
    },
    setPrjidWmsLayer (res) {
      var layer = [];
      var sql = [];
      var dirid = this.$store.state.pigCode
      for (var i in res) {
        layer.push(res[i].url)
        if (res[i].isProject == 1) {
          var val = "dirid like '" + dirid + "%'"
          sql.push(val)
        } else {
          sql.push("1 = 1")
        }
      }
      layer = layer.reverse();
      sql = sql.reverse().join(";")
      var getFeatureInfoFormat = new Cesium.GetFeatureInfoFormat("html", null, function (html) {
        that.getFeatureInfo(html)
      });
      window.layerWMS = new Cesium.WebMapServiceImageryProvider({
        url: geoServerURl,
        layers: layer.toString(),
        getFeatureInfoParameters: { info_format: 'text/html' },
        enablePickFeatures: true,
        getFeatureInfoFormats: [getFeatureInfoFormat],
        parameters: {
          transparent: true,
          format: "image/png",
          srs: "EPSG:4490",
          styles: "",
          cql_filter: sql
        },
        tileWidth: 512,
        tileHeight: 512,
      });
      layerWMS.name = "Wms_Layer";
      window.Viewer.imageryLayers.addImageryProvider(window.layerWMS);
      var layer2 = new Image({
        name: "Wms_Layer",
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: layer.toString(),
            cql_filter: sql
          },
        }),
      });
      if (res.opacity) {
        layer2.setOpacity(parseInt(res.opacity) / 100);
      }
      window.map.addLayer(layer2);
    },
    setClearWmsLayer () {
      for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
        var val_id = window.Viewer.imageryLayers._layers[i].imageryProvider.name;
        if (val_id == "Wms_Layer") {
          window.Viewer.imageryLayers.remove(
            window.Viewer.imageryLayers._layers[i]
          );
        }
      }
      var layers_ol = window.map.getAllLayers();
      for (var i in layers_ol) {
        var layerOl = layers_ol[i];
        if (layerOl.values_.name == "Wms_Layer") {
          window.map.removeLayer(layers_ol[i]); //显示图层
        }
      }
    },
    setAddWmsLayer (res) {
      var url = [];
      for (var i in res) {
        if (res[i].url) {
          url.push(res[i].url)
        }
      }
      url = url.reverse();
      var that = this;
      var getFeatureInfoFormat = new Cesium.GetFeatureInfoFormat("html", null, function (html) {
        that.getFeatureInfo(html)
      });
      window.layerWMS = new Cesium.WebMapServiceImageryProvider({
        url: geoServerURl,
        layers: url.toString(),
        getFeatureInfoParameters: { info_format: 'text/html' },
        enablePickFeatures: true,
        getFeatureInfoFormats: [getFeatureInfoFormat],
        parameters: {
          transparent: true,
          format: "image/png",
          srs: "EPSG:4490",
          styles: "",
        },
        tileWidth: 512,
        tileHeight: 512,
      });
      layerWMS.name = "Wms_Layer";
      window.Viewer.imageryLayers.addImageryProvider(window.layerWMS);
      var layer2 = new Image({
        name: "Wms_Layer",
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: url.toString(),
          },
        }),
      });
      if (res.opacity) {
        layer2.setOpacity(parseInt(res.opacity) / 100);
      }
      window.map.addLayer(layer2);
    },
    async getFeatureInfo (html) {
      var start = html.indexOf("<caption class=\"featureInfo\">") + "<caption class=\"featureInfo\">".length;
      var end = html.indexOf("</caption>");
      var tab = html.substr(start, end - start);
      start = html.lastIndexOf(tab) + tab.length + 1;
      end = html.indexOf("</td>", start);
      var gid = html.substr(start, end - start);
      if (gid && tab) {
        this.$store.state.pickoption = {
          gid: gid,
          name: tab.replaceAll("_", "")
        }
        const res = await dataQuery_selectTabByEntity({
          name: this.$store.state.pickoption.name
        })
        if (res.code != 200) {
          return;
        }
        var value = res.result.split('.')
        this.$store.state.propertiesName = {
          ns: value[0],
          enName: value[1],
          tabDesc: '拾取信息'
        }
        var name = this.$store.state.pickoption.name;
        const data = await inquiry_selectFields({ name: name })
        if (data.code != 200) {
          this.$message.error("列表调用失败")
        }
        const data1 = await inquiry_selectDomains({ name: name })
        if (data1.code != 200) {
          this.$message.error("列表调用失败")
        }
        this.optionx = []
        this.attributeData = []
        var valadata = data.result
        var laydomain = data1.result
        this.optionx = data1.result
        for (var i in valadata) {
          if (valadata[i].showtype == 1) {
            if (
              valadata[i].domainNa != null &&
              valadata[i].domainNa != undefined
            ) {
              for (var j in laydomain) {
                if (laydomain[j].domName == valadata[i].domainNa) {
                  // valadata[i].domainNa = laydomain[j].codeDesc
                }
              }
            }
            // this.optionx.push(valadata[i])
            this.attributeData.push(valadata[i])
          }
        }
        this.getTableData()
      }
    },
    //格式化时间
    format (shijianchuo) {
      //shijianchuo是整数,否则要parseInt转换
      var time = new Date(shijianchuo);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return (
        y +
        '-' +
        this.add0(m) +
        '-' +
        this.add0(d) +
        ' ' +
        h +
        ':' +
        mm +
        ':' +
        s
      );
    },
    //格式化时间
    add0 (m) {
      return m < 10 ? '0' + m : m;
    },
    async getTableData () {
      this.tableData = []
      const data = await dataQuery_selectByGid(this.$store.state.pickoption)
      if (data.code != 200) {
        return
      }
      var valste = data.result
      valste.dirid = valste.dirName;
      valste.depid = valste.depName;
      valste.verid = valste.verName;
      valste.createuser = valste.createName;
      valste.updateuser = valste.updateName;
      if (valste.createtime) {
        valste.createtime = this.format(valste.createtime)
      }
      if (valste.updatetime) {
        valste.updatetime = this.format(valste.updatetime)
      }
      for (var j in this.optionx) {
        if (
          this.optionx[j].domainNa != null &&
          this.optionx[j].domainNa != undefined
        ) {
          valste[this.optionx[j].field] = this.optionx[j].domainNa
        }
      }
      var arr = {}
      for (var i = (this.attributeData.length - 1); i >= 0; i--) {
        var vla = this.attributeData[i]
        if (vla.domainNa) {
          var val = this.optionx.filter(res => {
            if (res.domName == vla.domainNa && res.domCode == valste[vla.field]) {
              return res;
            }
          })
          var vlue = null
          if (val.length > 0) {
            vlue = val[0].codeDesc
          } else {
            vlue = ''
          }
          arr[vla.alias] = vlue
        } else {
          arr[vla.alias] = valste[vla.field]
        }
      }
      arr['eventid'] = valste.eventid
      this.$store.state.propertiesInfo = arr;
      this.$store.state.propertiesFlag = '1'
    },
    showModelAttach () {
      if (this.$store.state.attachModel) {
        var name = this.$store.state.attachinfo.cnName;
        this.$refs &&
          this.$refs.modelAttach &&
          this.$refs.modelAttach.open(name, null, {
            close: () => { },
          });
      } else {
      }
    },
    async showModelCatch () {
      if (this.$store.state.catModel) {
        this.formInline = {
          title: '',
          file: '',
          name: '',
          type: '',
          info: '',
          icon: '',
          bak: ''
        }
        this.formInline.title = this.$store.state.catModelInfo.name;
        this.formInline.Id = this.$store.state.catModelInfo.id;
        this.formInline.LayerName = this.$store.state.catModelInfo.layerName;
        this.startModelData();
        this.activeName = "first"
        this.getAttacthFlieList();
        this.dialogVisible = true;
      } else {
        this.dialogVisible = false;
        window.pickedFeature.color = window.pickedColor;
      }
    },
    async startModelData () {
      var obj = {
        layerid: this.$store.state.catModelInfo.layerId,
        modelid: this.$store.state.catModelInfo.id
      }
      const data = await comprehensive_selectModelByGuid(obj);
      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;
      }
    },
    async EditData () {
      const data = await comprehensive_updateModel(this.formInline)
      if (data.code != 200) {
        this.$message.error('修改失败');
      } else {
        this.$message({
          message: '修改成功',
          type: 'success'
        });
      }
      this.startModelData();
    },
    async InsertData () {
      var std = {
        "bak": this.formInline.bak,
        "guid": this.$store.state.catModelInfo.id,
        "layerid": this.$store.state.catModelInfo.layerId,
        "modelid": this.$store.state.catModelInfo.id,
        "name": this.formInline.name,
        "type": this.formInline.type
      }
      const data = await comprehensive_insertModel(std)
      if (data.code != 200) {
        this.$message.error('添加失败');
      } else {
        this.$message({
          message: '添加成功',
          type: 'success'
        });
      }
      this.startModelData();
    },
    handleClose () {
      this.$store.state.catModel = false;
    },
    //附件列表新增
    setAttachInsert () {
      var token = getToken();
      var fs = document.getElementById("insertFile");
      if (fs.files.length == 0) {
        this.$message({
          message: '请选择要上传的文件!',
          type: 'warning'
        });
        return;
      }
      const formData = new FormData()
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append('file', fs.files[i]); // fs.files[i].name,file
      }
      $.ajax(BASE_URL + "/comprehensive/uploadFiles?token=" + token + "&tabName=lf.sys_style&eventid=" + this.$store.state.catModelInfo.id, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: (rs) => {
          this.$message({
            message: '附件添加成功',
            type: 'success'
          });
          document.getElementById("insertFile").value = "";
          this.formInline.file = "";
          this.getAttacthFlieList();
        },
        error: (e) => {
          document.getElementById("insertFile").value = "";
          this.formInline.file = "";
          this.$message.error('附件添加失败');
        }
      });
    },
    //附件列表查询
    async getAttacthFlieList () {
      var obj = {
        eventid: this.$store.state.catModelInfo.id,
        tabName: "lf.sys_style"
      };
      const res = await comprehensive_selectFiles(obj);
      if (res.code != 200) {
        this.$message.error('列表调用失败');
        return
      }
      this.tableData = res.result;
    },
    //附件=>文件选择
    getInsertFile () {
      $('#insertFile').click();
    },
    insertFile () {
      var val = document.getElementById('insertFile').files;
      if (!val || !val.length) return;
      this.formInline.file = val[0].name;
    },
    statSizeChange (row, column) {
      return this.stateFormatSizes(row.sizes)
    },
    stateFormatSizes (res) {
      if (res >= 1024) {
        const val = parseFloat(res / 1024).toFixed(3);
        return val + ' GB';
      } else {
        return res + ' MB';
      }
    },
    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
        || 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;
    },
    refreshAttatchDetail () {
      this.dialog.src = "";
      this.dialog.dialogVisible = false;
      this.dialog.isPdf = false;
      this.dialog.isJpg = false;
    },
    //附件查看
    setAttatchDetail (index, row) {
      this.refreshAttatchDetail()
      var name = row.name;
      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
        || 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
      }
    },
    handleClick (tab, event) {
      if (tab.name == "second") {
        this.getAttacthFlieList();
      }
    },
    //附件刪除
    async setAttachDel () {
      var std = [];
      for (var i in this.attacgSelection) {
        std.push(this.attacgSelection[i].id);
      }
      const res = await comprehensive_deletes({ ids: std.toString() });
      if (res.code != 200) {
        this.$message.error('文件删除失败');
      }
      this.getAttacthFlieList();
    },
    // 附件=>表格选择
    handleAttatchChange (val) {
      this.attacgSelection = val;
    },
    //拾取数据获取
    async getPickUpData (info) {
      let checkedLayers = JSON.parse(sessionStorage.getItem("checkedLayers"));
      let showPop = false;
      for (const item of checkedLayers) {
        let name = item.url.replaceAll("LF:", "");
        name = name.replaceAll("_", "");
        let params = {
          buffer: 10,
          limit: 20,
          name: name,
          wkt: `POINT (${info.lon} ${info.lat})`,
        }
        const res = await selectByBuffer(params);
        if (res.result && res.result.length > 0) {
          this.$store.state.mapPopBoxFlag = "4";
          this.$store.state.pickUpPointInfo = info;
          this.$refs &&
            this.$refs.queryinfo &&
            this.$refs.queryinfo.open("拾取分析", null,);
          showPop = true;
          break;
        }
      }
      if (!showPop) {
        this.$message.warning("暂无数据!");
      }
    },
    showPopBox () {
      if (this.$store.state.showPopBoxFlag == true) {
        this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close();
        this.$refs &&
          this.$refs.queryinfo &&
          this.$refs.queryinfo.open("属性", null, {
            close: () => {
              this.$store.state.showPopBoxFlag == false
              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();
              }
            },
          });
      }
    },
    setPellucidity () {
      this.$refs && this.$refs.setPellucidity && this.$refs.setPellucidity.open();
    },
    setDialogInsertVisible (res) {
      this.ruleForm = res;
      this.dialogInsertVisible = true;
    },
    downloadx () {
      this.$bus.$emit("setInsertDown1", this.codeForm)
      this.closeDownx();
    },
    handleCloseDown1 () {
      this.$confirm("确认关闭?")
        .then(_ => {
          this.closeDownx();
        })
        .catch(_ => { })
    },
    closeDownx () {
      this.dialogVisible1 = false;
      this.codeForm = {
        password: '',
        repassword: '',
      }
    },
    closeInsertDown () {
      this.ruleForm = {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      }
      this.dialogInsertVisible = false
    },
    handleInsertClose () {
      this.$confirm("确认关闭?")
        .then(_ => {
          this.closeInsertDown()
        })
        .catch(_ => { })
    },
    getInsertDownz () {
      this.dialogInsertVisible = false;
      // this.dialogVisible1 = true;
      //
      this.$bus.$emit("setInsertApply1", this.ruleForm)
    },
    handleExtentClose () {
      this.dialogExtentVisible = false
      this.setExtent = 10;
    },
    handleExtentinsert () {
      this.$bus.$emit("setExtentBUff", this.setExtent)
      this.handleExtentClose();
    }
  },
  mounted () {
    this.$bus.$off();
    this.measureData = new Map();
    this.colorAll = {
      point: Cesium.Color.fromCssColorString("#ff0000"),
      polyline: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
      polygon: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
    };
    this.$store.state.setAlphaList = []
    this.$bus.$on("setChangeTwoMenu", (res) => {
      if (res == 8) {
        this.setLayerScene();
      } else {
        this.menuChange(res);
      }
    });
    this.$bus.$on("showMenuLayer", ((res) => {
      this.setAddLayers(res);
    }));
    this.$bus.$on("showPellucidity", res => {
      this.setPellucidity();
    });
    this.$store.state.isProjectLayer = [],
      this.$store.state.pigCode = null,
      this.$store.state.showAllLayers = true;
    this.$store.state.layerMnage = false;
    this.$store.state.treeData = null;
    this.$store.state.checkedKeys = [];
    // this.setCoverage("a1");
    this.layersStart();
    this.$bus.$on("setDialogInsertVisible", (res) => {
      if (res == true) {
        this.dialogVisible1 = true;
      } else {
        this.setDialogInsertVisible(res);
      }
    })
    this.$bus.$on('showExtentLayer', res => {
      this.dialogExtentVisible = res;
    });
  },
  watch: {
    Obj (newVal, oldVal) {
      this.showModelAttach();
    },
    catch (newVal, oldVal) {
      this.showModelCatch();
    },
    popObj (newVal, oldVal) {
      this.showPopBox();
    }
  },
  computed: {
    Obj () {
      return this.$store.state.attachModel;
    },
    catch () {
      return this.$store.state.catModel;
    },
    popObj () {
      return this.$store.state.showPopBoxFlag;
    }
  },
};
</script>
<style lang="less" scoped>
.menu_Box {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  // text-align: center;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  .leftMen_div {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    border: 1px solid rgba(0, 0, 0, 0);
    padding: 5px;
    min-width: 100px;
    margin-left: 10px;
    margin-top: 10px;
    border-radius: 5px;
    text-align: center;
  }
  .leftMen_div:hover {
    background: rgba(64, 158, 255, 0.4);
    border: 1px solid #409eff;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
  }
  .lefMenuDivActive {
    background: rgba(64, 158, 255, 0.4);
    border: 1px solid #409eff;
  }
  .menuTwoImage {
    width: 30px;
    height: 30px;
    display: inline-block;
  }
  .pdfClass {
    height: 63vh;
    width: 100%;
  }
}
</style>
<template>
  <div class="menu_Box box_div">
    <div
      class="leftMen_div"
      @click="setChangeTwoMenu(item)"
      v-for="(item, index) in setListTwoMenu"
      :class="{ lefMenuDivActive: showTwoMenuFlag == item.id }"
    >
      <div
        class="menuTwoImage"
        :class="item.css"
      ></div>
      <div>{{ $t(item.label) }}</div>
    </div>
    <mapinfo ref="mapinfo" />
    <maplayer ref="maplayer" />
    <queryinfo ref="queryinfo" />
    <terrainDig ref="terrainDig" />
    <modelAttach ref="modelAttach" />
    <undergroundModel ref="undergroundModel" />
    <setPellucidity ref="setPellucidity" />
    <input
      type="file"
      accept=".kml"
      class="file"
      style="display: none"
    />
    <input
      :accept="'.shp, .shx, .dbf, .prj'"
      style="display: none"
      ref="pathClear"
      type="file"
      name="file"
      id="shpFile"
      multiple="multiple"
      @change="handleOpenShp()"
    />
    <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="预览"
        :append-to-body="false"
        :visible.sync="dialog.dialogVisible"
        width="70%"
        :modal="false"
        :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 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-form-item :label="$t('common.name')">
                <!-- <el-input v-model="formInline.name"></el-input> -->
                {{formInline.name}}
              </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-option>
                </el-select> -->
                {{formInline.type}}
              </el-form-item>
              <el-form-item :label="$t('common.bak')">
                <!-- <el-input v-model="formInline.bak"></el-input> -->
                {{formInline.bak}}
              </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-form-item> -->
            </el-form>
          </el-tab-pane>
          <el-tab-pane
            label="附件"
            name="second"
          >
            <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"
              >
                <template slot-scope="scope">
                  <el-link
                    v-if="matchState(scope, /[]/)"
                    @click="setAttatchDetail(scope.$index, scope.row)"
                    class="elLink"
                  >{{ $t('common.see') }}</el-link>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
    </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.depid">
                  {{ 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="getInsertDownz()"
            >{{
              $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>
    <el-dialog
      :title="$t('common.passworld')"
      :visible.sync="dialogVisible1"
      width="30%"
      top="35vh"
      :modal="false"
      :before-close="handleCloseDown1"
    >
      <el-form
        :model="codeForm"
        :rules="rules"
        ref="codeForm"
        label-width="100px"
        class="codeForm"
      >
        <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-input
            type="password"
            v-model="codeForm.repassword"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            class="primary"
            size="small"
            @click="downloadx('codeForm')"
          >{{ $t("common.confirm") }}</el-button>
          <el-button
            type="info"
            size="small"
            @click="closeDownx('codeForm')"
          >{{
            $t("common.cancel")
          }}</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog
      title="范围"
      :visible.sync="dialogExtentVisible"
      width="30%"
      :before-close="handleExtentClose"
      :modal="false"
      :lock-scroll="false"
      :close-on-click-modal="false"
    >
      <el-row :gutter="20">
        <el-col :span="16">
          <el-input v-model="setExtent"></el-input>
        </el-col>
        <el-col :span="6">
          <div>
            单位:(m)
          </div>
        </el-col>
      </el-row>
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="handleExtentClose">取 消</el-button>
        <el-button
          @click="handleExtentinsert"
          type="primary"
        >确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { transform } from "ol/proj";
import mapinfo from "../Tools/mapinfo.vue";
import maplayer from "../Tools/maplayer.vue";
import queryinfo from "../Tools/queryinfo.vue";
import terrainDig from "../Tools/terrainDig.vue";
import modelAttach from "../Tools/ModelAttach.vue";
import undergroundModel from "../Tools/undergroundModel.vue";
import setPellucidity from "../Tools/setPellucidity.vue";
import $ from "jquery";
import { getToken } from "@/utils/auth";
import ImageWMS from "ol/source/ImageWMS";
import Image from "ol/layer/Image";
import GeoJSON from "ol/format/GeoJSON.js";
import { Vector as VectorSource } from "ol/source";
import { Vector as VectorLayer } from "ol/layer";
import {
  perms_selectLayers,
  comprehensive_selectModelByGuid,
  comprehensive_selectFiles,
  comprehensive_deletes,
  comprehensive_selectModelByPageAndCount,
  comprehensive_insertModel,
  comprehensive_updateModel, selectByBuffer,
  dataQuery_selectTabByEntity,
  inquiry_selectDomains,
  inquiry_selectFields,
  dataQuery_selectByGid,
} from '../../api/api.js'
import {
  OverviewMap,
  defaults as defaultControls,
  FullScreen,
  ScaleLine,
  Rotate,
} from "ol/control.js";
import * as turf from "@turf/turf";
import { geometry } from "@turf/turf";
export default {
  components: { mapinfo, maplayer, queryinfo, terrainDig, modelAttach, undergroundModel, setPellucidity },
  data() {
    var repasswordValidator = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'));
      } else if (value !== this.codeForm.password) {
        callback(new Error('两次输入密码不一致!'));
      } else {
        callback();
      }
    };
    var passwordValidator = (rule, value, callback) => {
      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位')
        );
      } else {
        callback();
      }
    };
    return {
      rules: {
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }, { validator: passwordValidator, trigger: 'blur' }],
        repassword: [
          { required: true, message: '请输入确认密码', trigger: 'blur' },
          { validator: repasswordValidator, trigger: 'blur' },
        ],
      },
      codeForm: {
        password: '',
        repassword: '',
      },
      showTwoMenuFlag: false,
      setListTwoMenu: [],
      setListTwoMenuAll: [
        [
          {
            id: "a1",
            label: "synthesis.layer",
            name: "图层管理",
            css: "twoMenu_imge11",
          },
          {
            id: "b1",
            label: "synthesis.split",
            name: "分屏",
            css: "twoMenu_imge21",
          },
          {
            id: "b9",
            label: "synthesis.undergroundMode",
            name: "地下模式",
            css: "twoMenu_imge29",
          },
          // {
          //   id: "b10",
          //   label: "synthesis.undergroundMode",
          //   name: "瓦片下载",
          //   css: "twoMenu_imge29",
          // },
        ],
        [
          {
            id: "b1",
            label: "synthesis.split",
            name: "分屏",
            css: "twoMenu_imge21",
          },
          {
            id: "b2",
            label: "synthesis.twod",
            name: "二维",
            css: "twoMenu_imge22",
          },
          {
            id: "b3",
            label: "synthesis.threed",
            name: "三维",
            css: "twoMenu_imge23",
          },
          {
            id: "b4",
            label: "synthesis.full",
            name: "全图",
            css: "twoMenu_imge24",
          },
          {
            id: "b5",
            label: "synthesis.zommin",
            name: "放大",
            css: "twoMenu_imge25",
          },
          {
            id: "b6",
            label: "synthesis.zoomout",
            name: "缩小",
            css: "twoMenu_imge26",
          },
          {
            id: "b7",
            label: "synthesis.rule",
            name: "比例尺",
            css: "twoMenu_imge27",
          },
          {
            id: "b8",
            label: "synthesis.compass",
            name: "指北针",
            css: "twoMenu_imge28",
          },
          {
            id: "b9",
            label: "synthesis.undergroundMode",
            name: "地下模式",
            css: "twoMenu_imge29",
          },
        ],
        [
          {
            id: "c1",
            label: "synthesis.someroaming",
            name: "点漫游",
            css: "twoMenu_imge31",
          },
          {
            id: "c2",
            label: "synthesis.lineroaming",
            name: "线路漫游",
            css: "twoMenu_imge32",
          },
          {
            id: "c3",
            label: "synthesis.mouseroaming",
            name: "鼠标漫游",
            css: "twoMenu_imge33",
          },
          {
            id: "c4",
            label: "synthesis.snapshot",
            name: "地图快照",
            css: "twoMenu_imge34",
          },
        ],
        [
          {
            id: "d1",
            label: "synthesis.contouranalysis",
            name: "等高线",
            css: "twoMenu_imge41",
          },
          {
            id: "d2",
            label: "synthesis.slopeanalysis",
            name: "坡度分析",
            css: "twoMenu_imge42",
          },
          {
            id: "d3",
            label: "synthesis.pathanalysis",
            name: "路径分析",
            css: "twoMenu_imge43",
          },
          {
            id: "d4",
            label: "synthesis.cuttinganalysis",
            name: "地形剖切",
            css: "twoMenu_imge44",
          },
          {
            id: "d5",
            label: "synthesis.floodanalysis",
            name: "淹没分析",
            css: "twoMenu_imge45",
          },
          {
            id: "d6",
            label: "synthesis.earthworkcalculation",
            name: "土方量计算",
            css: "twoMenu_imge46",
          },
          {
            id: "d7",
            label: "synthesis.crosssectionanalysis",
            name: "三维截面",
            css: "twoMenu_imge47",
          },
          {
            id: "d8",
            label: "synthesis.imagecontrast",
            name: "影像对比",
            css: "twoMenu_imge48",
          },
          {
            id: "d9",
            label: "synthesis.pipelineAnalysis",
            name: "管道分析",
            css: "twoMenu_imge49",
          },
          {
            id: "d10",
            label: "synthesis.flatterrain",
            name: "地形平整",
            css: "twoMenu_imge410",
          },
          {
            id: "d11",
            label: "synthesis.terrainexcavation",
            name: "地形开挖",
            css: "twoMenu_imge411",
          },
          {
            id: "d12",
            label: "synthesis.visibilityAnalysis",
            name: "通视分析",
            css: "twoMenu_imge412",
          },
          {
            id: "d13",
            label: "synthesis.viewAnalysis",
            name: "视域分析",
            css: "twoMenu_imge413",
          },
          {
            id: "d14",
            label: "synthesis.circularViewAnalysis",
            name: "圆形视域分析",
            css: "twoMenu_imge414",
          },
        ],
        [
          {
            id: "e1",
            label: "synthesis.attributequery",
            name: "属性查询",
            css: "twoMenu_imge51",
          },
          {
            id: "e2",
            label: "synthesis.rangequery",
            name: "空间查询",
            css: "twoMenu_imge52",
          },
        ],
        [
          {
            id: "f1",
            label: "synthesis.gpsrtk",
            name: "坐标定位",
            css: "twoMenu_imge61",
          },
          {
            id: "f2",
            label: "synthesis.placenamelocation",
            name: "地名定位",
            css: "twoMenu_imge62",
          },
        ],
        [
          {
            id: "j1",
            label: "synthesis.synthobj.m1",
            name: "表面距离",
            css: "twoMenu_imge71",
          },
          {
            id: "j2",
            label: "synthesis.synthobj.m4",
            name: "垂直高度",
            css: "twoMenu_imge72",
          },
          {
            id: "j3",
            label: "synthesis.synthobj.m6",
            name: "平面面积",
            css: "twoMenu_imge73",
          },
          {
            id: "j4",
            label: "synthesis.synthobj.m7",
            name: "体积",
            css: "twoMenu_imge74",
          },
          {
            id: "j5",
            label: "synthesis.synthobj.m5",
            name: "表面面积",
            css: "twoMenu_imge75",
          },
          {
            id: "j6",
            label: "synthesis.synthobj.m2",
            name: "空间距离",
            css: "twoMenu_imge76",
          },
          {
            id: "j7",
            label: "synthesis.synthobj.m9",
            name: "高程量测",
            css: "twoMenu_imge77",
          },
        ],
        [
          {
            id: "h1",
            label: "synthesis.point",
            name: "点",
            css: "twoMenu_imge81",
          },
          {
            id: "h8",
            label: "synthesis.addlabel",
            name: "文字",
            css: "twoMenu_imge88",
          },
          {
            id: "h2",
            label: "synthesis.line",
            name: "线",
            css: "twoMenu_imge82",
          },
          {
            id: "h3",
            label: "synthesis.rectangle",
            name: "矩形",
            css: "twoMenu_imge83",
          },
          {
            id: "h4",
            label: "synthesis.polygon",
            name: "多边形",
            css: "twoMenu_imge84",
          },
          {
            id: "h5",
            label: "synthesis.import",
            name: "导入KML",
            css: "twoMenu_imge85",
          },
          {
            id: "h6",
            label: "synthesis.export",
            name: "导出KML",
            css: "twoMenu_imge86",
          },
          {
            id: "h9",
            label: "synthesis.import1",
            name: "导入SHP",
            css: "twoMenu_imge85",
          },
          {
            id: "h10",
            label: "synthesis.export1",
            name: "导出SHP",
            css: "twoMenu_imge86",
          },
          {
            id: "h7",
            label: "synthesis.removepaint",
            name: "清除",
            css: "twoMenu_imge87",
          },
        ],
        [
          {
            id: "i1",
            name: "场景提取",
            label: "synthesis.sceneExtraction",
            css: "twoMenu_imge12",
          },
          {
            id: "i2",
            label: "synthesis.release",
            name: "场景发布",
            css: "twoMenu_imge13",
          },
          {
            id: "i3",
            label: "synthesis.tdisplay",
            name: "三维演示",
            css: "twoMenu_imge35",
          },
        ],
      ],
      isRuler: false,
      isNaviget: false,
      isolineFlag: false,
      isslopeFlag: false,
      isContrastFlag: false,
      UndergroundMode: false,
      scaleLine: null,
      Excavation: false,
      entityaLayers: [],
      isMenuFlag: null,
      isRouter: false, //路径分析
      isPiple: false, //管道分析
      DXZPState: null, //地形整平
      dialogVisible: false,
      formInline: {
        title: '',
        file: '',
        name: '',
        type: '',
        info: '',
        icon: '',
        bak: ''
      },
      tableData: [],
      dialog: {
        dialogVisible: false,
        isPdf: false,
        isJpg: false,
        src: ''
      },
      activeName: "first",
      isShowModel: false,
      options: [
        {
          value: '倾斜模型',
          label: '倾斜模型'
        }, {
          value: 'BIM模型',
          label: 'BIM模型'
        }, {
          value: '点云模型',
          label: '点云模型'
        }, {
          value: '地质设计模型',
          label: '地质设计模型'
        }, {
          value: '人工模型',
          label: '人工模型'
        }, {
          value: '其他模型',
          label: '其他模型'
        }],
      modelClip: false,
      showPickUp: false,
      dialogInsertVisible: false,
      dialogVisible1: false,
      ruleForm: {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      },
      dialogExtentVisible: false,
      setExtent: 10,
    };
  },
  methods: {
    //二級菜单点击切换
    setChangeTwoMenu(res) {
      var val = res.id[0];
      if (window.model != null) {
        // window.model.deleteObject();
        // window.model = null;
      }
      sgworld.Analysis.clearCurtainContrast();
      this.showPickUp = false;
      if (this.isMenuFlag == "d") {
        this.clearAllAnalsy();
      }
      this.$store.state.propertiesFlag = '';
      if (this.isMenuFlag != val) {
        if (res.id != "b9") {
          this.$store.state.mapMenuBoolean = false;
          this.$store.state.mapMenuBoxFlag = null;
          this.$store.state.mapPopBoolean = false;
          this.$store.state.mapPopBoxFlag = null;
          this.isMenuFlag = val;
          if (this.entityaLayers.length != 0) {
            for (var i in this.entityaLayers) {
              sgworld.Viewer.entities.remove(this.entityaLayers[i]);
            }
            this.entityaLayers = [];
          }
          for (var i in this.$store.state.queryInfo) {
            sgworld.Viewer.entities.remove(this.$store.state.queryInfo[i]);
          }
          this.$store.state.queryInfo = [];
          if (this.$store.state.primitLayer != null) {
            sgworld.Viewer.entities.remove(this.$store.state.primitLayer);
            sgworld.Creator.DeleteObject(this.$store.state.primitLayer);
            this.$store.state.primitLayer = null;
          }
        }
      }
      this.showTwoMenuFlag = res.id;
      if (val != 'h' && res.id != "b9") {
        sgworld.Creator.SimpleGraphic.clear();
        Viewer.entities.removeAll();
      }
      switch (val) {
        case "a": //图层管理
          this.setCoverage(res.id);
          break;
        case "b":
          this.setViewport(res.id);
          break;
        case "c":
          this.setWander(res.id);
          break;
        case "d":
          this.setAnalsy(res.id);
          break;
        case "e":
          this.setIquery(res.id);
          break;
        case "f":
          this.setOrientation(res.id);
          break;
        case "j":
          this.setMeasurement(res.id);
          break;
        case "h":
          sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
          this.setPlot(res.id);
          break;
      }
    },
    setPlot(res) {
      switch (res) {
        case "h1":
          sgworld.Creator.createSimpleGraphic(
            "point",
            {},
            function (entity) { }
          );
          break;
        case "h2":
          sgworld.Creator.createSimpleGraphic(
            "polyline",
            {},
            function (entity) { }
          );
          break;
        case "h3":
          sgworld.Creator.createSimpleGraphic(
            "rectangle",
            {},
            function (entity) { }
          );
          break;
        case "h4":
          sgworld.Creator.createSimpleGraphic(
            "polygon",
            {},
            function (entity) { }
          );
          break;
        case "h5":
          this.handleOpenClick();
          break;
        case "h6":
          this.handleSaveClick();
          break;
        case "h9":
          // this.handleOpenShp();
          $("#shpFile").click();
          break;
        case "h10":
          this.handleSaveShp();
          break;
        case "h7":
          sgworld.Creator.SimpleGraphic.clear();
          for (var i in this.entityaLayers) {
            sgworld.Viewer.entities.remove(this.entityaLayers[i]);
          }
          this.entityaLayers = [];
          break;
        case "h8":
          sgworld.Creator.createSimpleGraphic(
            "label",
            {},
            function (entity) { }
          );
          break;
      }
    },
    handleSaveClick() {
      let funDownload = function (content, filename) {
        let eleLink = document.createElement("a");
        eleLink.download = filename;
        eleLink.style.display = "none";
        // 字符内容转变成blob地址
        let blob = new Blob([content]);
        eleLink.href = URL.createObjectURL(blob);
        // 触发点击
        document.body.appendChild(eleLink);
        eleLink.click();
        // 然后移除
        document.body.removeChild(eleLink);
      };
      let entities = new Cesium.EntityCollection();
      let dataSources = sgworld.Viewer.dataSources;
      for (let i = 0, j = dataSources.length; i < j; i++) {
        for (let v of dataSources.get(i).entities.values) {
          entities.add(v);
        }
      }
      for (let v of sgworld.Viewer.entities.values) {
        entities.add(v);
      }
      if (entities.values.length) {
        console.log(sgworld.Viewer.entities);
        let promise = Cesium.exportKml({ entities: sgworld.Viewer.entities });
        console.log(entities);
        // let promise = Cesium.exportKml({ entities: entities });
        promise.then(function (e) {
          funDownload(e.kml, new Date().getTime() + ".kml");
        });
      } else {
        alert("当前场景没有entities实体");
      }
    },
    handleSaveShp() {
      var entities = sgworld.Viewer.entities.values;
      if (entities.length == 0) {
        return;
      }
      var std = [];
      for (var i in entities) {
        var type, fillColor, alpha, wkt, name;
        var bak = {};
        if (entities[i].name) {
          name = entities[i].name;
        }
        if (entities[i].properties) {
          var properties = entities[i].properties.propertyNames;
          for (var j in properties) {
            bak[properties[j]] = entities[i].properties[properties[j]]._value;
          }
        } else {
          bak = {
            name: entities[i].name,
          };
        }
        if (entities[i].rectangle) {
          //矩形
          type = "rectangle";
          var east = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().east
          );
          var north = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().north
          );
          var west = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().west
          );
          var south = Cesium.Math.toDegrees(
            entities[i].rectangle.coordinates.getValue().south
          );
          var line = turf.polygon([
            [
              [east, north],
              [west, north],
              [west, south],
              [east, south],
              [east, north],
            ],
          ]);
          wkt = this.$wkt.convert(line.geometry);
          var fill = entities[i].rectangle._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].point) {
          //点
          type = "point";
          let ellipsoid = Viewer.scene.globe.ellipsoid;
          let cartographic = ellipsoid.cartesianToCartographic(
            entities[i].position.getValue()
          );
          let lat = Cesium.Math.toDegrees(cartographic.latitude);
          let lng = Cesium.Math.toDegrees(cartographic.longitude);
          let alt = cartographic.height;
          let point = turf.point([lng, lat, alt]);
          wkt = this.$wkt.convert(point.geometry);
          var fill = entities[i].point._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].polygon) {
          type = "polygon";
          var fill = entities[i].polygon._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
          var geometry = entities[i].polygon.hierarchy.getValue().positions;
          var coordinates = [];
          for (var k in geometry) {
            coordinates.push(this.setCartesianToEightFour(geometry[k]));
          }
          if (coordinates[0] != coordinates[1]) {
            coordinates.push(coordinates[0]);
          }
          var polygon = turf.polygon([coordinates]);
          wkt = this.$wkt.convert(polygon.geometry);
        } else if (entities[i].polyline) {
          type = "polyline";
          var coordinates = [];
          var geometry = entities[i].polyline.positions.getValue();
          for (var k in geometry) {
            coordinates.push(this.setCartesianToEightFour(geometry[k]));
          }
          var polyline = turf.lineString(coordinates);
          wkt = this.$wkt.convert(polyline.geometry);
          var fill = entities[i].polyline._material._color._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        } else if (entities[i].label) {
          type = "label";
          let ellipsoid = Viewer.scene.globe.ellipsoid;
          let cartographic = ellipsoid.cartesianToCartographic(
            entities[i].position.getValue()
          );
          let lat = Cesium.Math.toDegrees(cartographic.latitude);
          let lng = Cesium.Math.toDegrees(cartographic.longitude);
          let alt = cartographic.height;
          let point = turf.point([lng, lat, alt]);
          wkt = this.$wkt.convert(point.geometry);
          var fill = entities[i].label.backgroundColor._value;
          fillColor = fill.red + "," + fill.green + "," + fill.blue;
          alpha = fill.alpha;
        }
        std.push({
          id: parseInt(i) + 1,
          type: type,
          fillColor: fillColor,
          opacity: alpha,
          name: name,
          bak: JSON.stringify(bak),
          wkt: wkt,
        });
      }
      $.ajax({
        url: BASE_URL + "/comprehensive/downloadShp?token=" + getToken(),
        type: "POST",
        data: JSON.stringify(std),
        dataType: "json", // html、json、jsonp、script、text
        contentType: "application/json", // "application/x-www-form-urlencoded"
        success: (rs) => {
          if (rs && rs.code == 200) {
            var a = document.createElement("a"); // 创建一个a标签元素
            a.style.display = "none"; // 设置元素不可见
            a.href =
              BASE_URL +
              "/comprehensive/downloadFile?token=" +
              getToken() +
              "&guid=" +
              rs.result;
            document.body.appendChild(a); // 加入
            a.click(); // 触发点击,下载
            document.body.removeChild(a); // 释放
          }
        },
        error: function (e) { },
      });
    },
    handleOpenShp() {
      var formData = new FormData();
      var fs = document.getElementById("shpFile");
      var exts = [".shp", ".shx", ".dbf", ".prj"];
      var count = 0;
      for (var i = 0, c = fs.files.length; i < c; i++) {
        var name = fs.files[i].name.toLocaleLowerCase();
        var ext = name.substring(name.lastIndexOf("."));
        if (exts.indexOf(ext) > -1) {
          count++;
          formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file
        }
      }
      if (count != 4) {
        alert("ShapeFile文件选择不全!");
        return;
      }
      var that = this;
      $.ajax(BASE_URL + "/comprehensive/uploadShp?token=" + getToken(), {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: function (rs) {
          if (rs.code == 200) {
            that.showShpEntity(rs.result);
          }
        },
        error: function (e) {
          console.error(e);
        },
      });
      document.getElementById("shpFile").value = "";
    },
    showShpEntity(res) {
      for (var i in res) {
        var wkt = this.$wkt.parse(res[i].wkt);
        var fillColor = res[i].fillColor.split(",");
        var color = new Cesium.Color(
          parseFloat(fillColor[0]),
          parseFloat(fillColor[1]),
          parseFloat(fillColor[2]),
          res[i].opacity
        );
        var name = res[i].name;
        switch (res[i].type) {
          case "rectangle":
          case "polygon":
            var std = [];
            var geo = wkt.coordinates[0];
            for (var i in geo) {
              std.push(geo[i][0]);
              std.push(geo[i][1]);
            }
            var entity = Viewer.entities.add({
              name: name,
              polygon: {
                hierarchy: Cesium.Cartesian3.fromDegreesArray(std),
                //height : 100000,
                material: color,
                outline: true,
                outlineColor: color,
              },
            });
            this.entityaLayers.push(entity);
            sgworld.Navigate.flyToObj(entity)
            break;
          case "point":
            let point = Viewer.entities.add({
              name: name,
              position: Cesium.Cartesian3.fromDegrees(
                wkt.coordinates[0],
                wkt.coordinates[1]
              ), //经纬度转世界坐标
              point: {
                show: true,
                color: color,
                pixelSize: 10,
                outlineColor: color,
                outlineWidth: 3,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            });
            this.entityaLayers.push(point);
            sgworld.Navigate.flyToObj(point)
            break;
          case "polyline":
            var std = [];
            var geo = wkt.coordinates;
            for (var i in geo) {
              std.push(geo[i][0]);
              std.push(geo[i][1]);
            }
            let line = Viewer.entities.add({
              name: name,
              polyline: {
                //经纬度数组转世界坐标,带高度的话是fromDegreesArrayHeights
                positions: Cesium.Cartesian3.fromDegreesArray(std),
                width: 10,
                material: color,
                clampToGround: true,
              },
            });
            this.entityaLayers.push(line);
            sgworld.Navigate.flyToObj(line)
            break;
          case "label":
            const label = Viewer.entities.add({
              position: Cesium.Cartesian3.fromDegrees(
                wkt.coordinates[0],
                wkt.coordinates[1]
              ),
              label: {
                text: name,
                fillColor: color,
                font: "28px",
                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                verticalOrigin: Cesium.VerticalOrigin.TOP,
                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                disableDepthTestDistance: Number.POSITIVE_INFINITY,
              },
            });
            this.entityaLayers.push(label);
            sgworld.Navigate.flyToObj(label)
            break;
        }
      }
    },
    setCartesianToEightFour(res) {
      var std = [];
      let ellipsoid = Viewer.scene.globe.ellipsoid;
      let cartographic = ellipsoid.cartesianToCartographic(res);
      let lat = Cesium.Math.toDegrees(cartographic.latitude);
      let lng = Cesium.Math.toDegrees(cartographic.longitude);
      let alt = cartographic.height;
      std = [lng, lat, alt];
      return std;
    },
    handleOpenClick() {
      var that = this;
      sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
      let fileInput = document.querySelector(".file");
      fileInput.onchange = function (evt) {
        let files = evt.target.files;
        if (files.length > 0) {
          let file = evt.target.files[0];
          let fileReader = new FileReader();
          fileReader.readAsDataURL(file);
          fileReader.onload = () => {
            var kmlOptions = {
              camera: sgworld.Viewer.scene.camera,
              canvas: sgworld.Viewer.scene.canvas,
              clampToGround: true,
            };
            var geocachePromise = Cesium.KmlDataSource.load(
              fileReader.result,
              kmlOptions
            );
            sgworld.Navigate.flyToObj(geocachePromise)
            geocachePromise.then(function (dataSource) {
              var geocacheEntities = dataSource.entities.values;
              that.entityaLayers = geocacheEntities;
              for (var i = 0; i < geocacheEntities.length; i++) {
                var entity = geocacheEntities[i];
                sgworld.Viewer.entities.add(entity);
              }
            });
            // sgworld.Viewer.dataSources
            //   .add(
            //     Cesium.KmlDataSource.load(fileReader.result, {
            //       camera: sgworld.Viewer.scene.camera,
            //       canvas: sgworld.Viewer.scene.canvas,
            //     })
            //   )
            //   .then((KmlDataSource) => {
            //     console.log(KmlDataSource);
            //     // let entities = kmlDataSource.entities;
            //   });
          };
        }
        // fileInput.value = null;
      };
      fileInput.click();
    },
    setLayerScene() {
      var URL = window.location.href.split("#");
      this.openwindow({ url: URL[0] + "LfSKyline/index.html" });
    },
    openwindow(data) {
      var url = data.url; //转向网页的地址;
      var name = data.title || "选择要添加的页面"; //网页名称,可为空;
      var iWidth = window.screen.width; //弹出窗口的宽度;
      var iHeight = window.screen.height; //弹出窗口的高度;
      var iTop = 0; //获得窗口的垂直位置;
      var iLeft = 0; //获得窗口的水平位置;
      window.open(
        url,
        name,
        "height=" +
        iHeight +
        ",,innerHeight=" +
        iHeight +
        ",width=" +
        iWidth +
        ",innerWidth=" +
        iWidth +
        ",top=" +
        iTop +
        ",left=" +
        iLeft +
        ",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no"
      );
    },
    setMeasurement(res) {
      switch (res) {
        case "j1":
          var measure = window.sgworld.Command.execute(
            0,
            2,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("表面距离", data);
            }
          );
          break;
        case "j6":
          var measure = window.sgworld.Command.execute(
            0,
            10,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("空间距离", data);
            }
          );
          break;
        // case 'j3':
        //   var measure = window.sgworld.Command.execute(0, 3, this.colorAll, (data) => {
        //     data.id = window.sgworld.Core.getuid();
        //     this.measureData.set(data.id, measure);
        //     this.openMeasureResultInfo('平面面积', data);
        //   });
        //   break;
        case "j2":
          var measure = window.sgworld.Command.execute(
            0,
            5,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("垂直高度", data);
            }
          );
          break;
        case "j5":
          var measure = window.sgworld.Command.execute(
            0,
            8,
            {
              ...this.colorAll,
              tin: true, // 是否显示tin三角网
              onlyTerrain: false, // 是否只测量精细地形
            },
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("表面面积", data);
            }
          );
          break;
        case "j3":
          var measure = window.sgworld.Command.execute(
            0,
            3,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("平面面积", data);
            }
          );
          break;
        case "j4":
          var volumetricMeasurementTool =
            window.sgworld.Creator.createVolumetricMeasureTool();
          volumetricMeasurementTool.startDrawing(
            { ...this.colorAll, onlyTerrain: false },
            "auto",
            (data) => {
              if (volumetricMeasurementTool.popupData) {
                volumetricMeasurementTool.popupData.value = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
                  }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
              } else {
                data.id = window.sgworld.Core.getuid();
                this.measureData.set(data.id, volumetricMeasurementTool);
                let popupData = this.openMeasureResultInfo("体积方量", data);
                volumetricMeasurementTool.popupData = popupData;
              }
            }
          );
          break;
        case "j8":
          var measure = window.sgworld.Command.execute(
            0,
            12,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("角度", data);
            }
          );
          break;
        case "j7":
          var measure = window.sgworld.Command.execute(
            1,
            11,
            this.colorAll,
            (data) => {
              data.id = window.sgworld.Core.getuid();
              this.measureData.set(data.id, measure);
              this.openMeasureResultInfo("海拔高度", data);
            }
          );
          break;
      }
    },
    openMeasureResultInfo(name, data) {
      let info = "";
      switch (name) {
        case "表面距离":
        case "空间距离":
          info = "总长度:" + data.distance[data.distance.length - 1];
          break;
        case "海拔高度":
          info = "高度:" + data.height;
          break;
        case "垂直高度":
          info = `${data.gddistance}<br>${data.kjdistance}<br>${data.spdistance}`;
          break;
        case "表面面积":
        case "平面面积":
          info = data.mj;
          break;
        case "角度":
          data.labels.forEach((label) => {
            info += label.label.text.getValue() + "<br>";
          });
          break;
        case "体积方量":
          info = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
            }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
          break;
      }
      return (
        this.$refs &&
        this.$refs.mapinfo &&
        this.$refs.mapinfo.open(name, info, {
          close: () => {
            // 清除测量
            this.clearMeasure(data.id);
          },
        })
      );
    },
    clearMeasure(id) {
      if (id) {
        let data = this.measureData.get(id);
        data && data.deleteObject && data.deleteObject();
        // 体积方量
        data && data.cleanUp && data.cleanUp();
        this.measureData.delete(id);
      } else {
        this.measureData.forEach((data) => {
          data.deleteObject && data.deleteObject();
          // 体积方量
          data.cleanUp && data.cleanUp();
        });
        this.measureData.clear();
      }
    },
    setIquery(res) {
      switch (res) {
        case "e2":
          this.showPickUp = false;
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "1";
          break;
        case "e1":
          this.$store.state.mapMenuBoolean = !this.$store.state.mapMenuBoolean;
          this.$store.state.mapMenuBoxFlag = "2";
          this.showPickUp = false;
          break;
        //拾取功能
        case "e3":
          this.$store.state.mapMenuBoolean = false;
          this.showPickUp = !this.showPickUp;
          if (this.showPickUp) {
            let that = this;
            Viewer.screenSpaceEventHandler.setInputAction(function (event) {
              let p = sgworld.Navigate.getMouseDegrees(event);
              console.log(p);
              if (that.showPickUp) {
                that.getPickUpData(p);
              }
            }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
          } else {
            this.$refs.queryinfo.closeAll();
            Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          }
          break;
      }
    },
    clearAllAnalsy() {
      // switch (this.showTwoMenuFlag) {
      //   case 'd1':
      //     that.isolineFlag = false;
      //     elevationTool.tf = that.isolineFlag;
      //     elevationTool.render();
      //     break;
      //   case 'd2':
      //     that.isslopeFlag = false;
      //     elevationTool.type = 'none';
      //     elevationTool.render();
      //     break;
      // }
    },
    ClearDraw() {
      //console.log(sgworld);
      //   console.log(sgworld.drawObj.drawHandler);
      //   sgworld.drawObj.drawHandler.destroy();
      //   sgworld.drawObj.end()
    },
    setAnalsy(res) {
      //this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close("queryinfo");
      this.$bus.$emit("closeMenuPop", res);
      var that = this;
      switch (res) {
        case "d1": //等高线分析
          this.closePipelinePop();
          that.isolineFlag = !that.isolineFlag;
          elevationTool.tf = that.isolineFlag;
          elevationTool.render();
          break;
        case "d2": //坡度分析
          this.closePipelinePop();
          that.isslopeFlag = !that.isslopeFlag;
          var val = {
            name: "Lengend",
            id: res,
            vshow: that.isslopeFlag,
          };
          this.$bus.$emit("mapChangeBox", val);
          window.PDelevationTool = new SmartEarth.ElevationTool(sgworld); //全局变量
          if (that.isslopeFlag == true) {
            PDelevationTool.type = "slope";
            PDelevationTool.tf = this.checked;
          } else {
            PDelevationTool.type = "none";
          }
          PDelevationTool.render();
          break;
        case "d3": //路径分析
          this.closePipelinePop();
          this.isRouter = !this.isRouter;
          let value;
          if (this.isRouter) {
            value = {
              name: "Analysis",
              id: 3,
              show: true,
            };
          } else {
            value = {
              name: "Analysis",
              id: 3,
              show: false,
            };
          }
          this.$bus.$emit("mapChangeBox", value);
          break;
        case "d4": //剖面分析
          this.closePipelinePop();
          if (window.AnalysisDXPM) {
            window.AnalysisDXPM.end && window.AnalysisDXPM.end("cancel");
            this.clear(res);
          } else {
            this.addterrainSectionAnalysis();
          }
          break;
        case "d5": //洪水淹没分析
          this.closePipelinePop();
          if (window.AnalysisFlood) {
            this.clear(res);
          } else {
            this.addAnalysisFlood();
          }
          break;
        case "d6": //土方量分析
          this.closePipelinePop();
          if (window.TFvolumetricMeasurementTool) {
            TFvolumetricMeasurementTool.cleanUp();
            if (TFvolumetricMeasurementTool._mouseHandler) {
              TFvolumetricMeasurementTool._mouseHandler.destroy();
              TFvolumetricMeasurementTool = null;
              Viewer._container.style.cursor = "default";
              return;
            }
            TFvolumetricMeasurementTool = null;
            this.$refs.mapinfo && this.$refs.mapinfo.close();
          } else {
            var that = this;
            window.TFvolumetricMeasurementTool =
              sgworld.Creator.createVolumetricMeasureTool();
            TFvolumetricMeasurementTool.startDrawing(
              { ...this.colorAll, onlyTerrain: false },
              "auto",
              (data) => {
                if (TFvolumetricMeasurementTool.popupData) {
                  TFvolumetricMeasurementTool.popupData.value = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
                    }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
                } else {
                  data.id = sgworld.Core.getuid();
                  this.measureData.set(data.id, TFvolumetricMeasurementTool);
                  let popupData = that.openMeasureResultInfo("体积方量", data);
                  TFvolumetricMeasurementTool.popupData = popupData;
                }
              }
            );
          }
          break;
        case "d7": //三维截面分析
          this.closePipelinePop();
          // if(window.MXModel) {
          //   Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          //   window.MXModel=null;
          // } else {
          var that = this;
          that.modelClip = !that.modelClip;
          if (that.modelClip) {
            // that.$store.state.propertiesFlag = '3';
            if (window.model) {
              that.modelClipping();
            }
            else {
              var tileset = Viewer.scene.primitives.add(
                new Cesium.Cesium3DTileset({
                  name: res.cnName,
                  url: modelUrl + "/tileset/m/SN/tileset.json",
                  maximumScreenSpaceError: modelUrl.indexOf("/pnts/") > -1 ? 16 : 64, // 最大屏幕空间错误:16
                  maximumMemoryUsage: 768, // 最大内存:512
                  dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
                  skipLevelOfDetail: true, // 在遍历时候跳过详情:false
                })
              );
              tileset.readyPromise.then((tileset) => {
                tileset.id = res.cnName;
                tileset.layerId = res.id;
                Viewer.flyTo(tileset);
                that.modelClipping();
              });
              window.model = tileset
            }
          }
          else {
            // that.$store.state.propertiesFlag = '';
            Viewer.entities.removeAll();
          }
          // window.model = sgworld.Creator.create3DTilesets(
          //   "",
          //   modelUrl + "/tileset/m/SN/tileset.json",
          //   {},
          //   {},
          //   "0",
          //   true,
          //   (data) => {
          //     sgworld.Navigate.flyToObj(data);
          //     that.setclippingModel();
          //   }
          // );
          break;
        case "d9": //管道分析
          this.isPiple = !this.isPiple;
          if (this.isPiple) {
            this.$store.state.mapPopBoxFlag = "3";
            this.$refs &&
              this.$refs.queryinfo &&
              this.$refs.queryinfo.open("管道空间分析", null, {
                close: () => {
                  if (this.$store.state.pipelineEntity.length != 0) {
                    for (var i in this.$store.state.pipelineEntity) {
                      sgworld.Viewer.entities.remove(
                        this.$store.state.pipelineEntity[i]
                      );
                    }
                  }
                },
              });
          } else {
            this.$refs &&
              this.$refs.queryinfo &&
              this.$refs.queryinfo.close("queryinfo");
          }
          break;
        case "d8": //影像对比
          this.closePipelinePop();
          if (this.isContrastFlag == false) {
            this.isContrastFlag = true;
            var localUrl = '{host}/LFData/2d/tiles/img/{z}/{x}/{y}.png'
            localUrl = localUrl.replace("{host}", iisHost)
            window.contRastLayer = Viewer.imageryLayers.addImageryProvider(
              new Cesium.UrlTemplateImageryProvider({
                url: localUrl,
                maximumLevel: 22,
                enablePickFeatures: false
              })
            );
            Viewer.imageryLayers.lowerToBottom(window.contRastLayer);//将图层移到最底层
            Viewer.imageryLayers.raise(window.contRastLayer);//将图层上移一层
            if (window.BaseMapLayer) {
              Viewer.imageryLayers.raise(window.contRastLayer);//将图层上移一层
              sgworld.Analysis.createCurtainContrast(1, 2);
            } else {
              sgworld.Analysis.createCurtainContrast(0, 1);
            }
          } else {
            this.isContrastFlag = false;
            sgworld.Analysis.clearCurtainContrast();
            if (window.contRastLayer) {
              window.Viewer.imageryLayers.remove(
                window.contRastLayer
              );
              window.contRastLayer = null;
            }
          }
          break;
        case "d10": //地面整平
          this.closePipelinePop();
          var val = {
            name: "Trrain",
            id: res,
          };
          this.$bus.$emit("mapChangeBox", val);
          // if (this.DXZPState != null) {
          //   this.DXZPState.drawHandler && this.DXZPState.drawHandler.destroy();
          //   Viewer._container.style.cursor = "default";
          //   this.DXZPState.tooltip && this.DXZPState.tooltip.show(false);
          //   if (window.DXTerrainFlattening != null) {
          //     DXTerrainFlattening.remove();
          //   }
          //   window.DXTerrainFlattening = null;
          //   this.DXZPState = null;
          // } else {
          //   this.DXZPState = sgworld.Creator.createSimpleGraphic(
          //     "polygon",
          //     {
          //       clampToGround: true,
          //     },
          //     function (entity) {
          //       let positions = entity.polygon.hierarchy.getValue().positions;
          //       sgworld.Creator.SimpleGraphic.remove(entity.id);
          //       window.DXTerrainFlattening =
          //         sgworld.Creator.createTerrainModifier(
          //           "地形压平",
          //           positions,
          //           10,
          //           {}
          //         );
          //     }
          //   );
          // }
          break;
        case "d11": //地形开挖
          this.closePipelinePop();
          // this.$refs &&
          //   this.$refs.terrainDig &&
          //   this.$refs.terrainDig.open("管道空间分析", null, {
          //     close: () => {
          //     },
          //   });
          if (window.Excavation) {
            window.Excavation.drawHandler &&
              window.Excavation.drawHandler.destroy();
            Viewer._container.style.cursor = "default";
            window.Excavation.tooltip && window.Excavation.tooltip.show(false);
            window.Excavation.clear();
            window.Excavation = null;
          } else {
            window.Excavation = sgworld.Analysis.TerrainExcavation(
              10,
              {},
              function () { }
            );
          }
          break;
        case "d12": //通视分析
          this.closePipelinePop();
          if (window.TSExcavation != null) {
            window.TSExcavation._SimpleGraphic.drawHandler &&
              window.TSExcavation._SimpleGraphic.drawHandler.destroy();
            Viewer._container.style.cursor = "default";
            window.TSExcavation._SimpleGraphic.tooltip &&
              window.TSExcavation._SimpleGraphic.tooltip.show(false);
            window.TSExcavation.deleteObject();
            window.TSExcavation = null;
          } else {
            window.TSExcavation = sgworld.Analysis.createSightLine({
              type: "default",
            });
          }
          break;
        case "d13": //视域分析
          this.closePipelinePop();
          if (window.SYExcavatio) {
            window.SYExcavatio.end && window.SYExcavatio.end();
            window.SYExcavatio.close();
            window.SYExcavatio = null;
          } else {
            var SYFX_visible_color = { r: 0.0, g: 1.0, b: 0.0 },
              SYFX_notVisible_color = { r: 1.0, g: 0.0, b: 0.0 };
            window.SYExcavatio = sgworld.Analysis.create3DViewshed({
              name: "Viewshed On Frederick",
              height: 1.8,
              color: {
                Back: SYFX_notVisible_color,
                Fore: SYFX_visible_color,
              },
              isSpherical: "",
            });
          }
          break;
        case "d14": //圆形时域分析
          this.closePipelinePop();
          if (window.YXSYExcavation) {
            window.YXSYExcavation.end && window.YXSYExcavation.end();
            window.YXSYExcavation.close();
            window.YXSYExcavation = null;
          } else {
            var SYFX_visible_color = { r: 0.0, g: 1.0, b: 0.0 },
              SYFX_notVisible_color = { r: 1.0, g: 0.0, b: 0.0 };
            window.YXSYExcavation = sgworld.Analysis.create3DViewshed({
              name: "Viewshed On Frederick",
              height: 1.8,
              color: {
                Back: SYFX_notVisible_color,
                Fore: SYFX_visible_color,
              },
              isSpherical: "spherical",
            });
          }
          break;
      }
    },
    //模型裁切
    modelClipping() {
      const scene = Viewer.scene;
      let targetY = 40.0;
      let planeEntities = [];
      let selectedPlane;
      let clippingPlanes = new Cesium.ClippingPlaneCollection({
        planes: [ // ClippingPlane对象数组集合
          new Cesium.ClippingPlane( // 裁切面
            new Cesium.Cartesian3(0.0, 0.0, -1.0), // 法线方向
            0// 原点到平面的最短距离,设置0就好
          ),
        ],
        enabled: true,
        edgeWidth: 1.0, // 模型被裁切部分的截面线宽
      });
      // let clippingPlanes = new Cesium.ClippingPlaneCollection({
      //   planes: [ // ClippingPlane对象数组集合
      //     //前后切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 1, 0), 0), //后
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, -1, 0), 0),  //前
      //     // 左右切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(1.0, 0.0, 0), 0), //左
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(-1.0, 0.0, 0), 0),  //右
      //     // 上下切割
      //     new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, -1), 0),  //上→下
      //     // new Cesium.ClippingPlane(new Cesium.Cartesian3(0, 0.0, 1), 0),  //下→上、
      //   ],
      //   enabled: true,
      //   edgeWidth: 1.0, // 模型被裁切部分的截面线宽
      //   unionClippingRegions: true, //true 才能多个切割
      // });
      let boundingSphere = window.model.boundingSphere;
      // 创建一个坐标轴,便于测试
      // var transform = Cesium.Transforms.eastNorthUpToFixedFrame(boundingSphere.center);
      // var modelMatrixPrimitive = Viewer.scene.primitives.add(new Cesium.DebugModelMatrixPrimitive({
      //   // modelMatrix: transform,
      //   length: 140.0
      // }));
      // // 创建添加裁剪平面
      for (let i = 0; i < clippingPlanes.length; ++i) {
        const plane = clippingPlanes.get(i);
        const planeEntity = Viewer.entities.add({
          position: boundingSphere.center,
          plane: {
            dimensions: new Cesium.Cartesian2(
              boundingSphere.radius * 1.5,
              boundingSphere.radius * 1.5
            ),//切面的长和宽
            material: Cesium.Color.WHITE.withAlpha(0.1),
            plane: new Cesium.CallbackProperty(
              // 添加绑定事件,不断调用
              createPlaneUpdateFunction(plane),
              false
            ),
            outline: true,
            outlineColor: Cesium.Color.WHITE,
          },
        });
        planeEntities.push(planeEntity);
      }
      // 创建添加裁剪平面
      // let m_box;
      // for (let i = 0; i < clippingPlanes.length; ++i) {
      //   let plane = clippingPlanes.get(i);
      //   let getPlaneType = getType4Plane(plane);
      //   let planeEntity = Viewer.entities.add({ //添加平面实体 直观裁切面
      //     id: 'ClipPlane' + i,
      //     position: boundingSphere.center,// 根据3dtiles同步调整裁切面高度
      //     plane: {
      //       dimensions: new Cesium.Cartesian2(80, 80),//切面的长和宽
      //       plane: new Cesium.CallbackProperty(createPlaneUpdateFunction_box(plane, getPlaneType, boundingSphere.center), false),
      //       material: Cesium.Color.WHITE.withAlpha(0.2),
      //       outline: false,
      //       outlineColor: Cesium.Color.WHITE,
      //     }
      //   });
      //   if (!m_box) {
      //     m_box = Viewer.entities.add({
      //       id: 'ClopBox',
      //       modelMatrixPrimitive: modelMatrixPrimitive,
      //       position: boundingSphere.center,
      //       box: {
      //         dimensions: new Cesium.Cartesian3(boundingSphere.radius * 1.2, boundingSphere.radius * 1.2, 40),
      //         material: Cesium.Color.WHITE.withAlpha(0.3),
      //       }
      //     })
      //   }
      // }
      window.model.clippingPlanes = clippingPlanes;
      if (window.modelHeight && window.modelHeight != 0) {
        // console.log("window.modelHeight---",window.modelHeight)
        window.model.clippingPlanes.modelMatrix = Cesium.Matrix4.fromTranslation(
          new Cesium.Cartesian3(0.0, 0.0, window.modelHeight)
        );
      }
      // 绑定上移动事件
      const downHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      downHandler.setInputAction(function (movement) {
        const pickedObject = scene.pick(movement.position);
        if (
          Cesium.defined(pickedObject) &&
          Cesium.defined(pickedObject.id.plane)
        ) {
          selectedPlane = pickedObject.id.plane;
          selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.05);
          selectedPlane.outlineColor = Cesium.Color.WHITE;
          scene.screenSpaceCameraController.enableInputs = false;
        }
      }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
      // 绑定下移动事件
      const upHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      upHandler.setInputAction(function () {
        if (Cesium.defined(selectedPlane)) {
          selectedPlane.material = Cesium.Color.WHITE.withAlpha(0.1);
          selectedPlane.outlineColor = Cesium.Color.WHITE;
          selectedPlane = undefined;
        }
        scene.screenSpaceCameraController.enableInputs = true;
      }, Cesium.ScreenSpaceEventType.LEFT_UP);
      // Update plane on mouse move
      const moveHandler = new Cesium.ScreenSpaceEventHandler(
        Viewer.scene.canvas
      );
      moveHandler.setInputAction(function (movement) {
        if (Cesium.defined(selectedPlane)) {
          const deltaY = movement.startPosition.y - movement.endPosition.y;
          targetY += deltaY;
          // console.log("targetY----",targetY)
        }
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      function createPlaneUpdateFunction(plane) {
        return function () {
          plane.distance = targetY;
          // console.log("targetY----",targetY)
          return plane;
        };
      }
      //获取切面的type // 上、下、左、右、前、后
      function getType4Plane(plane) {
        var m_type;
        var normal = plane._normal;
        var x = normal.x;
        var y = normal.y;
        var z = normal.z;
        if (x == 1 && y == 0 && z == 0) {
          m_type = 'left';
        }
        else if (x == -1 && y == 0 && z == 0) {
          m_type = 'right';
        }
        else if (x == 0 && y == 1 && z == 0) {
          m_type = 'behind';
        }
        else if (x == 0 && y == -1 && z == 0) {
          m_type = 'front';
        }
        else if (x == 0 && y == 0 && z == -1) {
          m_type = 'top';
        }
        return m_type;
      }
      function createPlaneUpdateFunction_box(plane, type, origin) {
        return function () {
          var num_x = window.localStorage.getItem('slider_x') / 100000;
          var num_y = window.localStorage.getItem('slider_y') / 100000;
          var num_z = window.localStorage.getItem('slider_z') / 1.5;//读取滑动条值
          var origin_degree = cartesian3ToDegrees(origin);
          var target_degree_x = [origin_degree[0] + num_x, origin_degree[1], +origin_degree[2]];
          var target_degree_y = [origin_degree[0], origin_degree[1] + num_y, +origin_degree[2]];
          var target_degree_z = [origin_degree[0], origin_degree[1], +origin_degree[2] + num_z];
          var m_dis_x = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_x[0], target_degree_x[1], target_degree_x[2]));
          var m_dis_y = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_y[0], target_degree_y[1], target_degree_y[2]));
          var m_dis_z = Cesium.Cartesian3.distance(origin, Cesium.Cartesian3.fromDegrees(target_degree_z[0], target_degree_z[1], target_degree_z[2]));
          createPlanePos(origin_degree, num_x, num_y, num_z);
          let distance = 140;
          if (type == 'left') {
            if (num_x < 0) {
              plane.distance = distance - (-m_dis_x);
              return plane;
            } else {
              plane.distance = distance - m_dis_x
              return plane;
            }
          }
          else if (type == 'behind') {
            if (num_y < 0) {
              plane.distance = distance - (-m_dis_y);
              return plane;
            } else {
              plane.distance = distance - m_dis_y;
              return plane;
            }
          }
          else if (type == 'right') {
            if (num_x < 0) {
              plane.distance = distance - m_dis_x;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_x);
              return plane;
            }
          }
          else if (type == 'front') {
            if (num_y < 0) {
              plane.distance = distance - m_dis_y;
              return plane;
            } else {
              plane.distance = distance - (-m_dis_y);
              return plane;
            }
          }
          else if (type == 'top') {
            if (num_z < 0) {
              plane.distance = m_dis_z;
              // console.log('num_z=========',num_z)
              // console.log('m_dis_z=========',m_dis_z)
              // plane.distance = distance - m_dis_z;
              return plane;
            } else {
              // plane.distance = 100;
              plane.distance = distance - (-m_dis_z);
              return plane;
            }
          }
          return plane;
        };
      }
      function createPlanePos(origin, x, y, z) {
        var clipbox = Viewer.entities.getById('ClopBox');
        if (clipbox) {
          clipbox.position = new Cesium.CallbackProperty(function () {
            return Cesium.Cartesian3.fromDegrees(origin[0] + x, origin[1] + y, +origin[2] + z);//实时返回当前盒子的位置
          }, false);
        }
      }
      function cartesian3ToDegrees(cartesian3) {
        var ellipsoid = Viewer.scene.globe.ellipsoid;
        var cartographic = ellipsoid.cartesianToCartographic(cartesian3);
        var lat = Cesium.Math.toDegrees(cartographic.latitude);
        var lng = Cesium.Math.toDegrees(cartographic.longitude);
        var alt = cartographic.height;
        var pos = [lng, lat, alt];
        return pos;
      }
    },
    //关闭管道信息弹窗
    closePipelinePop() {
      this.$refs &&
        this.$refs.queryinfo &&
        this.$refs.queryinfo.close("queryinfo");
    },
    setclippingModel() {
      if (window.model) {
        setTimeout(() => {
          window.model.clippingModel({
            direction: "z",
          });
        }, 1000);
        // window.model.clippingModel({
        //   direction: 'z',
        // });
      }
    },
    clear(res) {
      switch (res) {
        case "d4":
          layer.close(this.dxpmIndex);
          this.dxpmIndex = undefined;
          if (window.AnalysisDXPM) {
            window.AnalysisDXPM.flyPoint &&
              Viewer.entities.remove(window.AnalysisDXPM.flyPoint);
            window.AnalysisDXPM && window.AnalysisDXPM.deleteObject();
            window.AnalysisDXPM = undefined;
          }
          break;
        case "d5":
          window.AnalysisFlood.endWater();
          window.AnalysisFlood = undefined;
          break;
      }
    },
    addAnalysisFlood() {
      var url = window.location.href;
      var testurl = "";
      if (url.indexOf("web") != -1) {
        testurl = "/web";
      }
      var method = {
        pointSelect: true,
        spood: 20,
        GroupID: 0,
        url: testurl + "/SmartEarthSDK/Workers/image/33.gif",
      };
      window.AnalysisFlood = sgworld.Command.execute(
        2,
        2,
        method,
        (value) => { }
      );
    },
    addterrainSectionAnalysis() {
      window.AnalysisDXPM = sgworld.Command.execute(
        2,
        6,
        { cyjj: 50, objid: 0 },
        (Distance) => {
          if (Distance.gcs && Distance.gcs.length) {
            var url = window.location.href;
            var testurl = "";
            if (url.indexOf("web") != -1) {
              testurl = "/web";
            }
            window.AnalysisDXPM.analyseData = Distance;
            this.dxpmIndex = layer.open({
              type: 2,
              title: "分析结果",
              shade: false,
              area: ["80%", "280px"],
              offset: "b",
              skin: "other-class",
              content:
                testurl + "/SmartEarthSDK/Workers/analysis/AnalysisDXPM.html",
              end: () => {
                this.dxpmIndex && this.clear("d4");
              },
            });
          } else {
            //剖面
            window.AnalysisDXPM && window.AnalysisDXPM.deleteObject();
          }
        }
      );
    },
    setWander(res) {
      switch (res) {
        case "c1":
          if (window.PointMY != null) {
            window.PointMY.drawHandler && window.PointMY.drawHandler.destroy();
            window.PointMY.end && window.PointMY.end();
            window.PointMY = null;
          } else {
            window.PointMY = window.sgworld.Analysis.setPointFly();
          }
          break;
        case "c2":
          var url = window.location.href;
          var testurl = "";
          if (url.indexOf("web") != -1) {
            testurl = "/web";
          }
          window.sgworld.Command.execute(2, 3, "", (data) => {
            data.showPoint = false;
            data.showLine = true;
            data.mode = 0;
            // 弹窗数据
            window.PathAnimationData = {
              flyData: data,
            };
            window.PathAnimationData.winIndex = layer.open({
              type: 2,
              title: "路径动画",
              shade: false,
              area: ["352px", "690px"],
              offset: "r",
              skin: "other-class",
              content: testurl + "/SmartEarthSDK/Workers/path/Path.html",
              end: function () {
                PathAnimationData.fly && PathAnimationData.fly.exit();
              },
            });
          });
          break;
        case "c3":
          sgworld.Analysis.createindoormode({ showHelp: true });
          break;
        case "c4":
          window.sgworld.Analysis.createScreenshot();
          break;
      }
    },
    setOrientation(res) {
      var resid;
      switch (res) {
        case "f1":
          resid = 1;
          break;
        case "f2":
          resid = 2;
          break;
      }
      var val = {
        name: "Coord",
        id: resid,
      };
      this.$bus.$emit("mapChangeBox", val);
    },
    setViewport(res) {
      switch (res) {
        case "b1": //分屏
          this.$bus.$emit("changemap", 1);
          break;
        case "b2": //二维
          this.$bus.$emit("changemap", 2);
          break;
        case "b3": //三维
          this.$bus.$emit("changemap", 3);
          break;
        case "b4": //全图
          window.sgworld.Navigate.jumpTo({
            //跳转视角
            destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000),
          });
          window.map
            .getView()
            .setCenter(transform([110, 32], "EPSG:4326", "EPSG:3857"));
          window.map.getView().setZoom(4);
          break;
        case "b5": //放大
          window.sgworld.Navigate.zoomIn();
          // 获取当前视图
          var zoom = window.map.getView().getZoom(); // 获取当前缩放级别
          window.map.getView().setZoom(zoom + 1); // 设置缩放级别
          break;
        case "b6": //缩小
          window.sgworld.Navigate.zoomOut();
          var zoom = window.map.getView().getZoom(); // 获取当前缩放级别
          window.map.getView().setZoom(zoom - 1); // 设置缩放级别
          break;
        case "b7": //比例尺
          this.isRuler = !this.isRuler;
          window.sgworld.navControl("scale", this.isRuler);
          if (this.isRuler == true) {
            this.scaleLine = new ScaleLine({
              units: "metric",
            });
            window.map.addControl(this.scaleLine);
          } else {
            window.map.removeControl(this.scaleLine);
            this.scaleLine = false;
          }
          break;
        case "b8": //指北针
          this.isNaviget = !this.isNaviget;
          window.sgworld.navControl("nav", this.isNaviget);
          this.$store.state.isNaviget = this.isNaviget;
          break;
        case "b9": //地下模式
          // this.UndergroundMode = !this.UndergroundMode;
          // window.sgworld.Analysis.UndergroundMode(this.UndergroundMode, 0.3);
          if (window.UndergroundMode) {
            this.$refs &&
              this.$refs.undergroundModel &&
              this.$refs.undergroundModel.close();
          } else {
            this.$refs &&
              this.$refs.undergroundModel &&
              this.$refs.undergroundModel.open("地下模式", null,);
          }
          break;
      }
    },
    setCoverage(res) {
      switch (res) {
        case "a1":
          if (this.$store.state.layerMnage == false) {
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.closeAll();
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.open();
            this.$store.state.layerMnage = true;
          } else if (this.$store.state.layerMnage == true) {
            this.$bus.$emit("treeDataCopy", "true");
            this.$refs && this.$refs.maplayer && this.$refs.maplayer.closeAll();
            this.$store.state.layerMnage = false;
          }
          break;
      }
    },
    menuChange(res) {
      this.setListTwoMenu = this.setListTwoMenuAll[res];
    },
    async layersStart() {
      const data = await perms_selectLayers();
      if (data.code != 200) {
        return this.$message.error("图层列表查询失败");
      }
      var std = data.result;
      var that = this;
      var checkKey = [];
      let checkedLayers = [];
      this.$store.state.isProjectLayer = [];
      var val = std.filter((str) => {
        if (str.type == 1) {
          return str;
        }
        if (str.url != null && str.type == 2) {
          if (str.isShow == 1) {
            checkKey.push(str.id);
          }
          return str;
        }
      });
      var value = std.filter((str) => {
        if (str.url != null && str.type == 2 && str.isShow == 1) {
          return str;
        }
      })
      var layer = std.filter((str) => {
        if (str.isProject == 1 && str.type == 2) {
          this.$store.state.isProjectLayer.push(str);
        }
      })
      this.setAddLayers(value);
      var res = this.setTreeData(val);
      this.$store.state.pigCode = null;
      //存储选中图层
      // sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
      // for (var i in res) {
      //   res[i].children = res[i].children.filter((val) => {
      //     if (val.children != null) {
      //       return val;
      //     }
      //   });
      // }
      this.$store.state.oldTree = val;
      this.$store.state.treeData = res;
      this.$store.state.checkedKeys = checkKey;
    },
    setTreeData(source) {
      let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
        if (branchArr.length > 0) {
          branchArr.sort(function (a, b) {
            return a.orderNum - b.orderNum
          })
        }
        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 == 0; // 返回一级菜单
      });
    },
    setAddLayers(res) {
      this.setClearWmsLayer()
      var std = [[]];
      for (var i in res) {
        switch (res[i].serveType) {
          case "WMS":
            std[0].push(res[i])
            break;
        }
      }
      if (std[0].length != 0) {
        if (this.$store.state.pigCode) {
          this.setPrjidWmsLayer(std[0])
        } else {
          this.setAddWmsLayer(std[0])
        }
      }
    },
    setPrjidWmsLayer(res) {
      var layer = [];
      var sql = [];
      var dirid = this.$store.state.pigCode
      var that = this;
      for (var i in res) {
        layer.push(res[i].url)
        if (res[i].isProject == 1) {
          var val = "dirid like '" + dirid + "%'"
          sql.push(val)
        } else {
          sql.push("1 = 1")
        }
      }
      layer = layer.reverse();
      sql = sql.reverse().join(";")
      var getFeatureInfoFormat = new Cesium.GetFeatureInfoFormat("html", null, function (html) {
        that.getFeatureInfo(html)
      });
      window.layerWMS = new Cesium.WebMapServiceImageryProvider({
        url: geoServerURl,
        layers: layer.toString(),
        getFeatureInfoParameters: { info_format: 'text/html' },
        enablePickFeatures: true,
        getFeatureInfoFormats: [getFeatureInfoFormat],
        parameters: {
          transparent: true,
          format: "image/png",
          srs: "EPSG:4490",
          styles: "",
          cql_filter: sql
        },
        tileWidth: 512,
        tileHeight: 512,
      });
      layerWMS.name = "Wms_Layer";
      window.Viewer.imageryLayers.addImageryProvider(window.layerWMS);
      var layer2 = new Image({
        name: "Wms_Layer",
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: layer.toString(),
            cql_filter: sql
          },
        }),
      });
      if (res.opacity) {
        layer2.setOpacity(parseInt(res.opacity) / 100);
      }
      window.map.addLayer(layer2);
    },
    setClearWmsLayer() {
      for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
        var val_id = window.Viewer.imageryLayers._layers[i].imageryProvider.name;
        if (val_id == "Wms_Layer") {
          window.Viewer.imageryLayers.remove(
            window.Viewer.imageryLayers._layers[i]
          );
        }
      }
      var layers_ol = window.map.getAllLayers();
      for (var i in layers_ol) {
        var layerOl = layers_ol[i];
        if (layerOl.values_.name == "Wms_Layer") {
          window.map.removeLayer(layers_ol[i]); //显示图层
        }
      }
    },
    setAddWmsLayer(res) {
      var url = [];
      for (var i in res) {
        if (res[i].url) {
          url.push(res[i].url)
        }
      }
      url = url.reverse();
      var that = this;
      var getFeatureInfoFormat = new Cesium.GetFeatureInfoFormat("html", null, function (html) {
        that.getFeatureInfo(html)
      });
      window.layerWMS = new Cesium.WebMapServiceImageryProvider({
        url: geoServerURl,
        layers: url.toString(),
        getFeatureInfoParameters: { info_format: 'text/html' },
        enablePickFeatures: true,
        getFeatureInfoFormats: [getFeatureInfoFormat],
        parameters: {
          transparent: true,
          format: "image/png",
          srs: "EPSG:4490",
          styles: "",
        },
        tileWidth: 512,
        tileHeight: 512,
      });
      layerWMS.name = "Wms_Layer";
      window.Viewer.imageryLayers.addImageryProvider(window.layerWMS);
      var layer2 = new Image({
        name: "Wms_Layer",
        source: new ImageWMS({
          crossOrigin: "anonymous",
          url: geoServerURl,
          params: {
            FORMAT: "image/png",
            VERSION: "1.1.1",
            LAYERS: url.toString(),
          },
        }),
      });
      if (res.opacity) {
        layer2.setOpacity(parseInt(res.opacity) / 100);
      }
      window.map.addLayer(layer2);
    },
    async getFeatureInfo(html) {
      var start = html.indexOf("<caption class=\"featureInfo\">") + "<caption class=\"featureInfo\">".length;
      var end = html.indexOf("</caption>");
      var tab = html.substr(start, end - start);
      start = html.lastIndexOf(tab) + tab.length + 1;
      end = html.indexOf("</td>", start);
      var gid = html.substr(start, end - start);
      if (gid && tab) {
        this.$store.state.pickoption = {
          gid: gid,
          name: tab.replaceAll("_", "")
        }
        if (tab == 'm_surface_deformation_data') {
          this.$store.state.surfaceDeForm.flag = true;
          this.$store.state.surfaceDeForm.gid = gid;
        } else {
          this.$store.state.surfaceDeForm.flag = false;
          this.$store.state.surfaceDeForm.gid = null;
        }
        const res = await dataQuery_selectTabByEntity({
          name: this.$store.state.pickoption.name
        })
        if (res.code != 200) {
          return;
        }
        var value = res.result.split('.')
        this.$store.state.propertiesName = {
          ns: value[0],
          enName: value[1],
          tabDesc: '拾取信息'
        }
        var name = this.$store.state.pickoption.name;
        const data = await inquiry_selectFields({ name: name })
        if (data.code != 200) {
          this.$message.error("列表调用失败")
        }
        const data1 = await inquiry_selectDomains({ name: name })
        if (data1.code != 200) {
          this.$message.error("列表调用失败")
        }
        this.optionx = []
        this.attributeData = []
        var valadata = data.result
        var laydomain = data1.result
        this.optionx = data1.result
        for (var i in valadata) {
          if (valadata[i].showtype == 1) {
            if (
              valadata[i].domainNa != null &&
              valadata[i].domainNa != undefined
            ) {
              for (var j in laydomain) {
                if (laydomain[j].domName == valadata[i].domainNa) {
                  // valadata[i].domainNa = laydomain[j].codeDesc
                }
              }
            }
            // this.optionx.push(valadata[i])
            this.attributeData.push(valadata[i])
          }
        }
        this.getTableData()
      }
    },
    //格式化时间
    format(shijianchuo) {
      //shijianchuo是整数,否则要parseInt转换
      var time = new Date(shijianchuo);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return (
        y +
        '-' +
        this.add0(m) +
        '-' +
        this.add0(d) +
        ' ' +
        h +
        ':' +
        mm +
        ':' +
        s
      );
    },
    //格式化时间
    add0(m) {
      return m < 10 ? '0' + m : m;
    },
    async getTableData() {
      this.tableData = []
      const data = await dataQuery_selectByGid(this.$store.state.pickoption)
      if (data.code != 200) {
        return
      }
      var valste = data.result
      valste.dirid = valste.dirName;
      valste.depid = valste.depName;
      valste.verid = valste.verName;
      valste.createuser = valste.createName;
      valste.updateuser = valste.updateName;
      if (valste.createtime) {
        valste.createtime = this.format(valste.createtime)
      }
      if (valste.updatetime) {
        valste.updatetime = this.format(valste.updatetime)
      }
      for (var j in this.optionx) {
        if (
          this.optionx[j].domainNa != null &&
          this.optionx[j].domainNa != undefined
        ) {
          valste[this.optionx[j].field] = this.optionx[j].domainNa
        }
      }
      var arr = {}
      for (var i = (this.attributeData.length - 1); i >= 0; i--) {
        var vla = this.attributeData[i]
        if (vla.domainNa) {
          var val = this.optionx.filter(res => {
            if (res.domName == vla.domainNa && res.domCode == valste[vla.field]) {
              return res;
            }
          })
          var vlue = null
          if (val.length > 0) {
            vlue = val[0].codeDesc
          } else {
            vlue = ''
          }
          arr[vla.alias] = vlue
        } else {
          arr[vla.alias] = valste[vla.field]
        }
      }
      arr['eventid'] = valste.eventid
      this.$store.state.propertiesInfo = arr;
      this.$store.state.propertiesFlag = '1'
    },
    showModelAttach() {
      if (this.$store.state.attachModel) {
        var name = this.$store.state.attachinfo.cnName;
        this.$refs &&
          this.$refs.modelAttach &&
          this.$refs.modelAttach.open(name, null, {
            close: () => { },
          });
      } else {
      }
    },
    async showModelCatch() {
      if (this.$store.state.catModel) {
        this.formInline = {
          title: '',
          file: '',
          name: '',
          type: '',
          info: '',
          icon: '',
          bak: ''
        }
        this.formInline.title = this.$store.state.catModelInfo.name;
        this.formInline.Id = this.$store.state.catModelInfo.id;
        this.formInline.LayerName = this.$store.state.catModelInfo.layerName;
        this.startModelData();
        this.activeName = "first"
        this.getAttacthFlieList();
        this.dialogVisible = true;
      } else {
        this.dialogVisible = false;
        window.pickedFeature.color = window.pickedColor;
      }
    },
    async startModelData() {
      var obj = {
        layerid: this.$store.state.catModelInfo.layerId,
        modelid: this.$store.state.catModelInfo.id
      }
      const data = await comprehensive_selectModelByGuid(obj);
      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;
      }
    },
    async EditData() {
      const data = await comprehensive_updateModel(this.formInline)
      if (data.code != 200) {
        this.$message.error('修改失败');
      } else {
        this.$message({
          message: '修改成功',
          type: 'success'
        });
      }
      this.startModelData();
    },
    async InsertData() {
      var std = {
        "bak": this.formInline.bak,
        "guid": this.$store.state.catModelInfo.id,
        "layerid": this.$store.state.catModelInfo.layerId,
        "modelid": this.$store.state.catModelInfo.id,
        "name": this.formInline.name,
        "type": this.formInline.type
      }
      const data = await comprehensive_insertModel(std)
      if (data.code != 200) {
        this.$message.error('添加失败');
      } else {
        this.$message({
          message: '添加成功',
          type: 'success'
        });
      }
      this.startModelData();
    },
    handleClose() {
      this.$store.state.catModel = false;
    },
    //附件列表新增
    setAttachInsert() {
      var token = getToken();
      var fs = document.getElementById("insertFile");
      if (fs.files.length == 0) {
        this.$message({
          message: '请选择要上传的文件!',
          type: 'warning'
        });
        return;
      }
      const formData = new FormData()
      for (var i = 0, c = fs.files.length; i < c; i++) {
        formData.append('file', fs.files[i]); // fs.files[i].name,file
      }
      $.ajax(BASE_URL + "/comprehensive/uploadFiles?token=" + token + "&tabName=lf.sys_style&eventid=" + this.$store.state.catModelInfo.id, {
        type: "post",
        data: formData,
        async: true,
        cache: false,
        processData: false,
        contentType: false,
        success: (rs) => {
          this.$message({
            message: '附件添加成功',
            type: 'success'
          });
          document.getElementById("insertFile").value = "";
          this.formInline.file = "";
          this.getAttacthFlieList();
        },
        error: (e) => {
          document.getElementById("insertFile").value = "";
          this.formInline.file = "";
          this.$message.error('附件添加失败');
        }
      });
    },
    //附件列表查询
    async getAttacthFlieList() {
      var obj = {
        eventid: this.$store.state.catModelInfo.id,
        tabName: "lf.sys_style"
      };
      const res = await comprehensive_selectFiles(obj);
      if (res.code != 200) {
        this.$message.error('列表调用失败');
        return
      }
      this.tableData = res.result;
    },
    //附件=>文件选择
    getInsertFile() {
      $('#insertFile').click();
    },
    insertFile() {
      var val = document.getElementById('insertFile').files;
      if (!val || !val.length) return;
      this.formInline.file = val[0].name;
    },
    statSizeChange(row, column) {
      return this.stateFormatSizes(row.sizes)
    },
    stateFormatSizes(res) {
      if (res >= 1024) {
        const val = parseFloat(res / 1024).toFixed(3);
        return val + ' GB';
      } else {
        return res + ' MB';
      }
    },
    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
        || 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;
    },
    refreshAttatchDetail() {
      this.dialog.src = "";
      this.dialog.dialogVisible = false;
      this.dialog.isPdf = false;
      this.dialog.isJpg = false;
    },
    //附件查看
    setAttatchDetail(index, row) {
      this.refreshAttatchDetail()
      var name = row.name;
      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
        || 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
      }
    },
    handleClick(tab, event) {
      if (tab.name == "second") {
        this.getAttacthFlieList();
      }
    },
    //附件刪除
    async setAttachDel() {
      var std = [];
      for (var i in this.attacgSelection) {
        std.push(this.attacgSelection[i].id);
      }
      const res = await comprehensive_deletes({ ids: std.toString() });
      if (res.code != 200) {
        this.$message.error('文件删除失败');
      }
      this.getAttacthFlieList();
    },
    // 附件=>表格选择
    handleAttatchChange(val) {
      this.attacgSelection = val;
    },
    //拾取数据获取
    async getPickUpData(info) {
      let checkedLayers = JSON.parse(sessionStorage.getItem("checkedLayers"));
      let showPop = false;
      for (const item of checkedLayers) {
        let name = item.url.replaceAll("LF:", "");
        name = name.replaceAll("_", "");
        let params = {
          buffer: 10,
          limit: 20,
          name: name,
          wkt: `POINT (${info.lon} ${info.lat})`,
        }
        const res = await selectByBuffer(params);
        if (res.result && res.result.length > 0) {
          this.$store.state.mapPopBoxFlag = "4";
          this.$store.state.pickUpPointInfo = info;
          this.$refs &&
            this.$refs.queryinfo &&
            this.$refs.queryinfo.open("拾取分析", null,);
          showPop = true;
          break;
        }
      }
      if (!showPop) {
        this.$message.warning("暂无数据!");
      }
    },
    showPopBox() {
      if (this.$store.state.showPopBoxFlag == true) {
        this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close();
        this.$refs &&
          this.$refs.queryinfo &&
          this.$refs.queryinfo.open("属性", null, {
            close: () => {
              this.$store.state.showPopBoxFlag == false
              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();
              }
            },
          });
      }
    },
    setPellucidity() {
      this.$refs && this.$refs.setPellucidity && this.$refs.setPellucidity.open();
    },
    setDialogInsertVisible(res) {
      this.ruleForm = res;
      this.dialogInsertVisible = true;
    },
    downloadx() {
      this.$bus.$emit("setInsertDown1", this.codeForm)
      this.closeDownx();
    },
    handleCloseDown1() {
      this.$confirm("确认关闭?")
        .then(_ => {
          this.closeDownx();
        })
        .catch(_ => { })
    },
    closeDownx() {
      this.dialogVisible1 = false;
      this.codeForm = {
        password: '',
        repassword: '',
      }
    },
    closeInsertDown() {
      this.ruleForm = {
        depname: [],
        tabs: [],
        pwd: null,
        repwd: null,
        wkt: null,
        descr: null,
      }
      this.dialogInsertVisible = false
    },
    handleInsertClose() {
      this.$confirm("确认关闭?")
        .then(_ => {
          this.closeInsertDown()
        })
        .catch(_ => { })
    },
    getInsertDownz() {
      this.dialogInsertVisible = false;
      // this.dialogVisible1 = true;
      //
      this.$bus.$emit("setInsertApply1", this.ruleForm)
    },
    handleExtentClose() {
      this.dialogExtentVisible = false
      this.setExtent = 10;
    },
    handleExtentinsert() {
      this.$bus.$emit("setExtentBUff", this.setExtent)
      this.handleExtentClose();
    }
  },
  mounted() {
    this.$bus.$off();
    this.measureData = new Map();
    this.colorAll = {
      point: Cesium.Color.fromCssColorString("#ff0000"),
      polyline: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
      polygon: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
    };
    this.$store.state.setAlphaList = []
    this.$bus.$on("setChangeTwoMenu", (res) => {
      if (res == 8) {
        this.setLayerScene();
      } else {
        this.menuChange(res);
      }
    });
    this.$bus.$on("showMenuLayer", ((res) => {
      this.setAddLayers(res);
    }));
    this.$bus.$on("showPellucidity", res => {
      this.setPellucidity();
    });
    this.$store.state.isProjectLayer = [];
    this.$store.state.pigCode = null;
    this.$store.state.showAllLayers = true;
    this.$store.state.layerMnage = false;
    this.$store.state.treeData = null;
    this.$store.state.checkedKeys = [];
    // this.setCoverage("a1");
    this.layersStart();
    this.$bus.$on("setDialogInsertVisible", (res) => {
      if (res == true) {
        this.dialogVisible1 = true;
      } else {
        this.setDialogInsertVisible(res);
      }
    })
    this.$bus.$on('showExtentLayer', res => {
      this.dialogExtentVisible = res;
    });
  },
  watch: {
    Obj(newVal, oldVal) {
      this.showModelAttach();
    },
    catch(newVal, oldVal) {
      this.showModelCatch();
    },
    popObj(newVal, oldVal) {
      this.showPopBox();
    }
  },
  computed: {
    Obj() {
      return this.$store.state.attachModel;
    },
    catch() {
      return this.$store.state.catModel;
    },
    popObj() {
      return this.$store.state.showPopBoxFlag;
    }
  },
};
</script>
<style lang="less" scoped>
.menu_Box {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  // text-align: center;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  .leftMen_div {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    border: 1px solid rgba(0, 0, 0, 0);
    padding: 5px;
    min-width: 100px;
    margin-left: 10px;
    margin-top: 10px;
    border-radius: 5px;
    text-align: center;
  }
  .leftMen_div:hover {
    background: rgba(64, 158, 255, 0.4);
    border: 1px solid #409eff;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
  }
  .lefMenuDivActive {
    background: rgba(64, 158, 255, 0.4);
    border: 1px solid #409eff;
  }
  .menuTwoImage {
    width: 30px;
    height: 30px;
    display: inline-block;
  }
  .pdfClass {
    height: 63vh;
    width: 100%;
  }
}
</style>