Explorar o código

增加tab类型

zhangxc %!s(int64=5) %!d(string=hai) anos
pai
achega
13f09eae72
Modificáronse 4 ficheiros con 295 adicións e 94 borrados
  1. 36 4
      src/css/knowledgeMap.less
  2. 21 12
      src/html/knowledgeGraph.html
  3. 199 28
      src/js/graphMap.js
  4. 39 50
      src/js/index.js

+ 36 - 4
src/css/knowledgeMap.less

@@ -82,9 +82,9 @@
                     position: relative;
                 }
                 .iconSlide{
-                    width: 7px;
+                    width: 16px;
                     position: absolute ;
-                    top: 18px;
+                    top: 16px;
                     right: 10px;
                 }
                 .selectList{
@@ -188,15 +188,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;
@@ -205,6 +212,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;

+ 21 - 12
src/html/knowledgeGraph.html

@@ -32,12 +32,12 @@
 						<span class="selectedName">疾病</span>
 						<img class="iconSlide" src="./images/iconSlideDown.png" alt="iconSlide">
 						<ul class="selectList">
-						<li class="selectItem" data-id="疾病">疾病</li>
-						<li class="selectItem" data-id="药品通用名">药品</li>
-						<li class="selectItem" data-id="症状">症状</li>
-						<li class="selectItem" data-id="手术和操作">手术和操作</li>
-						<li class="selectItem" data-id="实验室检查">实验室检查</li>
-						<li class="selectItem" data-id="辅助检查">辅助检查</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>
+						<li class="selectItem" title="实验室检查" data-id="实验室检查">实验室检查</li>
+						<li class="selectItem" title="辅助检查" data-id="辅助检查">辅助检查</li>
 					</ul>
 					</div>
 					<div class="search">
@@ -51,12 +51,21 @@
 				</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" data-id="症状">症状</span>
-						<span  class="tab"  data-id="手术和操作">手术和操作</span>
-						<span  class="tab" data-id="实验室检查">实验室检查</span>
-						<span  class="tab"  data-id="辅助检查">辅助检查</span>
+						<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="tabBottom">

+ 199 - 28
src/js/graphMap.js

@@ -1,6 +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 getGraph(val, type){
@@ -134,6 +138,7 @@ function drawGraph(data,resultShowId) {
 
 function dataClick(param){
     var data = param.data;
+    console.log('data',data)
     const clientHei = $(window).height()
     const contentHei = clientHei - 80
     // console.log('data', data,select_type)
@@ -150,31 +155,44 @@ function dataClick(param){
                 getGraph(data.label,select_type);
               
             }else {
-               
+                let renderTabInfo = getTab(data.type) 
+                renderTab(renderTabInfo) 
+                if(data.type == "药品通用名"){
+                    $('.selectedName').html("药品")
+                }else{
+                    $('.selectedName').html(select_type)
+                }
                 if(data.type == "疾病"){
                     $(".radioList").show()
-                    select_type_noSearch = data.type
-                    select_type = data.type
-                    $('.selectedName').html(select_type)
-                    $(".activeTab").removeClass("activeTab")
-                    $(".diagnose").addClass("activeTab")
                     $(".ztree").css("height",contentHei-80-43-60-20+'px')
-                    $('#searchInp').val(data.label)
                     $('.iconRadio').attr('src','/images/radioUnSelect.png')
                     $('.ICD10 img').attr('src','/images/radioSelect.png')
+                }else{
+                    $(".radioList").hide()
+                    $(".ztree").css("height",contentHei-80-43-20+'px')
+                }
+                select_type_noSearch = data.type
+                select_type = data.type
+                $('#searchInp').val(data.label)
+                if(data.type == "疾病"){
                     getTree(1,1,data.label);
                     getGraph(data.label,select_type);
                 }else if(data.type == "药品通用名"){
-                    $(".radioList").hide()
-                    select_type_noSearch = data.type
-                    select_type = data.type
-                    $('.selectedName').html("药品")
-                    $(".activeTab").removeClass("activeTab")
-                    $(".drug").addClass("activeTab")
-                    $(".ztree").css("height",contentHei-80-43-20+'px')
-                    $('#searchInp').val(data.label)
                     getTree(0,2,data.label);
                     getGraph(data.label,select_type);
+                }else if(data.type == "症状"){
+                  
+                    getTree(0,3,data.label);
+                    getGraph(data.label,select_type);
+                }else if(data.type == "手术和操作"){
+                    getTree(0,4,data.label);
+                    getGraph(data.label,select_type);
+                }else if(data.type == "实验室检查"){
+                    getTree(0,5,data.label);
+                    getGraph(data.label,select_type);
+                }else if(data.type == "辅助检查"){
+                    getTree(0,6,data.label);
+                    getGraph(data.label,select_type);
                 }
             }
         }
@@ -253,12 +271,13 @@ function drawTree(data, showNodeName){
                     const name = treeNodeName.substring(index+1)
                     if(select_type != select_type_noSearch){
                         select_type_noSearch = select_type
-                        if(select_type == "疾病"){
-                            $(".selectedName").html("疾病")
-                        } else if(select_type == "药品通用名"){
+                        if(select_type == "药品通用名"){
                             $(".selectedName").html("药品")
+                        }else{
+                            $(".selectedName").html(select_type)
                         }
                     }
+                   
                     getGraph(name,select_type)
                     const selectPId = $('.curSelectedNode').attr('id')
                     if(selectPId){
@@ -307,22 +326,32 @@ function getNode(val, type){
                 $(".tabNameList").hide()
                 if(select_type_noSearch != select_type){
                     select_type = select_type_noSearch
-                  
+                    let renderInfo = getTab(select_type) 
+                    renderTab(renderInfo)
+                    if(select_type == '疾病'){
+                       
+                        // $('#searchInp').val("高血压3级")
+                        getTree(1,1,txt);
+                    }else if(select_type == '药品通用名'){
+                        
+                        getTree(0,2,txt);
+                    }else if(select_type == '症状'){
+                        getTree(0,3,txt);
+                    }else if(select_type == '手术和操作'){
+                        getTree(0,4,txt);
+                    }else if(select_type == '实验室检查'){
+                        getTree(0,5,txt);
+                    }else if(select_type == '辅助检查'){
+                        getTree(0,6,txt);
+                    }
                     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,txt);
-                    }else if(select_type == '药品通用名'){
+                    }else{
                         $(".radioList").hide()
                         $(".ztree").css("height",contentHei-80-43-20+'px')
-                        $(".activeTab").removeClass("activeTab")
-                        $(".drug").addClass("activeTab")
-                        getTree(0,2,txt);
                     }
                 }else{
                     updateTree(txt)
@@ -393,11 +422,153 @@ function getKeyEvent(evt) {
     }
 }
 
+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,"高血压3级");
+                getGraph("高血压3级",select_type);
+            
+            }else if(id=="药品通用名"){
+                $('#searchInp').val("氟康唑注射液")
+                getTree(0,2,"氟康唑注射液");
+                getGraph("氟康唑注射液",select_type);
+              
+            }else if(id == "症状"){
+                $('#searchInp').val("")
+                getTree(0,3,"");
+                getGraph("",select_type);
+            }else if(id == "手术和操作"){
+                $('#searchInp').val("")
+                getTree(0,4,"");
+                getGraph("",select_type);
+            }else if(id == "实验室检查"){
+                $('#searchInp').val("")
+                getTree(0,5,"");
+                getGraph("",select_type);
+            }else if(id == "辅助检查"){
+                $('#searchInp').val("")
+                getTree(0,6,"");
+                getGraph("",select_type);
+            }
+           
+            // getTree(1,1,"");  //切换tab重新画菜单树
+        }
+       
+        hideHideTab()
+    })
+}
+
 
 module.exports ={
     drawGraph,
     updateTree,
     getGraph,
     getTree,
-    getNode
+    getNode,
+    getTab,
+    renderTab
 }

+ 39 - 50
src/js/index.js

@@ -19,9 +19,11 @@ require('./../resources/images/logo_shaoyifu.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');
 const { post, api } = require('./api.js');
 const { mapData, zTreeData,mapData3,zTreeData3 } = require('./data.js');
-const { drawGraph,updateTree,getGraph,getTree,getNode } = require('./graphMap.js');
+const { drawGraph,updateTree,getGraph,getTree,getNode,getTab,renderTab} = require('./graphMap.js');
 
 window.select_type="疾病";
 window.select_type_noSearch="疾病";
@@ -54,12 +56,15 @@ $('.selectList .selectItem').click(function(){
     select_type_noSearch = $(this).attr('data-id')
     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}名称`)
+     $("#searchInp").attr
     if(txt != oldTxt){
         $('#searchInp').val("")
     }
@@ -105,21 +110,30 @@ $('#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 == '药品通用名'){
+                    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+'px')
-                    $(".activeTab").removeClass("activeTab")
-                    $(".drug").addClass("activeTab")
-                    getTree(0,2,val);
                 }
+                let renderTabInfo = getTab("疾病") 
+                renderTab(renderTabInfo)
             }else{
                 updateTree(val)
             }
@@ -132,41 +146,11 @@ $('#searchBtn').click(function(e){
     }
 })
 
-//切换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 = id
-            select_type = id
-            $('.selectedName').html(select_type)
-            $(".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,"高血压3级");
-            getGraph("高血压3级",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,"氟康唑注射液");
-            getGraph("氟康唑注射液",select_type);
-          
-        }
-        select_type = id
-        // getTree(1,1,"");  //切换tab重新画菜单树
-    }
-})
+
+
+let renderTabInfo = getTab("疾病") 
+renderTab(renderTabInfo)
+
 
 //点击页面其他地方关闭下拉
 $('html').click(function(){
@@ -185,6 +169,11 @@ $('html').click(function(){
         $('.tabNameListNoSearch').hide()
     }
 })
+
+module.exports ={
+    getTab,
+    renderTab
+}