zhangxc 5 лет назад
Родитель
Сommit
3c05aad519
2 измененных файлов с 26 добавлено и 12 удалено
  1. 10 5
      src/js/graphMap.js
  2. 16 7
      src/js/schemaMap.js

+ 10 - 5
src/js/graphMap.js

@@ -236,8 +236,11 @@ function drawTree(data, showNodeName){
         callback:{
             onClick: function (treeId, treeNode) {
                 const selectPId = $('.curSelectedNode').attr('id')
-                const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
-                $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                if(selectPId){
+                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                    $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                }
+              
             },
             beforeClick: function (treeId, treeNode) {
                 var zTree = $.fn.zTree.getZTreeObj("tree");
@@ -258,9 +261,11 @@ function drawTree(data, showNodeName){
                     }
                     getGraph(name,select_type)
                     const selectPId = $('.curSelectedNode').attr('id')
-                  
-                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
-                    $('#'+selectId + ' .iconSelect').remove()
+                    if(selectPId){
+                        const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                        $('#'+selectId + ' .iconSelect').remove()
+                    }
+             
                     // showKnowledgeGraph(treeNode.name, 'graph', 0);
                     return true;
                 }

+ 16 - 7
src/js/schemaMap.js

@@ -53,8 +53,11 @@ function drawTree(data, showNodeName){
         callback:{
             onClick: function (treeId, treeNode) {
                 const selectPId = $('.curSelectedNode').attr('id')
-                const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
-                $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                if(selectPId){
+                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                    $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                }
+              
             },
             beforeClick: function (treeId, treeNode) {
                 var zTree = $.fn.zTree.getZTreeObj("tree");
@@ -75,8 +78,11 @@ function drawTree(data, showNodeName){
                     }
                     getSchema(name,select_type)
                     const selectPId = $('.curSelectedNode').attr('id')
-                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
-                    $('#'+selectId + ' .iconSelect').remove()
+                    if(selectPId){
+                        const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                        $('#'+selectId + ' .iconSelect').remove()
+                    }
+             
                     return true;
                 }
             }
@@ -173,9 +179,12 @@ function updateTree(keyWord, txt) {
         var zTree = $.fn.zTree.getZTreeObj("tree");
                 zTree.selectNode(zTree.getNodeByParam("name", keyWord));
                 const selectPId = $('.curSelectedNode').attr('id')
-                const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
-                $('.iconSelect').remove()
-                $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                if(selectPId){
+                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                    $('.iconSelect').remove()
+                    $('#'+selectId).append('<img class="iconSelect" src="./images/iconSelect.png">')
+                }
+                
 }
 
 function getSchema(val, type){