diag_push.js 3.0 KB

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