home.js 7.7 KB

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