浏览代码

修改bug

zhangxc 5 年之前
父节点
当前提交
090be6a188
共有 4 个文件被更改,包括 71 次插入51 次删除
  1. 11 5
      src/js/graphMap.js
  2. 29 22
      src/js/index.js
  3. 27 22
      src/js/knowledgeTree.js
  4. 4 2
      src/js/schemaMap.js

+ 11 - 5
src/js/graphMap.js

@@ -4,19 +4,21 @@ const { post, api } = require('./api.js');
 
 //关系图
 function getGraph(val, type){
-    post(api.getGraph,{
+    return post(api.getGraph,{
         "inputStr": val,
         "labelName": type
     }).then(res=>{
         if(res.data.code == 0) {
-            select_type = select_type_noSearch
+            // select_type = select_type_noSearch
             $('#searchInp').val(val)
             drawGraph(res.data.data)
+            window.refreshTree = true
         }else{
             let nodeStr
             nodeStr = '<li class="ellipsis">暂无符合数据</li>'
             $(".tabNameList").html(nodeStr)
             $(".tabNameList").show()
+            window.refreshTree = false
         }
     })
 }
@@ -256,6 +258,7 @@ 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()
                     // showKnowledgeGraph(treeNode.name, 'graph', 0);
@@ -353,9 +356,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">')
+                }
+       
 }
 
 

+ 29 - 22
src/js/index.js

@@ -25,6 +25,7 @@ const { drawGraph,updateTree,getGraph,getTree,getNode } = require('./graphMap.js
 
 window.select_type="疾病";
 window.select_type_noSearch="疾病";
+window.refreshTree = true
  const clientHei = $(window).height()
  const contentHei = clientHei - 80
  $(".left").css("height",contentHei+'px')
@@ -96,29 +97,35 @@ $('#searchBtn').click(function(e){
         const clientHei = $(window).height()
         const contentHei = clientHei - 80
         $(".tabNameList").hide()
-        if(select_type_noSearch != select_type){
-            select_type = select_type_noSearch
-            
-            if(select_type == '疾病'){
-                $(".radioList").show()
-                $(".activeTab").removeClass("activeTab")
-                $(".diagnose").addClass("activeTab")
-                $(".ztree").css("height",contentHei-80-43-60-20+'px')
-                // $('#searchInp').val("高血压3级")
-                $('.iconRadio').attr('src','/images/radioUnSelect.png')
-                $('.ICD10 img').attr('src','/images/radioSelect.png')
-                getTree(1,1,val);
-            }else if(select_type == '药品通用名'){
-                $(".radioList").hide()
-                $(".ztree").css("height",contentHei-80-43-20+'px')
-                $(".activeTab").removeClass("activeTab")
-                $(".drug").addClass("activeTab")
-                getTree(0,2,val);
+        getGraph(val,select_type_noSearch).then(()=>{
+            if(!window.refreshTree){
+                return
             }
-        }else{
-            updateTree(val)
-        }
-        getGraph(val,select_type)
+            if(select_type_noSearch != select_type){
+                select_type = select_type_noSearch
+                
+                if(select_type == '疾病'){
+                    $(".radioList").show()
+                    $(".activeTab").removeClass("activeTab")
+                    $(".diagnose").addClass("activeTab")
+                    $(".ztree").css("height",contentHei-80-43-60-20+'px')
+                    // $('#searchInp').val("高血压3级")
+                    $('.iconRadio').attr('src','/images/radioUnSelect.png')
+                    $('.ICD10 img').attr('src','/images/radioSelect.png')
+                    getTree(1,1,val);
+                }else if(select_type == '药品通用名'){
+                    $(".radioList").hide()
+                    $(".ztree").css("height",contentHei-80-43-20+'px')
+                    $(".activeTab").removeClass("activeTab")
+                    $(".drug").addClass("activeTab")
+                    getTree(0,2,val);
+                }
+            }else{
+                updateTree(val)
+            }
+        })
+        
+   
        
     }else{
        $('.tabNameListNoSearch').show()

+ 27 - 22
src/js/knowledgeTree.js

@@ -23,6 +23,7 @@ const {getSchema,updateTree,getTree,getNode} = require('./schemaMap.js');
 
 window.select_type="疾病";
 window.select_type_noSearch="疾病";
+window.refreshTree = true
  const clientHei = $(window).height()
  const contentHei = clientHei - 80
  $(".left").css("height",contentHei+'px')
@@ -93,29 +94,33 @@ $('#searchBtn').click(function(e){
         const clientHei = $(window).height()
         const contentHei = clientHei - 80
         $(".tabNameList").hide()
-        if(select_type_noSearch != select_type){
-            select_type = select_type_noSearch
-            
-            if(select_type == '疾病'){
-                $(".radioList").show()
-                $(".activeTab").removeClass("activeTab")
-                $(".diagnose").addClass("activeTab")
-                $(".ztree").css("height",contentHei-80-43-60-20+'px')
-                // $('#searchInp').val("高血压3级")
-                $('.iconRadio').attr('src','/images/radioUnSelect.png')
-                $('.ICD10 img').attr('src','/images/radioSelect.png')
-                getTree(1,1,val);
-            }else if(select_type == '药品通用名'){
-                $(".radioList").hide()
-                $(".ztree").css("height",contentHei-80-43-20+'px')
-                $(".activeTab").removeClass("activeTab")
-                $(".drug").addClass("activeTab")
-                getTree(0,2,val);
+        getSchema(val,select_type_noSearch).then(()=>{
+            if(!window.refreshTree){
+                return
             }
-        }else{
-            updateTree(val)
-        }
-        getSchema(val,select_type)
+            if(select_type_noSearch != select_type){
+                select_type = select_type_noSearch
+                
+                if(select_type == '疾病'){
+                    $(".radioList").show()
+                    $(".activeTab").removeClass("activeTab")
+                    $(".diagnose").addClass("activeTab")
+                    $(".ztree").css("height",contentHei-80-43-60-20+'px')
+                    // $('#searchInp').val("高血压3级")
+                    $('.iconRadio').attr('src','/images/radioUnSelect.png')
+                    $('.ICD10 img').attr('src','/images/radioSelect.png')
+                    getTree(1,1,val);
+                }else if(select_type == '药品通用名'){
+                    $(".radioList").hide()
+                    $(".ztree").css("height",contentHei-80-43-20+'px')
+                    $(".activeTab").removeClass("activeTab")
+                    $(".drug").addClass("activeTab")
+                    getTree(0,2,val);
+                }
+            }else{
+                updateTree(val)
+            }
+        })
     }else{
        $('.tabNameListNoSearch').show()
     }

+ 4 - 2
src/js/schemaMap.js

@@ -179,24 +179,26 @@ function updateTree(keyWord, txt) {
 }
 
 function getSchema(val, type){
-    post(api.getSchema,{
+    return post(api.getSchema,{
         "labelName": type,
         "pramNme": val
     }).then(res=>{
         if(res.data.code == 0) {
             $('#searchInp').val(val)
             if(res.data.data.length >0){
-               
+                window.refreshTree = true
                 drawSchema(res.data.data)
 
             }else{
                 let nodeStr
+                window.refreshTree = false
                 nodeStr = '<li class="ellipsis">暂无符合数据</li>'
                 $(".tabNameList").html(nodeStr)
                 $(".tabNameList").show()
             }
         }else{
             let nodeStr
+            window.refreshTree = false
             nodeStr = '<li class="ellipsis">暂无符合数据</li>'
             $(".tabNameList").html(nodeStr)
             $(".tabNameList").show()