home.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. photo: '../../../images/zigetongji_icon.png',
  46. label: '资质分析',
  47. url: 'qualifications-analysis.html'
  48. }, {
  49. photo: '../../../images/buzhufeiyong_icon.png',
  50. label: '补助费用统计',
  51. url: 'subsidy-cost.html'
  52. }, {
  53. photo: '../../../images/gongdanfenxi_icon.png',
  54. label: '服务工单分析',
  55. url: 'service-sheet-analysis.html'
  56. }, {
  57. photo: '../../../images/xiangyinfenxi_icon.png',
  58. label: '响应速度分析',
  59. url: 'response-speed-analysis.html'
  60. }],
  61. signRateData: {
  62. signTask: {
  63. text: '',
  64. rate: '0.00',
  65. sign: 0,
  66. people: 0
  67. },
  68. sign: {
  69. text: '',
  70. rate: '0.00',
  71. sign: 0,
  72. people: 0
  73. },
  74. renew: {
  75. text: '',
  76. rate: '0.00',
  77. sign: 0,
  78. people: 0
  79. }
  80. }
  81. },
  82. methods: {
  83. open: function() {
  84. EventBus.$emit('open-click', {});
  85. },
  86. showDetail: function(url) {
  87. window.location.href = url;
  88. },
  89. goToPage: function(val){
  90. var url = "sign-progress.html";
  91. if(val == 2){
  92. url = "renew-progress.html";
  93. }
  94. window.location.href = url;
  95. }
  96. },
  97. mounted: function() {
  98. //获取缓存里面的userRole
  99. var roles = window.sessionStorage.getItem("userRole");
  100. //如果没有缓存userRole,则说明是第一次进入统计页面,需要重新请求患者信息
  101. if(!roles){
  102. var vm = this;
  103. httpRequest.getDoctorInfo().then(function(res){
  104. var docInfo = res.data,
  105. userRole = docInfo.userRole;
  106. window.sessionStorage.setItem("userRole", JSON.stringify(userRole));
  107. window.sessionStorage.setItem("docInfo", JSON.stringify(docInfo));
  108. vm.roles = userRole;
  109. vm.selectedRole = userRole[0].code;
  110. var selected = userRole[0];
  111. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  112. })
  113. }else{
  114. this.roles = JSON.parse(roles);
  115. var selected = window.sessionStorage.getItem("selectedRole");
  116. if(selected && selected!= "undefined") {
  117. this.selectedRole = JSON.parse(selected).code;
  118. } else {
  119. this.selectedRole = this.roles[0].code;
  120. var selected = this.roles[0];
  121. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  122. }
  123. }
  124. $("#main").removeClass("c-hide")
  125. },
  126. watch: {
  127. selectedRole: function(val) {
  128. var selected = _.findWhere(this.roles, {
  129. code: val
  130. });
  131. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  132. getSignData(this);
  133. }
  134. }
  135. })
  136. function getSignData(vm){
  137. var code = vm.selectedRole,
  138. now = new Date(),
  139. params = {
  140. area: code,
  141. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  142. endDate: now.format("yyyy-MM-dd")
  143. };
  144. statisticAPI.getSignInfo(params).then(function(res){
  145. if(res.status == 200){
  146. var data = res.data;
  147. vm.signRateData = {
  148. signTask: {
  149. text: formatRate(data.signTaskRate.rate),
  150. rate: '0.00',
  151. sign: data.signTaskRate.sign,
  152. people: data.signTaskRate.people
  153. },
  154. sign: {
  155. text: formatRate(data.signRate.rate),
  156. rate: '0.00',
  157. sign: data.signRate.sign,
  158. people: data.signRate.people
  159. },
  160. renew: {
  161. text: data.renewRange,
  162. rate: '0.00',
  163. sign: data.renew.split("/")[0],
  164. people: data.renew.split("/")[1]
  165. }
  166. }
  167. var val1 = data.signRate.people - data.signRate.sign,
  168. val2 = data.signTaskRate.people - data.signTaskRate.sign;
  169. var signArr = [
  170. {name: "签约数", value: data.signRate.sign},
  171. {name: "未签约数", value: val1 >0 ? val1 : 0},
  172. ],
  173. signTaskArr = [
  174. {name: "签约数", value: data.signTaskRate.sign},
  175. {name: "未达标数", value: val2 >0 ? val2 : 0 }
  176. ],
  177. val = data.renew.split("/")[1] - data.renew.split("/")[0],
  178. renewArr = [
  179. {name: "续签数", value: data.renew.split("/")[0]},
  180. {name: "未达标数", value: val<0 ? 0 : val}
  181. ],
  182. color = ['#12b7f5', '#EBEBF5'];
  183. var signChart = drawPieChart("signMain", signArr, color, true);
  184. var completeChart = drawPieChart("completeMain", signTaskArr, color, true);
  185. var renewChart = drawPieChart("renewMain", renewArr, color, true);
  186. window.onresize = function() {
  187. signChart.resize();
  188. completeChart.resize();
  189. renewChart.resize();
  190. }
  191. }else{
  192. console.log(res.msg);
  193. }
  194. })
  195. }
  196. function formatRate(str){
  197. var val = parseFloat(str);
  198. return val.toFixed(2)+"%";
  199. }