home.js 7.3 KB

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