family-section.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. (function(){
  2. Vue.component('family-section', {
  3. template: '<div class="panel-box panel-box1">\
  4. <h4 class="c-b5e1fc c-f16 c-t-center">家庭成员</h4>\
  5. <div v-show="hasData">\
  6. <div id="wrapper1" class="family-group mt10">\
  7. <div id="scroller" class="clearfix">\
  8. <div v-for="member in familyMembers" class="family c-t-center mr20">\
  9. <img :src="member.photo | getPatientPhoto" class="portrait-img">\
  10. <div class="c-b5e1fc c-f14">{{member.name}}({{member.familyRelationName}})</div>\
  11. </div>\
  12. </div>\
  13. </div>\
  14. <div class="sub-title">\
  15. <div :class="preClassObj" @click="pre()"></div>\
  16. <span class="c-b5e1fc c-f14">{{tabs[selectedTab].name}}</span>\
  17. <div :class="nextClassObj" @click="next()"></div>\
  18. </div>\
  19. <div class="c-nowrap-multi-4 c-b5e1fc c-f12 lh18 mt20">{{tabs[selectedTab].content}}</div>\
  20. </div>\
  21. <div v-show="!hasData" class="no-result-panel">\
  22. <div class="no-result-img">\
  23. <img src="../images/wushuju_icon.png">\
  24. </div>\
  25. <div class="no-result-text">暂无绑定家庭成员</div>\
  26. </div>\
  27. </div>',
  28. props: ['patient'],
  29. data: function() {
  30. return {
  31. familyMembers:[],
  32. hasData: true,
  33. selectedTab: 0,
  34. tabs:[{
  35. index: 0,
  36. name: '家族病史',
  37. content: '家族病史,也就是医学中常常提到的家族史。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。'
  38. },{
  39. index: 1,
  40. name: '家族病史1',
  41. content: '1家族病史,也就是医学中常常提到的家族史。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。'
  42. },{
  43. index: 2,
  44. name: '家族病史2',
  45. content: '2家族病史,也就是医学中常常提到的家族史。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。是指某一种并的患者的家庭成员(较大范围的家庭成员,不仅限于祖孙等直系亲属)中发病情况。'
  46. }]
  47. }
  48. },
  49. mounted: function() {
  50. var vm = this;
  51. getFamilyInfo(vm);
  52. },
  53. computed: {
  54. preClassObj: function(){
  55. return {
  56. 'pre-icon': true,
  57. 'active': this.selectedTab != 0
  58. }
  59. },
  60. nextClassObj: function(){
  61. return {
  62. 'next-icon': true,
  63. 'active': this.selectedTab != (this.tabs.length - 1)
  64. }
  65. }
  66. },
  67. methods: {
  68. pre: function(){
  69. if(this.selectedTab == 0){
  70. return false;
  71. }
  72. this.selectedTab --;
  73. },
  74. next: function(){
  75. if(this.selectedTab == (this.tabs.length - 1)){
  76. return false;
  77. }
  78. this.selectedTab ++;
  79. }
  80. },
  81. filters: {
  82. getPatientPhoto: function(str){
  83. if(str){
  84. if(str.indexOf("../") > -1){
  85. return "../images/p-female.png";
  86. }else{
  87. return str;
  88. }
  89. }else{
  90. return "../images/p-female.png";
  91. }
  92. }
  93. }
  94. });
  95. function getFamilyInfo(vm){
  96. var params = {
  97. patient: vm.patient
  98. };
  99. patientAPI.getFamilyInfo(params).then(function(res){
  100. if(res.status == 200){
  101. vm.familyMembers = res.data;
  102. if(res.data.length > 0){
  103. vm.hasData = true;
  104. }else{
  105. vm.hasData = false;
  106. }
  107. var width = window.screen.width;
  108. $("#scroller").width(0.05 * width * res.data.length);
  109. new IScroll('#wrapper1', { scrollX: true, scrollY: false, mouseWheel: true });
  110. }else{
  111. console.log(res.msg);
  112. }
  113. })
  114. }
  115. })()