<template>
|
<div class="edit">
|
<div class="layerBox">
|
<div class="layerTitle">
|
<div class="tileLeft">
|
<div class="titleImg" @click="editState">
|
<ArrowLeft />
|
</div>
|
<div class="titleLable">图层编辑</div>
|
</div>
|
</div>
|
<div class="layerContent">
|
<el-tree
|
node-key="id"
|
:props="props"
|
:highlight-current="true"
|
:current-node-key="selectedNodeId"
|
:data="layerTree"
|
:expand-on-click-node="false"
|
@node-click="handleNodeClick"
|
ref="treeRef"
|
/>
|
</div>
|
</div>
|
<div class="edit_box">
|
<div class="edit_box_btn btnstyle">
|
<el-button type="primary" :icon="Plus" @click="insertLayerData(1)"
|
>新增同级</el-button
|
>
|
<el-button type="primary" :icon="Plus" @click="insertLayerData(2)"
|
>新增子级</el-button
|
>
|
<el-button
|
type="primary"
|
:icon="Delete"
|
class="delbtn"
|
@click="delLayer"
|
>删除</el-button
|
>
|
<el-button type="primary" :icon="Top" @click="move(1)"
|
>向上移动</el-button
|
>
|
<el-button type="primary" :icon="Bottom" @click="move(2)"
|
>向下移动</el-button
|
>
|
</div>
|
<div class="edit_box_form">
|
<el-form :model="formInline" label-width="120px">
|
<el-form-item label="选中图层">
|
<el-select style="width: 100%" v-model="formInline.isLayer">
|
<el-option label="图层组" value="0"></el-option>
|
<el-option label="图层" value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
<!-- 服务资源-->
|
<el-form-item v-show="formInline.isLayer == 1" label="服务资源">
|
<el-button
|
size="small"
|
class="serviceButton"
|
@click="setServiceChange('0')"
|
key="0"
|
:class="{ serviceActive: !serviceActive }"
|
>否</el-button
|
>
|
<el-button
|
size="small"
|
class="serviceButton"
|
@click="setServiceChange('1')"
|
key="1"
|
:class="{ serviceActive: serviceActive }"
|
>是</el-button
|
>
|
</el-form-item>
|
|
<el-form-item label="图层名称">
|
<el-input
|
v-model="formInline.cnName"
|
placeholder="请输入图层名称"
|
/>
|
</el-form-item>
|
<!-- 数据类型 -->
|
<el-form-item v-show="formInline.isLayer == 1" label="数据类型">
|
<el-select
|
style="width: 100%"
|
v-model="formInline.data"
|
:disabled="serviceActive"
|
@change="setFromDataTypeClick"
|
>
|
<el-option
|
v-for="item in serveType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- 数据类型 -->
|
<el-form-item v-show="formInline.isLayer == 1" label="服务类型">
|
<el-select
|
style="width: 100%"
|
v-model="formInline.type"
|
:disabled="serviceActive"
|
>
|
<el-option
|
v-for="item in dataType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="服务地址" v-show="formInline.isLayer == 1">
|
<el-input
|
v-model="formInline.serviceUrl"
|
placeholder="请输入服务地址"
|
:disabled="serviceActive"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<div class="btnstyle editBtn">
|
<el-button type="primary" @click="onSubmit">确定</el-button>
|
<el-button class="delbtn" @click="updateRest">取消</el-button>
|
</div>
|
</el-form-item>
|
</el-form>
|
</div>
|
</div>
|
<el-dialog title="新增" v-model:visible="dialogVisible" width="50%">
|
<div style="width: 100%; max-height: 63vh; overflow-y: auto">
|
<el-form :model="formInline" label-width="120px">
|
<el-form-item label="选中图层">
|
<el-select style="width: 100%" v-model="formInline.isLayer">
|
<el-option label="图层组" value="0"></el-option>
|
<el-option label="图层" value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
<!-- 服务资源-->
|
<el-form-item v-show="formInline.isLayer == 1" label="服务资源">
|
<el-button
|
size="small"
|
class="serviceButton"
|
@click="setServiceChange('0')"
|
key="0"
|
:class="{ serviceActive: !serviceActive }"
|
>否</el-button
|
>
|
<el-button
|
size="small"
|
class="serviceButton"
|
@click="setServiceChange('1')"
|
key="1"
|
:class="{ serviceActive: serviceActive }"
|
>是</el-button
|
>
|
</el-form-item>
|
|
<el-form-item label="图层名称">
|
<el-input
|
v-model="formInline.cnName"
|
placeholder="请输入图层名称"
|
/>
|
</el-form-item>
|
<!-- 数据类型 -->
|
<el-form-item v-show="formInline.isLayer == 1" label="数据类型">
|
<el-select
|
style="width: 100%"
|
v-model="formInline.data"
|
@change="setFromDataTypeClick"
|
>
|
<el-option
|
v-for="item in serveType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<!-- 数据类型 -->
|
<el-form-item v-show="formInline.isLayer == 1" label="服务类型">
|
<el-select style="width: 100%" v-model="formInline.type">
|
<el-option
|
v-for="item in dataType"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="服务地址" v-show="formInline.isLayer == 1">
|
<el-input
|
v-model="formInline.serviceUrl"
|
placeholder="请输入服务地址"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<div class="btnstyle editBtn">
|
<el-button type="primary" @click="onSubmit">确定</el-button>
|
<el-button class="delbtn" @click="updateRest">取消</el-button>
|
</div>
|
</el-form-item>
|
</el-form>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts" setup>
|
import {
|
ref,
|
onMounted,
|
onBeforeUnmount,
|
reactive,
|
defineProps,
|
defineEmits,
|
} from "vue";
|
import { Plus, Delete, Top, Bottom } from "@element-plus/icons-vue";
|
import { ElMessage } from "element-plus";
|
import { serve_type, data_type } from "./js/layerManage.js";
|
import { removeToken, getToken } from "@/utils/auth";
|
const stretchValue = ref("");
|
const emits = defineEmits(["SETstate", "addlayer", "delLayer"]);
|
//defineProps 来接收组件的传值
|
const defineProp = defineProps({
|
layerTree: Array,
|
});
|
let treeRef = ref();
|
|
const stretchOptions = [
|
{
|
value: "目录",
|
label: "目录",
|
},
|
{
|
value: "Option2",
|
label: "Option2",
|
},
|
{
|
value: "Option3",
|
label: "Option3",
|
},
|
{
|
value: "Option4",
|
label: "Option4",
|
},
|
{
|
value: "Option5",
|
label: "Option5",
|
},
|
];
|
|
const formInline = ref({
|
cnName: null,
|
type: null,
|
serveType: null,
|
url: null,
|
dataType: null,
|
bak: null,
|
isShow: "1",
|
isProject: "0",
|
enName: "",
|
isLayer: null,
|
category: null,
|
status: null,
|
service: "0",
|
serviceUrl: null,
|
});
|
const insertData = ref({
|
cnName: null,
|
type: null,
|
serveType: null,
|
url: null,
|
dataType: null,
|
bak: null,
|
isShow: "1",
|
isProject: "0",
|
enName: "",
|
isLayer: null,
|
category: null,
|
status: null,
|
service: "0",
|
serviceUrl: null,
|
});
|
const props = {
|
label: "cnName",
|
children: "children",
|
};
|
let dialogVisible = ref(false);
|
// 当前选中的节点 id
|
const selectedNodeId = ref(null as any); //做类型断言处理
|
const selectedObj = ref(null);
|
let menuOption = ref([]);
|
let serviceActive = ref(false);
|
let dataType = ref(null);
|
let serveType = ref(null);
|
let backUpData = ref(null);
|
const insertLayerData = (res) => {
|
// if (res == 1) {
|
// //新增同级
|
// id = this.formInline.pid;
|
// let pchildNodes = this.$refs.tree.getNode(this.newNode.id).parent
|
// .childNodes;
|
// orderNum = this.getMaxOrderNum(pchildNodes);
|
// lever = this.formInline.level;
|
// } else if (res == 2) {
|
// //新增子级
|
// id = this.formInline.id;
|
// let pchildNodes = this.$refs.tree.getNode(this.newNode.id).childNodes;
|
// orderNum = this.getMaxOrderNum(pchildNodes);
|
// lever = this.formInline.level + 1;
|
// }
|
// this.insertData.pid = id;
|
// this.insertData.level = lever;
|
// this.insertData.orderNum = orderNum;
|
|
dialogVisible.value = true;
|
};
|
//修改重置
|
const updateRest = () => {
|
var res = JSON.parse(backUpData.value);
|
formInline.value = res;
|
formInline.value.isLayer = res.isLayer.toString();
|
|
formInline.value.status = res.status.toString();
|
// this.formInline.isProject = res.isProject.toString();
|
};
|
//下拉菜单初始化
|
const optionsStart = () => {
|
var std = [];
|
var ste = [];
|
for (var i in serve_type) {
|
ste.push({
|
value: serve_type[i].value,
|
label: serve_type[i].name,
|
});
|
}
|
serveType.value = std;
|
for (var i in data_type) {
|
std.push({
|
value: data_type[i].value,
|
label: data_type[i].name,
|
children: data_type[i].children,
|
});
|
}
|
dataType.value = ste;
|
};
|
const setInsertDataTypeChange = (res) => {
|
var filter = serveType.value.filter((rs) => {
|
if (rs.value == res) {
|
return rs;
|
}
|
});
|
if (filter.length <= 0) return;
|
var std = [];
|
var data = filter[0].children;
|
for (var i in data) {
|
for (var j in serve_type) {
|
if (serve_type[j].value == data[i]) {
|
std.push({
|
value: serve_type[j].value,
|
label: serve_type[j].name,
|
});
|
}
|
}
|
}
|
dataType.value = std;
|
};
|
const setFromDataTypeClick = (res) => {
|
setInsertDataTypeChange(res);
|
formInline.value.type = dataType.value[0].value;
|
};
|
const setServiceChange = (res) => {
|
if (res == "1") {
|
// this.setServiceRest()
|
} else {
|
serviceActive.value = false;
|
formInline.value.resid = 0;
|
}
|
};
|
const handleCheckChange = (
|
data: Tree,
|
checked: boolean,
|
indeterminate: boolean
|
) => {
|
console.log(data, checked, indeterminate);
|
};
|
const onSubmit = () => {
|
console.log("submit!");
|
};
|
|
// 处理节点点击事件
|
function handleNodeClick(data: any) {
|
console.log(data);
|
console.log(formInline.value);
|
if (data.id === selectedNodeId.value) {
|
// 如果当前节点已经选中,则取消选中
|
selectedNodeId.value = null;
|
} else {
|
// 否则选中当前节点
|
selectedNodeId.value = data.id;
|
selectedObj.value = data;
|
backUpData.value = JSON.stringify(data);
|
// this.currentData = JSON.stringify(result)
|
formInline.value = data;
|
formInline.value.isLayer = data.isLayer.toString();
|
if (data.resid && data.resid > 0) {
|
serviceActive.value = true;
|
} else {
|
serviceActive.value = false;
|
}
|
var url;
|
if (!serviceActive.value) {
|
url = data.url;
|
} else if (serviceActive.value) {
|
var token = getToken();
|
if (data.url.indexOf("{token}") > -1) {
|
url = BASE_URL + data.url.replaceAll("{token}", token);
|
} else {
|
url = data.url;
|
}
|
}
|
formInline.value.serviceUrl = url;
|
}
|
}
|
//新增
|
const added = (t) => {
|
var id = "";
|
for (var i = 0; i < 7; i++) {
|
id += Math.floor(Math.random() * 10);
|
}
|
var addObj = {
|
id: id,
|
cnName: formInline.value.name,
|
region: formInline.value.region,
|
url: formInline.value.layerUrl,
|
children: [],
|
type: 2, //数据类型
|
proxy: null,
|
data: 0,
|
tab: "", //Geoserver 名称,
|
category: "", //服务类别 Geoserver ,
|
};
|
if (formInline.value.region == "目录") {
|
addObj.type = 1;
|
}
|
|
if (t == "t") {
|
// console.log(treeRef.value.getNode(selectedObj.value));
|
// addObj.parentId = selectedObj.value.parentId;
|
treeRef.value.insertAfter(addObj, treeRef.value.getNode(selectedObj.value));
|
} else {
|
// addObj.parentId = selectedNodeId.value;
|
treeRef.value.append(addObj, treeRef.value.getNode(selectedObj.value));
|
}
|
};
|
//删除
|
const delLayer = () => {
|
console.log(selectedObj.value);
|
console.log(treeRef.value.getNode(selectedObj.value));
|
treeRef.value.remove(treeRef.value.getNode(selectedObj.value));
|
// emits("delLayer", selectedNodeId.value);
|
};
|
//图层设置弹框
|
const layerSet = () => {};
|
//关闭状态
|
const editState = () => {
|
emits("SETstate", false);
|
};
|
const handlIsShow = (res: string) => {
|
menuOption.value.forEach((e) => {
|
if (e.name == res) {
|
e.isShow = !e.isShow;
|
}
|
});
|
};
|
//移动
|
const move = (type) => {
|
// let node = treeRef.value.getCurrentNode();
|
let node = treeRef.value.getNode(selectedObj.value);
|
let data = selectedObj.value;
|
// 将变动之前的node备份
|
let copyNode = { ...node };
|
copyNode.previousSibling = { ...node.previousSibling };
|
copyNode.nextSibling = { ...node.nextSibling };
|
// window.sessionStorage.setItem("menuNode", CircularJSON.stringify(copyNode));
|
|
if (type === 1) {
|
// 上移
|
if (node.previousSibling) {
|
// 删除原先的node
|
treeRef.value.remove(node.data);
|
// 拿到copy的node
|
// nodeData = CircularJSON.parse(window.sessionStorage.getItem("menuNode"));
|
// 复制该node到指定位置(参数:1. 要增加的节点的 data 2. 要增加的节点的后一个节点的 data、key 或者 node)
|
|
treeRef.value.insertBefore(copyNode.data, copyNode.previousSibling.data);
|
// window.sessionStorage.removeItem("menuNode");
|
} else {
|
return ElMessage.warning("该菜单已经是当前层最上级");
|
}
|
} else {
|
// 下移
|
if (node.nextSibling) {
|
treeRef.value.remove(node.data);
|
treeRef.value.insertAfter(copyNode.data, copyNode.nextSibling.data);
|
} else {
|
return ElMessage.warning("该菜单已经是当前层最下级");
|
}
|
}
|
emits("addlayer", { type: type, id: selectedObj.value.id });
|
};
|
optionsStart();
|
</script>
|
|
<style lang="less" scoped>
|
.edit {
|
width: 1227px;
|
display: flex;
|
position: absolute;
|
top: 60px;
|
left: 395px;
|
// top: 50%;
|
// left: 50%;
|
// transform: translateX(-50%);
|
// transform: translateY(-50%);
|
background: rgba(7, 8, 14, 0.8);
|
box-shadow: inset 0px 10px 40px 10px rgba(38, 47, 71, 1);
|
border: 1px solid #d6e4ff;
|
z-index: 10;
|
}
|
.edit_box {
|
width: 867px;
|
padding: 30px 0;
|
.edit_box_btn {
|
display: flex;
|
justify-content: center;
|
margin-bottom: 47px;
|
}
|
.edit_box_form {
|
padding: 0 116px;
|
/deep/ .el-form-item__label {
|
color: #fff;
|
}
|
}
|
}
|
.btnstyle {
|
.el-button {
|
height: 37px;
|
background: rgba(104, 156, 255, 0.2);
|
border: 1px solid #234066;
|
border-radius: 2px;
|
font-size: 16px;
|
font-weight: 400;
|
color: #ffffff;
|
}
|
.el-button:hover {
|
border: 1px solid #689cff;
|
}
|
.delbtn {
|
background: rgba(245, 108, 108, 0.2);
|
border: 1px solid #5a0914;
|
}
|
}
|
.layerBox {
|
width: 359px;
|
height: 615px;
|
background: rgba(7, 8, 14, 0.8);
|
// padding-bottom: 60px;
|
box-sizing: border-box;
|
.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: 24px;
|
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);
|
cursor: pointer;
|
}
|
}
|
.layerContent {
|
padding: 0 8px;
|
height: 92%;
|
overflow: 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);
|
}
|
.contentBox {
|
margin-top: 3px;
|
.content {
|
}
|
}
|
.contentTile {
|
width: 100%;
|
height: 42px;
|
background: #0d131d;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
|
.contentLeft {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
.contentImg {
|
width: 22px;
|
height: 22px;
|
background: url("../../assets/img/leftBtn/矩形 8 拷贝 3.png") no-repeat;
|
background-size: 100% 100%;
|
margin-left: 16px;
|
}
|
.contentLabel {
|
font-size: 20px;
|
font-family: Source Han Sans CN;
|
font-weight: 300;
|
color: #ffffff;
|
margin-left: 7px;
|
}
|
}
|
.contentRight {
|
margin-right: 32px;
|
display: flex;
|
align-items: center;
|
|
.contentUP {
|
width: 18px;
|
height: 11px;
|
background: url("../../assets/img/leftBtn/箭头-左 拷贝.png") no-repeat
|
center;
|
background-size: 100% 100%;
|
|
cursor: pointer;
|
}
|
.accordion {
|
transform: rotate(180deg);
|
}
|
.contentDown {
|
width: 18px;
|
height: 11px;
|
background: url("../../assets/img/leftBtn/箭头-左 拷贝 4.png");
|
}
|
}
|
}
|
.content {
|
background: #1e2a3d;
|
padding: 10px;
|
}
|
.layer_box {
|
padding: 4px;
|
margin-bottom: 4px;
|
color: #ffffff;
|
font-size: 18px;
|
font-weight: 400;
|
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;
|
.contentLeft {
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
.contentImg {
|
width: 22px;
|
height: 22px;
|
background: url("../../assets/img/leftBtn/矩形 8 拷贝 3.png") no-repeat;
|
background-size: 100% 100%;
|
margin-left: 16px;
|
}
|
.contentLabel {
|
font-size: 20px;
|
font-family: Source Han Sans CN;
|
font-weight: 300;
|
color: #ffffff;
|
margin-left: 7px;
|
}
|
}
|
}
|
}
|
|
.editBtn {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
padding-top: 36px;
|
.delbtn {
|
margin-left: 40px;
|
}
|
}
|
.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;
|
}
|
}
|
// .layerContent
|
// /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;
|
}
|
.serviceButton {
|
background: transparent !important;
|
color: #dcdfe6;
|
}
|
.serviceActive {
|
background: transparent !important;
|
color: #46a6ff;
|
border: 1px solid #46a6ff;
|
}
|
</style>
|