surprise
2024-01-10 2a960cd2c5b88b143cea4acfaeafb96daef0f29b
src/components/left/layerTree/Layer.vue
@@ -97,9 +97,10 @@
import AddOnlineMap from "./AddOnlineMap.vue";
import GetScene from "./GetScene.vue";
import SaveScene from "./SaveScene.vue";
import { Op_SelectByPage, Op_Insert, Op_UpdateById } from '../../../api/api.js'
import { Op_SelectByPage, Op_Insert, Op_UpdateById, Img_SelectByPage, Img_DeleteByIds } from '../../../api/api.js'
import model from "../../../assets/js/Layer/model";
import mapOL from "../../../assets/js/Layer/mapOL";
import mapGeo from "../../../assets/js/Layer/mapGeo";
// 工程树工具
let _treeTool;
function arrGroup(arr, fn) {
@@ -154,6 +155,16 @@
    };
  },
  mounted() {
    Bus.$on("reastLayer", (type) => {
      this.setTreeData([]);
      this.initData({});
      model.deleteAll();
      setTimeout(() => {
        this.histotyPlotting();
      }, 100);
    });
    // 获取本地配置文件
    if (this.$route.query.hasOwnProperty("layer")) {
      axios
@@ -196,12 +207,13 @@
      Bus.$emit("checkTab", "index/add/treeLayer", false);
    },
    closeLayer() {
      this.$store.state.isShowLayer= false
      this.$store.state.isShowLayer = false
      // this.$parent.hideLayer();
    },
    // 定义中转站事件
    initBusEvent() {
      Bus.$off("addLayer");
      Bus.$on("addLayer", (type) => {
        this.selectNode = this.$refs.tree && this.$refs.tree.getCurrentNode();
        this.openThisTypePop(type);
@@ -394,7 +406,9 @@
      this.setTreeData([]);
      this.initData({});
      model.deleteAll();
      var finalPlotting = [];
      const data = await Op_SelectByPage({ pageSize: 1000000, pageIndex: 1, name: '' });
      const data1 = await Img_SelectByPage({ pageSize: 1000000, pageIndex: 1, name: '' });
      if (data.status == 200 && data.data.length > 0) {
        var val_data = data.data;
        for (var i in val_data) {
@@ -405,7 +419,7 @@
            let plottingArr = [];
            plottingArr.push(val[0]);
            const newArr = arrGroup(plottingArr, (item) => item.name);
            let finalPlotting = [];
            newArr.map((a) => {
              let newObj = {};
              a.map((b) => {
@@ -417,16 +431,33 @@
              });
              finalPlotting.push(newObj);
            });
            let json = {
              name: "江苏交控智慧高速",
              id: 1,
              open: true,
              children: finalPlotting,
            };
            this.initData(json);
          }
        }
      }
      if (data1.status == 200) {
        var img_data = data1.data;
        if (img_data && img_data.length > 0) {
          for (var i = 0; i < img_data.length; i++) {
            var item = img_data[i]
            item.sourceType = 'imgUp'
            item.sid = item.id;
            item.id = new Date().getTime() + i;
            item.checked = true;
            finalPlotting[0].children.push(item)
          }
        }
      }
      var json = {
        name: "江苏交控智慧高速",
        id: 1,
        open: true,
        children: finalPlotting
      };
      this.initData(json);
      // const downloading = this.$loading({
      //   lock: true,
      //   text: "会议保障历史数据加载中,请稍后",
@@ -555,7 +586,7 @@
        if (addData && node._children) {
          node._children.forEach((item) => {
            _treeTool.addData(item);
            console.log(item)
            this.setAddGLBLayer(item);
          });
        } else {
@@ -597,7 +628,7 @@
        if (isCheck) {
          mapOL.addLayerData(treeNode);
        } else {
          mapOL.removeLayerD(treeNode);
          mapOL.removeLayerData(treeNode);
        }
      }
      // 只能同时加载一个地形
@@ -823,7 +854,11 @@
        model.addModelLayer(res);
      } else if (res.sourceType == "SimpleGraphic" && res.checked) {
        mapOL.addLayerData(res);
      }
      } else if (res.sourceType == "imgUp" && res.checked) {
        model.addImgUpLayer(res);
      }else if(res.sourceType == "DrawGrid" && res.checked) {
        mapGeo.addGridLayer(res);
      }
    },
    // 添加演示动画
    editDemoAnimation() {
@@ -941,6 +976,9 @@
    // 右键菜单元素
    rightClick(e, data, node, comp) {
      this.isClickParent = !!data.children;
      if (data.sourceType == 'imgUp') {
        this.isClickParent = true;
      }
      this.selectNode = data;
      this.rightClickMenuStyle = { top: e.pageY + "px", left: e.pageX + "px" };
      this.rightClickMenuDisplay = true;
@@ -957,16 +995,15 @@
      if (this.selectNode.sourceType === "GLB") {
        model.setDelGLBModel(this.selectNode)
      }
       if (this.selectNode.sourceType === "SimpleGraphic") {
      if (this.selectNode.sourceType === "SimpleGraphic") {
        mapOL.removeLayerData(this.selectNode)
      }
      if (this.selectNode.sourceType === "imgUp") {
        this.removeimgUpData(this.selectNode)
      }
      this.remove(this.selectNode);
      this.$refs.tree && this.$refs.tree.setCurrentKey(null);
      this.selectNode = undefined;
    },
    // 右键编辑按钮编辑树节点
    editTreeNode() {
@@ -993,6 +1030,18 @@
        }
      }
    },
    async removeimgUpData(res) {
      const data = await Img_DeleteByIds(res.sid);
      if (data.status == 200) {
      }
    },
    // 添加目录
    addFold() {
      let newChild = {