anxiao_web/pages/hikVideo/js/tree.js

148 lines
4.7 KiB
JavaScript
Raw Normal View History

2024-07-24 09:22:32 +08:00
import { hkIpcList } from "./index.js"
import { getAloneVideoData } from "./rightPage.js";
var treeData=[];
function showTree(){
for(var i=0;i<hkIpcList.length;i++){
setDeviceMenu(hkIpcList[i]);
}
console.log(treeData);
setParameterTree(treeData);//画出节点
}
function setDeviceMenu(deviceData){
var borough=deviceData["borough"]
var detachment=deviceData["detachment"]
var station=deviceData["station"]
var name=deviceData["cameraName"]
var deviceid=deviceData["cameraIndexCode"];
for(var iRoot=0;iRoot<treeData.length;iRoot++){
var oneNodeName=treeData[iRoot]["text"];
if(oneNodeName == borough){
var brigadeChildren=treeData[iRoot]["children"];
for(var boroughNode=0;boroughNode<brigadeChildren.length;boroughNode++){
var twoNodeName=brigadeChildren[boroughNode]["text"];
if(twoNodeName==detachment){
var boroughChildren=brigadeChildren[boroughNode]["children"];
for(var detachmentNode=0;detachmentNode<boroughChildren.length;detachmentNode++){
var threeNodeName=boroughChildren[detachmentNode]["text"]
if(threeNodeName==station){
boroughChildren[detachmentNode]["children"].push(
{
"id":4,
"text":name,
"iconCls":"icon_detachment",
"deviceid":deviceid
}
)
return;
}
}
brigadeChildren[boroughNode]["children"].push(
{
"id":3,
"text":station,
"iconCls":"icon_detachment",
"children":[
{
"id":4,
"text":name,
"iconCls":"icon_detachment",
"deviceid":deviceid
}
]
}
)
return;
}
}
treeData[iRoot]["children"].push({
"id":2,
"text":detachment,
"iconCls":"icon_borough",
"children":[
{
"id":3,
"text":station,
"iconCls":"icon_detachment",
"children":[
{
"id":4,
"text":name,
"iconCls":"icon_detachment",
"deviceid":deviceid
}
]
}
]
})
return;
}
}
var stationObj={
"id":1,
"text":borough,
"iconCls":"icon_brigade",
"children":[
{
"id":2,
"text":detachment,
"iconCls":"icon_borough",
"children":[
{
"id":3,
"text":station,
"iconCls":"icon_detachment",
"children":[
{
"id":4,
"text":name,
"iconCls":"icon_detachment",
"deviceid":deviceid
}
]
}
]
}
]
}
treeData.push(stationObj);
return;
}
function setParameterTree(treeData){
$('.easyui-tree').tree({
data:treeData,
formatter:function(node){
var s = "";
if (node.children){
s += "<span>"+node.text+"</span>"
+'<span></span>'
}else{
s +=`<span deviceid='${node.deviceid}'>${node.text}</span>`
}
return s;
},
animate:true,
onClick:function(node){
var id=node["id"];
if(id==4){
var deviceid=node["deviceid"];
var name=node["text"];
getAloneVideoData(deviceid,name)
}
}
})
}
export {showTree}