patient-info.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. (function(){
  2. Vue.component('patient-info', {
  3. template: '<div>\
  4. <table style="width: 100%;">\
  5. <tr v-for="(row, index) in labelList">\
  6. <td style="width: 33%;" :class="labelClass[index][0]">{{row[0].labelName}}</td>\
  7. <td v-if="index==0" rowspan="4">\
  8. <div class="person-img">\
  9. <img src="../images/laoren_img.png">\
  10. </div>\
  11. </td>\
  12. <td style="width: 33%;" :class="labelClass[index][1]">{{row[1] ? row[1].labelName : ""}}</td>\
  13. </tr>\
  14. </table>\
  15. <table class="c-f16 c-b5e1fc" style="margin: 0.05rem auto;">\
  16. <tr>\
  17. <td class="plr30">姓名:{{patientInfo.name}}</td>\
  18. <td class="plr30">性别:{{patientInfo.sex == "1" ? "男" : "女"}}</td>\
  19. <td class="plr30">年龄:{{patientInfo.age}}</td>\
  20. </tr>\
  21. </table>\
  22. <table class="c-f12 c-0fa5f2" style="margin: 0.05rem auto;">\
  23. <tr>\
  24. <td class="plr30 ptb5">居住地</td>\
  25. <td class="plr30 ptb5">{{patientInfo.address}}</td>\
  26. </tr>\
  27. <tr>\
  28. <td class="plr30 ptb5">家庭医生</td>\
  29. <td class="plr30 ptb5">{{patientInfo.doctorName}}</td>\
  30. </tr>\
  31. <tr>\
  32. <td class="plr30 ptb5">签约机构</td>\
  33. <td class="plr30 ptb5">{{patientInfo.hospitalName}}</td>\
  34. </tr>\
  35. </table>\
  36. </div>',
  37. props: ['patient'],
  38. data: function() {
  39. return {
  40. patientInfo: {},
  41. labelList: [],
  42. labelClass: [
  43. ["c-f20 c-ffff00 c-t-right", "c-f20 c-abdbe9"],
  44. ["c-f26 c-d259d6 c-t-right mr20", "c-f26 c-ffff00"],
  45. ["c-f16 c-05a561 c-t-right mr20", "c-f16 c-b82f1a"],
  46. ["c-f20 c-abdbe9 c-t-right", "c-f20 c-abdbe9"]
  47. ],
  48. }
  49. },
  50. mounted: function(){
  51. var vm = this;
  52. getPatientInfo(vm);
  53. },
  54. methods: {
  55. // getDeseaseInfo: function(obj){
  56. // //只有高血压和糖尿病的标签点击才会修改右侧的信息
  57. // if(obj && obj.labelType == "3" && (obj.label == "2" || obj.label == "1")){
  58. // EventBus.$emit('get-disease-info'', {labelType: obj.labelType, label: obj.label});
  59. // }
  60. // }
  61. }
  62. });
  63. function getPatientInfo(vm){
  64. patientAPI.getPatientInfo({patient: vm.patient}).then(function(res){
  65. if(res.status == 200){
  66. vm.patientInfo = res.data;
  67. var list = res.data.labelList,
  68. len = list.length;
  69. var diseases = []; //标记高血压和糖尿病
  70. for(i=0; i<len; i++){
  71. var item = list[i];
  72. if(item.labelType == "3" && (item.label == "2" || item.label == "1")){
  73. // EventBus.$emit('get-desease-info', {labelType: item.labelType, label: item.label});
  74. // break;
  75. diseases.push(item);
  76. }
  77. }
  78. if(diseases.length > 0){
  79. var diseaseType = 0;
  80. if(diseases[0].labelType == "3" && diseases[0].label == "1"){
  81. //"高血压";
  82. diseaseType = 2;
  83. }else if(diseases[0].labelType == "3" && diseases[0].label == "2"){
  84. //"糖尿病";
  85. diseaseType = 1;
  86. }
  87. //控制右边区域的数据显示
  88. EventBus.$emit('get-disease-info', {length: diseases.length, type: diseaseType});
  89. //控制左下角区域的数据显示
  90. EventBus.$emit('show-disease-zhibiao', {type: diseaseType});
  91. //控制图标数据显示
  92. EventBus.$emit("get-chart-data", {
  93. type: diseaseType,
  94. dateType: 1, //初始时值为1
  95. gi_type: diseaseType == 2 ? 0 : 1 //血糖默认获取1周的时间
  96. });
  97. }
  98. var newList = [],
  99. list3 = [];
  100. if(len < 8){
  101. //标签展示的时候是展示8个,为了排版好看,少于8个的情况需要补充数据显示
  102. var list2 = [{
  103. "labelName": res.data.sex == 1 ? "男性" : "女性"
  104. },{
  105. "labelName": "厦门"
  106. }];
  107. if(len >= 7){
  108. list3 = [list2[0]].concat(list);
  109. }else if(len <=6 ){
  110. list3 = list2.concat(list);
  111. }
  112. }
  113. var currData = [];
  114. for(j=0; j<list3.length; j++){
  115. var it = list3[j];
  116. currData.push(it);
  117. //在这里求2的余数,如果i不等于0,且可以整除 或者考虑到不满2个或等于2个的情况就要加上 i等于当前数组长度-1的时候
  118. if((j != 0 && (j+1) % 2 == 0) || j == list3.length - 1) {
  119. newList.push(currData);
  120. currData = [];
  121. }
  122. }
  123. vm.labelList = newList;
  124. }else{
  125. console.log(res.msg);
  126. }
  127. });
  128. }
  129. })()