console.js 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. const $ = require('jquery');
  2. require("../css/reset.less")
  3. require("../css/console.less")
  4. require("../images/logo.png")
  5. require("../images/arrow_down.png")
  6. // import 'zrender/lib/svg/svg';
  7. const echarts = require('echarts');
  8. const {post,setCookie,delCookie,getCookie} = require('../js/utils.js');
  9. let payMoney = [],dayLis = [],dataType = 1;
  10. $(function(){
  11. if(!hasData('YH-KZT')){
  12. $("body").html('')
  13. }
  14. $(".partTitle p span").html(getCookie("hospital"))
  15. setInterval(() => {
  16. getTimeDetail()
  17. }, 1000);
  18. resizeBox()
  19. initConsole()//质控列表
  20. getBarData()//图标数据获取
  21. dateChange()
  22. $(window).click(function(){
  23. window.parent.userActionHide()
  24. $(".toggleSlide ul").css("display","none")
  25. })
  26. let sildeIS = true
  27. if(!hasData('FUNC000045')&&!hasData('FUNC000046')){
  28. $(".toggleSlide").css("opacity","0.5")
  29. sildeIS = false
  30. }
  31. $(".toggleSlide p").click(function(e){
  32. if(!sildeIS)return
  33. e.stopPropagation()
  34. $(this).next().slideToggle()
  35. })
  36. $(".toggleSlide li").click(function(){
  37. let str = $(this).attr("data-str"),type = $(this).attr("data-type")
  38. if(type == 1){
  39. if(!hasData('FUNC000045')){
  40. return
  41. }
  42. $(".pubEchart .title").html("科室平均住院天数柱状图")
  43. barChart(dayLis,dataType)
  44. }else{
  45. if(!hasData('FUNC000046')){
  46. return
  47. }
  48. $(".pubEchart .title").html("科室平均住院花费柱状图")
  49. barChart(payMoney,dataType)
  50. }
  51. $(this).parent().slideToggle().prev().find("span").html(str)
  52. })
  53. })
  54. //判断有无某一权限
  55. function hasData(data){
  56. let lis = JSON.parse(getCookie("codeLis"))
  57. // console.log(lis)
  58. if(lis.indexOf(data)>-1){//有权限
  59. return true
  60. }
  61. return false;
  62. }
  63. function resizeBox(){
  64. $(".partWrap").css({
  65. height:$(window).height()-38+'px'
  66. })
  67. }
  68. //所有数据切换日期筛选
  69. function dateChange(){
  70. $(".monthYear .mon").click(function(){
  71. $(this).css({
  72. backgroundColor:'#5A8EEE',
  73. color:'#fff'
  74. }).siblings().css({
  75. color:'#5A8EEE',
  76. backgroundColor:'#fff'
  77. })
  78. dataType = 1
  79. getBarData(1)
  80. })
  81. $(".monthYear .year").click(function(){
  82. $(this).css({
  83. backgroundColor:'#5A8EEE',
  84. color:'#fff'
  85. }).siblings().css({
  86. color:'#5A8EEE',
  87. backgroundColor:'#fff'
  88. })
  89. dataType = 2
  90. getBarData(2)
  91. })
  92. }
  93. //控制台数
  94. function initConsole(result){
  95. let url = {
  96. '本月病历数':require("../images/icon6.png"),
  97. '本月不合格病历-机器':require("../images/icon7.png"),
  98. '本月质控数-机器':require("../images/icon10.png"),
  99. '本月甲级病历-机器':require("../images/icon8.png"),
  100. '本月乙级病历-机器':require("../images/icon9.png"),
  101. '本年病历数':require("../images/icon6.png"),
  102. '本年不合格病历-机器':require("../images/icon7.png"),
  103. '本年质控数-机器':require("../images/icon10.png"),
  104. '本年甲级病历-机器':require("../images/icon8.png"),
  105. '本年乙级病历-机器':require("../images/icon9.png"),
  106. }
  107. let dom = '';
  108. for(let i in result){
  109. if(i.indexOf("人工")==-1){
  110. let name = i.split("-")[0];
  111. let num = 0;
  112. if(name=='本月病历数'||name=='本年病历数'){
  113. num = result[i]
  114. }else{
  115. num = result[name+'-人工']+result[i]
  116. }
  117. dom += `
  118. <li class="partLi">
  119. <div class="partIn">
  120. <p class="top">${name}</p>
  121. <p class="btm clearfix">
  122. <img src="${url[i]}" alt="">
  123. <span>${num}</span>
  124. </p>
  125. </div>
  126. </li>
  127. `
  128. }
  129. }
  130. $(".partAll").html(dom)
  131. }
  132. //获取图表数据
  133. function getBarData(type){
  134. if(hasData('FUNC000045')){
  135. post('/console/getAverageDayNum',{//平均住院天数
  136. "type": type||1//1月2年
  137. }).then((res)=>{
  138. let data = res.data;
  139. if(data.code == 0){
  140. let result2 = data.data['平均住院日']||[]
  141. dayLis = result2
  142. barChart(result2,type||1)
  143. }
  144. })
  145. }else{
  146. $(".toggleSlide1").css("opacity",0.5)
  147. }
  148. if(hasData('FUNC000046')){
  149. post('/console/getAverageFee',{//平均住院费用
  150. "type": type||1//1月2年
  151. }).then((res)=>{
  152. let data = res.data;
  153. if(data.code == 0){
  154. let result3 = data.data['平均住院费用']||[]
  155. payMoney = result3;
  156. barChart(result2,type||1)
  157. }
  158. })
  159. }else{
  160. $(".toggleSlide2").css("opacity",0.5)
  161. }
  162. if(hasData('FUNC000047')){
  163. post('/console/getAverageScore',{//各科室质控平均分
  164. "type": type||1//1月2年
  165. }).then((res)=>{
  166. let data = res.data;
  167. if(data.code == 0){
  168. let result1 = data.data['各科室质控平均分']||[]
  169. let dataX1=[],dataY1=[]
  170. for(let i = 0;i < result1.length;i++){
  171. dataX1.push(result1[i].name)
  172. dataY1.push(result1[i].averageValue)
  173. }
  174. barChartPay(dataX1,dataY1)
  175. }
  176. })
  177. }
  178. if(hasData('FUNC000048')){
  179. post('/console/getLevelResultDept',{//各科室甲级占比
  180. "type": type||1//1月2年
  181. }).then((res)=>{
  182. let data = res.data;
  183. if(data.code == 0){
  184. let result2 = data.data['各科室甲级病历占比']||[]
  185. let dataX2=[],dataY2=[];
  186. for(let i = 0;i < result2.length;i++){
  187. dataX2.push(result2[i].deptName)
  188. dataY2.push(result2[i].firstPercent.replace('%',''))
  189. }
  190. lineChart(dataX2,dataY2)
  191. }
  192. })
  193. }
  194. if(hasData('FUNC000049')){
  195. post('/console/leaveHosCount',{//出院人数统计
  196. "type": type||1//1月2年
  197. }).then((res)=>{
  198. let data = res.data;
  199. if(data.code == 0){
  200. // barChart(result2,type||1)
  201. // console.log(data)
  202. let result1 = data.data['出院人数统计']||[]
  203. personNum(result1)
  204. }
  205. })
  206. }
  207. if(hasData('FUNC000050')){
  208. post('/console/mrCount',{//质控病历统计
  209. "type": type||1//1月2年
  210. }).then((res)=>{
  211. let data = res.data
  212. if(data.code == 0){
  213. let result3 = data.data['病历数统计']||[]
  214. if(result3.length == 0){
  215. result3 = [
  216. {
  217. "id":null,
  218. "name":"累计质控病历数",
  219. "totleNum":0,
  220. "num":0,
  221. "percent":null,
  222. "percentStr":null
  223. },
  224. {
  225. "id":null,
  226. "name":"甲级病历",
  227. "totleNum":10,
  228. "num":0,
  229. "percent":0,
  230. "percentStr":"0.00%"
  231. },
  232. {
  233. "id":null,
  234. "name":"乙级病历",
  235. "totleNum":10,
  236. "num":0,
  237. "percent":0,
  238. "percentStr":"0.00%"
  239. },
  240. {
  241. "id":null,
  242. "name":"丙级病历",
  243. "totleNum":10,
  244. "num":0,
  245. "percent":0,
  246. "percentStr":"0.00%"
  247. }
  248. ]
  249. }
  250. setNumDetail(result3)
  251. }
  252. })
  253. }
  254. if(hasData('FUNC000051')){
  255. post('/console/entryCountGroupByCase',{//各模块缺陷占比排行
  256. "type": type||1//1月2年
  257. }).then((res)=>{
  258. let data = res.data;
  259. if(data.code == 0){
  260. let result1 = data.data['各模块缺陷占比排行']||[]
  261. queList(result1)
  262. }
  263. })
  264. }
  265. if(hasData('FUNC000052')){
  266. post('/console/entryCountGroupByEntry',{//条目缺陷占比
  267. "type": type||1//1月2年
  268. }).then((res)=>{
  269. let data = res.data;
  270. if(data.code == 0){
  271. let result3 = data.data['条目缺陷占比']||[]
  272. for(let i = 0;i < result3.length;i++){
  273. result3[i].value = result3[i].num
  274. }
  275. emptyCircleB(result3)
  276. panDetailB(result3)
  277. }
  278. })
  279. }
  280. if(hasData('FUNC000053')){
  281. post('/console/entryByDept',{//各科室缺陷占比
  282. "type": type||1//1月2年
  283. }).then((res)=>{
  284. let data = res.data;
  285. if(data.code == 0){
  286. let result2 = data.data['各科室缺陷占比']||[]
  287. for(let i = 0;i < result2.length;i++){
  288. result2[i].value = result2[i].num
  289. }
  290. emptyCircle(result2)
  291. panDetail(result2)
  292. }
  293. })
  294. }
  295. }
  296. //part01
  297. function personNum(data){
  298. $(".personNum").html("总人数:"+data['总人数'])
  299. $(".died").html(data['死亡人数'])
  300. $(".newborn").html(data['新生儿人数'])
  301. $(".patientNum").html(data['手术病人数'])
  302. }
  303. //part02
  304. function setNumDetail(data){
  305. // console.log(data,2222222222)
  306. if(data.length == 0)return
  307. let str = ''
  308. for(let i = 0;i < data.length;i++){
  309. str += `
  310. <li class="${i==0?'fst':''}">
  311. <p class="numShow">${data[i].num}</p>
  312. <p class="explainNum">${data[i].name}</p>
  313. </li>
  314. `
  315. if(data[i].name == '甲级病历'){
  316. let tmp = []
  317. data[i].value = data[i].num
  318. tmp.push(data[i])
  319. tmp.push({percentStr:(1-data[i].percent)*100+'%',value:data[i].totleNum - data[i].num})
  320. part02pan(tmp,'fen01')
  321. }
  322. if(data[i].name == '乙级病历'){
  323. let tmp = []
  324. data[i].value = data[i].num
  325. tmp.push(data[i])
  326. tmp.push({percentStr:(1-data[i].percent)*100+'%',value:data[i].totleNum - data[i].num})
  327. part02pan(tmp,'fen02')
  328. }
  329. if(data[i].name == '丙级病历'){
  330. let tmp = []
  331. data[i].value = data[i].num
  332. tmp.push(data[i])
  333. tmp.push({percentStr:(1-data[i].percent)*100+'%',value:data[i].totleNum - data[i].num})
  334. part02pan(tmp,'fen03')
  335. }
  336. }
  337. $('.bingli').html(str)
  338. }
  339. //part02pan
  340. function part02pan(data,dom){
  341. // console.log(data,33333)
  342. dom = echarts.init(document.getElementById(dom));
  343. $(window).resize(function(){
  344. dom.resize()
  345. });
  346. let bgColor = '#fff';
  347. let title = '总量';
  348. let color = ['#37CBCB','#dedede'];
  349. let echartData = data;
  350. option = {
  351. backgroundColor: bgColor,
  352. color: color,
  353. title: [{
  354. text:'{val|' + echartData[0].percentStr + '}',
  355. top: 'center',
  356. left: 'center',
  357. textStyle: {
  358. rich: {
  359. val: {
  360. fontSize: 14,
  361. color: '#333',
  362. fontWeight: 'bold',
  363. padding: [10, 0]
  364. },
  365. name: {
  366. fontSize: 12,
  367. fontWeight: 'normal',
  368. color: '#777',
  369. }
  370. }
  371. }
  372. }],
  373. series: [{
  374. name: '',
  375. type: 'pie',
  376. radius: ['70%', '90%'],
  377. data: echartData,
  378. hoverAnimation:false,
  379. label: {
  380. normal: {
  381. show:false,
  382. }
  383. },
  384. }]
  385. };
  386. dom.setOption(option);
  387. }
  388. //折现图
  389. function lineChart(dataX,dataY){
  390. var myCharts = echarts.init(document.getElementById('lineChart'));
  391. $(window).resize(function(){
  392. myCharts.resize()
  393. });
  394. option = {
  395. color:"#5A8EEE",
  396. tooltip: {
  397. trigger: 'axis',
  398. color:'#fff',
  399. formatter: function(param) {
  400. return '<div style="color:#fff;"> '+ param[0].name + "<br>" +"甲级病历占比:"+ param[0].value+"%" + "<br>"
  401. '</div>'
  402. }
  403. },
  404. grid: {
  405. left: '3%',
  406. right: '5%',
  407. bottom: '3%',
  408. containLabel: true
  409. },
  410. title:[{
  411. text: '百分比',
  412. top: 15,
  413. left: 0,
  414. textStyle: {
  415. fontSize: 14,
  416. color:'#666666',
  417. fontWeight: 400
  418. }
  419. }],
  420. toolbox: {
  421. show: false,
  422. feature: {
  423. dataZoom: {
  424. yAxisIndex: 'none'
  425. },
  426. dataView: {readOnly: false},
  427. magicType: {type: ['line', 'bar']},
  428. restore: {
  429. },
  430. saveAsImage: {}
  431. },
  432. emphasis:{
  433. iconStyle:{
  434. color:'red'
  435. }
  436. },
  437. },
  438. xAxis: {
  439. type: 'category',
  440. boundaryGap: false,
  441. data: dataX,
  442. axisLabel: {//x轴刻度
  443. textStyle: {
  444. color: '#333'
  445. },
  446. rotate:'45',
  447. formatter: function (value) {
  448. //x轴的文字改为竖版显示
  449. if(value.length>7){
  450. return value.slice(0,7)+'...'
  451. }
  452. return value;
  453. }
  454. },
  455. axisLine: {//x轴
  456. lineStyle:{
  457. color:'#AAAAAA'
  458. }
  459. }
  460. },
  461. yAxis: {
  462. type: 'value',
  463. axisLabel: {
  464. formatter: '{value} %',
  465. textStyle: {
  466. color: '#333333'
  467. }
  468. },
  469. axisLine: {//y轴
  470. show: false
  471. },
  472. axisTick: {
  473. show: false
  474. },
  475. splitLine:{//分割线
  476. lineStyle:{
  477. color:'#EFF3FC'
  478. }
  479. }
  480. },
  481. series: [
  482. {
  483. name: '甲级病历占比:',
  484. type: 'line',
  485. data: dataY,
  486. }
  487. ]
  488. };
  489. myCharts.setOption(option);
  490. }
  491. //柱状图住院费用
  492. function barChartPay(dataX,dataY){
  493. var myCharts = echarts.init(document.getElementById('barChartPay'));
  494. var lengthNum = dataX.length;
  495. $(window).resize(function(){
  496. myCharts.resize()
  497. });
  498. option = {
  499. color: ['#3398DB'],
  500. tooltip: {
  501. trigger: 'axis',
  502. position: 'right',
  503. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  504. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  505. }
  506. },
  507. grid: {
  508. left: '3%',
  509. right: '4%',
  510. bottom: '3%',
  511. containLabel: true
  512. },
  513. xAxis: [
  514. {
  515. type: 'category',
  516. data: dataX,
  517. axisTick: {
  518. alignWithLabel: true
  519. },
  520. axisLabel: {//x轴刻度
  521. textStyle: {
  522. color: '#333'
  523. },
  524. rotate:45,
  525. formatter: function (value) {
  526. //x轴的文字改为竖版显示
  527. if(value.length>7){
  528. return value.slice(0,7)+'...'
  529. }
  530. return value;
  531. }
  532. },
  533. axisLine: {//x轴
  534. lineStyle:{
  535. color:'#AAAAAA'
  536. }
  537. }
  538. }
  539. ],
  540. yAxis: [
  541. {
  542. type: 'value',
  543. axisLine: {//y轴
  544. show: false
  545. },
  546. axisTick: {
  547. show: false
  548. },
  549. axisLabel: {//y轴刻度
  550. textStyle: {
  551. color: '#333333'
  552. }
  553. },
  554. splitLine:{//分割线
  555. lineStyle:{
  556. color:'#EFF3FC'
  557. }
  558. }
  559. }
  560. ],
  561. title:[{
  562. text: '分数',
  563. top: 15,
  564. left: 10,
  565. textStyle: {
  566. fontSize: 14,
  567. color:'#666666',
  568. fontWeight: 400
  569. }
  570. }],
  571. series: [
  572. {
  573. name: '质控平均分',
  574. type: 'bar',
  575. barWidth: '23%',
  576. data: dataY
  577. }
  578. ]
  579. };
  580. myCharts.setOption(option);
  581. }
  582. //柱状图住院日期
  583. function barChart(data,type){
  584. var myChart = echarts.init(document.getElementById('barChart'));
  585. $(window).resize(function(){
  586. myChart.resize()
  587. });
  588. var posList = [
  589. 'left', 'right', 'top', 'bottom',
  590. 'inside',
  591. 'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
  592. 'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
  593. ];
  594. let app = {}
  595. app.configParameters = {
  596. rotate: {
  597. min: -90,
  598. max: 90
  599. },
  600. align: {
  601. options: {
  602. left: 'left',
  603. center: 'center',
  604. right: 'right'
  605. }
  606. },
  607. verticalAlign: {
  608. options: {
  609. top: 'top',
  610. middle: 'middle',
  611. bottom: 'bottom'
  612. }
  613. },
  614. position: {
  615. options: echarts.util.reduce(posList, function (map, pos) {
  616. map[pos] = pos;
  617. return map;
  618. }, {})
  619. },
  620. distance: {
  621. min: 0,
  622. max: 100
  623. }
  624. };
  625. app.config = {
  626. rotate: 90,
  627. align: 'left',
  628. verticalAlign: 'middle',
  629. position: 'insideBottom',
  630. distance: 15,
  631. onChange: function () {
  632. var labelOption = {
  633. normal: {
  634. rotate: app.config.rotate,
  635. align: app.config.align,
  636. verticalAlign: app.config.verticalAlign,
  637. position: app.config.position,
  638. distance: app.config.distance
  639. }
  640. };
  641. myChart.setOption({
  642. series: [{
  643. label: labelOption
  644. }, {
  645. label: labelOption
  646. }, {
  647. label: labelOption
  648. }, {
  649. label: labelOption
  650. }]
  651. });
  652. }
  653. };
  654. var labelOption = {
  655. show: false,
  656. position: app.config.position,
  657. distance: app.config.distance,
  658. align: app.config.align,
  659. verticalAlign: app.config.verticalAlign,
  660. rotate: app.config.rotate,
  661. formatter: '{c} {name|{a}}',
  662. fontSize: 12,
  663. rich: {
  664. name: {
  665. textBorderColor: '#fff'
  666. }
  667. }
  668. };
  669. let dataX = []
  670. let data1 = []
  671. let data2 = []
  672. let data3 = []
  673. for(let i = 0;i < data.length;i++){
  674. dataX.push(data[i].name)
  675. data1.push(data[i].averageValue)//本月
  676. data2.push(data[i].lastAverageValue)//本年
  677. data3.push(data[i].lastYearAverageValue)//去年本月
  678. }
  679. option = {
  680. color: ['#5A8EEE', '#FAD336', '#37CBCB'],
  681. tooltip: {
  682. trigger: 'axis',
  683. axisPointer: {
  684. type: 'shadow'
  685. }
  686. },
  687. grid: {
  688. left: '3%',
  689. right: '4%',
  690. bottom: '3%',
  691. containLabel: true
  692. },
  693. title:[{
  694. text: type==1?'天数':'元',
  695. top: 15,
  696. left: 10,
  697. textStyle: {
  698. fontSize: 14,
  699. color:'#666666',
  700. fontWeight: 400
  701. }
  702. }],
  703. legend: {
  704. itemWidth :10,
  705. itemHeight :10,
  706. right:15,
  707. top:15,
  708. selectedMode:false,
  709. formatter: function (name) {
  710. return name;
  711. }
  712. },
  713. toolbox: {
  714. show: false,
  715. orient: 'vertical',
  716. left: 'right',
  717. top: 'center',
  718. feature: {
  719. mark: {show: true},
  720. dataView: {show: true, readOnly: false},
  721. magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  722. restore: {show: true},
  723. saveAsImage: {show: true}
  724. }
  725. },
  726. xAxis: [
  727. {
  728. type: 'category',
  729. axisTick: {show: false},
  730. data: dataX,
  731. axisLabel: {//x轴刻度
  732. textStyle: {
  733. color: '#333'
  734. },
  735. rotate:'45',
  736. formatter: function (value) {
  737. //x轴的文字改为竖版显示
  738. if(value.length>7){
  739. return value.slice(0,7)+'...'
  740. }
  741. return value;
  742. }
  743. },
  744. axisLine: {//x轴
  745. lineStyle:{
  746. color:'#AAAAAA'
  747. }
  748. },
  749. }
  750. ],
  751. yAxis: [
  752. {
  753. type: 'value',
  754. axisLine: {//y轴
  755. show: false
  756. },
  757. axisTick: {
  758. show: false
  759. },
  760. splitLine:{//分割线
  761. lineStyle:{
  762. color:'#EFF3FC'
  763. }
  764. }
  765. }
  766. ],
  767. series: [
  768. {
  769. name: type==1?'上月':'',
  770. type: 'bar',
  771. barGap: 0,
  772. label: labelOption,
  773. barWidth: '15%',
  774. data: type==1?data2:[]
  775. },
  776. {
  777. name: type==1?'去年本月':'去年',
  778. type: 'bar',
  779. label: labelOption,
  780. barWidth: '15%',
  781. data: data3
  782. },
  783. {
  784. name: type==1?'本月':'本年',
  785. type: 'bar',
  786. label: labelOption,
  787. barWidth: '15%',
  788. data: data1
  789. }
  790. ]
  791. };
  792. myChart.setOption(option);
  793. }
  794. //空心饼图
  795. function emptyCircle(data){
  796. // console.log(data,1111111111)
  797. var myChart = echarts.init(document.getElementById('emptyCircle'));
  798. $(window).resize(function(){
  799. myChart.resize()
  800. });
  801. let bgColor = '#fff';
  802. let title = '总量';
  803. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  804. let echartData = data;
  805. let total = 0;
  806. for(let i = 0;i < echartData.length;i++){
  807. total += echartData[i].num
  808. }
  809. option = {
  810. backgroundColor: bgColor,
  811. color: color,
  812. title: [{
  813. text: data.length>0?'{val|' + total + '}\n{name|' + title + '}':'',
  814. top: 'center',
  815. left: 'center',
  816. textStyle: {
  817. rich: {
  818. val: {
  819. fontSize: 24,
  820. color: '#333',
  821. fontWeight: 'bold',
  822. padding: [10, 0]
  823. },
  824. name: {
  825. fontSize: 12,
  826. fontWeight: 'normal',
  827. color: '#777',
  828. }
  829. }
  830. }
  831. }],
  832. tooltip: {
  833. trigger: 'item',
  834. // formatter: '{b} : {c} ({d}%)',
  835. formatter:function(item){
  836. const {name, num, percentStr} = item.data
  837. return `${name} : ${num} (${percentStr})`
  838. }
  839. },
  840. series: [{
  841. name: '',
  842. type: 'pie',
  843. radius: ['70%', '90%'],
  844. data: echartData,
  845. hoverAnimation:true,
  846. hoverOffset:5,
  847. itemStyle: {
  848. normal: {
  849. borderColor: bgColor,
  850. borderWidth: 2
  851. }
  852. },
  853. labelLine: {
  854. normal: {
  855. length: 20,
  856. length2: 120,
  857. lineStyle: {
  858. color: '#e6e6e6'
  859. }
  860. }
  861. },
  862. label: {
  863. normal: {
  864. show:false,
  865. formatter: params => {
  866. return params.name == 'A类'?params.name:''
  867. },
  868. padding: [0 , -100, 25, -100],
  869. rich: {
  870. icon: {
  871. fontSize: 16
  872. },
  873. name: {
  874. fontSize: 14,
  875. padding: [0, 10, 0, 4],
  876. color: '#666666'
  877. },
  878. value: {
  879. fontSize: 18,
  880. fontWeight: 'bold',
  881. color: '#333333'
  882. }
  883. }
  884. }
  885. },
  886. }]
  887. };
  888. myChart.setOption(option);
  889. }
  890. function emptyCircleB(data){
  891. var myChart = echarts.init(document.getElementById('emptyCircleB'));
  892. $(window).resize(function(){
  893. myChart.resize()
  894. });
  895. let bgColor = '#fff';
  896. let title = '总量';
  897. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  898. let echartData = data;
  899. let total = 0;
  900. for(let i = 0;i < echartData.length;i++){
  901. total += echartData[i].num
  902. }
  903. option = {
  904. backgroundColor: bgColor,
  905. color: color,
  906. title: [{
  907. text: data.length>0?'{val|' + total + '}\n{name|' + title + '}':'',
  908. top: 'center',
  909. left: 'center',
  910. textStyle: {
  911. rich: {
  912. val: {
  913. fontSize: 24,
  914. color: '#333',
  915. fontWeight: 'bold',
  916. padding: [10, 0]
  917. },
  918. name: {
  919. fontSize: 12,
  920. fontWeight: 'normal',
  921. color: '#777',
  922. }
  923. }
  924. }
  925. }],
  926. tooltip: {
  927. trigger: 'item',
  928. position: 'right',
  929. // formatter: '{b} : {c} ({d}%)',
  930. formatter:function(item){
  931. const {name, num, percentStr} = item.data
  932. return `${name} : ${num} (${percentStr})`
  933. }
  934. },
  935. series: [{
  936. name: '',
  937. type: 'pie',
  938. radius: ['70%', '90%'],
  939. data: echartData,
  940. hoverAnimation:true,
  941. hoverOffset:5,
  942. itemStyle: {
  943. normal: {
  944. borderColor: bgColor,
  945. borderWidth: 2
  946. }
  947. },
  948. labelLine: {
  949. normal: {
  950. length: 20,
  951. length2: 120,
  952. lineStyle: {
  953. color: '#e6e6e6'
  954. }
  955. }
  956. },
  957. label: {
  958. normal: {
  959. show:false,
  960. formatter: params => {
  961. return params.name == 'A类'?params.name:''
  962. },
  963. padding: [0 , -100, 25, -100],
  964. rich: {
  965. icon: {
  966. fontSize: 16
  967. },
  968. name: {
  969. fontSize: 14,
  970. padding: [0, 10, 0, 4],
  971. color: '#666666'
  972. },
  973. value: {
  974. fontSize: 18,
  975. fontWeight: 'bold',
  976. color: '#333333'
  977. }
  978. }
  979. }
  980. },
  981. }]
  982. };
  983. myChart.setOption(option);
  984. }
  985. //缺陷列表渲染
  986. function queList(data){
  987. let strAll = '',tmp = `mm
  988. <tr class="thead">
  989. <td class="td01">排名</td>
  990. <td class="td02">缺陷详情</td>
  991. <td class="td03">数量</td>
  992. <td class="td04">占比</td>
  993. </tr>`
  994. for(let i = 0;i < data.length;i++){
  995. strAll += `
  996. <tr>
  997. <td style="text-align:center;"><i style="background:${i < 3?'#bea571':'#eff3fc'};color:${i < 3?'#fff':'#999'};">${i+1}</i></td>
  998. <td>${data[i].name}</td>
  999. <td>${data[i].num}</td>
  1000. <td>${data[i].percentStr}</td>
  1001. </tr>
  1002. `
  1003. }
  1004. $(".qtable").html(tmp+strAll)
  1005. }
  1006. //饼图列表注释渲染
  1007. function panDetail(data){
  1008. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  1009. let strAll = '';
  1010. for(let i = 0;i < data.length;i++){
  1011. strAll += `
  1012. <tr class="explainLi">
  1013. <td class="deptName" title="${data[i].name}">
  1014. <p class="smp"><i class="tip" style="background-color:${color[i]}"></i>${data[i].name}</p>
  1015. </td>
  1016. <td class="deptNum">${data[i].num}</td>
  1017. <td class="percent">(${data[i].percentStr})</td>
  1018. </tr>
  1019. `
  1020. }
  1021. $(".explainPanT table").html(strAll);
  1022. $(".explainPan").css({
  1023. marginTop:-($(".explainPan").height()/2-20)+'px'
  1024. })
  1025. }
  1026. function panDetailB(data){
  1027. let color = ['#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336','#F2637B','#975FE4', '#399FFF', '#37CBCB', '#4CCB73','#FAD336'];
  1028. let strAll = '';
  1029. for(let i = 0;i < data.length;i++){
  1030. strAll += `
  1031. <tr class="explainLi">
  1032. <td class="deptName" title="${data[i].name}">
  1033. <p><i class="tip" style="background-color:${color[i]}"></i>${data[i].name}</p>
  1034. </td>
  1035. <td class="deptNum">${data[i].num}</td>
  1036. <td class="percent">(${data[i].percentStr})</td>
  1037. </tr>
  1038. `
  1039. }
  1040. $(".explainPanB table").html(strAll);
  1041. $(".explainPan").css({
  1042. marginTop:-($(".explainPan").height()/2-20)+'px'
  1043. })
  1044. }
  1045. //时间获取
  1046. function getTimeDetail(){
  1047. const d = new Date();
  1048. const days = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
  1049. let sec = d.getSeconds()
  1050. let min = d.getMinutes()
  1051. let hour = d.getHours()
  1052. let str = `${d.getFullYear()}年${d.getMonth()+1}月${d.getDate()}日 / ${days[d.getDay()]} / ${hour>9?hour:'0'+hour}:${min>9?min:'0'+min}:${sec>9?sec:'0'+sec}`
  1053. $(".dateDetail").html(str)
  1054. }