console.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. const $ = require('jquery');
  2. require("../css/reset.less")
  3. require("../css/console.less")
  4. require("../images/logo.png")
  5. // import 'zrender/lib/svg/svg';
  6. const echarts = require('echarts');
  7. const {post,setCookie,delCookie} = require('../js/utils.js');
  8. $(function(){
  9. // var mySwiper = new Swiper('.swiper-container',{
  10. // // autoplay : 500,//可选选项,自动滑动
  11. // loop : true,//可选选项,开启循环
  12. // slidesPerView : 3,
  13. // })
  14. $(".partWrap").css({
  15. height:$(window).height()-38+'px'
  16. })
  17. initConsole()//质控列表
  18. getBarData()//图标数据获取
  19. dateChange()
  20. // $(window).click(function(){
  21. // window.parent.userActionHide()
  22. // })
  23. })
  24. //所有数据切换日期筛选
  25. function dateChange(){
  26. $(".monthYear .mon").click(function(){
  27. $(this).css({
  28. backgroundColor:'#5A8EEE',
  29. color:'#fff'
  30. }).siblings().css({
  31. color:'#5A8EEE',
  32. backgroundColor:'#fff'
  33. })
  34. getBarData(1)
  35. })
  36. $(".monthYear .year").click(function(){
  37. $(this).css({
  38. backgroundColor:'#5A8EEE',
  39. color:'#fff'
  40. }).siblings().css({
  41. color:'#5A8EEE',
  42. backgroundColor:'#fff'
  43. })
  44. getBarData(2)
  45. })
  46. }
  47. //控制台数
  48. function initConsole(result){
  49. let url = {
  50. '本月病历数':require("../images/icon6.png"),
  51. '本月不合格病历-机器':require("../images/icon7.png"),
  52. '本月质控数-机器':require("../images/icon10.png"),
  53. '本月甲级病历-机器':require("../images/icon8.png"),
  54. '本月乙级病历-机器':require("../images/icon9.png"),
  55. '本年病历数':require("../images/icon6.png"),
  56. '本年不合格病历-机器':require("../images/icon7.png"),
  57. '本年质控数-机器':require("../images/icon10.png"),
  58. '本年甲级病历-机器':require("../images/icon8.png"),
  59. '本年乙级病历-机器':require("../images/icon9.png"),
  60. }
  61. let dom = '';
  62. for(let i in result){
  63. if(i.indexOf("人工")==-1){
  64. let name = i.split("-")[0];
  65. let num = 0;
  66. if(name=='本月病历数'||name=='本年病历数'){
  67. num = result[i]
  68. }else{
  69. num = result[name+'-人工']+result[i]
  70. }
  71. dom += `
  72. <li class="partLi">
  73. <div class="partIn">
  74. <p class="top">${name}</p>
  75. <p class="btm clearfix">
  76. <img src="${url[i]}" alt="">
  77. <span>${num}</span>
  78. </p>
  79. </div>
  80. </li>
  81. `
  82. }
  83. }
  84. $(".partAll").html(dom)
  85. }
  86. //获取图表数据
  87. function getBarData(type){
  88. post('/console/mrStatistics',{
  89. "type": type||1//1月2年
  90. }).then((res)=>{
  91. let data = res.data;
  92. if(data.code == 0){
  93. let result = data.data
  94. initConsole(result)
  95. }
  96. })
  97. post('/console/averageStatistics',{//柱状数据
  98. type:type||1
  99. }).then((res)=>{
  100. let data = res.data;
  101. if(data.code == 0){
  102. let result1 = data.data['平均住院费用']
  103. let result2 = data.data['平均住院日']
  104. let dataX1=[],dataY1=[],dataX2=[],dataY2=[];
  105. for(let i = 0;i < result1.length;i++){
  106. dataX1.push(result1[i].deptName)
  107. dataY1.push(result1[i].averageValue)
  108. }
  109. for(let i = 0;i < result2.length;i++){
  110. dataX2.push(result2[i].deptName)
  111. dataY2.push(result2[i].averageValue)
  112. }
  113. barChartPay(dataX1,dataY1)
  114. barChart(dataX2,dataY2)
  115. }
  116. })
  117. post('/console/resultStatistics',{//饼图数据
  118. type:type||1
  119. }).then((res)=>{
  120. let data = res.data;
  121. if(data.code == 0){
  122. let result1 = data.data['缺陷排行列表']
  123. let result2 = data.data['各科室缺陷占比']
  124. for(let i = 0;i < result2.length;i++){
  125. result2[i].value = result2[i].num
  126. }
  127. queList(result1)
  128. emptyCircle(result2)
  129. panDetail(result2)
  130. }
  131. })
  132. }
  133. //柱状图住院费用
  134. function barChartPay(dataX,dataY){
  135. var myCharts = echarts.init(document.getElementById('barChartPay'));
  136. var lengthNum = dataX.length;
  137. $(window).resize(function(){
  138. myCharts.resize()
  139. });
  140. option = {
  141. color: ['#3398DB'],
  142. tooltip: {
  143. trigger: 'axis',
  144. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  145. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  146. }
  147. },
  148. grid: {
  149. left: '3%',
  150. right: '4%',
  151. bottom: '3%',
  152. containLabel: true
  153. },
  154. xAxis: [
  155. {
  156. type: 'category',
  157. data: dataX,
  158. axisTick: {
  159. alignWithLabel: true
  160. },
  161. axisLabel: {//x轴刻度
  162. textStyle: {
  163. color: '#333'
  164. },
  165. rotate:lengthNum>8?30:0
  166. },
  167. axisLine: {//x轴
  168. lineStyle:{
  169. color:'#AAAAAA'
  170. }
  171. }
  172. }
  173. ],
  174. yAxis: [
  175. {
  176. type: 'value',
  177. axisLine: {//y轴
  178. show: false
  179. },
  180. axisTick: {
  181. show: false
  182. },
  183. axisLabel: {//y轴刻度
  184. textStyle: {
  185. color: '#333333'
  186. }
  187. },
  188. splitLine:{//分割线
  189. lineStyle:{
  190. color:'#EFF3FC'
  191. }
  192. }
  193. }
  194. ],
  195. title:[{
  196. text: '平均住院费用',
  197. top: 15,
  198. left: 10,
  199. textStyle: {
  200. fontSize: 14,
  201. color:'#666666',
  202. fontWeight: 400
  203. }
  204. }],
  205. series: [
  206. {
  207. name: '平均住院费用',
  208. type: 'bar',
  209. barWidth: lengthNum<5?'8%':'23%',
  210. data: dataY
  211. }
  212. ]
  213. };
  214. myCharts.setOption(option);
  215. }
  216. //柱状图住院日期
  217. function barChart(dataX,dataY){
  218. var myChart = echarts.init(document.getElementById('barChart'));
  219. var lengthNum = dataX.length;
  220. $(window).resize(function(){
  221. myChart.resize()
  222. });
  223. option = {
  224. color: ['#3398DB'],
  225. tooltip: {
  226. trigger: 'axis',
  227. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  228. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  229. }
  230. },
  231. grid: {
  232. left: '3%',
  233. right: '4%',
  234. bottom: '3%',
  235. containLabel: true
  236. },
  237. xAxis: [
  238. {
  239. type: 'category',
  240. data: dataX,
  241. axisTick: {
  242. alignWithLabel: true
  243. },
  244. axisLabel: {//x轴刻度
  245. textStyle: {
  246. color: '#333'
  247. },
  248. rotate:lengthNum>8?30:0
  249. },
  250. axisLine: {//x轴
  251. lineStyle:{
  252. color:'#AAAAAA'
  253. }
  254. }
  255. }
  256. ],
  257. yAxis: [
  258. {
  259. type: 'value',
  260. axisLine: {//y轴
  261. show: false
  262. },
  263. axisTick: {
  264. show: false
  265. },
  266. axisLabel: {//y轴刻度
  267. textStyle: {
  268. color: '#333333'
  269. }
  270. },
  271. splitLine:{//分割线
  272. lineStyle:{
  273. color:'#EFF3FC'
  274. }
  275. }
  276. }
  277. ],
  278. title:[{
  279. text: '平均住院日',
  280. top: 15,
  281. left: 10,
  282. textStyle: {
  283. fontSize: 14,
  284. color:'#666666',
  285. fontWeight: 400
  286. }
  287. }],
  288. series: [
  289. {
  290. name: '平均住院日',
  291. type: 'bar',
  292. barWidth: lengthNum<5?'8%':'23%',
  293. data: dataY
  294. }
  295. ]
  296. };
  297. myChart.setOption(option);
  298. }
  299. //空心饼图
  300. function emptyCircle(data){
  301. var myChart = echarts.init(document.getElementById('emptyCircle'));
  302. $(window).resize(function(){
  303. myChart.resize()
  304. });
  305. let bgColor = '#fff';
  306. let title = '总量';
  307. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  308. let echartData = data;
  309. let total = 0;
  310. for(let i = 0;i < echartData.length;i++){
  311. total += echartData[i].num
  312. }
  313. option = {
  314. backgroundColor: bgColor,
  315. color: color,
  316. title: [{
  317. text: data.length>0?'{val|' + total + '}\n{name|' + title + '}':'',
  318. top: 'center',
  319. left: 'center',
  320. textStyle: {
  321. rich: {
  322. val: {
  323. fontSize: 24,
  324. color: '#333',
  325. fontWeight: 'bold',
  326. padding: [10, 0]
  327. },
  328. name: {
  329. fontSize: 12,
  330. fontWeight: 'normal',
  331. color: '#777',
  332. }
  333. }
  334. }
  335. }],
  336. tooltip: {
  337. trigger: 'item',
  338. formatter: '{b} : {c} ({d}%)'
  339. },
  340. series: [{
  341. name: '',
  342. type: 'pie',
  343. radius: ['70%', '90%'],
  344. data: echartData,
  345. hoverAnimation:true,
  346. hoverOffset:5,
  347. itemStyle: {
  348. normal: {
  349. borderColor: bgColor,
  350. borderWidth: 2
  351. }
  352. },
  353. labelLine: {
  354. normal: {
  355. length: 20,
  356. length2: 120,
  357. lineStyle: {
  358. color: '#e6e6e6'
  359. }
  360. }
  361. },
  362. label: {
  363. normal: {
  364. show:false,
  365. formatter: params => {
  366. return params.name == 'A类'?params.name:''
  367. },
  368. padding: [0 , -100, 25, -100],
  369. rich: {
  370. icon: {
  371. fontSize: 16
  372. },
  373. name: {
  374. fontSize: 14,
  375. padding: [0, 10, 0, 4],
  376. color: '#666666'
  377. },
  378. value: {
  379. fontSize: 18,
  380. fontWeight: 'bold',
  381. color: '#333333'
  382. }
  383. }
  384. }
  385. },
  386. }]
  387. };
  388. myChart.setOption(option);
  389. }
  390. //缺陷列表渲染
  391. function queList(data){
  392. let strAll = '',tmp = `
  393. <tr class="thead">
  394. <td class="td01">排名</td>
  395. <td class="td02">缺陷名称</td>
  396. <td class="td03">数量</td>
  397. <td class="td04">占比</td>
  398. </tr>`
  399. for(let i = 0;i < data.length;i++){
  400. strAll += `
  401. <tr>
  402. <td style="text-align:center;"><i style="background:${i < 3?'#bea571':'#eff3fc'};color:${i < 3?'#fff':'#999'};">${i+1}</i></td>
  403. <td>${data[i].name}</td>
  404. <td>${data[i].num}</td>
  405. <td>${data[i].percentStr}</td>
  406. </tr>
  407. `
  408. }
  409. $(".qtable").html(tmp+strAll)
  410. }
  411. //饼图列表注释渲染
  412. function panDetail(data){
  413. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  414. let strAll = '';
  415. for(let i = 0;i < data.length;i++){
  416. strAll += `
  417. <tr class="explainLi">
  418. <td class="deptName"><i class="tip" style="background-color:${color[i]}"></i>${data[i].name}</td>
  419. <td class="deptNum">${data[i].num}</td>
  420. <td class="percent">(${data[i].percentStr})</td>
  421. </tr>
  422. `
  423. }
  424. $(".explainPan table").html(strAll);
  425. $(".explainPan").css({
  426. marginTop:-($(".explainPan").height()/2-20)+'px'
  427. })
  428. }