home.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. new Vue({
  2. el: '#main',
  3. data: {
  4. roles: [],
  5. selectedRole: '',
  6. isopen: true,
  7. signAnalysis: [
  8. {
  9. photo: '../../../images/qianyujingzhan_icon.png',
  10. label: '签约进展',
  11. url: 'sign-progress.html',
  12. allowArea: ''
  13. },
  14. {
  15. photo: '../../../images/xuqianjingzhan_icon.png',
  16. label: '续签进展',
  17. url: 'renew-progress.html',
  18. allowArea: ''
  19. },
  20. {
  21. photo: '../../../images/jumingfenxi_icon.png',
  22. label: '居民分析',
  23. url: 'resident-analysis.html',
  24. allowArea: ''
  25. },
  26. {
  27. photo: '../../../images/jiankangguanli_icon.png',
  28. label: '健康管理',
  29. url: 'health-management-analysis.html',
  30. allowArea: ''
  31. },
  32. {
  33. photo: '../../../images/tuigaiqian_icon.png',
  34. label: '退改签',
  35. url: 'change-back.html',
  36. allowArea: ''
  37. },
  38. {
  39. photo: '../../../images/lianglvfenxi_icon.png',
  40. label: '两率分析',
  41. url: 'two-rate-analysis.html',
  42. allowArea: ''
  43. }
  44. ],
  45. serviceAnalysis: [
  46. {
  47. photo: '../../../images/zongtifenxi_icon.png',
  48. label: '总体分析',
  49. url: 'comprehensive-analysis.html',
  50. allowArea: ''
  51. },
  52. {
  53. photo: '../../../images/zixunfenxi_icon.png',
  54. label: '咨询分析',
  55. url: 'consulting-analysis.html',
  56. allowArea: ''
  57. },
  58. {
  59. photo: '../../../images/pijianfenxi_icon.png',
  60. label: '评价分析',
  61. url: 'estimate-analysis.html',
  62. allowArea: ''
  63. },
  64. {
  65. photo: '../../../images/changcufangfenxi_icon.png',
  66. label: '长处方分析',
  67. url: 'prescription-analysis.html',
  68. allowArea: ''
  69. },
  70. {
  71. photo: '../../../images/zhufufenxi_icon_pc.png',
  72. label: '祝福分析',
  73. url: 'blessing-analysis.html',
  74. allowArea: ''
  75. },
  76. {
  77. photo: '../../../images/shangmenfuwu_icon.png',
  78. label: '上门服务',
  79. url: 'smfw-analysis.html',
  80. allowArea: ''
  81. },
  82. {
  83. photo: '../../../images/shaichafenxin_icon.png',
  84. label: '筛查分析',
  85. url: 'jbsc-analysis.html',
  86. allowArea: ''
  87. },
  88. {
  89. photo: '../../../images/zhuanbingfenxi_icon.png',
  90. label: '专病分析',
  91. url: 'special-analysis.html',
  92. allowArea: ''
  93. }
  94. ],
  95. signRateData: {
  96. signTask: {
  97. text: '',
  98. rate: '0.00',
  99. sign: 0,
  100. people: 0
  101. },
  102. sign: {
  103. text: '',
  104. rate: '0.00',
  105. sign: 0,
  106. people: 0
  107. },
  108. renew: {
  109. text: '',
  110. rate: '0.00',
  111. sign: 0,
  112. people: 0
  113. }
  114. },
  115. dataQuery: [
  116. {
  117. photo: '../../../images/shujudaochu_icon.png',
  118. label: '数据查询',
  119. url: 'comprehensive-query.html',
  120. allowArea: ''
  121. },
  122. {
  123. photo: '../../../images/weijishihuifu_icon.png',
  124. label: '咨询未及时回复',
  125. url: 'consult-not-reply.html',
  126. allowArea: ''
  127. },
  128. {
  129. photo: '../../../images/icon-baobiao.png',
  130. label: '年度考核报表',
  131. url: 'annual-appraisal-report.html',
  132. allowArea: ''
  133. }
  134. ],
  135. paramValue: '',
  136. paramType: '',
  137. isGugan: false
  138. },
  139. methods: {
  140. open: function () {
  141. EventBus.$emit('open-click', {})
  142. },
  143. showDetail: function (url) {
  144. window.location.href = url
  145. },
  146. goToPage: function (val) {
  147. var url = 'sign-progress.html'
  148. if (val == 2) {
  149. url = 'renew-progress.html'
  150. } else if (val == 3) {
  151. url = 'comprehensive-query.html'
  152. }
  153. window.location.href = url
  154. },
  155. userRoleData: function (v) {
  156. var vm = this
  157. var roles = window.sessionStorage.getItem('userRole')
  158. //如果没有缓存userRole,则说明是第一次进入统计页面,需要重新请求患者信息
  159. // if(!roles){
  160. var vm = this
  161. httpRequest.getDoctorInfo().then(function (res) {
  162. var docInfo = res.data,
  163. userRole = docInfo.userRole
  164. if (docInfo.expandLevelName) {
  165. vm.isGugan = docInfo.expandLevelName.indexOf('慢病骨干') > -1
  166. }
  167. _.each(userRole, function (item, index) {
  168. if (item.areas != '350200') {
  169. item.roleType = '2'
  170. }
  171. })
  172. if (docInfo.specialistRole && docInfo.specialistRole.length) {
  173. //如果有专科权限
  174. _.each(docInfo.specialistRole, function (item, index) {
  175. var hasIndex = _.findIndex(userRole, { areas: item.areas })
  176. if (hasIndex == -1) {
  177. //去重
  178. item.roleType = '1'
  179. userRole.push(item)
  180. }
  181. })
  182. }
  183. if (userRole.length > 0) {
  184. window.sessionStorage.setItem('userRole', JSON.stringify(userRole))
  185. window.localStorage.setItem('docInfo', JSON.stringify(docInfo))
  186. window.sessionStorage.setItem('docInfo', JSON.stringify(docInfo))
  187. vm.roles = userRole
  188. vm.selectedRole = vm.getHighestRole(userRole).code
  189. var selected = vm.getHighestRole(userRole)
  190. window.sessionStorage.setItem('selectedRole', JSON.stringify(selected))
  191. $('#main').removeClass('c-hide')
  192. } else if (vm.isGugan) {
  193. window.localStorage.setItem('docInfo', JSON.stringify(docInfo))
  194. window.sessionStorage.setItem('docInfo', JSON.stringify(docInfo))
  195. var selected = {
  196. code: docInfo.town,
  197. areas: docInfo.town,
  198. name: docInfo.hospitalName
  199. }
  200. window.sessionStorage.setItem('selectedRole', JSON.stringify(selected))
  201. $('#main').removeClass('c-hide')
  202. }
  203. if (userRole.length == 0 && docInfo.specialistRole && docInfo.specialistRole.length == 0 && !vm.isGugan) {
  204. top.toastr.warning('您没有权限查看该页面')
  205. }
  206. })
  207. // }else{
  208. // this.roles = JSON.parse(roles);
  209. // if(this.roles.length>0){
  210. // var selected = window.sessionStorage.getItem("selectedRole");
  211. // if(selected && selected!= "undefined") {
  212. // this.selectedRole = JSON.parse(selected).code;
  213. // } else {
  214. // this.selectedRole = this.roles[0].code;
  215. // var selected = this.roles[0];
  216. // window.sessionStorage.setItem("selectedRole", JSON.stringify(selected));
  217. // }
  218. // $("#main").removeClass("c-hide")
  219. // }else{
  220. // top.toastr.warning("您没有权限查看该页面");
  221. // }
  222. // }
  223. },
  224. paramClick: function (v) {
  225. if (v == 'ztfx') {
  226. this.showDetail(this.serviceAnalysis[0].url)
  227. } else if (v == 'zxfx') {
  228. this.showDetail(this.serviceAnalysis[1].url)
  229. } else if (v == 'pjfx') {
  230. this.showDetail(this.serviceAnalysis[2].url)
  231. } else if (v == 'ccffx') {
  232. this.showDetail(this.serviceAnalysis[3].url)
  233. } else if (v == 'zffx') {
  234. this.showDetail(this.serviceAnalysis[4].url)
  235. } else if (v == 'smfw') {
  236. this.showDetail(this.serviceAnalysis[5].url)
  237. } else if (v == 'scfx') {
  238. this.showDetail(this.serviceAnalysis[6].url)
  239. } else if (v == 'zbfx') {
  240. if (this.paramType) {
  241. this.showDetail('special-analysis.html?type=' + this.paramType)
  242. } else {
  243. this.showDetail(this.serviceAnalysis[7].url)
  244. }
  245. } else if (v == 'sjcx') {
  246. this.showDetail(this.dataQuery[0].url)
  247. } else if (v == 'jkmzf') {
  248. this.showDetail('comprehensive-query.html?iSearch=1')
  249. } else if (v == 'gxb') {
  250. this.showDetail('comprehensive-query.html?selectType=gxb&iSearch=1')
  251. } else if (v == 'ndkhbb') {
  252. this.showDetail(this.dataQuery[2].url)
  253. } else if (v == 'jmfx') {
  254. this.showDetail(this.signAnalysis[2].url)
  255. } else if (v == 'jkgl') {
  256. this.showDetail(this.signAnalysis[3].url)
  257. } else if (v == 'tgq') {
  258. this.showDetail(this.signAnalysis[4].url)
  259. }
  260. },
  261. getHighestRole(userRole) {
  262. var vm = this
  263. var index = userRole.findIndex(function (item) {
  264. return item.code.indexOf(350200) > -1
  265. })
  266. if (index > -1) {
  267. return userRole[index]
  268. }
  269. index = userRole.findIndex(function (item) {
  270. return item.code.indexOf('jk_') > -1
  271. })
  272. if (index > -1) {
  273. return userRole[index]
  274. }
  275. index = userRole.findIndex(function (item) {
  276. return item.code.length == 6
  277. })
  278. if (index > -1) {
  279. return userRole[index]
  280. }
  281. return userRole[0]
  282. }
  283. },
  284. mounted: function () {
  285. //获取缓存里面的userRole
  286. this.userRoleData()
  287. //TODO 发布删除这个
  288. // window.location.href = 'comprehensive-query.html'
  289. // 获取URL地址
  290. var url = window.location.href
  291. // 获取参数部分
  292. var params = url.split('?')[1]
  293. // 将参数部分转换为对象
  294. var paramsObj = {}
  295. if (params) {
  296. var paramsArr = params.split('&')
  297. for (var i = 0; i < paramsArr.length; i++) {
  298. var param = paramsArr[i].split('=')
  299. paramsObj[param[0]] = param[1]
  300. }
  301. }
  302. // 获取指定参数的值
  303. this.paramValue = paramsObj['name']
  304. this.paramType = paramsObj['type']
  305. },
  306. watch: {
  307. selectedRole: function (val) {
  308. var vm = this
  309. var selected = _.findWhere(this.roles, {
  310. code: val
  311. })
  312. window.sessionStorage.setItem('selectedRole', JSON.stringify(selected))
  313. getSignData(this)
  314. console.log(this.selectedRole)
  315. if (vm.selectedRole) {
  316. vm.paramClick(vm.paramValue)
  317. }
  318. }
  319. // "paramValue":{
  320. // handler:function(v) {
  321. // this.paramClick(v)
  322. // },
  323. // },
  324. }
  325. })
  326. function getSignData(vm) {
  327. var code = vm.selectedRole,
  328. now = new Date(),
  329. params = {
  330. area: code,
  331. level: code == '350200' ? 4 : code.length == 6 ? 3 : 2,
  332. endDate: now.format('yyyy-MM-dd')
  333. }
  334. statisticAPI.getSignInfo(params).then(function (res) {
  335. if (res.status == 200) {
  336. var data = res.data
  337. vm.signRateData = {
  338. signTask: {
  339. text: formatRate(data.signTaskRate.rate),
  340. rate: '0.00',
  341. sign: data.signTaskRate.sign,
  342. people: data.signTaskRate.people
  343. },
  344. sign: {
  345. text: formatRate(data.signRate.rate),
  346. rate: '0.00',
  347. sign: data.signRate.sign,
  348. people: data.signRate.people
  349. },
  350. renew: {
  351. text: data.renewRange,
  352. rate: '0.00',
  353. sign: data.renew.split('/')[0],
  354. people: data.renew.split('/')[1]
  355. }
  356. }
  357. var val1 = data.signRate.people - data.signRate.sign,
  358. val2 = data.signTaskRate.people - data.signTaskRate.sign
  359. var signArr = [
  360. { name: '签约数', value: data.signRate.sign },
  361. { name: '未签约数', value: val1 > 0 ? val1 : 0 }
  362. ],
  363. signTaskArr = [
  364. { name: '签约数', value: data.signTaskRate.sign },
  365. { name: '未达标数', value: val2 > 0 ? val2 : 0 }
  366. ],
  367. val = data.renew.split('/')[1] - data.renew.split('/')[0],
  368. renewArr = [
  369. { name: '续签数', value: data.renew.split('/')[0] },
  370. { name: '未达标数', value: val < 0 ? 0 : val }
  371. ],
  372. color = ['#12b7f5', '#EBEBF5']
  373. var signChart = drawPieChart('signMain', signArr, color, true)
  374. var completeChart = drawPieChart('completeMain', signTaskArr, color, true)
  375. var renewChart = drawPieChart('renewMain', renewArr, color, true)
  376. window.onresize = function () {
  377. signChart.resize()
  378. completeChart.resize()
  379. renewChart.resize()
  380. }
  381. } else {
  382. console.log(res.msg)
  383. }
  384. })
  385. }
  386. function formatRate(str) {
  387. var val = parseFloat(str)
  388. return val.toFixed(2) + '%'
  389. }