|
|
<!DOCTYPE html>
|
|
|
<html lang="zh-CN">
|
|
|
|
|
|
<head>
|
|
|
<meta charset="UTF-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
<title>图形管理</title>
|
|
|
<link rel="shortcut icon" href="#"/>
|
|
|
<link rel="stylesheet" href="zTree/css/zTreeStyle/zTreeStyle.css" type="text/css" />
|
|
|
<style>
|
|
|
html,
|
|
|
body {
|
|
|
color: #000000;
|
|
|
/* background-color: #0072C6; */
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
margin: 0;
|
|
|
}
|
|
|
|
|
|
.container {
|
|
|
display: flex;
|
|
|
height: 100%;
|
|
|
/* 确保container占满整个页面高度 */
|
|
|
position: relative;
|
|
|
/* 让子元素相对于container定位 */
|
|
|
}
|
|
|
|
|
|
#leftPanel {
|
|
|
width: 198px;
|
|
|
padding: 0px;
|
|
|
border: 1px solid #ccc;
|
|
|
overflow-y: auto;
|
|
|
/* 使treeList内部可滚动 */
|
|
|
}
|
|
|
|
|
|
.splitter {
|
|
|
top: 0;
|
|
|
/* left: 198px; 初始位置 */
|
|
|
width: 5px;
|
|
|
height: 100%;
|
|
|
background-color: #ccc;
|
|
|
cursor: ew-resize;
|
|
|
/* 横向拖动光标 */
|
|
|
z-index: 1;
|
|
|
/* 确保分割条在顶层 */
|
|
|
border: 1px solid #dfdede;
|
|
|
box-sizing: border-box;
|
|
|
flex-shrink: 0;
|
|
|
/* 使splitter不缩小 */
|
|
|
position: relative;
|
|
|
/* 让子元素相对于container定位 */
|
|
|
}
|
|
|
|
|
|
#webDrawerFrame {
|
|
|
flex-grow: 1;
|
|
|
/* 使iframe占据剩余空间 */
|
|
|
/* left: 201px; */
|
|
|
height: 100vh;
|
|
|
border: 1px solid #ccc;
|
|
|
box-sizing: border-box;
|
|
|
overflow: auto;
|
|
|
}
|
|
|
|
|
|
.layerButton {
|
|
|
margin-top: 1px;
|
|
|
margin-right: 0px;
|
|
|
margin-bottom: 1px;
|
|
|
margin-left: 0px;
|
|
|
|
|
|
background-size: 16px 16px;
|
|
|
background-repeat: no-repeat;
|
|
|
background-position: center;
|
|
|
width: 24px;
|
|
|
height: 24px;
|
|
|
border: none;
|
|
|
padding: 0px;
|
|
|
display: inline-flex;
|
|
|
|
|
|
color: black;
|
|
|
background-color: transparent;
|
|
|
border: 0px solid black;
|
|
|
border-radius: 3px;
|
|
|
transition: all 0.3s ease;
|
|
|
cursor: pointer;
|
|
|
|
|
|
flex: 0 0 auto;
|
|
|
}
|
|
|
|
|
|
.layerButton:hover {
|
|
|
color: blue;
|
|
|
border-color: black;
|
|
|
background-color: #c8d7c8;
|
|
|
}
|
|
|
|
|
|
.layerButton:after {
|
|
|
background: #90EE90;
|
|
|
opacity: 0;
|
|
|
transition: all 0.8s
|
|
|
}
|
|
|
|
|
|
.layerButton:active:after {
|
|
|
opacity: 1;
|
|
|
transition: 0s
|
|
|
}
|
|
|
</style>
|
|
|
<script src="zTree/js/jquery.min.js"></script>
|
|
|
<script src="zTree/js/jquery.ztree.core-3.5.js"></script>
|
|
|
<script src="zTree/js/jquery.ztree.excheck-3.5.js"></script>
|
|
|
<script src="zTree/js/jquery.ztree.exedit-3.5.js"></script>
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
<div class="container">
|
|
|
<div id="leftPanel" class="leftDiv" style="flex-direction: column;">
|
|
|
<div
|
|
|
style=" border: 1px solid #f8f9fa; border-top: 0; border-left: 0; border-right:0; box-sizing: border-box;vertical-align:middle; display: flex; flex-direction: row;">
|
|
|
<button class="layerButton" style="background-image: url('img/allcheck.svg');"
|
|
|
title="可编辑"></button><button class="layerButton"
|
|
|
style="background-image: url('img/tianjiatongjituceng4.svg');" title="只读"></button><button
|
|
|
class="layerButton" style="background-image: url('img/tianjiazituceng1.svg');" title="隐藏"></button>
|
|
|
<div class="barSeparator"></div><button class="layerButton"
|
|
|
style="background-image: url('img/Action_Delete.svg');" title="删除"></button>
|
|
|
</div>
|
|
|
<div id="treeList">
|
|
|
<ul id="mapTree" class="ztree" style="padding-left: 0;"></ul>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="splitter"></div>
|
|
|
<iframe id="webDrawerFrame" src="WebDrawer.htm"></iframe>
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
var globalToken = generateGUID();
|
|
|
// document.getElementById('item1').addEventListener('click', () => {
|
|
|
// sendMessageToWebDrawer('item1');
|
|
|
// });
|
|
|
|
|
|
// document.getElementById('item2').addEventListener('click', () => {
|
|
|
// sendMessageToWebDrawer('item2');
|
|
|
// });
|
|
|
|
|
|
// document.getElementById('toggleButton').addEventListener('click', () => {
|
|
|
// sendMessageToWebDrawer('toggle');
|
|
|
// });
|
|
|
|
|
|
function sendMessageToWebDrawer(message) {
|
|
|
const iframe = document.getElementById('webDrawerFrame');
|
|
|
if (iframe.contentWindow) {
|
|
|
iframe.contentWindow.postMessage(message, '*');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
function filter(node) {
|
|
|
return (node.file != null && node.file.length > 0);
|
|
|
};
|
|
|
function generateGUID() {
|
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
|
const r = Math.random() * 16 | 0;
|
|
|
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
|
return v.toString(16);
|
|
|
});
|
|
|
};
|
|
|
// Listen for messages from the iframe (optional)
|
|
|
window.addEventListener('message', (event) => {
|
|
|
const data = event.data;
|
|
|
console.log('服务已连接:'+data.action);
|
|
|
if (data.action === 'webSocketOpened') {
|
|
|
// 进行操作
|
|
|
var zTree = $.fn.zTree.getZTreeObj("mapTree");
|
|
|
var node = zTree.getNodesByFilter(filter, true); // 仅查找一个节点
|
|
|
const message = { action: 'openFile', fileUrl: node.file, token: globalToken };
|
|
|
sendMessageToWebDrawer(message);
|
|
|
}
|
|
|
});
|
|
|
// 拖动分割条
|
|
|
document.querySelector('.splitter').addEventListener('mousedown', startDrag);
|
|
|
|
|
|
let isDragging = false;
|
|
|
let startX;
|
|
|
|
|
|
function startDrag(e) {
|
|
|
isDragging = true;
|
|
|
startX = e.clientX;
|
|
|
document.addEventListener('mousemove', drag);
|
|
|
document.addEventListener('mouseup', endDrag);
|
|
|
}
|
|
|
|
|
|
function drag(e) {
|
|
|
if (!isDragging) return;
|
|
|
const containerRect = document.querySelector('.container').getBoundingClientRect();
|
|
|
const newTreeListWidth = e.clientX - containerRect.left;
|
|
|
const minTreeListWidth = 100; // 最小宽度,防止过小
|
|
|
const maxTreeListWidth = containerRect.width - 100; // 最大宽度,防止iframe过小
|
|
|
|
|
|
if (newTreeListWidth > minTreeListWidth && newTreeListWidth < maxTreeListWidth) {
|
|
|
leftPanel.style.width = newTreeListWidth + 'px';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function endDrag() {
|
|
|
isDragging = false;
|
|
|
document.removeEventListener('mousemove', drag);
|
|
|
document.removeEventListener('mouseup', endDrag);
|
|
|
}
|
|
|
// 分割条处理结束
|
|
|
</script>
|
|
|
<SCRIPT type="text/javascript">
|
|
|
var setting = {
|
|
|
check: {
|
|
|
enable: true,
|
|
|
nocheckInherit: true
|
|
|
},
|
|
|
data: {
|
|
|
simpleData: {
|
|
|
enable: true
|
|
|
}
|
|
|
},
|
|
|
callback: {
|
|
|
// beforeClick: beforeClick,
|
|
|
// onClick: onClick
|
|
|
onDblClick: zTreeOnDblClick,
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var zNodes = [
|
|
|
{ id: 1, pId: 0, name: "构造图", open: true },
|
|
|
{ id: 11, pId: 1, name: "K1构造图", file: "构造图/K1.dfd" },
|
|
|
{ id: 12, pId: 1, name: "K2构造图", file: "构造图/K2.dfd" },
|
|
|
{ id: 13, pId: 1, name: "220250121154132", file: "构造图/220250121154132.dfd" },
|
|
|
|
|
|
{ id: 2, pId: 0, name: "厚度图", checked: true, open: true },
|
|
|
{ id: 21, pId: 2, name: "孔隙度图", open: true },
|
|
|
{ id: 211, pId: 21, name: "K1孔隙度", checked: true, file: "孔隙度/K1_2024_07_31_10_19_56.kev" },
|
|
|
{ id: 212, pId: 21, name: "K2孔隙度", file: "孔隙度/K2_2024_07_31_10_19_56.kev" },
|
|
|
{ id: 22, pId: 2, name: "渗透率图" },
|
|
|
{ id: 221, pId: 22, name: "K1渗透率", file: "渗透率/K1_2024_07_31_10_20_00.kev" },
|
|
|
{ id: 222, pId: 22, name: "K2渗透率", file: "渗透率/K2_2024_07_31_10_20_00.kev" },
|
|
|
];
|
|
|
function zTreeOnDblClick(event, treeId, treeNode) {
|
|
|
// alert(treeNode ? treeNode.tId + ", " + treeNode.name : "isRoot");
|
|
|
if (treeNode) {
|
|
|
let file = treeNode.file;
|
|
|
if (file) {
|
|
|
const message = { action: 'openFile', fileUrl: file, token: globalToken};
|
|
|
sendMessageToWebDrawer(message);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
function nocheckNode(e) {
|
|
|
var zTree = $.fn.zTree.getZTreeObj("mapTree"),
|
|
|
nocheck = e.data.nocheck,
|
|
|
nodes = zTree.getSelectedNodes();
|
|
|
if (nodes.length == 0) {
|
|
|
alert("请先选择一个节点");
|
|
|
}
|
|
|
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
|
|
nodes[i].nocheck = nocheck;
|
|
|
zTree.updateNode(nodes[i]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
$.fn.zTree.init($("#mapTree"), setting, zNodes);
|
|
|
// $("#nocheckTrue").bind("click", {nocheck: true}, nocheckNode);
|
|
|
// $("#nocheckFalse").bind("click", {nocheck: false}, nocheckNode);
|
|
|
});
|
|
|
</SCRIPT>
|
|
|
</body>
|
|
|
|
|
|
</html> |