info_push.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. (function ($) {
  2. var urls = {
  3. 'host':"/icss-web",
  4. //His推送接口
  5. 'get_push':'http://192.168.2.234:8080/web/doc/algorithm/neural'
  6. };
  7. $.support.cors = true;
  8. var config = {
  9. width:'560px', //推送内容显示的宽度
  10. num:'11', //每行显示的最大个数
  11. mode:'horizontal' //布局模式水平horizontal,垂直vertical
  12. };
  13. var urlSearch = parseUrl();
  14. handleConfig();
  15. getPushData();
  16. function parseUrl() {
  17. var r = window.location.search.substr(1).split("&"),
  18. obj = {};
  19. $.each(r, function (i, v) {
  20. if (v) {
  21. var arr = v.split("=");
  22. obj[arr[0]] = arr[1]?decodeURI(arr[1]):'';
  23. }
  24. });
  25. return obj;
  26. };
  27. function handleConfig(){
  28. $("tr td:last-child,.item-box").css({width:config.width});
  29. $('.'+config.mode).show();
  30. }
  31. function getPushData(){
  32. var url = urls.get_push;
  33. var myParam = {
  34. symptom: urlSearch.symptomJson||"",
  35. past: urlSearch.pastJson||"",
  36. other: urlSearch.otherJson||"",
  37. vital: urlSearch.vitalsJson||"",
  38. lis: urlSearch.labsJson||"",
  39. pacs: urlSearch.pacsJson||"",
  40. diag: urlSearch.disJson||"",
  41. featureType: "1,4,7"
  42. };
  43. $.ajax({
  44. url: url,
  45. type:'post',
  46. dataType: "json",
  47. contentType:"application/json",
  48. data:JSON.stringify(myParam),
  49. success:function(response){
  50. var data = response.data;
  51. if(response.ret=='0'){
  52. fillPushData(data);
  53. }
  54. },
  55. error:function(error){
  56. console.log("error:"+error);
  57. },
  58. complete:function(){
  59. console.log("complete")
  60. }
  61. });
  62. }
  63. //填入推送信息
  64. function fillPushData(data){
  65. if(!data||JSON.stringify(data)=='{}'){
  66. console.warn("获取推送数据为空!");
  67. return ;
  68. }
  69. var past = [];
  70. /*for(var p = 0;p <data.past.length; p++){
  71. past.push(data.past[p].name);
  72. }*/ //大数据推送没有现病史
  73. var body = [];
  74. for(var n = 0;n <data.vitals.length; n++){
  75. body.push(data.vitals[n].featureName);
  76. }
  77. var symptom = [];
  78. for(var x = 0;x <data.symptom.length; x++){
  79. symptom.push(data.symptom[x].featureName);
  80. }
  81. var dis = data.dis;
  82. var infoUrl,str='';
  83. var modeClass = '.'+config.mode;
  84. for(var i=0;i<dis.length;i++){
  85. infoUrl="./case_info.html?diseaseId="+dis[i].id;
  86. str += '<a>'+dis[i].featureName+'</a>';
  87. }
  88. mapItem(modeClass+" .main-suit",symptom);
  89. mapItem(modeClass+" .past-item", past);
  90. mapItem(modeClass+" .body-item", body);
  91. $(modeClass+" .treatment").html(str);
  92. }
  93. //遍历数据
  94. function mapItem(dom,item){
  95. var itemDom = '';
  96. for(var i=0;i<item.length;i++){
  97. if(i>config.num-1){
  98. itemDom += '<a href="##" class="hide">'+item[i]+'</a>';
  99. }else{
  100. itemDom += '<a href="##">'+item[i]+'</a>';
  101. }
  102. }
  103. $(dom).html(itemDom||"无");
  104. var hide = $(dom).find(".hide")[0];
  105. if(hide){
  106. $("<a class='more'>...</a>").insertBefore(hide);
  107. $(".more").click(function(e){
  108. $(e.target).siblings(".hide").removeClass("hide");
  109. $(e.target).hide();
  110. })
  111. }
  112. }
  113. })(jQuery);