home.js 7.4 KB

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