home.js 6.9 KB

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