console.js 12 KB

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