管道基础大数据平台系统开发-【前端】-新系統界面
13693261870
2023-05-23 2dee2fd0049aca6e2af948dabe19dbfecd889318
src/views/Tools/LayerTree.vue
@@ -58,18 +58,17 @@
             v-show="menuVisible">
      <div class="edit"
           @click="showLayerAttribute()"
           v-if="!showlocal && !shwoHistogram"
           v-show="!firstLevel">
           v-if="showProp && !shwoHistogram">
        <i class="el-icon-tickets"></i>&nbsp;&nbsp;属性
      </div>
      <div class="edit"
           @click="positioning()"
           v-if="showlocal">
           v-if="showLocal">
        <i class="el-icon-tickets"></i>&nbsp;&nbsp;定位
      </div>
      <div class="edit"
           @click="pellucidity()"
           v-if="showlocal">
           v-if="showOpacity">
        <i class="el-icon-tickets"></i>&nbsp;&nbsp;透明度
      </div>
      <div class="edit"
@@ -95,13 +94,20 @@
  components: { queryinfo },
  data () {
    return {
      shwoHistogram: false,
      showlocal: false,
      showProp: false, // 属性
      shwoHistogram: false, // 钻孔柱状图
      showLocal: false, // 定位
      showOpacity: false, // 不透明度
      menuVisible: false, // 菜单
      levelArray: [ // 调试数组
        0, 40000000, 20000000, 10000000, 5000000, 2000000, 1000000, 500000,
        250000, 200000, 100000, 50000, 17000, 9000, 5000, 2000, 1000, 500, 200,
        100, 50, 25, 10, 0,
      ],
      eleId: "",
      isShow: false,
      currentData: "",
      currentNode: "",
      menuVisible: false,
      firstLevel: false,
      filterText: "",
      appendNodetitle: "",
@@ -193,7 +199,6 @@
        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; // 返回一级菜单
      });
    },
@@ -215,48 +220,25 @@
      //  要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了
      document.removeEventListener("click", this.rmListener);
    },
    //转孔柱状图
    async histogram () {
      this.menuVisible = false
      var layer = this.currentData.enName.replaceAll("_", "");
      this.$store.state.mapSpaceQueryLayer = layer;
      this.$store.state.mapPopBoxFlag = "2";
      this.$store.state.showPopBoxFlag = true;
    // 过滤节点
    filterNode (value, data) {
      if (!value) return true;
      return data.cnName.indexOf(value) !== -1;
    },
    // 鼠标右击事件
    rightClick (event, object, Node, element) {
      if (object.type == 1) {
        return
      }
    rightClick (event, object, node, element) {
      debugger
      if (object.type == 1 || node.data.children != null) return;
      this.currentNode = node;
      this.currentData = object;
      this.currentNode = Node;
      this.$store.state.propertiesName = object;
      this.$store.state.propertiesName = this.currentData;
      if (this.currentData.serveType == "Tileset" || this.currentData.serveType == "3DML") {
        this.showModelAttach = true;
      } else {
        this.showModelAttach = false;
      }
      if (this.currentData.enName == "s_explorationpoint") {
        this.shwoHistogram = true;
      } else {
        this.shwoHistogram = false;
      }
      if (Node.data.children == null) {
        this.firstLevel = false;
      } else {
        this.firstLevel = true;
      }
      if (Node.data.children == null && Node.data.serveType == "Tileset" || Node.data.serveType == "3DML") {
        this.showlocal = true;
      } else if (Node.data.children == null && Node.data.serveType != "Tileset" || Node.data.serveType == "3DML") {
        this.showlocal = false;
      }
      this.menuVisible = true;
      this.showProp = object.serveType == "WMS"; // 属性
      this.shwoHistogram = this.showProp && object.enName == "s_explorationpoint"; // 钻孔柱状图
      this.showLocal = ["Tileset", "3DML", "Mpt", "TMS", "DOM", "DEM"].indexOf(object.serveType) > -1; // 定位
      this.showOpacity = ["Tileset", "3DML"].indexOf(object.serveType) > -1; // 不透明度
      this.menuVisible = this.showProp || this.shwoHistogram || this.showLocal || this.showOpacity; // 菜单
      this.$refs.card.$el.style.left = event.pageX + 20 + "px";
      this.$refs.card.$el.style.top = event.pageY + "px";
@@ -264,14 +246,50 @@
    // 属性显示
    showLayerAttribute (data) {
      this.rmListener();
      this.menuVisible = false
      this.currentData = data ? data : this.currentData;
      var layer = this.currentData.enName.replaceAll("_", "");
      this.$store.state.mapSpaceQueryLayer = layer;
      this.$store.state.showPopBoxFlag = true;
      this.$store.state.mapPopBoxFlag = "2";
    },
    // 模型设置透明度
    // 定位
    async positioning () {
      this.menuVisible = false;
      if (["Tileset", "3DML"].indexOf(this.currentData.serveType) > -1) {
        for (var i in Viewer.scene.primitives._primitives) {
          if (Viewer.scene.primitives._primitives[i].id == this.currentData.cnName) {
            Viewer.flyTo(Viewer.scene.primitives._primitives[i]);
            break;
          }
        }
        return;
      }
      if (["TMS", "DOM", "DEM"].indexOf(this.currentData.serveType) > -1 && this.currentData.pubid) {
        var data = await comprehensive_selectPubById({ id: this.currentData.pubid });
        if (data.result && data.result.geom) {
          var wkt = this.$wkt.parse(data.result.geom);
          var height = this.getHeight(wkt.coordinates[2]);
          Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], height), // 2000
          });
        }
        return;
      }
      if ("Mpt" == this.currentData.serveType) {
        viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(101.8, 37.9, 10000000.0) }); // 中国
      }
    },
    // 钻孔柱状图
    async histogram () {
      this.menuVisible = false
      var layer = this.currentData.enName.replaceAll("_", "");
      this.$store.state.mapSpaceQueryLayer = layer;
      this.$store.state.mapPopBoxFlag = "2";
      this.$store.state.showPopBoxFlag = true;
    },
    // 透明度
    pellucidity () {
      this.rmListener();
      this.menuVisible = false
@@ -284,82 +302,11 @@
        }
      }
    },
    // 模型定位
    positioning () {
      this.menuVisible = false
      for (var i in Viewer.scene.primitives._primitives) {
        if (
          Viewer.scene.primitives._primitives[i].id == this.currentData.cnName
        ) {
          Viewer.flyTo(Viewer.scene.primitives._primitives[i]);
        }
      }
    },
    // 编辑节点
    editNode (data) {
      this.rmListener();
      this.menuVisible = false
      this.currentData = data ? data : this.currentData;
      if (!this.currentData.isEdit) {
        this.$set(this.currentData, "isEdit", true);
      }
      // 获取焦点
      this.$nextTick(() => {
        this.$refs["slotTreeInput" + this.currentData.id].focus();
      });
    },
    menuMoveF (type) {
      // 将变动之前的node备份
      var node = this.currentNode;
      var data = this.currentData;
      let copyNode = this.currentNode;
    // 获取高度
    getHeight (level) {
      if (level > -1 && level < 23) return this.levelArray[level];
      let nodeData = {};
      if (type === "up") {
        // 上移
        if (node.previousSibling) {
          // 删除原先的node
          this.$refs.tree.remove(node.data);
          // 拿到copy的node
          // nodeData = CircularJSON.parse(window.sessionStorage.getItem('menuNode'))
          // // 复制该node到指定位置(参数:1. 要增加的节点的 data 2. 要增加的节点的后一个节点的 data、key 或者 node)
          // this.$refs.tree.insertBefore(nodeData.data,nodeData.previousSibling.data)
          window.sessionStorage.removeItem("menuNode");
        } else {
          this.$message.warning("该菜单已经是当前层最上级");
        }
      } else {
        // 下移
        if (node.nextSibling) {
          this.$refs.tree.remove(node.data);
          nodeData = CircularJSON.parse(
            window.sessionStorage.getItem("menuNode")
          );
          // 参数:1. 要增加的节点的 data 2. 要增加的节点的前一个节点的 data、key 或者 node
          this.$refs.tree.insertAfter(nodeData.data, nodeData.nextSibling.data);
          window.sessionStorage.removeItem("menuNode");
        } else {
          this.$message.warning("该菜单已经是当前层最下级");
        }
      }
    },
    handleDragStart (node, ev) {
      console.log("drag start", node);
    },
    handleDragEnter (draggingNode, dropNode, ev) {
      console.log("tree drag enter: ", dropNode.label);
    },
    handleDragLeave (draggingNode, dropNode, ev) {
      console.log("tree drag leave: ", dropNode.label);
    },
    handleDragOver (draggingNode, dropNode, ev) {
      console.log("tree drag over: ", dropNode.label);
    },
    handleDragEnd (draggingNode, dropNode, dropType, ev) {
      console.log("tree drag end: ", dropNode && dropNode.label, dropType);
    },
    handleDrop (draggingNode, dropNode, dropType, ev) {
      console.log("tree drop: ", dropNode.label, dropType);
      return this.levelArray[this.levelArray.length - 1];
    },
    handleCheckChange (data, checked, indeterminate) {
      if (data.type == 1) {
@@ -737,10 +684,10 @@
        layer.name = res.cnName;
        if (data.result.geom) {
          var wkt = this.$wkt.parse(data.result.geom);
          Viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
          });
          // var wkt = this.$wkt.parse(data.result.geom);
          // Viewer.camera.flyTo({
          //   destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
          // });
        }
        this.setChangeWMS();
      }
@@ -767,12 +714,6 @@
      //修改模型矩阵
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
      // Viewer.flyTo(tileset);
    },
    // 查询
    filterNode (value, data) {
      if (!value) return true;
      return data.cnName.indexOf(value) !== -1;
    },
    async setproChange (res) {
      if (res) {