123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- (function ($) {
- var urls = {
- 'host':"/icss-web",
- //His推送接口
- 'get_push':'http://192.168.2.234:5008/push-web/algorithm/neural'
- };
- $.support.cors = true;
- var config = {
- width:'560px', //推送内容显示的宽度
- num:'11', //每行显示的最大个数
- mode:'horizontal', //布局模式水平horizontal,垂直vertical,
- models:[5,6,7] //需要显示的推送模块,主诉-诊断1-7
- };
- var urlSearch = parseUrl();
- handleConfig();
- getPushData();
- function parseUrl() {
- var r = window.location.search.substr(1).split("&"),
- obj = {};
- $.each(r, function (i, v) {
- if (v) {
- var arr = v.split("=");
- obj[arr[0]] = arr[1]?decodeURI(arr[1]):'';
- }
- });
- return obj;
- };
- function handleConfig(){
- $("tr td:last-child,.item-box").css({width:config.width});
- $('.'+config.mode).show();
- $('.item-box:visible:first td:first').attr('rowspan',config.models.length);
- //显示对应项目
- config.models.map((it)=>{
- $('.'+config.mode+" .box"+it).show();
- });
- }
- function getPushData(){
- var url = urls.get_push;
- var myParam = {
- symptom: urlSearch.symptomJson||"",
- past: urlSearch.pastJson||"",
- other: urlSearch.otherJson||"",
- vital: urlSearch.vitalsJson||"",
- lis: urlSearch.labsJson||"",
- pacs: urlSearch.pacsJson||"",
- diag: urlSearch.disJson||"",
- featureType: config.models.join(",")
- };
- $.ajax({
- url: url,
- type:'post',
- dataType: "json",
- contentType:"application/json",
- data:JSON.stringify(myParam),
- success:function(response){
- var data = response.data;
- if(response.ret=='0'){
- fillPushData(data);
- }
- },
- error:function(error){
- console.log("error:"+error);
- },
- complete:function(){
- console.log("complete")
- }
- });
- }
- //填入推送信息
- function fillPushData(data){
- var maps = {1:'symptom',4:'vitals',5:'labs',6:'pacs',7:'dis',};
- if(!data||JSON.stringify(data)=='{}'){
- console.warn("获取推送数据为空!");
- return ;
- }
- var key='',modeClass='.'+config.mode;
- config.models.map((it)=>{
- key = maps[it];
- var arr = [];
- for(var n = 0;n <data[key].length; n++){
- arr.push(data[key][n].featureName);
- }
- mapItem(modeClass+" .box"+it+' .item-content', arr);
- });
- //$(modeClass+" .box .item-content").html(str); //治疗建议
- }
- //遍历数据
- function mapItem(dom,item){
- var itemDom = '';
- for(var i=0;i<item.length;i++){
- if(i>config.num-1){
- itemDom += '<a href="##" class="hide">'+item[i]+'</a>';
- }else{
- itemDom += '<a href="##">'+item[i]+'</a>';
- }
- }
- $(dom).html(itemDom||"无");
- var hide = $(dom).find(".hide")[0];
- if(hide){
- $("<a class='more'>...</a>").insertBefore(hide);
- $(".more").click(function(e){
- $(e.target).siblings(".hide").removeClass("hide");
- $(e.target).hide();
- })
- }
- }
- })(jQuery);
|