zhangxc 5 éve
szülő
commit
af821bc743
4 módosított fájl, 240 hozzáadás és 61 törlés
  1. 36 4
      src/css/knowledgeTree.less
  2. 20 7
      src/html/knowledgeTree.html
  3. 35 49
      src/js/knowledgeTree.js
  4. 149 1
      src/js/schemaMap.js

+ 36 - 4
src/css/knowledgeTree.less

@@ -85,9 +85,9 @@
                     position: relative;
                 }
                 .iconSlide{
-                    width: 7px;
+                    width: 16px;
                     position: absolute ;
-                    top: 18px;
+                    top: 16px;
                     right: 10px;
                 }
                 .selectList{
@@ -191,15 +191,22 @@
                 height: 43px;
                 box-sizing: border-box;
                 border-bottom: 1px solid #E6E6E6;
+                position: relative;
+                .tabBox{
+                    padding: 0 20px 0 10px;
+                }
                 .tab{
                     display: inline-block;
                     height: 42px;
                     line-height: 42px;
-                    padding: 0 20px 0 10px;
-                    font-size: 12px;
+                    margin: 0 20px 0 10px;
+                    font-size: 14px;
                     color: #777;
                     cursor: pointer;
                 }
+                .tab:hover{
+                    color: #5A8EEE;
+                }
                 .activeTab{
                     font-size: 16px;
                     color: #5A8EEE;
@@ -208,6 +215,31 @@
                     box-sizing: border-box;
                 }
             }
+            .showTabList{
+                margin-right: 66px;
+            }
+            .toggleArrow{
+                width: 11px;
+            }
+            .toggleTab{
+                display: inline-block;
+                position: absolute;
+                font-size: 14px ;
+                color: #AAA;
+                line-height: 44px;
+                right: 0;
+                top: 0;
+                width: 66px;
+                cursor: pointer;
+            }
+            .hideTabList{
+                position: absolute;
+                background: #fff;
+                margin-right: 18px;
+                z-index: 2;
+                display: none;
+                top: 43px;
+            }
             .radioList{
                 height: 60px;
                 line-height: 60px;

+ 20 - 7
src/html/knowledgeTree.html

@@ -34,8 +34,10 @@
               <ul class="selectList">
                 <li class="selectItem" data-id="疾病">疾病</li>
                 <li class="selectItem" data-id="药品通用名">药品</li>
-                <!-- <li class="selectItem">症状</li>
-                <li class="selectItem">诊疗</li> -->
+                <li class="selectItem" title="症状" data-id="症状">症状</li>
+                <li class="selectItem" title="手术和操作" data-id="手术和操作">手术和操作</li>
+                <li class="selectItem" title="实验室检查" data-id="实验室检查">实验室检查</li>
+                <li class="selectItem" title="辅助检查" data-id="辅助检查">辅助检查</li>
               </ul>
             </div>
             <div class="search">
@@ -46,11 +48,22 @@
           </div>
           <div class="bottom">
              <div class="tabList" id="tabList">
-                <span class="tab diagnose activeTab" data-id="疾病">疾病</span>
-                <span  class="tab drug" data-id="药品通用名">药品</span>
-                <!-- <span  class="tab">症状</span>
-                <span  class="tab">诊疗</span> -->
-             </div>
+              <div class="showTabList">
+                <!-- <span class="tab diagnose activeTab" data-id="疾病">疾病</span>
+                <span  class="tab drug"  data-id="药品通用名">药品</span>
+                <span  class="tab symptom" data-id="症状">症状</span>
+                <span  class="tab operation"  data-id="手术和操作">手术和操作</span> -->
+              </div>
+              <div class="toggleTab">
+                <span class="toggleTabTxt">展开</span>
+                <img class="toggleArrow" src="./images/iconDown.png" alt="">
+              </div>
+              <div class="hideTabList">
+                <!-- <span  class="tab lab" data-id="实验室检查">实验室检查</span>
+                <span  class="tab examination"  data-id="辅助检查">辅助检查</span> -->
+              </div>
+            
+            </div>
              <div class="radioList">
               <span class="radioItem ICD10" data-type="1">
                 <img class="iconRadio" src="/images/radioSelect.png" alt="iconRadio">

+ 35 - 49
src/js/knowledgeTree.js

@@ -18,8 +18,10 @@ require('./../resources/images/logo.png');
 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');
+const iconUp = require('./../resources/images/iconUp.png');
+const iconDown = require('./../resources/images/iconDown.png');
 // document.write("aaaa");
-const {getSchema,updateTree,getTree,getNode} = require('./schemaMap.js');
+const {getSchema,updateTree,getTree,getNode,getTab,renderTab} = require('./schemaMap.js');
 
 window.select_type="疾病";
 window.select_type_noSearch="疾病";
@@ -53,11 +55,14 @@ $('.selectList .selectItem').click(function(){
     const txt =  $(this).text()
     const oldTxt = $(".selectedName").html()
     $(".selectedName").html(txt)
-    if(txt == '疾病'){
-        $("#searchInp").attr("placeholder","请输入疾病名称")
-    }else if(txt == '药品'){
-        $("#searchInp").attr("placeholder","请输入药品名称")
+    if(txt.length > 3){
+        $(".selectedName").html(txt.slice(0,2)+"...")
+    }else{
+        $(".selectedName").html(txt)
     }
+   
+    $(".selectedName").attr('title',txt)
+    $("#searchInp").attr("placeholder",`请输入${txt}名称`)
     if(txt != oldTxt){
         $('#searchInp').val("")
     }
@@ -102,21 +107,33 @@ $('#searchBtn').click(function(e){
                 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 if(select_type == '症状'){
+                    getTree(0,3,val);
+                }else if(select_type == '手术和操作'){
+                    getTree(0,4,val);
+                }else if(select_type == '实验室检查'){
+                    getTree(0,5,val);
+                }else if(select_type == '辅助检查'){
+                    getTree(0,6,val);
                 }
+                if(select_type == '疾病'){
+                    $('.iconRadio').attr('src','/images/radioUnSelect.png')
+                    $('.ICD10 img').attr('src','/images/radioSelect.png')
+                    $(".radioList").show()
+                    $(".ztree").css("height",contentHei-80-43-60-20+'px')
+                }else{
+                    $(".radioList").hide()
+                    $(".ztree").css("height",contentHei-80-43-20-20+'px')
+                    $(".ztree").css({
+                        margin: '20 0 0 0px'
+                    })
+                }
+                let renderTabInfo = getTab("疾病") 
+                renderTab(renderTabInfo)
             }else{
                 updateTree(val)
             }
@@ -125,42 +142,11 @@ $('#searchBtn').click(function(e){
        $('.tabNameListNoSearch').show()
     }
 })
+let renderTabInfo = getTab("疾病") 
+renderTab(renderTabInfo)
 
 //切换tab
-$('.tabList .tab').click(function(){
-    const id = $(this).attr('data-id')
-    $(this).addClass("activeTab").siblings().removeClass('activeTab')
-    if(id != select_type){
-        if(id != "疾病"){
-            $(".radioList").hide()
-        }else{
-            $(".radioList").show()
-        }
-        if(id == "疾病"){
-            select_type_noSearch = "疾病"
-            select_type = "疾病"
-            $('.selectedName').html(select_type)
-            $(".ztree").css("height",contentHei-80-43-60-20+'px')
-            $('#searchInp').val("胆囊炎")
-            $('.iconRadio').attr('src','/images/radioUnSelect.png')
-            $('.ICD10 img').attr('src','/images/radioSelect.png')
-            getTree(1,1,"胆囊炎");
-            getSchema("胆囊炎",select_type);
-        
-        }else if(id=="药品通用名"){
-            select_type_noSearch = id
-            select_type = id
-            $('.selectedName').html("药品")
-            $(".ztree").css("height",contentHei-80-43-20+'px')
-            $('#searchInp').val("丹参片")
-            getTree(0,2,"丹参片");
-            getSchema("丹参片",select_type);
-          
-        }
-        select_type = id
-        // getTree(1,1,"");  //切换tab重新画菜单树
-    }
-})
+
 
 //点击页面其他地方关闭下拉
 $('html').click(function(){

+ 149 - 1
src/js/schemaMap.js

@@ -1,5 +1,10 @@
 const echarts = require("echarts");
 const { post, api } = require('./api.js');
+const iconUp = require('./../resources/images/iconUp.png');
+const iconDown = require('./../resources/images/iconDown.png');
+
+const clientHei = $(window).height()
+const contentHei = clientHei - 80
 
 function getTree(subType, type,showNodeName){
     post(api.getTree,
@@ -308,9 +313,152 @@ function getSchema(val, type){
     myChart.setOption(option);
  }
 
+
+ function getTab(tabName){
+    console.log('tabName', tabName)
+    let tabList = ["疾病","药品通用名","症状","手术和操作","实验室检查","辅助检查","辅助检查1","辅助检查2","辅助检查3","辅助检查4"]
+    let tabListCopy = tabList.slice()
+    const index = tabList.findIndex(item => item == tabName)
+  
+    if(index <= 3){
+        return {
+            activeIndex: index,
+            showTabList:tabListCopy.slice(0,4),
+            hideTabList:tabListCopy.slice(4)
+        }
+    }else{
+        tabListCopy.splice(index,1)
+        let hideTabList = tabListCopy.slice(3)
+        
+        return {
+            activeIndex: 3,
+            showTabList:tabListCopy.slice(0,3).concat(tabName),
+            hideTabList:hideTabList
+        }
+    }
+}
+
+function renderTab(data){
+    const showList = data.showTabList
+    const hideList = data.hideTabList
+    const activeIndex = data.activeIndex
+    let showtabStr = ``
+    let hidetabStr = ``
+    for(let i = 0; i < showList.length; i++){
+        showtabStr +=`    <span class="tab ${i === activeIndex ? 'activeTab':''}" data-id="${showList[i]}">${showList[i] =="药品通用名" ?"药品":showList[i]}</span>`
+        if(i === activeIndex){
+            if(showList[i] =="药品通用名"){
+                $("#searchInp").attr("placeholder",`请输入药品名称`)
+            }else{
+                $("#searchInp").attr("placeholder",`请输入${showList[i]}名称`)
+            }
+        }
+        
+    }
+    for(let i = 0; i < hideList.length; i++){
+        hidetabStr +=`<span class="tab " data-id="${hideList[i]}">${hideList[i]}</span>`
+    }
+    // console.log('showtabStr',showtabStr)
+    
+    $('.showTabList').html(showtabStr)
+    $('.hideTabList').html(hidetabStr)
+    bindTabClick()
+}
+ToggleTab()
+function ToggleTab(){
+    $(".toggleTab").click(function(){
+        const hideTabDis = $(".hideTabList").css("display")
+        if(hideTabDis == "none"){
+            showHideTab()
+        }else{
+            hideHideTab()
+        }
+    })
+}
+function showHideTab(){
+    $(".hideTabList").slideDown()
+    
+    $(".toggleTabTxt").html("收起")
+    $(".toggleArrow").attr("src",iconUp)
+}
+function hideHideTab(){
+    $(".hideTabList").slideUp()
+    $(".toggleTabTxt").html("展开")
+    $(".toggleArrow").attr("src",iconDown)
+}
+bindTabClick()
+//切换tab
+function bindTabClick(){
+    $('.tabList .tab').click(function(){
+        const id = $(this).attr('data-id')
+        $(this).addClass("activeTab").siblings().removeClass('activeTab')
+        let renderInfo = getTab(id) 
+        renderTab(renderInfo)
+        if(id != select_type){
+            if(id != "疾病"){
+                $(".radioList").hide()
+                $(".ztree").css("height",contentHei-80-43-20+'px')
+            }else{
+                $(".ztree").css("height",contentHei-80-43-60-20+'px')
+                $(".radioList").show()
+            }
+            select_type_noSearch = id
+            select_type = id
+            if(id=="药品通用名"){
+                $('.selectedName').html("药品")
+            }else{
+                $('.selectedName').attr('title', select_type)
+                if(select_type.length > 3){
+                    $('.selectedName').html(select_type.slice(0,2)+'...')
+                }else{
+                    $('.selectedName').html(select_type)
+                }
+               
+            }
+           
+            if(id == "疾病"){
+               
+                $('#searchInp').val("高血压3级")
+                $('.iconRadio').attr('src','/images/radioUnSelect.png')
+                $('.ICD10 img').attr('src','/images/radioSelect.png')
+                getTree(1,1,"胆囊炎");
+                getSchema("胆囊炎",select_type);
+            
+            
+            }else if(id=="药品通用名"){
+                $('#searchInp').val("氟康唑注射液")
+                getTree(0,2,"丹参片");
+                getSchema("丹参片",select_type);
+              
+            }else if(id == "症状"){
+                $('#searchInp').val("")
+                getTree(0,3,"");
+                getSchema("",select_type);
+            }else if(id == "手术和操作"){
+                $('#searchInp').val("")
+                getTree(0,4,"");
+                getSchema("",select_type);
+            }else if(id == "实验室检查"){
+                $('#searchInp').val("")
+                getTree(0,5,"");
+                getSchema("",select_type);
+            }else if(id == "辅助检查"){
+                $('#searchInp').val("")
+                getTree(0,6,"");
+                getSchema("",select_type);
+            }
+            // getTree(1,1,"");  //切换tab重新画菜单树
+        }
+       
+        hideHideTab()
+    })
+}
+
  module.exports ={
     getSchema,
     getTree,
     updateTree,
-    getNode
+    getNode,
+    getTab,
+    renderTab
  }