月球大数据地理空间分析展示平台-【前端】-月球2期前端
11
WX
2023-07-14 23aac3cf9903d404eb86310d502a0eeb5a68b407
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<template>
  <div v-drag class="layerBox">
    <div class="layerTitle">
      <div class="tileLeft">
        <div @click="setCloseLayer" class="titleImg">
          <ArrowLeft />
        </div>
        <div class="titleLable">图层管理</div>
      </div>
      <div class="titleImg set" @click="layerSetBox">
        <Setting />
      </div>
    </div>
    <div class="layerContent">
      <el-tree
        node-key="id"
        :props="props"
        :highlight-current="false"
        :current-node-key="selectedNodeId"
        :data="treeData"
        :expand-on-click-node="false"
        show-checkbox
        @check="handleCheckChange"
        ref="estreeRef"
        v-if="treeData.length"
      >
        <template #default="{ node, data }">
          <span class="custom-tree-node">
            <span class="label">{{ node.label }}</span>
            <!-- <span>
              <a @click="append(data)"> Append </a>
              <a style="margin-left: 8px" @click="remove(node, data)">
                Delete
              </a>
            </span> -->
            <span class="button" v-if="data.type == 2">
              <el-dropdown trigger="click">
                <span class="el-dropdown-link">
                  <el-icon class="el-icon--right">
                    <MoreFilled />
                  </el-icon>
                </span>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item @click.native="clickdropdown(1, data)"
                      >详细</el-dropdown-item
                    >
                    <el-dropdown-item @click.native="clickdropdown(2, data)"
                      >属性</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </span>
          </span>
        </template>
      </el-tree>
    </div>
  </div>
  <layer-set
    v-show="layerSetIsshow"
    @SETstate="SETstate"
    :layerTree="treeData"
    @addlayer="addlayer"
    @delLayer="delLayer"
  ></layer-set>
  <attribute-list
    v-show="layerAttributeIsshow"
    :layerData="layerObjData"
    @spatialClose="setSpatialClose"
  ></attribute-list>
  <layer-detail
    :layerData="layerObjData"
    v-if="layerDetailIsshow"
    @detailClose="detailClose"
  ></layer-detail>
</template>
 
<script lang="ts" setup>
import {
  ref,
  onMounted,
  onBeforeUnmount,
  reactive,
  defineProps,
  defineEmits,
} from "vue";
import layerSet from "./layerSet";
import attributeList from "./attributeList";
import layerDetail from "./layerDetail";
import { useStore } from "vuex"; // 引入useStore 方法
import { layer_selectAll } from "@/api/api";
const store = useStore(); // 该方法用于返回store 实例
const stretchValue = ref("");
 
let estreeRef = ref();
const stretchOptions = [
  {
    value: "Option1",
    label: "Option1",
  },
  {
    value: "Option2",
    label: "Option2",
  },
  {
    value: "Option3",
    label: "Option3",
  },
  {
    value: "Option4",
    label: "Option4",
  },
  {
    value: "Option5",
    label: "Option5",
  },
];
const transparence = ref(0);
var treeData = ref([]);
let menuOption = reactive([
  {
    id: 1,
    name: "测试",
    isShow: false,
    checkedAll: false,
    type: 1,
    parentId: null,
  },
  {
    id: 2,
    layerState: false,
    name: "图层名称",
    layerUrl: "",
    type: 2,
    parentId: 1,
  },
  {
    id: 3,
    layerState: false,
    name: "图层菜单",
    layerUrl: "",
    type: 1,
    parentId: 1,
  },
  {
    id: 5,
    layerState: false,
    name: "图层名称11",
    layerUrl: "",
    type: 2,
    parentId: 3,
  },
  {
    id: 4,
    name: "测试1",
    isShow: false,
    checkedAll: true,
    layerState: false,
    type: 1,
    parentId: null,
  },
]);
 
const layerSetIsshow = ref(false);
const layerAttributeIsshow = ref(false);
const layerDetailIsshow = ref(false);
const props = {
  label: "cnName",
  children: "children",
};
const layerObjData = ref(null);
// 当前选中的节点 id
const selectedNodeId = ref(null as any); //做类型断言处理
const emits = defineEmits(["setCloseLayer"]);
 
//图层设置弹框
const layerSetBox = () => {
  layerSetIsshow.value = !layerSetIsshow.value;
};
//关闭状态
const SETstate = (res) => {
  layerSetIsshow.value = res;
};
const setCloseLayer = () => {
  emits("setCloseLayer", false);
};
//选择图层
const handleCheckChange = (data, checked) => {
  let son = estreeRef.value.getCheckedNodes();
 
  store.commit("SET_CHECKLAYER", son);
};
const clickdropdown = (res, e) => {
  layerAttributeIsshow.value = false;
  layerDetailIsshow.value = false;
  layerObjData.value = e;
  if (res == 2) {
    layerAttributeIsshow.value = true;
  } else {
    layerDetailIsshow.value = true;
  }
};
const setSpatialClose = (res) => {
  layerAttributeIsshow.value = res;
};
const detailClose = (res) => {
  layerDetailIsshow.value = res;
};
//编辑图层树
const addlayer = (res) => {
  menuOption.push(res);
  treeData.value = handleTree(menuOption, "id", "pid", "children");
};
//删除图层树
const delLayer = (res) => {
  menuOption = menuOption.filter((item) => {
    return item.id != res;
  });
  console.log(res);
  console.log(menuOption);
  // treeData = handleTree(menuOption, "id", "pid", "children");
};
 
const getLayer = async () => {
  const dt = await layer_selectAll();
  treeData.value = setTreeData(dt.result);
  treeData.value = JSON.parse(JSON.stringify(treeData.value));
 
  console.log(treeData.value);
};
 
//构造树
function setTreeData(source) {
  let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
  return cloneData.filter((father) => {
    // 循环所有项
    let branchArr = cloneData.filter((child) => father.id == child.pid);
    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; // 返回一级菜单
  });
}
onMounted(() => {
  getLayer();
});
</script>
 
<style lang="less" scoped>
.layerBox {
  width: 359px;
  height: 680px;
  background: rgba(7, 8, 14, 0.8);
  box-shadow: inset 0px 10px 40px 10px rgba(38, 47, 71, 1);
  .layerTitle {
    width: calc(100% - 27px);
    height: 42px;
    background: #0e151f;
    box-shadow: 0px 0px 6px 0px #080c13,
      0px 14px 16px 0px rgba(38, 47, 71, 0.68);
    display: flex;
    justify-content: space-between;
    padding-left: 7px;
    padding-right: 20px;
    color: white;
    .tileLeft {
      height: 100%;
      display: flex;
      align-items: center;
 
      .titleLable {
        font-size: 18px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
      }
    }
    .titleImg {
      width: 20px;
      height: 100%;
      display: flex;
      align-items: center;
      color: rgba(104, 156, 255, 1);
    }
    .set {
      cursor: pointer;
    }
  }
  .layerContent {
    height: 635px;
    padding: 0 8px;
    overflow: auto;
    overflow-y: auto;
  }
  .layerContent::-webkit-scrollbar {
    width: 8px;
  }
  .layerContent::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
  }
  .layerContent::-webkit-scrollbar-track {
    border-radius: 0;
    background: rgba(0, 0, 0, 0);
  }
  .el-tree {
    width: 100%;
    overflow-y: auto;
  }
  .layerContent .el-tree-node__content {
    overflow: hidden;
  }
 
  .layerContent .custom-tree-node {
    overflow: hidden;
    flex-shrink: 1;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    padding-right: 8px;
  }
 
  .layerContent .custom-tree-node .label {
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }
 
  .layerContent .custom-tree-node .button {
    flex-grow: 0;
    flex-shrink: 0;
  }
}
.dropdown_box {
  position: relative;
}
 
/deep/.el-select-dropdown__item {
  font-size: 12px !important;
}
.el-tree {
  background: transparent;
}
/deep/ .el-tree-node {
  background: #0d131d;
  color: #ffffff;
  font-size: 20px;
  font-weight: 300;
  margin-top: 3px;
  padding: 8px;
}
/deep/ .el-tree-node:focus > .el-tree-node__content {
  background: transparent;
}
/deep/ .el-tree-node__content:hover {
  background: #0d131d;
}
/deep/ .el-tree-node__children {
  background: #1e2a3d;
  .el-tree-node {
    background: #1e2a3d;
    margin-top: 0;
    padding: 4px;
  }
}
/deep/
  .el-tree--highlight-current
  .el-tree-node.is-current
  > .el-tree-node__content {
  background: rgba(104, 156, 255, 0.5) !important;
}
.highlight {
  background: rgba(104, 156, 255, 0.5) !important;
}
// .custom-tree-node {
//   flex: 1;
//   display: flex;
//   align-items: center;
//   justify-content: space-between;
//   font-size: 16px;
//   padding-right: 8px;
// }
 
.el-dropdown-menu {
  background: rgba(7, 8, 14, 0.8);
  box-shadow: inset 0px 10px 40px 10px rgba(38, 47, 71, 1);
  color: #fff;
  border: 0;
  /deep/ .el-dropdown-menu__item {
    color: #fff;
  }
}
/deep/ .el-dropdown-menu__item:not(.is-disabled):focus {
  background-color: rgba(104, 156, 255, 0.5);
 
  color: #fff;
}
</style>
<style>
.el-popper.is-light {
  border: 1px solid rgba(7, 8, 14, 0.8) !important;
}
.el-scrollbar {
  border: 0 !important;
}
</style>