管道基础大数据平台系统开发-【前端】-新系統界面
584911253@qq.com
2023-03-10 eb6cfd90fd89f11263146dc4c38069c8a4845fab
src/views/Synthesis/LeftMenu.vue
@@ -6,13 +6,23 @@
      v-for="(item, index) in setListTwoMenu"
      :class="{ lefMenuDivActive: showTwoMenuFlag == item.id }"
    >
      <div class="menuTwoImage" :class="item.css"></div>
      <div
        class="menuTwoImage"
        :class="item.css"
      ></div>
      <div>{{ $t(item.label) }}</div>
    </div>
    <mapinfo ref="mapinfo" />
    <maplayer ref="maplayer" />
    <queryinfo ref="queryinfo" />
    <input type="file" accept=".kml" class="file" style="display: none" />
    <terrainDig ref="terrainDig" />
    <modelAttach ref="modelAttach" />
    <input
      type="file"
      accept=".kml"
      class="file"
      style="display: none"
    />
    <input
      :accept="'.shp, .shx, .dbf, .prj'"
      style="display: none"
@@ -23,6 +33,200 @@
      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"
        >
          <img
            style="width:100%; height:100%"
            :src="dialog.src"
            alt=""
          />
        </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>
              </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>
              </el-form-item>
              <el-form-item :label="$t('common.bak')">
                <el-input v-model="formInline.bak"></el-input>
              </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-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>
        <!-- <el-form :model="formInline">
          <el-form-item>
            <el-row :gutter="20">
              <el-col :span="20">
                <el-input
                  size="small"
                  disabled
                  v-model="formInline.file"
                ></el-input>
                <input
                  name="file1"
                  type="file"
                  id="insertFile"
                  multiple="multiple"
                  style="display: none"
                  @change="insertFile( )"
                />
              </el-col>
              <el-col :span="4">
                <el-link
                  @click="getInsertFile( )"
                  :underline="false"
                  icon="el-icon-folder"
                > </el-link>
              </el-col>
            </el-row>
          </el-form-item>
          <el-form-item>
            <el-button
              @click="setAttachInsert"
              size="mini"
              type="primary"
              plain
            >添加</el-button>
            <el-button
              type="danger"
              plain
              size="mini"
              @click="setAttachDel"
            >删除</el-button>
          </el-form-item>
        </el-form> -->
        <!--     @selection-change="handleAttatchChange" -->
      </div>
    </el-dialog>
  </div>
</template>
@@ -31,8 +235,24 @@
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 $ 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
} from "../../api/api.js";
import {
  OverviewMap,
  defaults as defaultControls,
@@ -44,7 +264,7 @@
import { geometry } from "@turf/turf";
export default {
  components: { mapinfo, maplayer, queryinfo },
  components: { mapinfo, maplayer, queryinfo, terrainDig, modelAttach },
  data() {
    return {
      showTwoMenuFlag: false,
@@ -56,6 +276,18 @@
            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",
          },
        ],
        [
@@ -396,6 +628,45 @@
      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: '其他模型'
      }]
    };
  },
  methods: {
@@ -412,26 +683,28 @@
      }
      if (this.isMenuFlag != val) {
        this.$store.state.mapMenuBoolean = false;
        this.$store.state.mapMenuBoxFlag = null;
        this.$store.state.mapPopBoolean = false;
        this.$store.state.mapPopBoxFlag = null;
        sgworld.Creator.SimpleGraphic.clear();
        this.isMenuFlag = val;
        if (this.entityaLayers.length != 0) {
          for (var i in this.entityaLayers) {
            sgworld.Viewer.entities.remove(this.entityaLayers[i]);
        if (res.id != "b9") {
          this.$store.state.mapMenuBoolean = false;
          this.$store.state.mapMenuBoxFlag = null;
          this.$store.state.mapPopBoolean = false;
          this.$store.state.mapPopBoxFlag = null;
          sgworld.Creator.SimpleGraphic.clear();
          this.isMenuFlag = val;
          if (this.entityaLayers.length != 0) {
            for (var i in this.entityaLayers) {
              sgworld.Viewer.entities.remove(this.entityaLayers[i]);
            }
            this.entityaLayers = [];
          }
          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;
          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;
@@ -470,28 +743,28 @@
          sgworld.Creator.createSimpleGraphic(
            "point",
            {},
            function (entity) {}
            function (entity) { }
          );
          break;
        case "h2":
          sgworld.Creator.createSimpleGraphic(
            "polyline",
            {},
            function (entity) {}
            function (entity) { }
          );
          break;
        case "h3":
          sgworld.Creator.createSimpleGraphic(
            "rectangle",
            {},
            function (entity) {}
            function (entity) { }
          );
          break;
        case "h4":
          sgworld.Creator.createSimpleGraphic(
            "polygon",
            {},
            function (entity) {}
            function (entity) { }
          );
          break;
        case "h5":
@@ -518,7 +791,7 @@
          sgworld.Creator.createSimpleGraphic(
            "label",
            {},
            function (entity) {}
            function (entity) { }
          );
          break;
      }
@@ -703,7 +976,7 @@
            document.body.removeChild(a); // 释放
          }
        },
        error: function (e) {},
        error: function (e) { },
      });
    },
    handleOpenShp() {
@@ -774,6 +1047,7 @@
              },
            });
            this.entityaLayers.push(entity);
            sgworld.Navigate.flyToObj(entity)
            break;
          case "point":
            let point = Viewer.entities.add({
@@ -794,6 +1068,7 @@
            });
            this.entityaLayers.push(point);
            sgworld.Navigate.flyToObj(point)
            break;
          case "polyline":
            var std = [];
@@ -814,6 +1089,7 @@
            });
            this.entityaLayers.push(line);
            sgworld.Navigate.flyToObj(line)
            break;
          case "label":
            const label = Viewer.entities.add({
@@ -832,6 +1108,7 @@
              },
            });
            this.entityaLayers.push(label);
            sgworld.Navigate.flyToObj(label)
            break;
        }
      }
@@ -867,6 +1144,8 @@
              fileReader.result,
              kmlOptions
            );
            sgworld.Navigate.flyToObj(geocachePromise)
            geocachePromise.then(function (dataSource) {
              var geocacheEntities = dataSource.entities.values;
@@ -910,18 +1189,18 @@
        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"
        iHeight +
        ",,innerHeight=" +
        iHeight +
        ",width=" +
        iWidth +
        ",innerWidth=" +
        iWidth +
        ",top=" +
        iTop +
        ",left=" +
        iLeft +
        ",toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no"
      );
    },
@@ -1009,9 +1288,8 @@
            "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}`;
                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);
@@ -1070,9 +1348,8 @@
          });
          break;
        case "体积方量":
          info = `填方:${
            data.volume.fill.toFixed(4) + data.unit.fill
          }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
          info = `填方:${data.volume.fill.toFixed(4) + data.unit.fill
            }<br>挖方:${data.volume.dig.toFixed(4) + data.unit.dig}`;
          break;
      }
      return (
@@ -1137,16 +1414,24 @@
    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";
@@ -1155,27 +1440,29 @@
            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
              show: true,
            };
          } else {
            value = {
              name: "Analysis",
              id: 3,
              show:false
              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);
@@ -1184,6 +1471,7 @@
          }
          break;
        case "d5": //洪水淹没分析
          this.closePipelinePop();
          if (window.AnalysisFlood) {
            this.clear(res);
          } else {
@@ -1191,6 +1479,7 @@
          }
          break;
        case "d6": //土方量分析
          this.closePipelinePop();
          if (window.TFvolumetricMeasurementTool) {
            TFvolumetricMeasurementTool.cleanUp();
            if (TFvolumetricMeasurementTool._mouseHandler) {
@@ -1210,9 +1499,8 @@
              "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}`;
                  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);
@@ -1224,6 +1512,7 @@
          }
          break;
        case "d7": //三维截面分析
          this.closePipelinePop();
          // if(window.MXModel) {
          //   Viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
          //   window.MXModel=null;
@@ -1231,7 +1520,7 @@
          var that = this;
          window.model = sgworld.Creator.create3DTilesets(
            "",
            modelUrl,
            modelUrl + "/tileset/m/SN/tileset.json",
            {},
            {},
            "0",
@@ -1253,8 +1542,9 @@
                close: () => {
                  if (this.$store.state.pipelineEntity.length != 0) {
                    for (var i in this.$store.state.pipelineEntity) {
                      var item = this.$store.state.pipelineEntity[i];
                      sgworld.Viewer.entities.remove(item);
                      sgworld.Viewer.entities.remove(
                        this.$store.state.pipelineEntity[i]
                      );
                    }
                  }
                },
@@ -1267,6 +1557,7 @@
          break;
        case "d8": //影像对比
          this.closePipelinePop();
          if (this.isContrastFlag == false) {
            this.isContrastFlag = true;
            sgworld.Analysis.createCurtainContrast(2, 1);
@@ -1276,38 +1567,52 @@
          }
          break;
        case "d10": //地面整平
          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,
                    {}
                  );
              }
            );
          }
          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();
@@ -1319,12 +1624,13 @@
            window.Excavation = sgworld.Analysis.TerrainExcavation(
              10,
              {},
              function () {}
              function () { }
            );
          }
          break;
        case "d12": //通视分析
          this.closePipelinePop();
          if (window.TSExcavation != null) {
            window.TSExcavation._SimpleGraphic.drawHandler &&
              window.TSExcavation._SimpleGraphic.drawHandler.destroy();
@@ -1341,6 +1647,7 @@
          }
          break;
        case "d13": //视域分析
          this.closePipelinePop();
          if (window.SYExcavatio) {
            window.SYExcavatio.end && window.SYExcavatio.end();
            window.SYExcavatio.close();
@@ -1360,6 +1667,7 @@
          }
          break;
        case "d14": //圆形时域分析
          this.closePipelinePop();
          if (window.YXSYExcavation) {
            window.YXSYExcavation.end && window.YXSYExcavation.end();
            window.YXSYExcavation.close();
@@ -1380,6 +1688,12 @@
          break;
      }
    },
    //关闭管道信息弹窗
    closePipelinePop(){
      this.$refs &&
      this.$refs.queryinfo &&
      this.$refs.queryinfo.close("queryinfo");
    },
    setclippingModel() {
      if (window.model) {
@@ -1416,13 +1730,13 @@
        pointSelect: true,
        spood: 20,
        GroupID: 0,
        url: "/SmartEarthSDK/Workers/image/waterNormals.jpg",
        url: "/SmartEarthSDK/Workers/image/33.gif",
      };
      window.AnalysisFlood = sgworld.Command.execute(
        2,
        2,
        method,
        (value) => {}
        (value) => { }
      );
    },
    addterrainSectionAnalysis() {
@@ -1459,9 +1773,7 @@
      );
    },
    setWander(res) {
      debugger;
      switch (res) {
        case "c1":
          if (window.PointMY != null) {
            window.PointMY.drawHandler && window.PointMY.drawHandler.destroy();
@@ -1599,6 +1911,368 @@
    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 = [];
      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);
            that.setAddLayers(str);
          }
          return str;
        }
      });
      var res = this.setTreeData(val);
      for (var i in res) {
        res[i].children = res[i].children.filter((val) => {
          if (val.children != null) {
            return val;
          }
        });
      }
      this.$store.state.treeData = res;
      // this.$refs.tree.setCheckedKeys(checkKey);
      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,分别上下级菜单,并返回数据
        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) {
      if (res.serveType == "WMS") {
        var resource = geoServerURl;
        if (res.resource != null && res.resource != undefined) {
          resource = res.resource;
        }
        var imageryLayers = window.Viewer.scene.imageryLayers;
        let layerWMS = new Cesium.WebMapServiceImageryProvider({
          url: resource,
          layers: res.url,
          parameters: {
            transparent: true,
            format: "image/png",
            srs: "EPSG:4490",
            styles: "",
          },
          tileWidth: 512,
          tileHeight: 512,
        });
        layerWMS.name = res.cnName;
        //透明度
        var tdtAnnoLayer = imageryLayers.addImageryProvider(layerWMS);
        if (res.opacity) {
          tdtAnnoLayer.alpha = parseInt(res.opacity) / 100;
        }
        var layer2 = new Image({
          name: res.cnName,
          source: new ImageWMS({
            crossOrigin: "anonymous",
            url: resource,
            params: {
              FORMAT: "image/png",
              VERSION: "1.1.1",
              LAYERS: res.url,
            },
          }),
        });
        if (res.opacity) {
          layer2.setOpacity(parseInt(res.opacity) / 100);
        }
        window.map.addLayer(layer2);
      } else if (res.serveType == "WFS") {
        var url =
          res.resource +
          "?service=WFS&version=1.0.0&request=GetFeature&typeName=" +
          res.url +
          "&outputFormat=application%2Fjson";
        $.ajax({
          url: url,
          cache: false,
          async: true,
          success: function (data) {
            var datasource = Cesium.GeoJsonDataSource.load(data, {
              stroke: Cesium.Color.YELLOW,
              fill: Cesium.Color.YELLOW.withAlpha(0.1),
              alpha: 0.1,
              strokeWidth: 8,
              clampToGround: true, //是否贴地
            });
            datasource.then((data) => {
              data.name = res.cnName;
              window.Viewer.dataSources.add(data);
            });
          },
          error: function (data) {
            console.log("error");
          },
        });
        var vectorLayer = new VectorLayer({
          name: res.cnName,
          source: new VectorSource({
            url: url,
            format: new GeoJSON(),
          }),
        });
        window.map.addLayer(vectorLayer);
      } else if (res.serveType == "Tileset") {
        var tileset = Viewer.scene.primitives.add(
          new Cesium.Cesium3DTileset({
            name: res.cnName,
            url: modelUrl + "/" + res.url, //192.168.20.106,to4
            maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
            maximumMemoryUsage: 768, // 最大内存:512
            dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
            skipLevelOfDetail: true, // 在遍历时候跳过详情:false
          })
        );
        tileset.readyPromise.then(function (tileset) {
          tileset.id = res.cnName;
          tileset.layerId = res.id;
          Viewer.flyTo(tileset);
        });
      }
    },
    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) {
        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) {
        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) {
        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;
    },
  },
  mounted() {
    this.measureData = new Map();
@@ -1607,6 +2281,7 @@
      polyline: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
      polygon: Cesium.Color.fromCssColorString("#ffff00").withAlpha(0.6),
    };
    this.$bus.$on("setChangeTwoMenu", (res) => {
      if (res == 8) {
        this.setLayerScene();
@@ -1619,7 +2294,24 @@
    this.$store.state.layerMnage = false;
    this.$store.state.treeData = null;
    this.$store.state.checkedKeys = [];
    this.setCoverage("a1");
    // this.setCoverage("a1");
    this.layersStart();
  },
  watch: {
    Obj(newVal, oldVal) {
      this.showModelAttach();
    },
    catch(newVal, oldVal) {
      this.showModelCatch();
    },
  },
  computed: {
    Obj() {
      return this.$store.state.attachModel;
    },
    catch() {
      return this.$store.state.catModel;
    },
  },
};
</script>
@@ -1628,6 +2320,7 @@
.menu_Box {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-y: auto;
@@ -1666,5 +2359,9 @@
    height: 30px;
    display: inline-block;
  }
  .pdfClass {
    height: 63vh;
    width: 100%;
  }
}
</style>