ソースを参照

Merge branch 'knowledgeTreeModify' into test

zhangxc 5 年 前
コミット
be9e41ff5c
5 ファイル変更487 行追加117 行削除
  1. 177 81
      src/css/knowledgeTree.less
  2. 52 18
      src/html/knowledgeTree.html
  3. 0 1
      src/js/graphMap.js
  4. 98 13
      src/js/knowledgeTree.js
  5. 160 4
      src/js/schemaMap.js

+ 177 - 81
src/css/knowledgeTree.less

@@ -21,99 +21,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: -50px 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;
     }
-    
 }

+ 52 - 18
src/html/knowledgeTree.html

@@ -2,28 +2,62 @@
 <html lang="en">
 
 <head>
-	<meta charset="UTF-8">
-	<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>
+  <meta charset="UTF-8">
+  <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="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 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 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>
-			<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>  
+      </div>
+  </div>
+
+</body>
 
 				</div>
 				<div class="empty">

+ 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">')
 }
 

+ 98 - 13
src/js/knowledgeTree.js

@@ -1,31 +1,116 @@
+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 {getSchema,updateTree,getTree,getNode} = require('./schemaMap.js');
+
+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')
+//关系图
+getSchema("胆囊炎",select_type);
+getTree(1,1,"胆囊炎");
+$('#searchInp').val("胆囊炎")
 
-$("#searchTxt").val("胆囊炎")
-getSchema('胆囊炎','diagnose')
+//选择类型
+$('.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')
+        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()
+    }
+})
+		
+		
+	
+
+
 
 
 

+ 160 - 4
src/js/schemaMap.js

@@ -1,18 +1,171 @@
 const echarts = require("echarts");
 const { post, api } = require('./api.js');
 
+function getTree(subType, type,showNodeName){
+    post(api.getTree,
+        {
+            "subType": subType,
+            "type": type
+        }
+    ).then(res=>{
+        if(res.data.code == 0) {
+            const data = res.data.data
+            drawTree(data,showNodeName)
+        }
+    })
+}
+function drawTree(data, showNodeName){
+    /**
+        属性说明  id  当前节点的唯一ID
+        pId [必须大写]  代表当前节点的父节点id
+        name:节点名称
+        open:是否展开当前节点,默认为false
+        isParent:true  标记当前节点是否为父节点 默认为如果当前节点下有子节点 则为true   否则为false
+        icon:设置节点的图标地址
+        iconOpen:设置节点展开时的图标地址  此节点必须是父节点 isParent:true
+        iconClose:设置节点收起的的图标地地址  此节点必须是父节点 isParent:true
+        url:点击节点打开的链接地址  如果想使用onClick:zTreeOnClick事件,就不要加url属性 或者改名字 href
+        target:设置打开链接的方式  [在新窗口打开(_blank),要本窗口打开(_self)]
+            
+    **/
+    var setting = {	
+        //数据格式的设置
+        data:{
+            simpleData: {
+                enable: true, //使用简单的JSON格式
+                idKey: "id",
+                pIdKey: "pId",
+                rootPId: ""
+            },
+        },
+        //树的显示设置
+        view:{
+            showLine:true, //设置是否显示连线 默认为true
+            showTitle: true,//设置是否显示鼠标悬浮时显示title的效果
+            dblClickExpand: true,//设置是否支持双击展开树节点
+            fontCss : {color:"#333"},//设置节点样式  
+            expandSpeed: "normal",//设置展开的速度  fast normal  slow 
+            nameIsHTML: true,//名字是否是HTML
+            selectedMulti: true,
+            
+        },
+        //设置事件回调
+        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">')
+            },
+            beforeClick: function (treeId, treeNode) {
+                var zTree = $.fn.zTree.getZTreeObj("tree");
+                if (treeNode.isParent) {
+                    zTree.expandNode(treeNode);
+                    return false;
+                } else {
+                    const treeNodeName = treeNode.name
+                    let index = treeNodeName.indexOf(' ')
+                    const name = treeNodeName.substring(index+1)
+                    getSchema(name,select_type)
+                    const selectPId = $('.curSelectedNode').attr('id')
+                    const selectId = selectPId.substring(0,selectPId.length-1) + 'ico'
+                    $('#'+selectId + ' .iconSelect').remove()
+                    return true;
+                }
+            }
+        }
+    };
+    var zNodes = data.nodes;
+    // var zNodes = zTreeData.nodes; 
+    $.fn.zTree.init($("#tree"), setting, zNodes);
+    if(showNodeName) {
+        updateTree(showNodeName)
+
+    }
+}
+
+function getNode(val, type){
+    post(api.getNode,
+        {
+            "inputStr": val,
+            "labelName": type
+        }
+    ).then(res=>{
+        if(res.data.code == 0) {
+            const data = res.data.data
+            let nodeStr =''
+            if(data.length > 0){
+                for(let i = 0; i < data.length; i++){
+                    nodeStr +=`<li class="ellipsis nodeItem" title=${data[i].name}>${data[i].name}</li>`
+                }
+            }else{
+                nodeStr = '<li class="ellipsis">暂无符合数据</li>'
+            }
+            $(".tabNameList").html(nodeStr)
+            $(".tabNameList").show()
+            $(".tabNameList li").click(function(){
+                const txt = $(this).text()
+                $(".tabNameList").hide()
+                getSchema(txt,select_type)
+                updateTree(txt)
+            })
+        }
+    })
+}
+
+function updateTree(keyWord, txt) {
+    var t = $("#tree");
+        // if(zNodes&& zNodes.length > 0 && zNodes[0]['name'].indexOf(txt) != -1){
+        //     $.fn.zTree.init(t, setting, zNodes);
+        //     var zTree = $.fn.zTree.getZTreeObj("tree");
+        //     zTree.selectNode(zTree.getNodeByParam("name", keyWord));
+        // }else {
+        var tree_select = document.getElementsByClassName("tree_selected");
+        for(i = 0; i < tree_select.length; i++){
+            tree_select[i].className = "tree_button";
+        }
+        var tree_button = document.getElementsByClassName("tree_button");
+        for(i = 0; i < tree_button.length; i++){
+            if(tree_button[i].text == txt){
+                tree_button[i].className = "tree_selected";
+            }
+        }
+        if(txt != "疾病"){
+            $("#radio").hide();
+        }else {
+             $("#radio").show();
+        }
+        selectedNode = keyWord;
+        var data = {"name":'tree'};
+        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">')
+}
+
 function getSchema(val, type){
     post(api.getSchema,{
         "labelName": type,
         "pramNme": val
     }).then(res=>{
         if(res.data.code == 0) {
+            $('#searchInp').val(val)
             if(res.data.data.length >0){
-                $('.empty').hide()
+               
+                drawSchema(res.data.data)
+
             }else{
-                $('.empty').show()
+                let nodeStr
+                nodeStr = '<li class="ellipsis">暂无符合数据</li>'
+                $(".tabNameList").html(nodeStr)
+                $(".tabNameList").show()
             }
-            drawSchema(res.data.data)
+        }else{
+            let nodeStr
+            nodeStr = '<li class="ellipsis">暂无符合数据</li>'
+            $(".tabNameList").html(nodeStr)
+            $(".tabNameList").show()
         }
     })
 }
@@ -111,5 +264,8 @@ function getSchema(val, type){
  }
 
  module.exports ={
-    getSchema
+    getSchema,
+    getTree,
+    updateTree,
+    getNode
  }