differenceV1.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. var vm = new Vue({
  2. el: '#app',
  3. data: {
  4. mark: "",
  5. module: "",
  6. year: "",
  7. month: "",
  8. modules: "",
  9. lines: "",
  10. newDates: [],
  11. planCapacities: [],
  12. capacities: [],
  13. differences: [],
  14. ms: [],
  15. ls: [],
  16. moduleType: "",
  17. keyInInfos: [],
  18. differenceInfos: [],
  19. line: 0,
  20. difference: 0,
  21. dom1: Object,
  22. myChart1: Object,
  23. option1: Object,
  24. dom2: Object,
  25. myChart2: Object,
  26. option2: Object
  27. },
  28. watch: {
  29. ms: function () {
  30. this.$nextTick(function () {
  31. $("input[name='optionsRadios'][value=" + this.moduleType + "]").prop("checked", true)
  32. });
  33. },
  34. ls: function () {
  35. this.$nextTick(function () {
  36. $("input[name='optionsRadios1'][value=" + this.line + "]").prop("checked", true)
  37. });
  38. }
  39. },
  40. mounted() {
  41. this.init()
  42. this.initEcharts()
  43. this.getMonthData()
  44. //this.getMonthDataByKeyin()
  45. },
  46. methods: {
  47. revert() {
  48. //window.open("/Home/V1", "home-v1");
  49. window.location.href = "/Home/V1";
  50. },
  51. onClickOptionsRadios() {
  52. let m = $("input[name='optionsRadios']:checked").val()
  53. if (m === "" || m === undefined) {
  54. m = "ALL"
  55. }
  56. this.moduleType = m
  57. let l = $("input[name='optionsRadios1']:checked").val()
  58. if (l === "" || l === undefined) {
  59. l = 0
  60. }
  61. this.line = l
  62. this.getMonthData()
  63. },
  64. init() {
  65. let url = new URL(window.location.href);
  66. this.mark = url.searchParams.get("mark");
  67. this.module = url.searchParams.get("module");
  68. this.year = url.searchParams.get("year");
  69. this.month = url.searchParams.get("month");
  70. this.lines = url.searchParams.get("lines");
  71. this.modules = url.searchParams.get("module");
  72. this.moduleType = "ALL";
  73. this.ms = this.modules.split(",");
  74. this.ls = this.lines.split(",");
  75. document.title = this.module + " - 差异详情";
  76. this.title = this.module + " " + this.year + "年 " + this.month + "月 " + "差异详情";
  77. },
  78. initEcharts() {
  79. this.dom1 = document.getElementById('container');
  80. this.myChart1 = echarts.init(this.dom1, 'dark');
  81. this.option1 = {
  82. backgroundColor: '#001529',
  83. legend: {
  84. left: 'right',
  85. selected: {
  86. '产能': true,
  87. '目标产能': true,
  88. '差异': true
  89. }
  90. },
  91. tooltip: {},
  92. xAxis: {
  93. axisLabel: {
  94. fontSize: 16
  95. }
  96. },
  97. textStyle: {
  98. "fontSize": 16
  99. },
  100. yAxis: {
  101. show: false,
  102. axisLabel: {
  103. fontSize: 16
  104. }
  105. },
  106. grid: {
  107. left: "25px",
  108. right: "25px"
  109. }
  110. };
  111. if (this.option1 && typeof option1 === 'object') {
  112. this.myChart1.setOption(this.option1);
  113. }
  114. window.addEventListener('resize', this.myChart1.resize);
  115. this.dom2 = document.getElementById('container1');
  116. this.myChart2 = echarts.init(this.dom2, 'dark');
  117. this.option2 = {
  118. backgroundColor: '#001529',
  119. legend: {
  120. show: false,
  121. left: 'right'
  122. },
  123. tooltip: {},
  124. xAxis: {
  125. show: false,
  126. axisLabel: {
  127. fontSize: 16
  128. }
  129. },
  130. textStyle: {
  131. "fontSize": 14
  132. },
  133. yAxis: {
  134. inverse: false,
  135. show: false,
  136. axisLabel: {
  137. fontSize: 16
  138. }
  139. },
  140. grid: {
  141. top: "15px",
  142. left: "25px",
  143. right: "25px",
  144. bottom: '25px',
  145. }
  146. };
  147. if (this.option2 && typeof option2 === 'object') {
  148. this.myChart2.setOption(this.option2);
  149. }
  150. window.addEventListener('resize', this.myChart2.resize);
  151. },
  152. addSerie(dates, capacities, planCapacities, differences) {
  153. this.option1.series = [];
  154. this.option1.xAxis.data = dates;
  155. var serie2 = {
  156. name: '产能',
  157. type: 'bar',
  158. stack: 'Total',
  159. label: {
  160. show: true
  161. },
  162. itemStyle: {
  163. normal: {
  164. color: '#4472c4'
  165. }
  166. },
  167. tooltip: {
  168. formatter: (params) => this.getMonthDayData(params),
  169. textStyle: {
  170. "fontSize": 18
  171. }
  172. },
  173. data: capacities
  174. }
  175. this.option1.series.push(serie2);
  176. var serie1 = {
  177. name: '目标产能',
  178. type: 'line',
  179. step: 'middle',
  180. itemStyle: {
  181. normal: {
  182. color: '#fddd60',
  183. lineStyle: {
  184. width: 3
  185. }
  186. }
  187. },
  188. tooltip: {
  189. formatter: (params) => this.getMonthDayData(params),
  190. textStyle: {
  191. "fontSize": 18
  192. }
  193. },
  194. label: {
  195. show: true
  196. },
  197. data: planCapacities
  198. }
  199. this.option1.series.push(serie1);
  200. var serie3 = {
  201. name: '差异',
  202. type: 'bar',
  203. stack: 'Total',
  204. itemStyle: {
  205. normal: {
  206. color: '#ff6e76'
  207. }
  208. },
  209. tooltip: {
  210. formatter: (params) => this.getMonthDayData(params),
  211. textStyle: {
  212. "fontSize": 18
  213. }
  214. },
  215. label: {
  216. show: true,
  217. color: '#fff'
  218. },
  219. data: differences
  220. }
  221. this.option1.series.push(serie3);
  222. this.myChart1.setOption(this.option1, true);
  223. this.myChart1.resize();
  224. },
  225. addSerie2(dates, linePlans) {
  226. this.option2.series = [];
  227. this.option2.xAxis.data = dates;
  228. for (let i = 0; i < linePlans.length; i++) {
  229. let x = linePlans[i].start + 0.5;
  230. let y = i + 1;
  231. let ds = [];
  232. for (let j = 0; j < linePlans[i].planDates.length; j++) {
  233. if (linePlans[i].planDates[j] === "") {
  234. ds[j] = ""
  235. } else {
  236. ds[j] = parseInt(linePlans[i].planDates[j]) + i
  237. }
  238. }
  239. let serie = {
  240. name: linePlans[i].line,
  241. type: 'line',
  242. step: 'middle',
  243. showSymbol: false,
  244. itemStyle: {
  245. normal: {
  246. color: 'rgba(74,125,215,0.6)',
  247. lineStyle: {
  248. width: 35
  249. }
  250. }
  251. },
  252. markPoint: {
  253. data: [{
  254. coord: [x, y],
  255. symbol: 'rect',
  256. symbolSize: [30, 0],
  257. animation: true,
  258. label: {
  259. show: true,
  260. formatter: linePlans[i].line + " Line"
  261. },
  262. tooltip: {
  263. formatter: linePlans[i].line + 'Line Plan: ' + linePlans[i].planCapacity + ' pcs',
  264. textStyle: {
  265. "fontSize": 18
  266. }
  267. }
  268. }]
  269. },
  270. data: ds
  271. }
  272. this.option2.series.push(serie);
  273. }
  274. this.myChart2.setOption(this.option2, true);
  275. this.myChart2.resize();
  276. },
  277. getMonthDayData(params) {
  278. var rev = ''
  279. rev += '<div class="show">'
  280. rev += '日期: ' + this.newDates[params.dataIndex] + ' <br/>'
  281. rev += '目标产能: ' + this.planCapacities[params.dataIndex] + ' pcs<br/>'
  282. rev += '实际产能: ' + this.capacities[params.dataIndex] + ' pcs<br/>'
  283. if (this.differences[params.dataIndex] === "") {
  284. rev += '差异产能: ' + 0 + ' pcs<br/>'
  285. } else {
  286. rev += '差异产能: ' + this.differences[params.dataIndex] + ' pcs<br/>'
  287. }
  288. rev += '</div>'
  289. return rev
  290. },
  291. getMonthData() {
  292. let _this = this
  293. if (_this.moduleType === "") {
  294. _this.moduleType = "ALL"
  295. }
  296. axios
  297. .get('/v1/MonthModule/Difference/MonthOverview',
  298. {
  299. params: {
  300. mark: _this.mark,
  301. year: _this.year,
  302. month: _this.month,
  303. moduleType: _this.moduleType,
  304. lines: _this.lines,
  305. moduleTypes: _this.module,
  306. line: _this.line
  307. }
  308. })
  309. .then(function (response) {
  310. if (response.data !== null) {
  311. _this.newDates = response.data.dates
  312. _this.planCapacities = response.data.planCapacities
  313. _this.capacities = response.data.capacities
  314. _this.differences = response.data.differences
  315. _this.addSerie(response.data.newDates, response.data.capacities,
  316. response.data.planCapacities, response.data.differences);
  317. _this.addSerie2(response.data.newDates, response.data.linePlans);
  318. _this.keyInInfos = response.data.keyInInfos;
  319. _this.differenceInfos = response.data.differenceInfos;
  320. _this.difference = response.data.difference;
  321. }
  322. })
  323. .catch(function (error) {
  324. console.log(error)
  325. });
  326. },
  327. getMonthDataByKeyin() {
  328. let _this = this
  329. axios
  330. .get('/v1/MonthModule/Difference/Keyin',
  331. {
  332. params: {
  333. mark: _this.mark,
  334. year: _this.year,
  335. month: _this.month,
  336. lines: _this.lines
  337. }
  338. })
  339. .then(function (response) {
  340. if (response.data !== null) {
  341. _this.keyInInfos = response.data;
  342. }
  343. })
  344. .catch(function (error) {
  345. console.log(error)
  346. });
  347. }
  348. }
  349. })