console.js 13 KB

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