home.js 7.1 KB

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