line.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. var vm = new Vue({
  2. el: '#app',
  3. data: {
  4. lineName:"",
  5. date: "",
  6. moduleType: "",
  7. moduleTypes: [],
  8. lineModuleType: "",
  9. isLine: false,
  10. lineOverViews: [],
  11. lineData: {},
  12. lineKeyFaults: [],
  13. selectId: "",
  14. lines: [],
  15. lineFault: [],
  16. lineMorningAccumulatedFault: [],
  17. lineNightAccumulatedFault: [],
  18. MorningCapacity: 0,
  19. NightCapacity: 0,
  20. TotalCapacity: 0,
  21. dom: Object,
  22. myChart: Object,
  23. option: Object,
  24. dom1: Object,
  25. myChart1: Object,
  26. option1: Object,
  27. dom2: Object,
  28. myChart2: Object,
  29. option2: Object,
  30. monthTitle: "",
  31. dates: [],
  32. newDates: [],
  33. planCapacities: [],
  34. capacities: [],
  35. differences: [],
  36. accumulatedDifferences: [],
  37. accumulatedDifference: 0
  38. },
  39. created() {
  40. this.getLines()
  41. },
  42. mounted() {
  43. this.init()
  44. this.initDatepicker()
  45. this.initCapacityEcharts()
  46. this.initData()
  47. this.initMonthDataEcharts()
  48. },
  49. watch: {
  50. moduleTypes: function () {
  51. this.$nextTick(function () {
  52. $("input[name='optionsRadios'][value=" + this.lineModuleType + "]").prop("checked", true)
  53. });
  54. }
  55. },
  56. methods: {
  57. init() {
  58. let width = document.body.clientWidth - 120;
  59. let homeTable1 = document.querySelector("#homeTable1");
  60. let homeTable2 = document.querySelector("#homeTable2");
  61. homeTable1.style.width = width + 'px';
  62. homeTable2.style.width = width + 'px';
  63. },
  64. onClickOptionsRadios() {
  65. let moduleType = $("input[name='optionsRadios']:checked").val()
  66. if (moduleType === "" || moduleType === undefined) {
  67. moduleType = "ALL"
  68. }
  69. this.lineModuleType = moduleType
  70. document.cookie = 'lineModuleType=' + moduleType
  71. this.getLineMonthData()
  72. },
  73. initMonthDataEcharts() {
  74. this.dom2 = document.getElementById('container3');
  75. this.myChart2 = echarts.init(this.dom2, 'dark');
  76. this.option2 = {
  77. backgroundColor: '#001529',
  78. legend: {
  79. show: false,
  80. left: 'right'
  81. },
  82. tooltip: {
  83. },
  84. xAxis: {
  85. /* type: 'value',*/
  86. show: false,
  87. axisLabel: {
  88. fontSize: 16
  89. }
  90. },
  91. textStyle: {
  92. "fontSize": 14
  93. },
  94. yAxis: {
  95. /*type: 'category',*/
  96. inverse: false,
  97. show: false,
  98. axisLabel: {
  99. fontSize: 16
  100. },
  101. max: 3
  102. },
  103. grid: {
  104. top: "15px",
  105. left: "25px",
  106. right: "25px",
  107. bottom: '25px',
  108. }
  109. };
  110. if (this.option2 && typeof option2 === 'object') {
  111. this.myChart2.setOption(this.option2);
  112. }
  113. window.addEventListener('resize', this.myChart2.resize);
  114. this.dom1 = document.getElementById('container2');
  115. this.myChart1 = echarts.init(this.dom1, 'dark');
  116. this.option1 = {
  117. backgroundColor: '#001529',
  118. legend: {
  119. show: true,
  120. left: 'right',
  121. padding: [0, 20, 15, 10],
  122. selected: {
  123. '产能': true,
  124. '目标产能': true,
  125. '差异': true,
  126. '累计差异': false
  127. }
  128. },
  129. tooltip: {},
  130. xAxis: {
  131. axisLabel: {
  132. fontSize: 16
  133. }
  134. },
  135. textStyle: {
  136. "fontSize": 16
  137. },
  138. yAxis: {
  139. show: false,
  140. axisLabel: {
  141. fontSize: 16
  142. }
  143. },
  144. grid: {
  145. left: "25px",
  146. right: "25px",
  147. bottom: '40px',
  148. }
  149. };
  150. this.myChart1.on('click', (params) => this.onClickMonthData(params));
  151. if (this.option1 && typeof option1 === 'object') {
  152. this.myChart1.setOption(this.option1);
  153. }
  154. window.addEventListener('resize', this.myChart1.resize);
  155. },
  156. addMonthData(dates, planCapacities, capacities, differences, accumulatedDifferences) {
  157. this.option1.series = [];
  158. this.option1.xAxis.data = dates;
  159. var serie2 = {
  160. name: '产能',
  161. type: 'bar',
  162. stack: 'Total',
  163. label: {
  164. show: true
  165. },
  166. itemStyle: {
  167. normal: {
  168. color: '#4472c4'
  169. }
  170. },
  171. tooltip: {
  172. formatter: (params) => this.getMonthDayData(params),
  173. textStyle: {
  174. "fontSize": 18
  175. }
  176. },
  177. data: capacities
  178. }
  179. this.option1.series.push(serie2);
  180. var serie1 = {
  181. name: '目标产能',
  182. type: 'line',
  183. step: 'middle',
  184. showSymbol: true,
  185. itemStyle: {
  186. normal: {
  187. color: '#fddd60',
  188. lineStyle: {
  189. width: 2
  190. }
  191. }
  192. },
  193. tooltip: {
  194. formatter: (params) => this.getMonthDayData(params),
  195. textStyle: {
  196. "fontSize": 18
  197. }
  198. },
  199. label: {
  200. show: true
  201. },
  202. data: planCapacities
  203. }
  204. this.option1.series.push(serie1);
  205. var serie3 = {
  206. name: '差异',
  207. type: 'bar',
  208. stack: 'Total',
  209. itemStyle: {
  210. normal: {
  211. color: '#ff6e76'
  212. }
  213. },
  214. tooltip: {
  215. formatter: (params) => this.getMonthDayData(params),
  216. textStyle: {
  217. "fontSize": 18
  218. }
  219. },
  220. label: {
  221. show: true,
  222. color: '#fff'
  223. },
  224. data: differences
  225. }
  226. this.option1.series.push(serie3);
  227. //var serie4 = {
  228. // name: '累计差异',
  229. // type: 'line',
  230. // itemStyle: {
  231. // normal: {
  232. // color: '#ed7d31'
  233. // }
  234. // },
  235. // label: {
  236. // show: true
  237. // },
  238. // tooltip: {
  239. // formatter: (params) => this.getMonthDayData(params),
  240. // textStyle: {
  241. // "fontSize": 18
  242. // }
  243. // },
  244. // data: accumulatedDifferences
  245. //}
  246. //this.option1.series.push(serie4);
  247. this.myChart1.setOption(this.option1, true);
  248. this.myChart1.resize();
  249. },
  250. addMonthDataPlan(datas, series) {
  251. this.option2.series = [];
  252. this.option2.xAxis.data = datas;
  253. for (var i = 0; i < series.length; i++) {
  254. var x = 0;
  255. var ds = [];
  256. var y = i % 3;
  257. for (var j = 0; j < series[i].values.length; j++) {
  258. if (series[i].values[j] === "") {
  259. ds[j] = ""
  260. } else {
  261. ds[j] = parseInt(series[i].values[j]) + y
  262. }
  263. x = series[i].start;
  264. }
  265. if (x === 0) {
  266. x += 0.5
  267. } else if (x === series[i].values.length - 1) {
  268. } else {
  269. x += 0.5
  270. }
  271. var serie = {
  272. name: series[i].name,
  273. type: 'line',
  274. step: 'middle',
  275. showSymbol: false,
  276. itemStyle: {
  277. normal: {
  278. color: 'rgba(74,125,215,0.6)',
  279. lineStyle: {
  280. width: 35
  281. }
  282. }
  283. },
  284. markPoint: {
  285. data: [{
  286. coord: [x, y + 1],
  287. symbol: 'rect',
  288. symbolSize: [30, 0],
  289. animation: true,
  290. label: {
  291. show: true,
  292. formatter: series[i].name
  293. },
  294. tooltip: {
  295. formatter: series[i].name + ' Plan: ' + series[i].planCapacities + ' pcs',
  296. textStyle: {
  297. "fontSize": 18
  298. }
  299. }
  300. }]
  301. },
  302. data: ds
  303. }
  304. this.option2.series.push(serie);
  305. }
  306. this.myChart2.setOption(this.option2, true);
  307. this.myChart2.resize();
  308. },
  309. getMonthDayData(params) {
  310. var rev = ''
  311. rev += '<div class="show">'
  312. rev += '日期: ' + this.newDates[params.dataIndex] + ' <br/>'
  313. rev += '目标产能: ' + this.planCapacities[params.dataIndex] + ' pcs<br/>'
  314. rev += '实际产能: ' + this.capacities[params.dataIndex] + ' pcs<br/>'
  315. if (this.differences[params.dataIndex] === "") {
  316. rev += '差异产能: ' + 0 + ' pcs<br/>'
  317. } else {
  318. rev += '差异产能: ' + this.differences[params.dataIndex] + ' pcs<br/>'
  319. }
  320. rev += '累计差异: ' + this.accumulatedDifferences[params.dataIndex] + ' pcs<br/>'
  321. rev += '</div>'
  322. return rev
  323. },
  324. onClickMonthData(params) {
  325. var d = new Date(this.dates[params.dataIndex])
  326. $("#date").val(d).datepicker('setDate', d)
  327. this.getData()
  328. },
  329. initData() {
  330. let cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)lineId\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  331. let cookieValueLineName = document.cookie.replace(/(?:(?:^|.*;\s*)lineName\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  332. let cookieLineModuleType = document.cookie.replace(/(?:(?:^|.*;\s*)lineModuleType\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  333. if (cookieValue != "") {
  334. this.selectId = cookieValue
  335. this.lineName = cookieValueLineName
  336. this.lineModuleType = cookieLineModuleType
  337. } else {
  338. this.selectId = "00000000-0000-0000-0000-000000000000"
  339. this.lineName = "总览"
  340. }
  341. this.getData()
  342. },
  343. getLineOverview() {
  344. let _this = this
  345. axios
  346. .get(
  347. '/Line/GetLineOverviewV1',
  348. {
  349. params: {
  350. date: $("#date").val()
  351. }
  352. }
  353. )
  354. .then(function (response) {
  355. _this.lineOverViews = response.data
  356. })
  357. .catch(function (error) {
  358. console.log(error)
  359. });
  360. },
  361. initDatepicker() {
  362. $("#date").datepicker({
  363. format: 'yyyy-mm-dd',
  364. language: "zh-CN",
  365. autoclose: true,
  366. todayBtn: "linked"
  367. }).on('changeDate',
  368. () => this.selectDatepicker()
  369. ).on('keydown', function (e) {
  370. return false;
  371. })
  372. },
  373. onClickCell(id, moduleType) {
  374. this.selectId = id
  375. $("#Line").val(id)
  376. this.lineName = $('#Line option:selected').text();
  377. document.cookie = 'lineId=' + id
  378. document.cookie = 'lineName=' + this.lineName
  379. document.cookie = 'action='
  380. //document.cookie = 'lineModuleType=' + moduleType
  381. //this.lineModuleType = moduleType;
  382. document.cookie = 'lineModuleType=' + 'ALL'
  383. this.lineModuleType = 'ALL';
  384. this.getData()
  385. this.getLineMonthData()
  386. },
  387. returnOverview() {
  388. let cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)lineId\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  389. let cookieValueLineName = document.cookie.replace(/(?:(?:^|.*;\s*)lineName\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  390. let action = document.cookie.replace(/(?:(?:^|.*;\s*)action\s*\=\s*([^;]*).*$)|^.*$/, "$1");
  391. if (action === 'Home') {
  392. window.location.href = "/Home";
  393. } else {
  394. this.selectId = '00000000-0000-0000-0000-000000000000'
  395. $("#Line").val(this.selectId)
  396. this.lineName = $('#Line option:selected').text();
  397. document.cookie = 'lineId=' + this.selectId
  398. document.cookie = 'lineName=' + this.lineName
  399. document.cookie = 'action='
  400. document.cookie = 'lineModuleType='
  401. this.getData()
  402. }
  403. },
  404. selectDatepicker(e) {
  405. this.getData()
  406. },
  407. initCapacityEcharts() {
  408. this.dom = document.getElementById('container1');
  409. this.myChart = echarts.init(this.dom, 'dark');
  410. this.option = {
  411. backgroundColor: '#001529',
  412. legend: {
  413. left: 'right',
  414. data: ["早班", "夜班", "目标产能", "差异"]
  415. },
  416. tooltip: {},
  417. xAxis: {
  418. data: [
  419. "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
  420. "20", "21", "22", "23", "00", "01", "02", "03", "04", "05", "06", "07"],
  421. axisLabel: {
  422. fontSize: 16
  423. }
  424. },
  425. textStyle: {
  426. "fontSize": 16
  427. },
  428. yAxis: {
  429. show: false,
  430. axisLabel: {
  431. fontSize: 16
  432. }
  433. },
  434. grid: {
  435. left: "25px",
  436. right: "25px"
  437. }
  438. };
  439. if (this.option && typeof option === 'object') {
  440. this.myChart.setOption(this.option);
  441. }
  442. window.addEventListener('resize', this.myChart.resize);
  443. },
  444. addHourCapacityAndCapa(data, tData) {
  445. this.MorningCapacity = this.sum(data.slice(0, 12))
  446. this.NightCapacity = this.sum(data.slice(12, 24))
  447. this.TotalCapacity = this.MorningCapacity + this.NightCapacity
  448. this.option.series = [];
  449. var serie1 = {
  450. name: '早班',
  451. type: 'bar',
  452. stack: 'Total',
  453. tooltip: {
  454. formatter: (params) => this.getHourData(params, ""),
  455. textStyle: {
  456. "fontSize": 18
  457. }
  458. },
  459. label: {
  460. show: true
  461. },
  462. data: data.slice(0, 12)
  463. }
  464. this.option.series.push(serie1);
  465. data1 = ['-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-']
  466. for (var i = 12; i < 24; i++) {
  467. data1.push(data[i])
  468. }
  469. var serie2 = {
  470. name: '夜班',
  471. type: 'bar',
  472. stack: 'Total',
  473. tooltip: {
  474. formatter: (params) => this.getHourData(params, ""),
  475. textStyle: {
  476. "fontSize": 18
  477. }
  478. },
  479. label: {
  480. show: true
  481. },
  482. data: data1
  483. }
  484. this.option.series.push(serie2);
  485. var serie3 = {
  486. name: '目标产能',
  487. type: 'line',
  488. tooltip: {
  489. valueFormatter: function (value) {
  490. return value + " pcs";
  491. }
  492. },
  493. label: {
  494. show: true
  495. },
  496. itemStyle: {
  497. normal: {
  498. lineStyle: {
  499. width: 3
  500. }
  501. }
  502. },
  503. data: tData
  504. }
  505. this.option.series.push(serie3);
  506. data2 = [];
  507. for (var i = 0; i < tData.length; i++) {
  508. var temp = tData[i] - data[i]
  509. if (temp > 0) {
  510. data2.push(temp)
  511. } else {
  512. data2.push('-')
  513. }
  514. }
  515. var serie4 = {
  516. name: '差异',
  517. type: 'bar',
  518. stack: 'Total',
  519. tooltip: {
  520. formatter: (params) => this.getHourData(params, "差异"),
  521. textStyle: {
  522. "fontSize": 18
  523. }
  524. },
  525. label: {
  526. show: true
  527. },
  528. data: data2
  529. }
  530. this.option.series.push(serie4);
  531. this.myChart.setOption(this.option, true);
  532. this.myChart.resize();
  533. },
  534. getHourData(params, serieName) {
  535. var rev = ''
  536. rev += '<div class="show">'
  537. rev += serieName + '产能: ' + params.value + ' pcs<br/>'
  538. rev += '<br/>'
  539. var idelTime = 0;
  540. if (this.lineData.hourKeyInInfos !== undefined) {
  541. for (var i = 0; i < this.lineData.hourKeyInInfos.length; i++) {
  542. var h = this.lineData.hourKeyInInfos[i].startTime.substring(11, 13)
  543. if (h == params.name) {
  544. idelTime += this.lineData.hourKeyInInfos[i].affectTime
  545. }
  546. }
  547. }
  548. rev += '<strong>Idel - ' + idelTime.toFixed(0) + 'min</strong><br/>'
  549. if (this.lineData.hourKeyInInfos !== undefined) {
  550. for (var i = 0; i < this.lineData.hourKeyInInfos.length; i++) {
  551. var h = this.lineData.hourKeyInInfos[i].startTime.substring(11, 13)
  552. if (h == params.name) {
  553. rev += this.lineData.hourKeyInInfos[i].keyInTypeName + ', '
  554. + this.lineData.hourKeyInInfos[i].description + ', '
  555. + this.lineData.hourKeyInInfos[i].affectTime.toFixed(0)
  556. + 'min<br/>'
  557. }
  558. }
  559. }
  560. rev += '<br/>'
  561. var downTime = 0;
  562. if (this.lineFault !== undefined) {
  563. for (var i = 0; i < this.lineFault.length; i++) {
  564. var h = this.lineFault[i].startTime.substring(11, 13)
  565. if (h == params.name) {
  566. downTime += this.lineFault[i].duration
  567. }
  568. }
  569. }
  570. rev += '<strong>Down - ' + downTime.toFixed(0) + ' min</strong><br/>'
  571. if (this.lineFault !== undefined) {
  572. for (var i = 0; i < this.lineFault.length; i++) {
  573. var h = this.lineFault[i].startTime.substring(11, 13)
  574. if (h == params.name) {
  575. if (this.lineFault[i].duration.toFixed(0) !== '0') {
  576. rev += this.lineFault[i].machineType + ', '
  577. + this.lineFault[i].faultInfo + ', '
  578. + this.lineFault[i].duration.toFixed(0)
  579. + 'min, '
  580. if (this.lineFault[i].dataSource === 0) {
  581. rev += "自动上抛<br/>"
  582. } else {
  583. rev += "人工录入<br/>"
  584. }
  585. }
  586. }
  587. }
  588. }
  589. rev += '</div>'
  590. return rev
  591. },
  592. sum(arr) {
  593. var sum = 0
  594. for (var i = 0; i < arr.length; i++) {
  595. sum += arr[i]
  596. }
  597. return sum
  598. },
  599. getData() {
  600. if (this.selectId === '00000000-0000-0000-0000-000000000000') {
  601. $("#overview").attr("class", "tab-pane active")
  602. $("#line").attr("class", "tab-pane")
  603. this.getLineOverview()
  604. this.date = $("#date").val()
  605. this.isLine = false
  606. } else {
  607. $("#overview").attr("class", "tab-pane")
  608. $("#line").attr("class", "tab-pane active")
  609. this.getLineData()
  610. this.getLineFault()
  611. this.getLineMorningAccumulatedFault()
  612. this.getLineNightAccumulatedFault()
  613. this.getLineMonthData()
  614. this.date = $("#date").val()
  615. this.isLine = true
  616. }
  617. },
  618. getLineData() {
  619. this.lineData = {}
  620. /* this.initCapacityEcharts()*/
  621. let _this = this
  622. axios
  623. .get(
  624. '/Line/GetLineData',
  625. {
  626. params: {
  627. lineId: _this.selectId,
  628. date: $("#date").val()
  629. }
  630. }
  631. )
  632. .then(function (response) {
  633. if (response.data !== null) {
  634. _this.lineData = response.data
  635. _this.moduleType = ""
  636. for (var i = 0; i < _this.lineData.statistics.length; i++) {
  637. _this.moduleType += _this.lineData.statistics[i].moduleType + " "
  638. }
  639. var data = []
  640. var tData = []
  641. for (var i = 0; i < _this.lineData.newOutPutPerHours.length; i++) {
  642. data.push(_this.lineData.newOutPutPerHours[i].outPut)
  643. }
  644. for (var i = 0; i < _this.lineData.newOutPutPerHours.length; i++) {
  645. if (_this.lineData.newOutPutPerHours[i].moduleType === "") {
  646. tData.push("")
  647. } else {
  648. var b = false
  649. for (var j = 0; j < _this.lineData.productionPlans.length; j++) {
  650. if (_this.lineData.newOutPutPerHours[i].moduleType.substr(0, 8)
  651. === _this.lineData.productionPlans[j].moduleType.substr(0, 8)) {
  652. tData.push((_this.lineData.productionPlans[j].capa / 24).toFixed(0))
  653. b = true
  654. break;
  655. }
  656. }
  657. if (b == false) {
  658. tData.push("")
  659. }
  660. }
  661. }
  662. _this.addHourCapacityAndCapa(data, tData)
  663. }
  664. })
  665. .catch(function (error) {
  666. console.log(error)
  667. });
  668. },
  669. getLines() {
  670. let _this = this
  671. axios
  672. .get('/ProductionLine/GetProductionLines')
  673. .then(function (response) {
  674. if (response.data !== null) {
  675. _this.lines = response.data.data
  676. _this.$nextTick(() => {
  677. $("#Line").prepend("<option value='00000000-0000-0000-0000-000000000000'>总览</option>");
  678. $("#Line").val(_this.selectId)
  679. })
  680. }
  681. })
  682. .catch(function (error) {
  683. console.log(error)
  684. });
  685. },
  686. select(event) {
  687. this.selectId = event.target.value
  688. this.lineName = $('#Line option:selected').text();
  689. document.cookie = 'lineId=' + this.selectId
  690. document.cookie = 'lineName=' + this.lineName
  691. document.cookie = 'lineModuleType=' + 'ALL';
  692. this.lineModuleType = "ALL";
  693. this.getData()
  694. },
  695. getLineKeyFaults() {
  696. this.lineKeyFaults = []
  697. let _this = this
  698. axios
  699. .get(
  700. '/Line/GetKeyFaults',
  701. {
  702. params: {
  703. id: _this.selectId,
  704. date: $("#date").val()
  705. }
  706. }
  707. )
  708. .then(function (response) {
  709. if (response.data !== null) {
  710. _this.lineKeyFaults = response.data
  711. }
  712. })
  713. .catch(function (error) {
  714. console.log(error)
  715. });
  716. },
  717. getLineFault() {
  718. this.lineFault = []
  719. let _this = this
  720. axios
  721. .get(
  722. '/Line/GetLineFault',
  723. {
  724. params: {
  725. lineId: _this.selectId,
  726. date: $("#date").val(),
  727. durationThreshold: 3
  728. }
  729. }
  730. )
  731. .then(function (response) {
  732. if (response.data !== null) {
  733. _this.lineFault = response.data
  734. }
  735. })
  736. .catch(function (error) {
  737. console.log(error)
  738. });
  739. },
  740. getLineMorningAccumulatedFault() {
  741. this.LineMorningAccumulatedFault = []
  742. let _this = this
  743. axios
  744. .get(
  745. '/Line/GetLineAccumulatedFaultByMorning',
  746. {
  747. params: {
  748. lineId: _this.selectId,
  749. date: $("#date").val()
  750. }
  751. }
  752. )
  753. .then(function (response) {
  754. if (response.data !== null) {
  755. _this.lineMorningAccumulatedFault = response.data
  756. }
  757. })
  758. .catch(function (error) {
  759. console.log(error)
  760. });
  761. },
  762. getLineNightAccumulatedFault() {
  763. this.lineNightAccumulatedFault = []
  764. let _this = this
  765. axios
  766. .get(
  767. '/Line/GetLineAccumulatedFaultByNight',
  768. {
  769. params: {
  770. lineId: _this.selectId,
  771. date: $("#date").val()
  772. }
  773. }
  774. )
  775. .then(function (response) {
  776. if (response.data !== null) {
  777. _this.lineNightAccumulatedFault = response.data
  778. }
  779. })
  780. .catch(function (error) {
  781. console.log(error)
  782. });
  783. },
  784. getFloorOverview(floor) {
  785. var data = []
  786. for (var i = 0; i < this.lineOverViews.length; i++) {
  787. if (this.lineOverViews[i].floor == floor) {
  788. data.push(this.lineOverViews[i])
  789. }
  790. }
  791. return data
  792. },
  793. nextDay() {
  794. var date = new Date($("#date").val())
  795. var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() + 1)
  796. $("#date").val(d).datepicker('setDate', d)
  797. },
  798. lastDay() {
  799. var date = new Date($("#date").val())
  800. var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() - 1)
  801. $("#date").val(d).datepicker('setDate', d)
  802. },
  803. getLineMonthData() {
  804. if (this.selectId !== '00000000-0000-0000-0000-000000000000') {
  805. let _this = this
  806. axios
  807. .get(
  808. '/Line/GetMonthData',
  809. {
  810. params: {
  811. lineId: _this.selectId,
  812. date: $("#date").val(),
  813. moduleType: _this.lineModuleType
  814. }
  815. }
  816. )
  817. .then(function (response) {
  818. _this.monthTitle = response.data.monthTitle;
  819. _this.dates = response.data.dates;
  820. _this.newDates = response.data.newDates;
  821. _this.planCapacities = response.data.planCapacities;
  822. _this.capacities = response.data.capacities;
  823. _this.differences = response.data.differences;
  824. _this.accumulatedDifferences = response.data.accumulatedDifferences;
  825. _this.accumulatedDifference = response.data.accumulatedDifference;
  826. _this.moduleTypes = response.data.moduleTypes;
  827. _this.addMonthData(response.data.newDates, response.data.planCapacities,
  828. response.data.capacities, response.data.differences,
  829. response.data.accumulatedDifferences)
  830. _this.addMonthDataPlan(response.data.newDates, response.data.series)
  831. })
  832. .catch(function (error) {
  833. console.log(error)
  834. });
  835. }
  836. },
  837. sort() {
  838. var iconName = $("#sortSpan").attr("class");
  839. switch (iconName) {
  840. case "glyphicon glyphicon-sort-by-alphabet":
  841. this.lineOverViews.sort(function (a, b) {
  842. return b.achievementRate - a.achievementRate;
  843. });
  844. $("#sortSpan").attr("class", "glyphicon glyphicon-sort-by-attributes-alt")
  845. break;
  846. case "glyphicon glyphicon-sort-by-attributes-alt":
  847. this.lineOverViews.sort(function (a, b) {
  848. return a.achievementRate - b.achievementRate;
  849. });
  850. $("#sortSpan").attr("class", "glyphicon glyphicon-sort-by-attributes");
  851. break;
  852. case "glyphicon glyphicon-sort-by-attributes":
  853. this.lineOverViews.sort(function (a, b) {
  854. return a.line - b.line;
  855. });
  856. this.lineOverViews.sort(function (a, b) {
  857. return b.floor - a.floor;
  858. });
  859. $("#sortSpan").attr("class", "glyphicon glyphicon-sort-by-alphabet");
  860. break;
  861. }
  862. },
  863. jumpEyz() {
  864. this.selectId = '00000000-0000-0000-0000-000000000000'
  865. $("#Line").val(this.selectId)
  866. this.lineName = $('#Line option:selected').text();
  867. document.cookie = 'lineId=' + this.selectId
  868. document.cookie = 'lineName=' + this.lineName
  869. document.cookie = 'action='
  870. document.cookie = 'lineModuleType='
  871. window.location.href = "http://eyz2rp3.toc.eink.com/ERS/#/Home/IndexPage";
  872. },
  873. ExportineAccumulatedFaultByMorning() {
  874. let _this = this
  875. window.open("/Line/ExportineAccumulatedFaultByMorning?lineId="
  876. + _this.selectId + "&date=" + $("#date").val());
  877. },
  878. ExportineAccumulatedFaultByNight() {
  879. let _this = this
  880. window.open("/Line/ExportineAccumulatedFaultByNight?lineId="
  881. + _this.selectId + "&date=" + $("#date").val());
  882. },
  883. jumpNextMonth() {
  884. let currentDate = new Date();
  885. let nextMonth = currentDate.getMonth() + 1;
  886. let nextMonthDay = currentDate.getDate();
  887. if (nextMonth === 13) {
  888. nextMonth = 0;
  889. }
  890. currentDate.setMonth(nextMonth);
  891. currentDate.setDate(nextMonthDay);
  892. $("#date").val(currentDate).datepicker('setDate', currentDate);
  893. },
  894. jumpTheSameDay() {
  895. let currentDate = new Date();
  896. $("#date").val(currentDate).datepicker('setDate', currentDate);
  897. }
  898. },
  899. filters: {
  900. dataTimeFormat: function (value) {
  901. return value.substr(11, 5)
  902. },
  903. dataTimeFormatV1: function (value) {
  904. return value.substr(0, 19)
  905. },
  906. dataTimeFormatV2: function (value) {
  907. return value.substr(5, 2) + "/" + value.substr(8, 2) + ' ' + value.substr(11, 5)
  908. }
  909. },
  910. computed: {
  911. getKeyInInfoAffectTime() {
  912. var keyInInfoAffectTime = 0
  913. if (this.lineData.keyInInfos !== undefined) {
  914. for (var i = 0; i < this.lineData.keyInInfos.length; i++) {
  915. keyInInfoAffectTime += this.lineData.keyInInfos[i].affectTime
  916. }
  917. }
  918. return keyInInfoAffectTime
  919. },
  920. getKeyInInfoAffectTime_8() {
  921. var keyInInfoAffectTime = 0
  922. if (this.lineData.keyInInfos !== undefined) {
  923. for (var i = 0; i < this.lineData.keyInInfos.length; i++) {
  924. if (this.lineData.keyInInfos[i].keyInType == 8) {
  925. keyInInfoAffectTime += this.lineData.keyInInfos[i].affectTime
  926. }
  927. }
  928. }
  929. return keyInInfoAffectTime
  930. },
  931. getKeyInInfoAffectTime_8_morning() {
  932. var keyInInfoAffectTime = 0
  933. if (this.lineData.morningReplaceConsumables !== undefined) {
  934. for (var i = 0; i < this.lineData.morningReplaceConsumables.length; i++) {
  935. keyInInfoAffectTime += this.lineData.morningReplaceConsumables[i].accumulativeTime
  936. }
  937. }
  938. return keyInInfoAffectTime
  939. },
  940. getKeyInInfoAffectTime_8_night() {
  941. var keyInInfoAffectTime = 0
  942. if (this.lineData.nightReplaceConsumables !== undefined) {
  943. for (var i = 0; i < this.lineData.nightReplaceConsumables.length; i++) {
  944. keyInInfoAffectTime += this.lineData.nightReplaceConsumables[i].accumulativeTime
  945. }
  946. }
  947. return keyInInfoAffectTime
  948. },
  949. getKeyInInfoAffectTime_9() {
  950. var keyInInfoAffectTime = 0
  951. if (this.lineData.keyInInfos !== undefined) {
  952. for (var i = 0; i < this.lineData.keyInInfos.length; i++) {
  953. if (this.lineData.keyInInfos[i].keyInType == 9) {
  954. keyInInfoAffectTime += this.lineData.keyInInfos[i].affectTime
  955. }
  956. }
  957. }
  958. return keyInInfoAffectTime
  959. },
  960. getKeyInInfoDown() {
  961. var keyInInfoAffectTime = 0
  962. if (this.lineData.faultStatistics !== undefined) {
  963. for (var i = 0; i < this.lineData.faultStatistics.length; i++) {
  964. keyInInfoAffectTime += this.lineData.faultStatistics[i].downTime
  965. }
  966. }
  967. return keyInInfoAffectTime
  968. }
  969. }
  970. })