console.js 12 KB

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