difference.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. var vm = new Vue({
  2. el: '#app',
  3. data: {
  4. mark: "",
  5. module: "",
  6. year: "",
  7. month: "",
  8. lines: "",
  9. newDates: [],
  10. planCapacities: [],
  11. capacities: [],
  12. differences: [],
  13. dom1: Object,
  14. myChart1: Object,
  15. option1: Object,
  16. },
  17. mounted() {
  18. this.init()
  19. this.initEcharts()
  20. this.getMonthData()
  21. },
  22. methods: {
  23. init() {
  24. let url = new URL(window.location.href);
  25. this.mark = url.searchParams.get("mark");
  26. this.module = url.searchParams.get("module");
  27. this.year = url.searchParams.get("year");
  28. this.month = url.searchParams.get("month");
  29. this.lines = url.searchParams.get("lines");
  30. document.title = this.module + " - 差异详情";
  31. this.title = this.module + " " + this.year + "年 " + this.month + "月 " + "差异详情";
  32. },
  33. initEcharts() {
  34. this.dom1 = document.getElementById('container');
  35. this.myChart1 = echarts.init(this.dom1, 'dark');
  36. this.option1 = {
  37. backgroundColor: '#001529',
  38. legend: {
  39. left: 'right',
  40. selected: {
  41. '产能': true,
  42. '目标产能': false,
  43. '差异': true
  44. }
  45. },
  46. tooltip: {},
  47. xAxis: {
  48. axisLabel: {
  49. fontSize: 16
  50. }
  51. },
  52. textStyle: {
  53. "fontSize": 16
  54. },
  55. yAxis: {
  56. show: false,
  57. axisLabel: {
  58. fontSize: 16
  59. }
  60. },
  61. grid: {
  62. left: "25px",
  63. right: "25px"
  64. }
  65. };
  66. if (this.option1 && typeof option1 === 'object') {
  67. this.myChart1.setOption(this.option1);
  68. }
  69. window.addEventListener('resize', this.myChart1.resize);
  70. },
  71. addSerie(dates, capacities, planCapacities, differences) {
  72. this.option1.series = [];
  73. this.option1.xAxis.data = dates;
  74. var serie2 = {
  75. name: '产能',
  76. type: 'bar',
  77. stack: 'Total',
  78. label: {
  79. show: true
  80. },
  81. itemStyle: {
  82. normal: {
  83. color: '#4472c4'
  84. }
  85. },
  86. tooltip: {
  87. formatter: (params) => this.getMonthDayData(params),
  88. textStyle: {
  89. "fontSize": 18
  90. }
  91. },
  92. data: capacities
  93. }
  94. this.option1.series.push(serie2);
  95. var serie1 = {
  96. name: '目标产能',
  97. type: 'line',
  98. step: 'middle',
  99. itemStyle: {
  100. normal: {
  101. color: '#fddd60',
  102. lineStyle: {
  103. color: '#fddd60'
  104. }
  105. }
  106. },
  107. tooltip: {
  108. formatter: (params) => this.getMonthDayData(params),
  109. textStyle: {
  110. "fontSize": 18
  111. }
  112. },
  113. label: {
  114. show: true
  115. },
  116. data: planCapacities
  117. }
  118. this.option1.series.push(serie1);
  119. var serie3 = {
  120. name: '差异',
  121. type: 'bar',
  122. stack: 'Total',
  123. itemStyle: {
  124. normal: {
  125. color: '#ff6e76'
  126. }
  127. },
  128. tooltip: {
  129. formatter: (params) => this.getMonthDayData(params),
  130. textStyle: {
  131. "fontSize": 18
  132. }
  133. },
  134. label: {
  135. show: true,
  136. color: '#fff'
  137. },
  138. data: differences
  139. }
  140. this.option1.series.push(serie3);
  141. this.myChart1.setOption(this.option1, true);
  142. this.myChart1.resize();
  143. },
  144. getMonthDayData(params) {
  145. var rev = ''
  146. rev += '<div class="show">'
  147. rev += '日期: ' + this.newDates[params.dataIndex] + ' <br/>'
  148. rev += '目标产能: ' + this.planCapacities[params.dataIndex] + ' pcs<br/>'
  149. rev += '实际产能: ' + this.capacities[params.dataIndex] + ' pcs<br/>'
  150. if (this.differences[params.dataIndex] === "") {
  151. rev += '差异产能: ' + 0 + ' pcs<br/>'
  152. } else {
  153. rev += '差异产能: ' + this.differences[params.dataIndex] + ' pcs<br/>'
  154. }
  155. rev += '</div>'
  156. return rev
  157. },
  158. getMonthData() {
  159. let _this = this
  160. axios
  161. .get('/MonthModule/Difference/MonthOverview',
  162. {
  163. params: {
  164. mark: _this.mark,
  165. year: _this.year,
  166. month: _this.month,
  167. moduleType: _this.module,
  168. lines: _this.lines
  169. }
  170. })
  171. .then(function (response) {
  172. if (response.data !== null) {
  173. _this.newDates = response.data.dates
  174. _this.planCapacities = response.data.planCapacities
  175. _this.capacities = response.data.capacities
  176. _this.differences = response.data.differences
  177. _this.addSerie(response.data.newDates, response.data.capacities,
  178. response.data.planCapacities, response.data.differences)
  179. }
  180. })
  181. .catch(function (error) {
  182. console.log(error)
  183. });
  184. }
  185. }
  186. })