home.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. new Vue({
  2. el: '#main',
  3. data: {
  4. roles: [],
  5. selectedRole: "",
  6. isopen: true,
  7. signAnalysis: [{
  8. photo: '../../../images/qianyujingzhan_icon.png',
  9. label: '签约进展',
  10. url: 'sign-progress.html'
  11. }, {
  12. photo: '../../../images/xuqianjingzhan_icon.png',
  13. label: '续签进展',
  14. url: 'renew-progress.html'
  15. }, {
  16. photo: '../../../images/jumingfenxi_icon.png',
  17. label: '居民分析',
  18. url: 'resident-analysis.html'
  19. }, {
  20. photo: '../../../images/tuigaiqian_icon.png',
  21. label: '退改签',
  22. url: 'change-back.html'
  23. }, {
  24. photo: '../../../images/lianglvfenxi_icon.png',
  25. label: '两率分析',
  26. url: 'two-rate-analysis.html'
  27. }],
  28. serviceAnalysis: [{
  29. photo: '../../../images/zongtifenxi_icon.png',
  30. label: '总体分析',
  31. url: 'comprehensive-analysis.html'
  32. }, {
  33. photo: '../../../images/zixunfenxi_icon.png',
  34. label: '咨询分析',
  35. url: 'consulting-analysis.html'
  36. }, {
  37. photo: '../../../images/pijianfenxi_icon.png',
  38. label: '评价分析',
  39. url: 'estimate-analysis.html'
  40. }, {
  41. photo: '../../../images/changcufangfenxi_icon.png',
  42. label: '长处方分析',
  43. url: 'prescription-analysis.html'
  44. }],
  45. signRateData: {
  46. signTask: {
  47. text: '',
  48. rate: '0.00',
  49. sign: 0,
  50. people: 0
  51. },
  52. sign: {
  53. text: '',
  54. rate: '0.00',
  55. sign: 0,
  56. people: 0
  57. },
  58. renew: {
  59. text: '',
  60. rate: '0.00',
  61. sign: 0,
  62. people: 0
  63. }
  64. }
  65. },
  66. methods: {
  67. open: function() {
  68. EventBus.$emit('open-click', {});
  69. },
  70. showDetail: function(url) {
  71. window.location.href = url;
  72. },
  73. goToPage: function(val){
  74. var url = "sign-progress.html";
  75. if(val == 2){
  76. url = "renew-progress.html";
  77. }
  78. window.location.href = url;
  79. }
  80. },
  81. mounted: function() {
  82. //获取缓存里面的userRole
  83. var roles = window.sessionStorage.getItem("userRole");
  84. //如果没有缓存userRole,则说明是第一次进入统计页面,需要重新请求患者信息
  85. if(!roles){
  86. var vm = this;
  87. httpRequest.getDoctorInfo().then(function(res){
  88. var docInfo = res.data,
  89. userRole = docInfo.userRole;
  90. window.sessionStorage.setItem("userRole", JSON.stringify(userRole));
  91. window.sessionStorage.setItem("docInfo", JSON.stringify(docInfo));
  92. vm.roles = userRole;
  93. vm.selectedRole = userRole[0].code;
  94. var selected = userRole[0];
  95. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  96. })
  97. }else{
  98. this.roles = JSON.parse(roles);
  99. var selected = window.sessionStorage.getItem("selectedRole");
  100. if(selected && selected!= "undefined") {
  101. this.selectedRole = JSON.parse(selected).code;
  102. } else {
  103. this.selectedRole = this.roles[0].code;
  104. var selected = this.roles[0];
  105. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  106. }
  107. }
  108. $("#main").removeClass("c-hide")
  109. },
  110. watch: {
  111. selectedRole: function(val) {
  112. var selected = _.findWhere(this.roles, {
  113. code: val
  114. });
  115. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  116. getSignData(this);
  117. }
  118. }
  119. })
  120. function getSignData(vm){
  121. var code = vm.selectedRole,
  122. now = new Date(),
  123. params = {
  124. area: code,
  125. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  126. endDate: now.format("yyyy-MM-dd")
  127. };
  128. statisticAPI.getSignInfo(params).then(function(res){
  129. if(res.status == 200){
  130. var data = res.data;
  131. vm.signRateData = {
  132. signTask: {
  133. text: formatRate(data.signTaskRate.rate),
  134. rate: '0.00',
  135. sign: data.signTaskRate.sign,
  136. people: data.signTaskRate.people
  137. },
  138. sign: {
  139. text: formatRate(data.signRate.rate),
  140. rate: '0.00',
  141. sign: data.signRate.sign,
  142. people: data.signRate.people
  143. },
  144. renew: {
  145. text: data.renewRange,
  146. rate: '0.00',
  147. sign: data.renew.split("/")[0],
  148. people: data.renew.split("/")[1]
  149. }
  150. }
  151. var val1 = data.signRate.people - data.signRate.sign,
  152. val2 = data.signTaskRate.people - data.signTaskRate.sign;
  153. var signArr = [
  154. {name: "签约数", value: data.signRate.sign},
  155. {name: "未签约数", value: val1 >0 ? val1 : 0},
  156. ],
  157. signTaskArr = [
  158. {name: "签约数", value: data.signTaskRate.sign},
  159. {name: "未达标数", value: val2 >0 ? val2 : 0 }
  160. ],
  161. val = data.renew.split("/")[1] - data.renew.split("/")[0],
  162. renewArr = [
  163. {name: "续签数", value: data.renew.split("/")[0]},
  164. {name: "未达标数", value: val<0 ? 0 : val}
  165. ],
  166. color = ['#12b7f5', '#EBEBF5'];
  167. var signChart = drawPieChart("signMain", signArr, color, true);
  168. var completeChart = drawPieChart("completeMain", signTaskArr, color, true);
  169. var renewChart = drawPieChart("renewMain", renewArr, color, true);
  170. window.onresize = function() {
  171. signChart.resize();
  172. completeChart.resize();
  173. renewChart.resize();
  174. }
  175. }else{
  176. console.log(res.msg);
  177. }
  178. })
  179. }
  180. function formatRate(str){
  181. var val = parseFloat(str);
  182. return val.toFixed(2)+"%";
  183. }