home.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. dataQuery: [{
  104. photo: '../../../images/shujudaochu_icon.png',
  105. label: '数据查询',
  106. url: 'comprehensive-query.html',
  107. allowArea:"",
  108. },{
  109. photo: '../../../images/weijishihuifu_icon.png',
  110. label: '咨询未及时回复',
  111. url: 'consult-not-reply.html',
  112. allowArea:"",
  113. },
  114. {
  115. photo: '../../../images/icon-baobiao.png',
  116. label: '年度考核报表',
  117. url: 'annual-appraisal-report.html',
  118. allowArea:"",
  119. },
  120. ],
  121. paramValue:'',
  122. paramType:'',
  123. isGugan: false,
  124. },
  125. methods: {
  126. open: function() {
  127. EventBus.$emit('open-click', {});
  128. },
  129. showDetail: function(url) {
  130. window.location.href = url;
  131. },
  132. goToPage: function(val){
  133. var url = "sign-progress.html";
  134. if(val == 2){
  135. url = "renew-progress.html";
  136. }else if(val == 3){
  137. url = "comprehensive-query.html";
  138. }
  139. window.location.href = url;
  140. },
  141. userRoleData:function(v) {
  142. var vm = this
  143. var roles = window.sessionStorage.getItem("userRole");
  144. //如果没有缓存userRole,则说明是第一次进入统计页面,需要重新请求患者信息
  145. // if(!roles){
  146. var vm = this;
  147. httpRequest.getDoctorInfo().then(function(res){
  148. var docInfo = res.data,
  149. userRole = docInfo.userRole;
  150. if(docInfo.expandLevelName){
  151. vm.isGugan = docInfo.expandLevelName.indexOf("慢病骨干")>-1
  152. }
  153. _.each(userRole,function(item,index){
  154. if(item.areas!="350200"){
  155. item.roleType='2'
  156. }
  157. })
  158. if(docInfo.specialistRole&&docInfo.specialistRole.length){ //如果有专科权限
  159. _.each(docInfo.specialistRole,function(item,index){
  160. var hasIndex = _.findIndex(userRole,{areas:item.areas})
  161. if(hasIndex == -1){ //去重
  162. item.roleType='1'
  163. userRole.push(item)
  164. }
  165. })
  166. }
  167. if(userRole.length>0){
  168. window.sessionStorage.setItem("userRole", JSON.stringify(userRole));
  169. window.localStorage.setItem("docInfo", JSON.stringify(docInfo))
  170. window.sessionStorage.setItem("docInfo", JSON.stringify(docInfo));
  171. vm.roles = userRole;
  172. vm.selectedRole = vm.getHighestRole(userRole).code;
  173. var selected = vm.getHighestRole(userRole);
  174. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  175. $("#main").removeClass("c-hide")
  176. }else if(vm.isGugan){
  177. window.localStorage.setItem("docInfo", JSON.stringify(docInfo))
  178. window.sessionStorage.setItem("docInfo", JSON.stringify(docInfo));
  179. var selected = {
  180. code: docInfo.town,
  181. areas: docInfo.town,
  182. name: docInfo.hospitalName
  183. }
  184. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  185. $("#main").removeClass("c-hide")
  186. }
  187. if(userRole.length==0&&docInfo.specialistRole&&docInfo.specialistRole.length==0&&!vm.isGugan){
  188. top.toastr.warning("您没有权限查看该页面");
  189. }
  190. })
  191. // }else{
  192. // this.roles = JSON.parse(roles);
  193. // if(this.roles.length>0){
  194. // var selected = window.sessionStorage.getItem("selectedRole");
  195. // if(selected && selected!= "undefined") {
  196. // this.selectedRole = JSON.parse(selected).code;
  197. // } else {
  198. // this.selectedRole = this.roles[0].code;
  199. // var selected = this.roles[0];
  200. // window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  201. // }
  202. // $("#main").removeClass("c-hide")
  203. // }else{
  204. // top.toastr.warning("您没有权限查看该页面");
  205. // }
  206. // }
  207. },
  208. paramClick:function(v) {
  209. if(v == 'ztfx') {
  210. this.showDetail(this.serviceAnalysis[0].url)
  211. }else if(v == 'zxfx') {
  212. this.showDetail(this.serviceAnalysis[1].url)
  213. }else if(v == 'pjfx') {
  214. this.showDetail(this.serviceAnalysis[2].url)
  215. }else if(v == 'ccffx') {
  216. this.showDetail(this.serviceAnalysis[3].url)
  217. }else if(v == 'zffx') {
  218. this.showDetail(this.serviceAnalysis[4].url)
  219. }else if(v == 'smfw') {
  220. this.showDetail(this.serviceAnalysis[5].url)
  221. }else if(v == 'scfx') {
  222. this.showDetail(this.serviceAnalysis[6].url)
  223. }else if(v == 'zbfx') {
  224. if(this.paramType) {
  225. this.showDetail('special-analysis.html?type='+this.paramType)
  226. }else{
  227. this.showDetail(this.serviceAnalysis[7].url)
  228. }
  229. }else if(v == 'sjcx') {
  230. this.showDetail(this.dataQuery[0].url)
  231. }else if(v=='jkmzf'){
  232. this.showDetail('comprehensive-query.html?iSearch=1')
  233. }
  234. else if(v == 'ndkhbb') {
  235. this.showDetail(this.dataQuery[2].url)
  236. }else if(v == 'jmfx') {
  237. this.showDetail(this.signAnalysis[2].url)
  238. }else if(v == 'jkgl') {
  239. this.showDetail(this.signAnalysis[3].url)
  240. }else if(v == 'tgq') {
  241. this.showDetail(this.signAnalysis[4].url)
  242. }
  243. },
  244. getHighestRole(userRole){
  245. var vm = this
  246. var index = userRole.findIndex(function(item){return item.code.indexOf(350200)>-1 })
  247. if(index>-1){
  248. return userRole[index]
  249. }
  250. index = userRole.findIndex(function(item){return item.code.indexOf('jk_')>-1})
  251. if(index>-1){
  252. return userRole[index]
  253. }
  254. index = userRole.findIndex(function(item){return item.code.length == 6})
  255. if(index>-1){
  256. return userRole[index]
  257. }
  258. return userRole[0]
  259. }
  260. },
  261. mounted: function() {
  262. //获取缓存里面的userRole
  263. this.userRoleData()
  264. //TODO 发布删除这个
  265. // window.location.href = 'comprehensive-query.html'
  266. // 获取URL地址
  267. var url = window.location.href;
  268. // 获取参数部分
  269. var params = url.split('?')[1];
  270. // 将参数部分转换为对象
  271. var paramsObj = {};
  272. if (params) {
  273. var paramsArr = params.split('&');
  274. for (var i = 0; i < paramsArr.length; i++) {
  275. var param = paramsArr[i].split('=');
  276. paramsObj[param[0]] = param[1];
  277. }
  278. }
  279. // 获取指定参数的值
  280. this.paramValue = paramsObj['name'];
  281. this.paramType = paramsObj['type'];
  282. },
  283. watch: {
  284. selectedRole: function(val) {
  285. var vm = this
  286. var selected = _.findWhere(this.roles, {
  287. code: val
  288. });
  289. window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  290. getSignData(this);
  291. console.log(this.selectedRole)
  292. if(vm.selectedRole) {
  293. vm.paramClick(vm.paramValue)
  294. }
  295. },
  296. // "paramValue":{
  297. // handler:function(v) {
  298. // this.paramClick(v)
  299. // },
  300. // },
  301. }
  302. })
  303. function getSignData(vm){
  304. var code = vm.selectedRole,
  305. now = new Date(),
  306. params = {
  307. area: code,
  308. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  309. endDate: now.format("yyyy-MM-dd")
  310. };
  311. statisticAPI.getSignInfo(params).then(function(res){
  312. if(res.status == 200){
  313. var data = res.data;
  314. vm.signRateData = {
  315. signTask: {
  316. text: formatRate(data.signTaskRate.rate),
  317. rate: '0.00',
  318. sign: data.signTaskRate.sign,
  319. people: data.signTaskRate.people
  320. },
  321. sign: {
  322. text: formatRate(data.signRate.rate),
  323. rate: '0.00',
  324. sign: data.signRate.sign,
  325. people: data.signRate.people
  326. },
  327. renew: {
  328. text: data.renewRange,
  329. rate: '0.00',
  330. sign: data.renew.split("/")[0],
  331. people: data.renew.split("/")[1]
  332. }
  333. }
  334. var val1 = data.signRate.people - data.signRate.sign,
  335. val2 = data.signTaskRate.people - data.signTaskRate.sign;
  336. var signArr = [
  337. {name: "签约数", value: data.signRate.sign},
  338. {name: "未签约数", value: val1 >0 ? val1 : 0},
  339. ],
  340. signTaskArr = [
  341. {name: "签约数", value: data.signTaskRate.sign},
  342. {name: "未达标数", value: val2 >0 ? val2 : 0 }
  343. ],
  344. val = data.renew.split("/")[1] - data.renew.split("/")[0],
  345. renewArr = [
  346. {name: "续签数", value: data.renew.split("/")[0]},
  347. {name: "未达标数", value: val<0 ? 0 : val}
  348. ],
  349. color = ['#12b7f5', '#EBEBF5'];
  350. var signChart = drawPieChart("signMain", signArr, color, true);
  351. var completeChart = drawPieChart("completeMain", signTaskArr, color, true);
  352. var renewChart = drawPieChart("renewMain", renewArr, color, true);
  353. window.onresize = function() {
  354. signChart.resize();
  355. completeChart.resize();
  356. renewChart.resize();
  357. }
  358. }else{
  359. console.log(res.msg);
  360. }
  361. })
  362. }
  363. function formatRate(str){
  364. var val = parseFloat(str);
  365. return val.toFixed(2)+"%";
  366. }