Pārlūkot izejas kodu

修改树形图

zhangxc 5 gadi atpakaļ
vecāks
revīzija
295be3bf0c
4 mainītis faili ar 321 papildinājumiem un 117 dzēšanām
  1. 177 81
      src/css/knowledgeTree.less
  2. 44 21
      src/html/knowledgeTree.html
  3. 0 1
      src/js/graphMap.js
  4. 100 14
      src/js/knowledgeTree.js

+ 177 - 81
src/css/knowledgeTree.less

@@ -19,99 +19,195 @@
         top: 3px;
         height: 20px;
     }
-    .tipsInfo{
-        margin: 0 0 20px 0;
-        cursor: default;
-    }
-    .tips{
-        color: #777;
-        font-size: 12px;
-        line-height: 18px;
-    }
     .content{
-        background: #fff;
         position: relative;
-        width: 1160px;
-        padding: 20px;
+        width: 1200px;
         left: 50%;
         margin-left: -600px;
         cursor: default;
         height: 100%;
-        .searchTxt{
-            min-height: 33px;
-            width: 1140px;
-            font-size: 14px;
-            color: #333;
-            resize: none;
-            // outline: none;
-            padding: 10px;
-            background: #F7F8FA;
-            border: none;
-            box-sizing: border-box;
-        }
-        .searchTxt:focus{
-            border: 1px solid #58a6e7;
-            outline: 0;
-            -webkit-box-shadow:#58a6e7 0px 0px 2px;
-            -moz-box-shadow: #58a6e7 0px 0px 2px;
-            box-shadow: #58a6e7 0px 0px 2px;
-        }
-        input::-webkit-input-placeholder{
-            color: #ccc;
-        }
-            
-    input:-moz-placeholder,textarea:-moz-placeholder{
-            color: #ccc;
-        }
-    input::-moz-placeholder,textarea::-moz-placeholder{
-            color: #ccc;
-        }
-    input:-ms-input-placeholder,textarea:-ms-input-placeholder{
-            color: #ccc;
-        }
-        .btnBox{
-            height: 60px;
-            text-align: center;
-        }
-        .sumbit{
-            padding: 8px 36px;
-            background: #5A8EEE;
-            color: #fff;
+    }
+    .left{
+        float: left;
+        background: #fff;
+        height: 100%;
+        margin: 10px 0 0 0;
+    }
+    .right{
+        // background: #fff;
+        width: 394px;
+        float: right;
+        height: 100%;
+        margin: 10px 0 0 0;
+        .top{
             position: relative;
-            border-radius: 4px;
-            top: 20px;
+            width:394px;
+            height:80px;
+            background:#FFFFFF;
+            border-radius:2px;
+            margin: 0 0 10px 0;
             font-size: 14px;
-            cursor: pointer;
-        }
-        .mainBox{
-            position: relative;
-        }
-        .empty{
-            position: absolute;
-            width: 216px;
-            height: 140px;
-            top: 50%;
-            left: 50%;
-            margin: -70px 0 0 -108px;
-            display: none;
-            .emptyImg{
-                width: 216px;
+            .select{
+                display: inline-block;
+                width:92px;
+                height:40px;
+                background:#E2ECFF;
+                border-radius:4px;
+                margin: 20px 10px  10px;
+                .selectedName{
+                    display: inline-block;
+                    width: 92px;
+                    height: 40px;
+                    text-align: center;
+                    line-height: 40px;
+                    color: #5A8EEE;
+                    position: relative;
+                }
+                .iconSlide{
+                    width: 7px;
+                    position: relative;
+                    top: -3px;
+                }
+                .selectList{
+                    position: absolute;
+                    display: none;
+                    width:90px;
+                    line-height: 30px;
+                    text-align: center;
+                    background: #fff;
+                    color: #333;
+                    border: 1px solid #e6e6e6;
+                    z-index: 2;
+                }
+                .selectItem:hover{
+                    background: #abcdef;
+                }
             }
-            .emptyTxt{
-                width: 216px;
-                font-size:12px;
-                margin: 40px 0 0 0;
-                text-align: center;
-                color: #ccc;
+            .search{
+                position: absolute;
+                display: inline-block;
+                width:272px;
+                top: 20px;
+                left: 112px;
+                input{
+                    width:192px;
+                    padding: 0 10px;
+                    height:40px;
+                    border:1px solid rgba(230,230,230,1);
+                    border-radius: 4px 0 0 4px;
+                    box-sizing: border-box;
+                    outline: none;
+                    color: #333;
+                    font-size: 14px;
+                    
+                }
+                input:focus{
+                    border: 1px solid #58a6e7;
+                    outline: 0;
+                    -webkit-box-shadow:#58a6e7 0px 0px 2px;
+                    -moz-box-shadow: #58a6e7 0px 0px 2px;
+                    box-shadow: #58a6e7 0px 0px 2px;
+                }
+                input::-ms-clear{display:none;}
+                input::-webkit-input-placeholder{
+                    color: #ccc;
+                }
+                    
+            input:-moz-placeholder,textarea:-moz-placeholder{
+                    color: #ccc;
+                }
+            input::-moz-placeholder,textarea::-moz-placeholder{
+                    color: #ccc;
+                }
+            input:-ms-input-placeholder,textarea:-ms-input-placeholder{
+                    color: #ccc;
+                }
+                .searchBtn{
+                    position: absolute;
+                    cursor: pointer;
+                    display: inline-block;
+                    width:60px;
+                    height:40px;
+                    text-align: center;
+                    line-height: 40px;
+                    background:#5A8EEE;
+                    border-radius:0px 4px 4px 0px;
+                    color: #fff;
+                }
+                .tabNameList,.tabNameListNoSearch{
+                    position: relative;
+                    top: 5px;
+                    display: none;
+                    width:192px;
+                    max-height:200px;
+                    background: #fff;
+                    border:1px solid rgba(230,230,230,1);
+                    border-radius: 4px 0 0 4px;
+                    box-sizing: border-box;
+                    overflow-y: auto;
+                    z-index:2;
+                    li{
+                        height: 40px;
+                        line-height: 40px;
+                        padding: 0 10px;
+                        color: #333;
+                    }
+                    li:hover{
+                        background: #E2ECFF;
+                    }
+                    .nodeItem{
+                        cursor: pointer;
+                    }
+                }
             }
         }
-        .mainWrapper{
-            border: 1px solid #E6E6E6;
-            cursor: pointer;
+        .bottom{
+            background: #fff;
+            padding: 0 10px;
+            .tabList{
+                width: 100%;
+                height: 43px;
+                box-sizing: border-box;
+                border-bottom: 1px solid #E6E6E6;
+                .tab{
+                    display: inline-block;
+                    height: 42px;
+                    line-height: 42px;
+                    padding: 0 20px 0 10px;
+                    font-size: 12px;
+                    color: #777;
+                }
+                .activeTab{
+                    font-size: 16px;
+                    color: #5A8EEE;
+                    font-weight: bold;
+                    border-bottom: 3px solid #5A8EEE;
+                    box-sizing: border-box;
+                }
+            }
+            .radioList{
+                height: 60px;
+                line-height: 60px;
+            }
+            .radioItem{
+                font-size: 14px;
+                color: #333;
+                line-height: 16px;
+            }
+            .iconRadio{
+                width: 14px;
+                position: relative;
+                top: 2px;
+            }
+            .iconSelect{
+                width: 16px;
+                top: 0px;
+                position: relative;
+            }
         }
     }
-    .disabled{
-        opacity: 0.5;
+   
+    .ztree{
+        overflow: auto;
     }
-    
 }

+ 44 - 21
src/html/knowledgeTree.html

@@ -5,34 +5,57 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title><%= htmlWebpackPlugin.options.title %></title>
+  <!-- <link rel="stylesheet" href="./../resources/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css"> -->
+	<!-- <script type="text/javascript" src="./../resources/zTree/js/jquery.ztree.core.min.js"></script> -->
 </head>
+
 <body>
   <div class="knowledgeTreeWrapper">
-    <div class="title">
-     
-      <div class="titleTxt"><img class="titleLogo" src="./images/logo.png" alt="logo">&nbsp;&nbsp;|&nbsp;&nbsp; 描述框架</div>
-    </div>
-    <div class="content">
-      <div class="tipsInfo">
-        <p class="tips">提示说明:输入疾病名称,展示其 schema 描述体系。</p>
-        <p  class="tips">输入示例:支气管肺炎 </p>
+      <div class="title">
+        <div class="titleTxt"><img class="titleLogo" src="./images/logo.png" alt="logo">&nbsp;&nbsp;|&nbsp;&nbsp;  医学知识图谱</div>
       </div>
-      <textarea class="searchTxt" id="searchTxt" placeholder="请输入" autocomplete="off" rows="5"></textarea>
-      <div class="btnBox"><span class="sumbit">提交</span></div>
-      <div class="mainBox">
-        <div id="main" class="mainWrapper" style="width: 1160px;height:600px;">
-          
-        </div>
-        <div class="empty">
-          <img class="emptyImg" src="./images/empty.png" alt="您提交的信息暂未收录">
-          <p class="emptyTxt">您提交的信息暂未收录!</p>
+      <div class="content clearfix">
+        <div class="left">
+          <div id="main" class="mapWrapper" style="width: 796px;height:600px;cursor: pointer;"></div>
         </div>
+        <div class="right">
+          <div class="top">
+            <div class="select">
+              <span class="selectedName">疾病</span>
+              <!-- <img class="iconSlide" src="./images/iconSlideDown.png" alt="iconSlide"> -->
+              <!-- <ul class="selectList">
+                <li class="selectItem" data-id="diagnose">疾病</li>
+                <li class="selectItem">药物</li>
+                <li class="selectItem">症状</li>
+                <li class="selectItem">诊疗</li>
+              </ul> -->
+            </div>
+            <div class="search">
+                <input type="text" id="searchInp" placeholder="搜索疾病名称" name="" autocomplete="off" ><span class="searchBtn" id="searchBtn">搜索</span>
+                <ul class="tabNameList"></ul>
+                <ul class="tabNameListNoSearch"><li class="ellipsis">请输入内容</li></ul>
+            </div>
+          </div>
+          <div class="bottom">
+             <div class="tabList" id="tabList">
+                <span class="tab activeTab" data-id="diagnose">疾病</span>
+                <!-- <span  class="tab">药物</span>
+                <span  class="tab">症状</span>
+                <span  class="tab">诊疗</span> -->
+             </div>
+             <div class="radioList">
+                <span class="radioItem">  
+                    <img class="iconRadio" src="/images/radioSelect.png" alt="iconRadio">
+                    ICD10
+                </span>
+             </div>
+             <div id="tree" class="ztree"></div>
+
+          </div>
+        </div>  
       </div>
-      
-    </div>
- 
   </div>
-  
+
 </body>
 
 </html>

+ 0 - 1
src/js/graphMap.js

@@ -305,7 +305,6 @@ function updateTree(keyWord, txt) {
                 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">')
 }
 

+ 100 - 14
src/js/knowledgeTree.js

@@ -1,31 +1,117 @@
+const $ = require("jquery");
 require("babel-polyfill");
+const echarts = require("echarts");
 require("./../css/knowledgeTree.less");
 require("./../css/common.css");
+// require("ztree");
+require('./../resources/images/icon.png');
+require('./../resources/images/iconOpen.png');
+require('./../resources/images/iconClose.png');
+require('./../resources/images/node.png');
+require('./../resources/images/radioUnSelect.png');
+require('./../resources/images/radioSelect.png');
+require('./../resources/images/iconSlideUp.png');
+require('./../resources/images/iconSlideDown.png');
+require('./../resources/images/iconSelect.png');
 require('./../resources/images/logo.png');
-require('./../resources/images/empty.png');
-const $ = require("jquery");
-const echarts = require('echarts');
-const { getSchema } = require('./schemaMap.js');
+require('./../resources/zTree/js/jquery.ztree.core.min.js');
+require('./../resources/zTree/js/jquery.ztree.excheck.min.js')
+require('./../resources/zTree/css/zTreeStyle/zTreeStyle.css');
+// document.write("aaaa");
+const { drawGraph,updateTree,getGraph,getTree,getNode } = require('./graphMap.js');
+
 
-$("#searchTxt").val("胆囊炎")
-getSchema('胆囊炎','diagnose')
+window.select_type="diagnose";
+window.select_type_noSearch="diagnose";
+ const clientHei = $(window).height()
+ const contentHei = clientHei - 80
+ $(".left").css("height",contentHei+'px')
+ $(".right").css("height",contentHei+'px')
+ $(".ztree").css("height",contentHei-80-43-60-20+'px')
+ $("#main").css("height",contentHei-20-20+'px')
+//关系图
+getGraph("急性冠脉综合征",select_type);
+getTree(1,1,"急性冠脉综合征");
+$('#searchInp').val("急性冠脉综合征")
+
+//选择类型
+$('.select').click(function(e){
+    e.stopPropagation();
+    const selectListShow = $('.selectList').css('display')
+    if(selectListShow == 'none'){
+        $('.iconSlide').attr('src','./images/iconSlideUp.png')
+    } else{
+        $('.iconSlide').attr('src','./images/iconSlideDown.png')
+    }
+    $('.selectList').fadeToggle()
+   
+})
+$('.selectList .selectItem').click(function(){
+    select_type_noSearch = $(this).attr('data-id')
+    const txt =  $(this).text()
+    $(".selectedName").html(txt)
+})
 
 //搜索节点名
-$("#searchTxt").bind("input propertychange",function(event){
-    const val = $("#searchTxt").val().trim()
-    if(!val){
-        $('.sumbit').addClass('disabled')
+$("#searchInp").bind("input propertychange",function(event){
+    const val = $("#searchInp").val().trim()
+    if(val){
+        getNode(val,select_type_noSearch)
     }else{
-        $('.sumbit').removeClass('disabled')
+        $(".tabNameList").hide()
     }
 });
-$(".sumbit").click(function(){
-    const val = $("#searchTxt").val().trim()
+
+
+//搜索
+$('#searchBtn').click(function(e){
+    e.stopPropagation()
+    const val = $('#searchInp').val()
     if(val){
-        getSchema(val,'diagnose')
+        getGraph(val,'diagnose')
+        updateTree(val)
+    }else{
+       $('.tabNameListNoSearch').show()
     }
 })
 
+//切换tab
+$('.tabList .tab').click(function(){
+    const id = $(this).attr('data-id')
+    $(this).addClass("activeTab").siblings().removeClass('activeTab')
+    if(id != select_type){
+        if(id != "diagnose"){
+            $(".radioList").hide()
+        }else{
+            $(".radioList").show()
+        }
+        select_type = id
+        // getTree(1,1,"");  //切换tab重新画菜单树
+    }
+})
+
+//点击页面其他地方关闭下拉
+$('html').click(function(){
+    const selectListShow = $('.selectList').css('display')
+    const tabNameListShow = $('.tabNameList').css('display')
+    const tabNameListNoSearchShow = $('.tabNameListNoSearch').css('display')
+
+    if(selectListShow == 'block'){
+        $('.selectList').hide()
+        $('.iconSlide').attr('src','./images/iconSlideDown.png')
+    }
+    if(tabNameListShow == 'block'){
+        $('.tabNameList').hide()
+    }
+    if(tabNameListNoSearchShow == 'block'){
+        $('.tabNameListNoSearch').hide()
+    }
+})
+		
+		
+	
+
+