|
@@ -0,0 +1,719 @@
|
|
|
+const echarts = require("echarts");
|
|
|
+const { post, api } = require('./api.js');
|
|
|
+
|
|
|
+
|
|
|
+//关系图
|
|
|
+// function showKnowledgeGraph(keyWord, resultShowId, type) {
|
|
|
+// keyWord = keyWord.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
+// if(isEmpty(keyWord)){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// var data = {"name":keyWord, 'tree_type':tree_type};
|
|
|
+// $.ajax({
|
|
|
+// type: 'GET',
|
|
|
+// url: '/knowledge',
|
|
|
+// data: data,
|
|
|
+// dataType: 'json',
|
|
|
+// success:function(data){
|
|
|
+// keyWord = data['name']
|
|
|
+// nodes = data['node'];
|
|
|
+// links = data['link'];
|
|
|
+// // nodes = [
|
|
|
+// // {"category": 0, "name": 0, "label":'e1',"symbolSize":40},
|
|
|
+// // {"category": 1, "name": 1, "label":'',"symbol":"diamond", "symbolSize": 10},
|
|
|
+// // {"category": 2, "name": 2, "label": 'e2', "symbolSize": 28},
|
|
|
+// // {"category": 0, "name": 3,"label": 'e1_pro', "symbol":"rect", "symbolSize": [40, 16]},
|
|
|
+// // {"category": 1, "name": 4,"label": 'rel_pro', "symbol":"rect", "symbolSize": [40, 16]},
|
|
|
+// // {"category": 2, "name": 5,"label": 'e2_pro', "symbol":"rect", "symbolSize": [40, 16]}
|
|
|
+// //
|
|
|
+// // ];
|
|
|
+// // links = [
|
|
|
+// // {"source": 0, "target": 1, "value":'rel'},
|
|
|
+// // {"source": 1, "target": 2, "value":''},
|
|
|
+// // {"source": 2, "target": 3, "value":''},
|
|
|
+// // {"source": 2, "target": 4, "value":''},
|
|
|
+// // {"source": 2, "target": 5, "value":''}
|
|
|
+// // ];
|
|
|
+// if(nodes.length < 5){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// else if(visitQue[visitQue.length - 1] == keyWord)
|
|
|
+// {
|
|
|
+// return;
|
|
|
+// }else{
|
|
|
+// visitQue.push(keyWord);
|
|
|
+// }
|
|
|
+// if(type == 0){
|
|
|
+// $('#searchPlaceholder').val(keyWord);
|
|
|
+// }else if(type == 1){
|
|
|
+// var txt = $(".select_txt").text();
|
|
|
+// updateTree(keyWord, txt);
|
|
|
+// }else if(type == 2){
|
|
|
+// $('#searchPlaceholder').val(keyWord);
|
|
|
+// }else {
|
|
|
+// tree_type = data['tree_type'];
|
|
|
+// console.log(tree_type);
|
|
|
+// updateTree(keyWord,tree_type);
|
|
|
+// }
|
|
|
+// drawGraph(data,resultShowId);
|
|
|
+// },
|
|
|
+// error:function(e){
|
|
|
+// last_word = visitQue.pop();
|
|
|
+// showKnowledgeGraph(last_word, 'graph', 3);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+function getGraph(val, type){
|
|
|
+ post(api.getGraph,{
|
|
|
+ "inputStr": val,
|
|
|
+ "labelName": type
|
|
|
+ }).then(res=>{
|
|
|
+ if(res.data.code == 0) {
|
|
|
+ $('#searchInp').val(val)
|
|
|
+ drawGraph(res.data.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function drawGraph(data,resultShowId) {
|
|
|
+ var myChart = echarts.init(document.getElementById('main'));
|
|
|
+ var categories = data['categories'];
|
|
|
+ var legends = categories.slice(2, categories.length);
|
|
|
+
|
|
|
+ var option = {
|
|
|
+ title: { text: '关系图谱' },
|
|
|
+ // color:colors,
|
|
|
+ tooltip: {
|
|
|
+ formatter: function (x) {
|
|
|
+ return x.data.label;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ legend: [{
|
|
|
+ type: 'scroll',
|
|
|
+ bottom: 0,
|
|
|
+ icon: 'circle',
|
|
|
+ cursor:'pointer',
|
|
|
+ data: legends.map(function (a) {
|
|
|
+ return a.name;
|
|
|
+ })
|
|
|
+ }],
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ type: 'graph',
|
|
|
+ layout: 'force',
|
|
|
+ cursor:'pointer',
|
|
|
+ categories: categories,
|
|
|
+ symbolSize: 80,
|
|
|
+ roam: true,
|
|
|
+ edgeSymbol: ['circle', 'arrow'],
|
|
|
+ edgeSymbolSize: [1, 5],
|
|
|
+ edgeLabel: {
|
|
|
+ normal: {
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 20
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ force: {
|
|
|
+ repulsion: 500,
|
|
|
+ gravity: 0.8,
|
|
|
+ edgeLength: [4, 7],
|
|
|
+ layoutAnimation : true
|
|
|
+ },
|
|
|
+ draggable: true,
|
|
|
+ animation: true,
|
|
|
+ hoverAnimation:false,
|
|
|
+ animationDuration:5000,
|
|
|
+ focusNodeAdjacency: true,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ width: 2,
|
|
|
+ // color: 'target',
|
|
|
+ curveness: 0,
|
|
|
+ opacity: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ lineStyle: {
|
|
|
+ normal: {
|
|
|
+ width: 2,
|
|
|
+ color: '#4b565b'
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ edgeLabel: {
|
|
|
+ normal: {
|
|
|
+ show: true,
|
|
|
+ formatter: function (x) {
|
|
|
+ return x.data.value; //横线关系
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ show: true,
|
|
|
+ textStyle: {
|
|
|
+ },
|
|
|
+ formatter: function (x) {
|
|
|
+ var tmp = x.data.label;
|
|
|
+ if(tmp.length >= 8){
|
|
|
+ tmp = tmp.substring(0,3);
|
|
|
+ tmp = tmp + "...";
|
|
|
+ }
|
|
|
+ return tmp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: data.node,
|
|
|
+ links: data.links
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ myChart.setOption(option);
|
|
|
+ myChart.on('click',dataClick);
|
|
|
+ // myChart = echarts.init(document.getElementById(resultShowId),'light');
|
|
|
+ // categories = data['categories'];
|
|
|
+ // var legends = categories.slice(2, categories.length);
|
|
|
+ // option = {
|
|
|
+ // color:colors,
|
|
|
+ // tooltip: {
|
|
|
+ // formatter: function (x) {
|
|
|
+ // return x.data.label;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // toolbox:{
|
|
|
+ // show:true,
|
|
|
+ // feature:{
|
|
|
+ // myBack: {
|
|
|
+ // show:true,
|
|
|
+ // title:'后退',
|
|
|
+ // icon:back_icon,
|
|
|
+ // onclick:function () {
|
|
|
+ // word = visitQue.pop();
|
|
|
+ // if(visitQue.length > 0){
|
|
|
+ // word = visitQue.pop();
|
|
|
+ // }
|
|
|
+ // showKnowledgeGraph(word, 'graph',4);
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // restore: {
|
|
|
+ // show: true
|
|
|
+ // },
|
|
|
+ // saveAsImage: {
|
|
|
+ // show: true
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // legend: {
|
|
|
+ // type: 'scroll',
|
|
|
+ // bottom: 0,
|
|
|
+ // icon: 'circle',
|
|
|
+ // data: legends.map(function (a) {
|
|
|
+ // return a.name;
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // series: [
|
|
|
+ // {
|
|
|
+ // type: 'graph',
|
|
|
+ // layout: 'force',
|
|
|
+ // categories: categories,
|
|
|
+ // roam: 'move',
|
|
|
+ // focusNodeAdjacency: true,
|
|
|
+ // edgeSymbol: ['none', 'arrow'],
|
|
|
+ // edgeSymbolSize: [1, 5],
|
|
|
+ // force: {
|
|
|
+ // repulsion: 500,
|
|
|
+ // gravity: 0.8,
|
|
|
+ // edgeLength: [4, 7],
|
|
|
+ // layoutAnimation : true
|
|
|
+ // },
|
|
|
+ // hoverAnimation:false,
|
|
|
+ // // draggable: false,
|
|
|
+ // // legendHoverLink: false,
|
|
|
+ // lineStyle: {
|
|
|
+ // normal: {
|
|
|
+ // width: 2,
|
|
|
+ // color: 'target',
|
|
|
+ // curveness: 0,
|
|
|
+ // opacity: 1
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // edgeLabel: {
|
|
|
+ // normal: {
|
|
|
+ // show: true,
|
|
|
+ // formatter:"{c}"
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // label: {
|
|
|
+ // normal: {
|
|
|
+ // show: true,
|
|
|
+ // formatter: function (x) {
|
|
|
+ // var tmp = x.data.label;
|
|
|
+ // if(tmp.length >= 8){
|
|
|
+ // tmp = tmp.substring(0,3);
|
|
|
+ // tmp = tmp + "...";
|
|
|
+ // }
|
|
|
+ // return tmp;
|
|
|
+ // },
|
|
|
+ // textStyle: {
|
|
|
+ // color: '#000',
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // nodes: nodes,
|
|
|
+ // links: links
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // };
|
|
|
+ // myChart.on('click',dataClick);
|
|
|
+ // myChart.setOption(option);
|
|
|
+}
|
|
|
+
|
|
|
+function dataClick(param){
|
|
|
+ var data = param.data;
|
|
|
+ // var nodes = option.series[0].nodes;
|
|
|
+ console.log('clickData',data);
|
|
|
+ if(data.source !== undefined && data.target !== undefined)
|
|
|
+ {
|
|
|
+ // myChart.setOption(option);
|
|
|
+ }else {
|
|
|
+ if(data.category == 1)
|
|
|
+ {
|
|
|
+ myChart.setOption(option);
|
|
|
+ }
|
|
|
+
|
|
|
+ // else if(data.parent == -1){
|
|
|
+ // var img = data.symbol;
|
|
|
+ // img = img.substring(8);
|
|
|
+ // showImg(img);
|
|
|
+ // }else if(data.parent == -2){
|
|
|
+ // window.open(data.video);
|
|
|
+ // }
|
|
|
+ else if(data.label.indexOf("http") != -1){
|
|
|
+ window.open(data.label);
|
|
|
+ }
|
|
|
+ else if(data.symbol == "rect"){
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ // showKnowledgeGraph(data.label, 'graph',3);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// //菜单
|
|
|
+// var setting = {
|
|
|
+// view: {
|
|
|
+// dblClickExpand: false,
|
|
|
+// showLine: true,
|
|
|
+// selectedMulti: false,
|
|
|
+// },
|
|
|
+// data: {
|
|
|
+// simpleData: {
|
|
|
+// enable: true,
|
|
|
+// idKey: "id",
|
|
|
+// pIdKey: "pId",
|
|
|
+// rootPId: ""
|
|
|
+// }
|
|
|
+// },
|
|
|
+// callback: {
|
|
|
+// beforeClick: function (treeId, treeNode) {
|
|
|
+// var zTree = $.fn.zTree.getZTreeObj("tree");
|
|
|
+// if (treeNode.isParent) {
|
|
|
+// zTree.expandNode(treeNode);
|
|
|
+// return false;
|
|
|
+// } else {
|
|
|
+// showKnowledgeGraph(treeNode.name, 'graph', 0);
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// };
|
|
|
+// var zNodes=[];
|
|
|
+// var selectedNode = "";
|
|
|
+
|
|
|
+// $(document).ready(function () {
|
|
|
+// var url = window.location.pathname;
|
|
|
+// if(url == '/mekg'){
|
|
|
+// var data = {"name":'tree'};
|
|
|
+// var t = $("#tree");
|
|
|
+
|
|
|
+// var url = window.location.search;
|
|
|
+// if(url.indexOf("?") != -1){
|
|
|
+// var str = decodeURI(url);
|
|
|
+// var name = str.split("=")[1];
|
|
|
+// var tree_ls = {'0':'疾病','1':'药物','2':'诊疗','3':'症状'};
|
|
|
+// showKnowledgeGraph(name,'graph', 2);
|
|
|
+// updateTree(name,tree_ls[str[2]]);
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// showKnowledgeGraph("支气管肺癌" ,"graph",2);
|
|
|
+// updateTree("支气管肺癌","疾病");
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// showGraphMenu('graph_menu');
|
|
|
+// // get_recommend();
|
|
|
+// // setInterval(get_recommend, 3000);
|
|
|
+// }
|
|
|
+
|
|
|
+// });
|
|
|
+
|
|
|
+// function showGraphMenu(dom_id) {
|
|
|
+// var data = {'name': dom_id}
|
|
|
+// $.ajax({
|
|
|
+// type: 'GET',
|
|
|
+// url: '/circle_menu',
|
|
|
+// data: data,
|
|
|
+// dataType: 'json',
|
|
|
+// success: function (data) {
|
|
|
+// var nodes = data['nodes'];
|
|
|
+// var links = data['links'];
|
|
|
+// var myChart = echarts.init(document.getElementById(dom_id), 'macarons')
|
|
|
+// var categories = [];
|
|
|
+// for (var i = 0; i < 10; i++) {
|
|
|
+// categories[i] = {
|
|
|
+// name: '' + i
|
|
|
+// }
|
|
|
+// }
|
|
|
+// nodes.forEach(function (node) {
|
|
|
+// node.itemStyle = null;
|
|
|
+// node.value = node.symbolSize;
|
|
|
+// node.category = (node.name % 10);
|
|
|
+// });
|
|
|
+// option = {
|
|
|
+// animationDurationUpdate: 1000,
|
|
|
+// animationEasingUpdate: 'quinticInOut',
|
|
|
+// tooltip: {
|
|
|
+// formatter: function (x) {
|
|
|
+// return x.data.showName;
|
|
|
+// }
|
|
|
+// },
|
|
|
+// series: [{
|
|
|
+// name: '100种常见病',
|
|
|
+// type: 'graph',
|
|
|
+// layout: 'circular',
|
|
|
+// circular: {
|
|
|
+// rotateLabel: true
|
|
|
+// },
|
|
|
+// data: nodes,
|
|
|
+// links: links,
|
|
|
+// categories: categories,
|
|
|
+// label: {
|
|
|
+// normal: {
|
|
|
+// position: 'right',
|
|
|
+// show: true,
|
|
|
+// formatter: function (x) {
|
|
|
+// var len = x.data.showName.length;
|
|
|
+// if (len < 5) {
|
|
|
+// return x.data.showName;
|
|
|
+// } else {
|
|
|
+// return '';
|
|
|
+// }
|
|
|
+
|
|
|
+// },
|
|
|
+// }
|
|
|
+// },
|
|
|
+// lineStyle: {
|
|
|
+// normal: {
|
|
|
+// color: 'source',
|
|
|
+// curveness: 0.3
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }]
|
|
|
+// };
|
|
|
+// function nodeClick(param) {
|
|
|
+// console.log('param',param)
|
|
|
+// var data = param.data;
|
|
|
+// if (data.source !== undefined && data.target !== undefined) {
|
|
|
+// myChart.setOption(option);
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// uri = encodeURI("/mekg?v0=" + data.showName);
|
|
|
+// // console.log(uri);
|
|
|
+// window.open(uri);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+// myChart.on('click', nodeClick);
|
|
|
+// myChart.setOption(option);
|
|
|
+
|
|
|
+// },
|
|
|
+// error: function (e) {
|
|
|
+// console.log('error loading graph menu');
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+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: false,//设置是否显示鼠标悬浮时显示title的效果
|
|
|
+ dblClickExpand: false,//设置是否支持双击展开树节点
|
|
|
+ fontCss : {color:"blue"},//设置节点样式
|
|
|
+ expandSpeed: "slow",//设置展开的速度 fast normal slow
|
|
|
+ nameIsHTML: true,//名字是否是HTML
|
|
|
+ selectedMulti: true,
|
|
|
+
|
|
|
+ },
|
|
|
+ //设置事件回调
|
|
|
+ callback:{
|
|
|
+ // onClick:zTreeOnClick,
|
|
|
+ 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)
|
|
|
+ getGraph(name,'diagnose')
|
|
|
+ // showKnowledgeGraph(treeNode.name, 'graph', 0);
|
|
|
+ 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) {
|
|
|
+ console.log('res',res)
|
|
|
+ const data = res.data.data
|
|
|
+ let nodeStr =''
|
|
|
+ if(data.length > 0){
|
|
|
+ for(let i = 0; i < data.length; i++){
|
|
|
+ nodeStr +=`<li>${data[i].name}</li>`
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ nodeStr = '<li>暂无符合数据</li>'
|
|
|
+ }
|
|
|
+ $(".tabNameList").html(nodeStr)
|
|
|
+ $(".tabNameList").show()
|
|
|
+ $(".tabNameList li").click(function(){
|
|
|
+ const txt = $(this).text()
|
|
|
+ $(".tabNameList").hide()
|
|
|
+
|
|
|
+ getGraph(txt,'diagnose')
|
|
|
+ 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));
|
|
|
+ // $.ajax({
|
|
|
+ // type: 'GET',
|
|
|
+ // url: '/load_tree/' + txt,
|
|
|
+ // // data: data,
|
|
|
+ // dataType: 'json',
|
|
|
+ // success: function (data) {
|
|
|
+ // zNodes= data['nodes'];
|
|
|
+ // tree_type = zNodes[0]['name'];
|
|
|
+ // $.fn.zTree.init(t, setting, zNodes);
|
|
|
+ // var zTree = $.fn.zTree.getZTreeObj("tree");
|
|
|
+ // zTree.selectNode(zTree.getNodeByParam("name", keyWord));
|
|
|
+ // },
|
|
|
+ // error: function (e) {
|
|
|
+ // zNodes = [];
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+}
|
|
|
+
|
|
|
+// function queryGraph() {
|
|
|
+// var url = window.location.pathname;
|
|
|
+// if(url == '/mekg'){
|
|
|
+// var node_name = document.getElementById("searchPlaceholder").value;
|
|
|
+// $('#word').empty();
|
|
|
+// $('#word').hide();
|
|
|
+// showKnowledgeGraph(node_name, 'graph', 1);
|
|
|
+// }else{
|
|
|
+// var node_name = document.getElementById("search1").value;
|
|
|
+// node_name = node_name.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
+// $('#word1').empty();
|
|
|
+// $('#word1').hide();
|
|
|
+// if(node_name.length == 0){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// var type_dic = {'疾病':'0','药物':'1', '诊疗':'2', '症状':'3'};
|
|
|
+// var txt = $('.select_txt1').text();
|
|
|
+// console.log(txt);
|
|
|
+// uri = encodeURI('/mekg?v' + type_dic[txt] + '='+node_name)
|
|
|
+// window.open(uri);
|
|
|
+// }
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
+function isEmpty(obj){
|
|
|
+ if(typeof obj == "undefined" || obj == null || obj == ""){
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getKeyEvent(evt) {
|
|
|
+ var evt = (evt) ? evt : ((window.event) ? window.event : "");
|
|
|
+ var key = evt.keyCode?evt.keyCode:evt.which;
|
|
|
+ if(key==13){
|
|
|
+ keyDown = true;
|
|
|
+ queryGraph();
|
|
|
+ evt.cancleBubble = true;
|
|
|
+ evt.returnValue = false;
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// function getSug() {
|
|
|
+// var url = window.location.pathname, input_id, hint_id, select_cls;
|
|
|
+// if(url == '/mekg'){
|
|
|
+// input_id = "searchPlaceholder";
|
|
|
+// hint_id = "word";
|
|
|
+// select_cls = "select_txt";
|
|
|
+// }else {
|
|
|
+// input_id = "search1";
|
|
|
+// hint_id = "word1";
|
|
|
+// select_cls = "select_txt1";
|
|
|
+// }
|
|
|
+// var input_name = document.getElementById(input_id).value;
|
|
|
+// input_name = input_name.replace(/(^\s*)|(\s*$)/g, "")
|
|
|
+// if (isEmpty(input_name) || keyDown == true){
|
|
|
+// $('#' + hint_id).empty();
|
|
|
+// $('#' + hint_id).hide();
|
|
|
+// if(keyDown == true){
|
|
|
+// keyDown = false;
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// var res_ls = [];
|
|
|
+// var type_dic = {'疾病':0,'药物':1, '诊疗':2, '症状':3};
|
|
|
+// var txt = $("." + select_cls).text();
|
|
|
+// var data = {'type': type_dic[txt]};
|
|
|
+// $.ajax({
|
|
|
+// type: 'GET',
|
|
|
+// url: '/get_sug/' + input_name,
|
|
|
+// data : data,
|
|
|
+// dataType: 'json',
|
|
|
+// beforeSend:function(){
|
|
|
+// $('#' + hint_id).append('<div>loading......</div>');
|
|
|
+// },
|
|
|
+// success: function (data) {
|
|
|
+// res_ls = data['sug'];
|
|
|
+// // console.log(res_ls);
|
|
|
+// $('#' + hint_id).empty().show();
|
|
|
+// if(res_ls == false){
|
|
|
+// $('#' + hint_id).append('<div class="error">Not Found </div>');
|
|
|
+// }
|
|
|
+// else {
|
|
|
+// for(var i = 0,l=res_ls.length;i<l;i++){
|
|
|
+// $('#' + hint_id).append('<div class="click_work" onclick="select_word(this)">'+ res_ls[i] +'</div>');
|
|
|
+// }
|
|
|
+// }
|
|
|
+// $('#' + hint_id).show();
|
|
|
+// },
|
|
|
+// error: function (e) {
|
|
|
+// $('#' + hint_id).empty().show();
|
|
|
+// $('#' + hint_id).append('<div class="click_work">Not Found </div>');
|
|
|
+// $('#' + hint_id).show();
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+
|
|
|
+// function select_word(obj) {
|
|
|
+// var url = window.location.pathname, input_id, hint_id;
|
|
|
+// var word = $(obj).text();
|
|
|
+// if(url == '/mekg'){
|
|
|
+// input_id = "searchPlaceholder";
|
|
|
+// hint_id = "word";
|
|
|
+// }else{
|
|
|
+// input_id = "search1";
|
|
|
+// hint_id = "word1";
|
|
|
+// }
|
|
|
+
|
|
|
+// $('#' + input_id).val(word);
|
|
|
+// $('#' + hint_id).hide();
|
|
|
+// }
|
|
|
+
|
|
|
+module.exports ={
|
|
|
+ drawGraph,
|
|
|
+ updateTree,
|
|
|
+ getGraph,
|
|
|
+ getTree,
|
|
|
+ getNode
|
|
|
+}
|