月球大数据地理空间分析展示平台-【前端】-月球2期前端
WX
2023-07-21 bf48462e6ce0e0baa899c1c64c24c05290dc77fd
src/views/layer/layerManage.vue
@@ -33,7 +33,7 @@
                Delete
              </a>
            </span> -->
            <span class="button" v-if="data.type == 2">
            <span class="button" v-if="data.type == 2 || data.type == 3">
              <el-dropdown trigger="click">
                <span class="el-dropdown-link">
                  <el-icon class="el-icon--right">
@@ -91,6 +91,7 @@
import { useStore } from "vuex"; // 引入useStore 方法
import { layer_selectAll } from "@/api/api";
import server from "@/assets/js/Map/server";
import { ElMessage } from "element-plus";
const store = useStore(); // 该方法用于返回store 实例
const stretchValue = ref("");
@@ -119,6 +120,7 @@
];
const transparence = ref(0);
var treeData = ref([]);
var layerListData = ref([]);
let menuOption = reactive([
  {
    id: 1,
@@ -305,16 +307,47 @@
};
//编辑图层树
const addlayer = (res) => {
  menuOption.push(res);
  // treeData.value = handleTree(menuOption, "id", "pid", "children");
  console.log(res);
  let node;
  layerListData.value.forEach((e) => {
    if (e.id == res.id) {
      node = estreeRef.value.getNode(e);
    }
  });
  // 将变动之前的node备份
  let copyNode = { ...node };
  copyNode.previousSibling = { ...node.previousSibling };
  copyNode.nextSibling = { ...node.nextSibling };
  if (res.type === 1) {
    // 上移
    if (node.previousSibling) {
      // 删除原先的node
      estreeRef.value.remove(node.data);
      // 拿到copy的node
      // nodeData = CircularJSON.parse(window.sessionStorage.getItem("menuNode"));
      // 复制该node到指定位置(参数:1. 要增加的节点的 data 2. 要增加的节点的后一个节点的 data、key 或者 node)
      estreeRef.value.insertBefore(
        copyNode.data,
        copyNode.previousSibling.data
      );
      // window.sessionStorage.removeItem("menuNode");
    }
  } else {
    // 下移
    if (node.nextSibling) {
      estreeRef.value.remove(node.data);
      estreeRef.value.insertAfter(copyNode.data, copyNode.nextSibling.data);
    }
  }
};
//删除图层树
const delLayer = (res) => {
  menuOption = menuOption.filter((item) => {
    return item.id != res;
  });
  console.log(res);
  console.log(menuOption);
  // menuOption = menuOption.filter((item) => {
  //   return item.id != res;
  // });
  // console.log(res);
  // console.log(menuOption);
  // treeData = handleTree(menuOption, "id", "pid", "children");
};
@@ -322,6 +355,7 @@
  const dt = await layer_selectAll();
  if (dt.code == 200) {
    treeData.value = setTreeData(dt.result);
    layerListData.value = dt.result;
  }
  // treeData.value = JSON.parse(JSON.stringify(treeData.value));
@@ -337,7 +371,7 @@
    let branchArr = cloneData.filter((child) => father.id == child.pid);
    if (branchArr.length > 0) {
      branchArr.sort(function (a, b) {
        return a.orderNum - b.orderNum;
        return a.sort - b.sort;
      });
    }