Index.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. var refreshGirdData;
  2. const CONFIG = {
  3. // 画布基准
  4. BASE_WIDTH: 1280,
  5. BASE_HEIGHT: 800,
  6. }
  7. let normalTableData = [
  8. {
  9. type: 'Card类型一',
  10. num: '66',
  11. rate: '40%',
  12. },
  13. {
  14. type: 'Card类型二',
  15. num: '22',
  16. rate: '30%',
  17. },
  18. {
  19. type: 'Card类型三',
  20. num: '11',
  21. rate: '20%',
  22. },
  23. {
  24. type: 'Card类型四',
  25. num: '11',
  26. rate: '20%',
  27. },
  28. {
  29. type: 'Card类型五',
  30. num: '11',
  31. rate: '20%',
  32. },
  33. {
  34. type: 'Card类型六',
  35. num: '11',
  36. rate: '20%',
  37. },
  38. ]
  39. let normalTableColumn = [
  40. {
  41. key: 'index',
  42. title: '排名',
  43. },
  44. {
  45. key: 'rate',
  46. title: '占比',
  47. render: (params) => {
  48. let width = genVH(14),
  49. height = genVH(14),
  50. pieRate = parseInt(params.rate) / 100 * 2,
  51. dataUrl,
  52. ctx,
  53. canvas = document.createElement('canvas')
  54. canvas.width = width
  55. canvas.height = height
  56. ctx = canvas.getContext('2d')
  57. ctx.moveTo(width / 2, height / 2)
  58. ctx.arc(width / 2, height / 2, width / 2, 0, Math.PI * pieRate, false)
  59. ctx.closePath()
  60. ctx.fillStyle = '#6ac8f1'
  61. ctx.fill()
  62. dataUrl = canvas.toDataURL('image/png')
  63. return `
  64. <div class="table-rate-wrap">
  65. <div class="table-pan-icon" style="background-image: url('${dataUrl}');
  66. width: ${width}px; height: ${height}px;"></div>
  67. <div class="table-rate-num">${params.rate}</div>
  68. </div>
  69. `
  70. },
  71. },
  72. {
  73. key: 'type',
  74. title: '类型',
  75. width: '40%',
  76. tooltip: true,
  77. align: 'center',
  78. },
  79. {
  80. key: 'num',
  81. title: '计数',
  82. align: 'right',
  83. class: 'normal-table-num',
  84. },
  85. ]
  86. const renderOtherModule = (config) => {
  87. let domMap = renderContentBasic(config)
  88. if (config.render) {
  89. config.render(domMap, config)
  90. }
  91. //if (config.onResize) {
  92. // window.addEventListener('resize', () => {
  93. // emptyAllDom(domMap)
  94. // config.onResize(domMap, config)
  95. // })
  96. //}
  97. }
  98. const genVH = (length) => {
  99. let clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  100. if (!clientHeight) return length
  101. return length * clientHeight / CONFIG.BASE_HEIGHT
  102. }
  103. const genVW = (length) => {
  104. let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  105. if (!clientWidth) return length
  106. return length * clientWidth / CONFIG.BASE_WIDTH
  107. }
  108. const renderContentBasic = (config) => {
  109. const { domHeight = 200, domId, renderBasic, renderTitle, name } = config
  110. if (renderBasic === false) return renderBasic
  111. const dom = document.getElementById(domId)
  112. dom.style.height = `${domHeight / CONFIG.BASE_HEIGHT * 100}vh`
  113. let innerHTML = '', titleDomHeight = 0
  114. if (renderTitle !== false) {
  115. // 添加标题容器
  116. innerHTML = `
  117. <div class="content-box-title-icon"></div>
  118. <div class="content-box-title-text fontSize14">${name}</div>
  119. `
  120. const titleDom = appendContentNode({
  121. dom,
  122. innerHTML,
  123. nodeWrapName: `${domId}-title`,
  124. className: `content-box-title-wrap ${domId}-title`,
  125. })
  126. titleDomHeight = titleDom.getBoundingClientRect().height
  127. }
  128. // 添加内容容器
  129. const style = {
  130. height: `calc(100% - ${titleDomHeight}px)`,
  131. }
  132. innerHTML = `
  133. <div class="before-${domId}"></div>
  134. <div class="chart-wrap _${domId}"></div>
  135. <div class="after-${domId}"></div>
  136. `
  137. appendContentNode({
  138. dom,
  139. innerHTML,
  140. nodeWrapName: `${domId}-inner-wrap`,
  141. className: `content-box-inner-wrap ${domId}-inner-wrap`,
  142. style,
  143. })
  144. return {
  145. beforeDomClass: `before-${domId}`,
  146. contentDomClass: `_${domId}`,
  147. afterDomClass: `after-${domId}`,
  148. titleClass: `${domId}-title`,
  149. }
  150. }
  151. const appendContentNode = (config) => {
  152. const { dom, innerHTML, nodeWrapName, className, style = {} } = config
  153. let contentNodeWrap = document.getElementsByClassName(nodeWrapName)
  154. if (contentNodeWrap.length) {
  155. contentNodeWrap.innerHTML = innerHTML
  156. } else {
  157. contentNodeWrap = document.createElement('div')
  158. contentNodeWrap.className = className
  159. contentNodeWrap.innerHTML = innerHTML
  160. Object.keys(style).forEach(key => {
  161. contentNodeWrap.style[key] = style[key]
  162. })
  163. dom.appendChild(contentNodeWrap)
  164. }
  165. return contentNodeWrap
  166. }
  167. const renderNormalTable = (classNameParams, config) => {
  168. const contentDom = document.getElementsByClassName(classNameParams.contentDomClass)
  169. let dom = ''
  170. let table = document.createElement('table')
  171. let tableHeader = document.createElement('table')
  172. let tableBodyWrap = document.createElement('div')
  173. table.className = 'normal-table fontSize12'
  174. tableHeader.className = 'normal-table fontSize12'
  175. tableBodyWrap.className = 'normal-table-wrap'
  176. // 表头
  177. if (!config.hideHeader) {
  178. dom += `<tr>`
  179. config.column.forEach(item => {
  180. const { width, align } = item
  181. let style = ' style="'
  182. if (width) style += `width: ${width};`
  183. if (align) style += `text-align: ${align};`
  184. style += `"`
  185. dom += `<th${style}><span>${item.title}</span></th>`
  186. })
  187. dom += `</tr>`
  188. }
  189. tableHeader.innerHTML = dom
  190. document.getElementsByClassName(classNameParams.beforeDomClass)[0].appendChild(tableHeader)
  191. // 表体
  192. dom = ''
  193. config.data.forEach((item, index) => {
  194. dom += `<tr>`
  195. config.column.forEach(cell => {
  196. const { render, key, width, align } = cell
  197. let { class: className = '' } = cell
  198. let style = ' style="'
  199. if (width) style += `width: ${width};`
  200. if (align) style += `text-align: ${align};`
  201. style += `"`
  202. if (cell.tooltip) className += ` ${config.domId}-table-overflow-text`
  203. if (render) {
  204. dom += `<td${style} class="${className}">${render(item)}</td>`
  205. } else if (key === 'index') {
  206. dom += `<td${style} class="${className}"><span>${index + 1}</span></td>`
  207. } else {
  208. dom += `<td${style} class="${className}"><span>${item[key]}</span></td>`
  209. }
  210. })
  211. dom += `</tr>`
  212. })
  213. if (!config.data.length) dom += `<tr><td colspan="${config.column.length}" style="text-align: center;height: 100%;">暂无数据</td></tr>`
  214. table.innerHTML = dom
  215. tableBodyWrap.appendChild(table)
  216. contentDom[0].appendChild(tableBodyWrap)
  217. contentDom[0].style.height = `calc(100% - ${tableHeader.getBoundingClientRect().height}px)`
  218. // scrollbar compensation
  219. if (tableBodyWrap.scrollHeight > tableBodyWrap.clientHeight) {
  220. document.getElementsByClassName(classNameParams.beforeDomClass)[0].classList.add('scrollbar-compensation')
  221. }
  222. // tooltips
  223. let tooltips = document.createElement('div')
  224. tooltips.className = 'table-tootips'
  225. tooltips.innerHTML = '<span class="tooltips-arrow"></span><span class="tooltips-text"></span>'
  226. contentDom[0].appendChild(tooltips)
  227. const tooltipsArrow = document.getElementsByClassName('tooltips-arrow')[0]
  228. const tooltipsText = document.getElementsByClassName('tooltips-text')[0]
  229. const tableOverflowTextDom = document.getElementsByClassName(`${config.domId}-table-overflow-text`)
  230. for (let i = 0; i < tableOverflowTextDom.length; i++) {
  231. if (tableOverflowTextDom[i].scrollWidth - tableOverflowTextDom[i].clientWidth > 1) {
  232. tableOverflowTextDom[i].addEventListener('mouseout', () => {
  233. tooltips.style.display = 'none'
  234. })
  235. tableOverflowTextDom[i].addEventListener('mouseover', () => {
  236. tooltips.style.display = 'block'
  237. const fontSize = '1.125vh'
  238. const padding = genVH(8)
  239. const size = getTextSize(tableOverflowTextDom[i].innerText, fontSize)
  240. tooltips.style.fontSize = fontSize
  241. tooltips.style.padding = `${padding}px`
  242. tooltips.style.left = `${tableOverflowTextDom[i].offsetLeft + (tableOverflowTextDom[i].clientWidth / 2 - size.width / 2 - padding)}px`
  243. tooltips.style.top = `${tableOverflowTextDom[i].offsetTop - tableBodyWrap.scrollTop - (size.height + padding * 2) - tooltipsArrow.clientHeight}px`
  244. tooltipsArrow.style.transform = `translate3d(${size.width / 2 + padding - tooltipsArrow.clientWidth / 2}px, 0, 0)`
  245. tooltipsText.innerHTML = tableOverflowTextDom[i].innerText
  246. })
  247. }
  248. }
  249. }
  250. var bootstrap = function ($, learun) {
  251. "use strict";
  252. const devices = ["SRM1", "SRM2", "SRM3"];
  253. var page = {
  254. init: function () {
  255. page.initGird();
  256. page.bind();
  257. page.GetLastTaskCompletionRate();
  258. page.GetTaskCompletionRate();
  259. page.GetTaskNumsData();
  260. page.GetMainDDJData();
  261. page.GetMainFaultsData();
  262. page.GetmainJobTimesData();
  263. page.GetDeviceTaskTimesData();
  264. page.GetDeviceRunTimesData();
  265. page.GetDeviceJobTimesData();
  266. // top.$('#iframebg').css("display", "none");
  267. },
  268. bind: function () {
  269. renderOtherModule({
  270. domId: 'card-8',
  271. name: '设备故障信息',
  272. domHeight: 220,
  273. data: normalTableData,
  274. column: normalTableColumn,
  275. render: renderNormalTable,
  276. });
  277. $.each(devices, function (n, item) {
  278. $("#Code").append($("<option value='" + item + "'>" + item + "</option>"));
  279. });
  280. $("#Code").change(function () {
  281. alert(123);
  282. });
  283. page.SpanFunction($("#mainTaskCompletionRateSpan").find('span'), page.GetTaskNumsData);
  284. page.SpanFunction($("#mainTaskNumsSpan").find('span'), page.GetTaskCompletionRate);
  285. page.SpanFunction($("#mainddjSpan").find('span'), page.GetMainDDJData);
  286. page.SpanFunction($("#mainFaultsSpan").find('span'), page.GetMainFaultsData);
  287. page.SpanFunction($("#mainJobTimesSpan").find('span'), page.GetmainJobTimesData);
  288. page.SpanFunction($("#deviceTaskTimesSpan").find('span'), page.GetDeviceTaskTimesData);
  289. page.SpanFunction($("#deviceRunTimesSpan").find('span'), page.GetDeviceRunTimesData);
  290. page.SpanFunction($("#deviceJobTimesSpan").find('span'), page.GetDeviceJobTimesData);
  291. },
  292. // 初始化列表
  293. initGird: function () {
  294. },
  295. search: function (param) {
  296. },
  297. SpanFunction: function (list, callBack) {
  298. $(list).on('click', function () {
  299. $(this).addClass('active').siblings('span').removeClass('active');
  300. var index = $(this).index();
  301. var text = $(this).text();
  302. //alert($(this).attr('queryValue'));
  303. if (!!callBack) {
  304. callBack();
  305. }
  306. })
  307. //for (var i = 0; i < list.length; i++) {
  308. // $(list[i]).on('click', function () {
  309. // var name = $(this).text();
  310. // list.each(function () {
  311. // if ($(this).text() == name) {
  312. // $(this).addClass('active');
  313. // if (!!callBack) {
  314. // callBack();
  315. // }
  316. // }
  317. // else {
  318. // $(this).removeClass('active');
  319. // }
  320. // });
  321. // });
  322. //}
  323. },
  324. //上一班完成率
  325. GetLastTaskCompletionRate: function () {
  326. // var chartDom = document.getElementById('mainLastTaskCompletionRate');
  327. var chartDom = document.getElementById('mainLastTaskCompletionRate');
  328. var myChart = echarts.init(chartDom);
  329. var option;
  330. option = {
  331. series: [
  332. {
  333. type: 'gauge',
  334. progress: {
  335. show: true,
  336. width: 12
  337. },
  338. axisLine: {
  339. lineStyle: {
  340. width: 12
  341. }
  342. },
  343. axisTick: {
  344. show: false
  345. },
  346. splitLine: {
  347. length: 10,
  348. lineStyle: {
  349. width: 2,
  350. color: '#999'
  351. }
  352. },
  353. axisLabel: {
  354. distance: 7,
  355. color: '#999',
  356. fontSize: 10
  357. },
  358. anchor: {
  359. show: true,
  360. showAbove: true,
  361. size: 15,
  362. itemStyle: {
  363. borderWidth: 10
  364. }
  365. },
  366. title: {
  367. show: false
  368. },
  369. detail: {
  370. valueAnimation: true,
  371. fontSize: 20,
  372. formatter: function (value) {
  373. return value + '%';
  374. },
  375. offsetCenter: [0, '70%']
  376. },
  377. data: [
  378. {
  379. value: 78
  380. }
  381. ]
  382. }
  383. ]
  384. };
  385. option && myChart.setOption(option);
  386. // var myChart = echarts.init(chartDom, null, {
  387. // renderer: 'canvas',
  388. // useDirtyRect: false
  389. // });
  390. // var option;
  391. // function renderItem(params, api) {
  392. // var valOnRadian = api.value(1);
  393. // var coords = api.coord([api.value(0), valOnRadian]);
  394. // var polarEndRadian = coords[3];
  395. // var imageStyle = {
  396. // image: _panelImageURL,
  397. // x: params.coordSys.cx - _outerRadius,
  398. // y: params.coordSys.cy - _outerRadius,
  399. // width: _outerRadius * 2,
  400. // height: _outerRadius * 2
  401. // };
  402. // return {
  403. // type: 'group',
  404. // children: [
  405. // {
  406. // type: 'image',
  407. // style: imageStyle,
  408. // clipPath: {
  409. // type: 'sector',
  410. // shape: {
  411. // cx: params.coordSys.cx,
  412. // cy: params.coordSys.cy,
  413. // r: _outerRadius,
  414. // r0: _innerRadius,
  415. // startAngle: 0,
  416. // endAngle: -polarEndRadian,
  417. // transition: 'endAngle',
  418. // enterFrom: { endAngle: 0 }
  419. // }
  420. // }
  421. // },
  422. // {
  423. // type: 'image',
  424. // style: imageStyle,
  425. // clipPath: {
  426. // type: 'polygon',
  427. // shape: {
  428. // points: makePionterPoints(params, polarEndRadian)
  429. // },
  430. // extra: {
  431. // polarEndRadian: polarEndRadian,
  432. // transition: 'polarEndRadian',
  433. // enterFrom: { polarEndRadian: 0 }
  434. // },
  435. // during: function (apiDuring) {
  436. // apiDuring.setShape(
  437. // 'points',
  438. // makePionterPoints(params, apiDuring.getExtra('polarEndRadian'))
  439. // );
  440. // }
  441. // }
  442. // },
  443. // {
  444. // type: 'circle',
  445. // shape: {
  446. // cx: params.coordSys.cx,
  447. // cy: params.coordSys.cy,
  448. // r: _insidePanelRadius
  449. // },
  450. // style: {
  451. // fill: '#fff',
  452. // shadowBlur: 25,
  453. // shadowOffsetX: 0,
  454. // shadowOffsetY: 0,
  455. // shadowColor: 'rgba(76,107,167,0.4)'
  456. // }
  457. // },
  458. // {
  459. // type: 'text',
  460. // extra: {
  461. // valOnRadian: valOnRadian,
  462. // transition: 'valOnRadian',
  463. // enterFrom: { valOnRadian: 0 }
  464. // },
  465. // style: {
  466. // text: makeText(valOnRadian),
  467. // fontSize: 50,
  468. // fontWeight: 700,
  469. // x: params.coordSys.cx,
  470. // y: params.coordSys.cy,
  471. // fill: 'rgb(0,50,190)',
  472. // align: 'center',
  473. // verticalAlign: 'middle',
  474. // enterFrom: { opacity: 0 }
  475. // },
  476. // during: function (apiDuring) {
  477. // apiDuring.setStyle(
  478. // 'text',
  479. // makeText(apiDuring.getExtra('valOnRadian'))
  480. // );
  481. // }
  482. // }
  483. // ]
  484. // };
  485. // }
  486. // function convertToPolarPoint(renderItemParams, radius, radian) {
  487. // return [
  488. // Math.cos(radian) * radius + renderItemParams.coordSys.cx,
  489. // -Math.sin(radian) * radius + renderItemParams.coordSys.cy
  490. // ];
  491. // }
  492. // function makePionterPoints(renderItemParams, polarEndRadian) {
  493. // return [
  494. // convertToPolarPoint(renderItemParams, _outerRadius, polarEndRadian),
  495. // convertToPolarPoint(
  496. // renderItemParams,
  497. // _outerRadius,
  498. // polarEndRadian + Math.PI * 0.03
  499. // ),
  500. // convertToPolarPoint(renderItemParams, _pointerInnerRadius, polarEndRadian)
  501. // ];
  502. // }
  503. // function makeText(valOnRadian) {
  504. // // Validate additive animation calc.
  505. // if (valOnRadian < -10) {
  506. // alert('illegal during val: ' + valOnRadian);
  507. // }
  508. // return ((valOnRadian / _valOnRadianMax) * 100).toFixed(0) + '%';
  509. // }
  510. // option = {
  511. // animationEasing: _animationEasingUpdate,
  512. // animationDuration: _animationDuration,
  513. // animationDurationUpdate: _animationDurationUpdate,
  514. // animationEasingUpdate: _animationEasingUpdate,
  515. // dataset: {
  516. // source: [[1, 156]]
  517. // },
  518. // tooltip: {},
  519. // angleAxis: {
  520. // type: 'value',
  521. // startAngle: 0,
  522. // show: false,
  523. // min: 0,
  524. // max: _valOnRadianMax
  525. // },
  526. // radiusAxis: {
  527. // type: 'value',
  528. // show: false
  529. // },
  530. // polar: {},
  531. // series: [
  532. // {
  533. // type: 'custom',
  534. // coordinateSystem: 'polar',
  535. // renderItem: renderItem
  536. // }
  537. // ]
  538. // };
  539. // setInterval(function () {
  540. // var nextSource = 98;// [[1, Math.round(Math.random() * _valOnRadianMax)]];
  541. // myChart.setOption({
  542. // dataset: {
  543. // source: nextSource
  544. // }
  545. // });
  546. // }, 3000);
  547. // if (option && typeof option === 'object') {
  548. // myChart.setOption(option);
  549. // }
  550. },
  551. //任务完成率
  552. GetTaskCompletionRate: function () {
  553. var chartDom = document.getElementById('mainTaskCompletionRate');
  554. var myChart = echarts.init(chartDom, null, {
  555. renderer: 'canvas',
  556. useDirtyRect: false
  557. });
  558. var option;
  559. option = {
  560. //title: {
  561. // text: 'Chart'
  562. //},
  563. tooltip: {
  564. trigger: 'axis',
  565. axisPointer: {
  566. type: 'cross',
  567. label: {
  568. backgroundColor: '#6a7985'
  569. }
  570. }
  571. },
  572. legend: {
  573. data: ['Email']
  574. },
  575. grid: {
  576. left: '3%',
  577. right: '4%',
  578. bottom: '1%',
  579. containLabel: true
  580. },
  581. xAxis: [
  582. {
  583. type: 'category',
  584. boundaryGap: false,
  585. data: ['5-1', '5-2', '5-3', '5-4', '5-5', '5-6', '5-7']
  586. }
  587. ],
  588. yAxis: [
  589. {
  590. interval: 25,
  591. axisLabel: {
  592. formatter: '{value} %'
  593. },
  594. axisLine: {
  595. show: true
  596. },
  597. type: 'value'
  598. }
  599. ],
  600. series: [
  601. {
  602. name: 'ttttt',
  603. type: 'line',
  604. stack: 'Total',
  605. label: {
  606. show: true,
  607. position: 'top'
  608. },
  609. areaStyle: {},
  610. emphasis: {
  611. focus: 'series'
  612. },
  613. data: [78, 93, 76, 55, 68, 89, 82]
  614. }
  615. ]
  616. };
  617. //option = {
  618. // xAxis: {
  619. // type: 'category',
  620. // boundaryGap: false,
  621. // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  622. // },
  623. // yAxis: {
  624. // axisLine: {
  625. // show: true
  626. // },
  627. // type: 'value'
  628. // },
  629. // grid: {
  630. // left: '3%',
  631. // right: '4%',
  632. // bottom: '3%',
  633. // containLabel: true
  634. // },
  635. // series: [
  636. // {
  637. // data: [820, 932, 901, 934, 1290, 1330, 1320],
  638. // type: 'line',
  639. // areaStyle: {}
  640. // }
  641. // ]
  642. //};
  643. option && myChart.setOption(option);
  644. },
  645. //任务量统计
  646. GetTaskNumsData: function () {
  647. var dom = document.getElementById('mainTaskNums');
  648. var myChart = echarts.init(dom, null, {
  649. renderer: 'canvas',
  650. useDirtyRect: false
  651. });
  652. var app = {};
  653. var option;
  654. const labelOption = {
  655. show: true,
  656. position: 'insideBottom',
  657. distance: 15,
  658. align: 'left',
  659. verticalAlign: 'middle',
  660. rotate: 90,
  661. formatter: '{c} {name|{a}}',
  662. fontSize: 16,
  663. rich: {
  664. name: {}
  665. }
  666. };
  667. option = {
  668. tooltip: {
  669. trigger: 'axis',
  670. axisPointer: {
  671. type: 'shadow'
  672. }
  673. },
  674. legend: {
  675. left: '70%',//调整位置
  676. data: ['下发任务', '完成任务']
  677. },
  678. xAxis: [
  679. {
  680. type: 'category',
  681. axisTick: { show: false },
  682. data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  683. }
  684. ],
  685. yAxis: [
  686. {
  687. //interval: 25,
  688. axisLabel: {
  689. formatter: '{value}'
  690. },
  691. type: 'value'
  692. }
  693. ],
  694. series: [
  695. {
  696. name: '下发任务',
  697. type: 'bar',
  698. barGap: 0,
  699. label: labelOption,
  700. emphasis: {
  701. focus: 'series'
  702. },
  703. data: [320, 332, 301, 334, 390]
  704. },
  705. {
  706. name: '完成任务',
  707. type: 'bar',
  708. label: labelOption,
  709. emphasis: {
  710. focus: 'series'
  711. },
  712. data: [220, 182, 191, 234, 290]
  713. }
  714. ]
  715. };
  716. if (option && typeof option === 'object') {
  717. myChart.setOption(option);
  718. }
  719. },
  720. //堆垛机数据统计
  721. GetMainDDJData: function () {
  722. var chartDom = document.getElementById('mainddj');
  723. var myChart = echarts.init(chartDom);
  724. var option;
  725. option = {
  726. title: {
  727. text: ''
  728. },
  729. tooltip: {
  730. trigger: 'axis'
  731. },
  732. legend: {
  733. left: '70%',//调整位置
  734. data: ['堆垛机利用率', '堆垛机故障率']
  735. },
  736. xAxis: {
  737. type: 'category',
  738. boundaryGap: false,
  739. data: ['5-8白班', '5-8晚班', '5-9白班', '5-9晚班', '5-10白班', '5-10晚班', '5-11白班', '5-11晚班', '5-12白班', '5-12晚班', '5-13白班', '5-13晚班', '5-14白班', '5-14晚班']
  740. },
  741. yAxis: {
  742. type: 'value',
  743. axisLabel: {
  744. formatter: '{value} %'
  745. }
  746. },
  747. series: [
  748. {
  749. name: '堆垛机故障率',
  750. type: 'line',
  751. data: [1, -2, 2, 5, 3, 2, 0],
  752. markPoint: {
  753. data: [{ name: '周最低', value: -2, xAxis: 1, yAxis: -1.5 }]
  754. },
  755. markLine: {
  756. data: [
  757. { type: 'average', name: 'Avg' },
  758. [
  759. {
  760. symbol: 'none',
  761. x: '90%',
  762. yAxis: 'max'
  763. },
  764. {
  765. symbol: 'circle',
  766. label: {
  767. position: 'start',
  768. formatter: 'Max'
  769. },
  770. type: 'max',
  771. name: '最高点'
  772. }
  773. ]
  774. ]
  775. }
  776. },
  777. {
  778. name: '堆垛机利用率',
  779. type: 'line',
  780. data: [10, 11, 13, 11, 12, 12, 9],
  781. markPoint: {
  782. data: [
  783. { type: 'max', name: 'Max' },
  784. { type: 'min', name: 'Min' }
  785. ]
  786. },
  787. markLine: {
  788. data: [{ type: 'average', name: 'Avg' }]
  789. }
  790. }
  791. ]
  792. };
  793. option && myChart.setOption(option);
  794. },
  795. //故障统计
  796. GetMainFaultsData: function () {
  797. var chartDom = document.getElementById('mainFaults');
  798. var myChart = echarts.init(chartDom);
  799. var option;
  800. option = {
  801. tooltip: {
  802. trigger: 'axis',
  803. axisPointer: {
  804. type: 'cross',
  805. crossStyle: {
  806. color: '#999'
  807. }
  808. }
  809. },
  810. legend: {
  811. left: '50%',//调整位置
  812. data: ['故障次数', '故障持续时间']
  813. },
  814. xAxis: [
  815. {
  816. type: 'category',
  817. data: ['SRM1', 'SRM2', 'SRM3', 'SRM4', 'SRM5', 'SRM6', '1011', '1012', '1013', '1014', '1015', '1016', '1017', '1018', '1019', '1020'],
  818. axisPointer: {
  819. type: 'shadow'
  820. },
  821. boundaryGap: false,
  822. }
  823. ],
  824. yAxis: [
  825. {
  826. axisLine: {
  827. show: true
  828. },
  829. type: 'value',
  830. name: '故障次数',
  831. interval: 25,
  832. axisLabel: {
  833. formatter: '{value} 次'
  834. }
  835. },
  836. {
  837. type: 'value',
  838. name: '故障持续时间',
  839. interval: 30,
  840. axisLabel: {
  841. formatter: '{value} 分钟'
  842. }
  843. }
  844. ],
  845. series: [
  846. {
  847. name: '故障次数',
  848. type: 'bar',
  849. barWidth: 12,
  850. tooltip: {
  851. valueFormatter: function (value) {
  852. return value + ' 次';
  853. }
  854. },
  855. label: {
  856. show: true,
  857. position: 'top'
  858. },
  859. data: [
  860. 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6
  861. ]
  862. },
  863. {
  864. name: '故障持续时间',
  865. type: 'line',
  866. yAxisIndex: 1,
  867. tooltip: {
  868. valueFormatter: function (value) {
  869. return value + ' 分钟';
  870. }
  871. },
  872. data: [60, 2.2, 45, 4.5, 6.3, 10.2, 20.3]
  873. }
  874. ]
  875. };
  876. option && myChart.setOption(option);
  877. },
  878. //作业时间数据统计
  879. GetmainJobTimesData: function () {
  880. var chartDom = document.getElementById('mainJobTimes');
  881. var myChart = echarts.init(chartDom);
  882. var option;
  883. option = {
  884. tooltip: {
  885. trigger: 'axis',
  886. axisPointer: {
  887. type: 'cross',
  888. crossStyle: {
  889. color: '#999'
  890. }
  891. }
  892. },
  893. legend: {
  894. left: '70%',//调整位置
  895. data: ['作业完成时间', '平均作业处理时间']
  896. },
  897. xAxis: [
  898. {
  899. type: 'category',
  900. data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  901. axisPointer: {
  902. type: 'shadow'
  903. }
  904. }
  905. ],
  906. yAxis: [
  907. {
  908. axisLine: {
  909. show: true
  910. },
  911. type: 'value',
  912. name: '作业完成时间',
  913. interval: 6,
  914. axisLabel: {
  915. formatter: '{value} h'
  916. }
  917. },
  918. {
  919. type: 'value',
  920. name: '平均作业处理时间',
  921. interval: 30,
  922. axisLabel: {
  923. formatter: '{value} h'
  924. }
  925. }
  926. ],
  927. series: [
  928. {
  929. name: '作业完成时间',
  930. type: 'bar',
  931. barWidth: 12,
  932. tooltip: {
  933. valueFormatter: function (value) {
  934. return value + ' ml';
  935. }
  936. },
  937. label: {
  938. show: true,
  939. position: 'top'
  940. },
  941. data: [
  942. 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6
  943. ]
  944. },
  945. {
  946. name: '平均作业处理时间',
  947. type: 'line',
  948. yAxisIndex: 1,
  949. tooltip: {
  950. valueFormatter: function (value) {
  951. return value + ' °C';
  952. }
  953. },
  954. data: [60, 2.2, 45, 4.5, 6.3, 10.2, 20.3]
  955. }
  956. ]
  957. };
  958. option && myChart.setOption(option);
  959. },
  960. //平均任务执行耗时
  961. GetDeviceTaskTimesData: function () {
  962. //deviceTaskTimes
  963. var chartDom = document.getElementById('deviceTaskTimes');
  964. var myChart = echarts.init(chartDom);
  965. var option;
  966. option = {
  967. legend: {
  968. data: ['']
  969. },
  970. grid: {
  971. left: '3%',
  972. right: '2%',
  973. bottom: '3%',
  974. containLabel: true
  975. },
  976. xAxis: [
  977. {
  978. type: 'category',
  979. boundaryGap: false,
  980. data: ['5-1', '5-2', '5-3', '5-4', '5-5', '5-6', '5-7', '5-8', '5-9', '5-10', '5-11', '5-12', '5-13', '5-14', '5-15', '5-16', '5-17', '5-18', '5-19', '5-20', '5-21', '5-22', '5-23', '5-24', '5-25', '5-26', '5-27', '5-28', '5-29', '5-30', '5-31'],
  981. }
  982. ],
  983. yAxis: [
  984. {
  985. interval: 6,
  986. axisLabel: {
  987. formatter: '{value} h'
  988. },
  989. axisLine: {
  990. show: true
  991. },
  992. type: 'value'
  993. }
  994. ],
  995. series: [
  996. {
  997. name: 'ttttt',
  998. type: 'line',
  999. stack: 'Total',
  1000. label: {
  1001. show: true,
  1002. position: 'top'
  1003. },
  1004. areaStyle: {},
  1005. emphasis: {
  1006. focus: 'series'
  1007. },
  1008. data: [20, 19, 23, 22, 18, 16, 14]
  1009. }
  1010. ]
  1011. };
  1012. option && myChart.setOption(option);
  1013. },
  1014. //设备运行耗时统计
  1015. GetDeviceRunTimesData: function () {
  1016. var dom = document.getElementById('deviceRunTimes');
  1017. var myChart = echarts.init(dom, null, {
  1018. renderer: 'canvas',
  1019. useDirtyRect: false
  1020. });
  1021. var app = {};
  1022. var option;
  1023. const labelOption = {
  1024. show: true,
  1025. position: 'insideBottom',
  1026. distance: 15,
  1027. align: 'left',
  1028. verticalAlign: 'middle',
  1029. rotate: 90,
  1030. formatter: '{c} {name|{a}}',
  1031. fontSize: 16,
  1032. rich: {
  1033. name: {}
  1034. }
  1035. };
  1036. option = {
  1037. tooltip: {
  1038. trigger: 'axis',
  1039. axisPointer: {
  1040. type: 'shadow'
  1041. }
  1042. },
  1043. legend: {
  1044. left: '70%',//调整位置
  1045. data: ['平均行驶时间', '平均取货时间', '平均放货时间']
  1046. },
  1047. xAxis: [
  1048. {
  1049. type: 'category',
  1050. axisTick: { show: false },
  1051. data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  1052. }
  1053. ],
  1054. yAxis: [
  1055. {
  1056. interval: 15,
  1057. axisLabel: {
  1058. formatter: '{value} min'
  1059. },
  1060. type: 'value'
  1061. }
  1062. ],
  1063. series: [
  1064. {
  1065. name: '平均行驶时间',
  1066. type: 'bar',
  1067. barGap: 0,
  1068. label: labelOption,
  1069. emphasis: {
  1070. focus: 'series'
  1071. },
  1072. data: [32, 32, 30, 34, 39]
  1073. },
  1074. {
  1075. name: '平均取货时间',
  1076. type: 'bar',
  1077. label: labelOption,
  1078. emphasis: {
  1079. focus: 'series'
  1080. },
  1081. data: [22, 18, 19, 34, 29]
  1082. },
  1083. {
  1084. name: '平均放货时间',
  1085. type: 'bar',
  1086. label: labelOption,
  1087. emphasis: {
  1088. focus: 'series'
  1089. },
  1090. data: [15, 23, 21, 15, 19]
  1091. }
  1092. ]
  1093. };
  1094. if (option && typeof option === 'object') {
  1095. myChart.setOption(option);
  1096. }
  1097. },
  1098. //作业时间数据统计
  1099. GetDeviceJobTimesData: function () {
  1100. var chartDom = document.getElementById('deviceJobTimes');
  1101. var myChart = echarts.init(chartDom);
  1102. var option;
  1103. option = {
  1104. tooltip: {
  1105. trigger: 'axis',
  1106. axisPointer: {
  1107. type: 'cross',
  1108. crossStyle: {
  1109. color: '#999'
  1110. }
  1111. }
  1112. },
  1113. legend: {
  1114. left: '70%',//调整位置
  1115. data: ['作业完成时间', '平均作业处理时间']
  1116. },
  1117. xAxis: [
  1118. {
  1119. type: 'category',
  1120. data: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
  1121. axisPointer: {
  1122. type: 'shadow'
  1123. }
  1124. }
  1125. ],
  1126. yAxis: [
  1127. {
  1128. axisLine: {
  1129. show: true
  1130. },
  1131. type: 'value',
  1132. name: '作业完成时间',
  1133. interval: 6,
  1134. axisLabel: {
  1135. formatter: '{value} h'
  1136. }
  1137. },
  1138. {
  1139. type: 'value',
  1140. name: '平均作业处理时间',
  1141. interval: 30,
  1142. axisLabel: {
  1143. formatter: '{value} h'
  1144. }
  1145. }
  1146. ],
  1147. series: [
  1148. {
  1149. name: '作业完成时间',
  1150. type: 'bar',
  1151. barWidth: 12,
  1152. tooltip: {
  1153. valueFormatter: function (value) {
  1154. return value + ' ml';
  1155. }
  1156. },
  1157. label: {
  1158. show: true,
  1159. position: 'top'
  1160. },
  1161. data: [
  1162. 2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6
  1163. ]
  1164. },
  1165. {
  1166. name: '平均作业处理时间',
  1167. type: 'line',
  1168. yAxisIndex: 1,
  1169. tooltip: {
  1170. valueFormatter: function (value) {
  1171. return value + ' °C';
  1172. }
  1173. },
  1174. data: [60, 2.2, 45, 4.5, 6.3, 10.2, 20.3]
  1175. }
  1176. ]
  1177. };
  1178. option && myChart.setOption(option);
  1179. },
  1180. };
  1181. refreshGirdData = function () {
  1182. };
  1183. page.init();
  1184. }
  1185. var dom = document.getElementById('mainLastTaskCompletionRate');
  1186. var mainmyChart = echarts.init(dom, null, {
  1187. renderer: 'canvas',
  1188. useDirtyRect: false
  1189. });
  1190. var app = {};
  1191. var ROOT_PATH = 'https://echarts.apache.org/examples';
  1192. var option;
  1193. var _panelImageURL = ROOT_PATH + '/data/asset/img/custom-gauge-panel.png';
  1194. var _animationDuration = 1000;
  1195. var _animationDurationUpdate = 1000;
  1196. var _animationEasingUpdate = 'quarticInOut';
  1197. var _valOnRadianMax = 200;
  1198. var _outerRadius = 200;
  1199. var _innerRadius = 170;
  1200. var _pointerInnerRadius = 40;
  1201. var _insidePanelRadius = 140;
  1202. var _currentDataIndex = 0;
  1203. function renderItem(params, api) {
  1204. var valOnRadian = api.value(1);
  1205. var coords = api.coord([api.value(0), valOnRadian]);
  1206. var polarEndRadian = coords[3];
  1207. var imageStyle = {
  1208. image: _panelImageURL,
  1209. x: params.coordSys.cx - _outerRadius,
  1210. y: params.coordSys.cy - _outerRadius,
  1211. width: _outerRadius * 2,
  1212. height: _outerRadius * 2
  1213. };
  1214. return {
  1215. type: 'group',
  1216. children: [
  1217. {
  1218. type: 'image',
  1219. style: imageStyle,
  1220. clipPath: {
  1221. type: 'sector',
  1222. shape: {
  1223. cx: params.coordSys.cx,
  1224. cy: params.coordSys.cy,
  1225. r: _outerRadius,
  1226. r0: _innerRadius,
  1227. startAngle: 0,
  1228. endAngle: -polarEndRadian,
  1229. transition: 'endAngle',
  1230. enterFrom: { endAngle: 0 }
  1231. }
  1232. }
  1233. },
  1234. {
  1235. type: 'image',
  1236. style: imageStyle,
  1237. clipPath: {
  1238. type: 'polygon',
  1239. shape: {
  1240. points: makePionterPoints(params, polarEndRadian)
  1241. },
  1242. extra: {
  1243. polarEndRadian: polarEndRadian,
  1244. transition: 'polarEndRadian',
  1245. enterFrom: { polarEndRadian: 0 }
  1246. },
  1247. during: function (apiDuring) {
  1248. apiDuring.setShape(
  1249. 'points',
  1250. makePionterPoints(params, apiDuring.getExtra('polarEndRadian'))
  1251. );
  1252. }
  1253. }
  1254. },
  1255. {
  1256. type: 'circle',
  1257. shape: {
  1258. cx: params.coordSys.cx,
  1259. cy: params.coordSys.cy,
  1260. r: _insidePanelRadius
  1261. },
  1262. style: {
  1263. fill: '#fff',
  1264. shadowBlur: 25,
  1265. shadowOffsetX: 0,
  1266. shadowOffsetY: 0,
  1267. shadowColor: 'rgba(76,107,167,0.4)'
  1268. }
  1269. },
  1270. {
  1271. type: 'text',
  1272. extra: {
  1273. valOnRadian: valOnRadian,
  1274. transition: 'valOnRadian',
  1275. enterFrom: { valOnRadian: 0 }
  1276. },
  1277. style: {
  1278. text: makeText(valOnRadian),
  1279. fontSize: 50,
  1280. fontWeight: 700,
  1281. x: params.coordSys.cx,
  1282. y: params.coordSys.cy,
  1283. fill: 'rgb(0,50,190)',
  1284. align: 'center',
  1285. verticalAlign: 'middle',
  1286. enterFrom: { opacity: 0 }
  1287. },
  1288. during: function (apiDuring) {
  1289. apiDuring.setStyle(
  1290. 'text',
  1291. makeText(apiDuring.getExtra('valOnRadian'))
  1292. );
  1293. }
  1294. }
  1295. ]
  1296. };
  1297. }
  1298. function convertToPolarPoint(renderItemParams, radius, radian) {
  1299. return [
  1300. Math.cos(radian) * radius + renderItemParams.coordSys.cx,
  1301. -Math.sin(radian) * radius + renderItemParams.coordSys.cy
  1302. ];
  1303. }
  1304. function makePionterPoints(renderItemParams, polarEndRadian) {
  1305. return [
  1306. convertToPolarPoint(renderItemParams, _outerRadius, polarEndRadian),
  1307. convertToPolarPoint(
  1308. renderItemParams,
  1309. _outerRadius,
  1310. polarEndRadian + Math.PI * 0.03
  1311. ),
  1312. convertToPolarPoint(renderItemParams, _pointerInnerRadius, polarEndRadian)
  1313. ];
  1314. }
  1315. function makeText(valOnRadian) {
  1316. // Validate additive animation calc.
  1317. if (valOnRadian < -10) {
  1318. alert('illegal during val: ' + valOnRadian);
  1319. }
  1320. return ((valOnRadian / _valOnRadianMax) * 100).toFixed(0) + '%';
  1321. }
  1322. option = {
  1323. animationEasing: _animationEasingUpdate,
  1324. animationDuration: _animationDuration,
  1325. animationDurationUpdate: _animationDurationUpdate,
  1326. animationEasingUpdate: _animationEasingUpdate,
  1327. dataset: {
  1328. source: [[1, 156]]
  1329. },
  1330. tooltip: {},
  1331. angleAxis: {
  1332. type: 'value',
  1333. startAngle: 0,
  1334. show: false,
  1335. min: 0,
  1336. max: _valOnRadianMax
  1337. },
  1338. radiusAxis: {
  1339. type: 'value',
  1340. show: false
  1341. },
  1342. polar: {},
  1343. series: [
  1344. {
  1345. type: 'custom',
  1346. coordinateSystem: 'polar',
  1347. renderItem: renderItem,
  1348. }
  1349. ]
  1350. };
  1351. setInterval(function () {
  1352. var nextSource = 98;// [[1, Math.round(Math.random() * _valOnRadianMax)]];
  1353. mainmyChart.setOption({
  1354. dataset: {
  1355. source: nextSource
  1356. }
  1357. });
  1358. }, 3000);
  1359. if (option && typeof option === 'object') {
  1360. mainmyChart.setOption(option);
  1361. }