moodProductionView.jsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * @Author: dayan_hjm 月度产量/发货量
  3. * @Date: 2023-10-23 09:32:12
  4. * @Last Modified by: dayan_hjm
  5. * @Last Modified time: 2023-11-08 15:24:45
  6. */
  7. import React, { useState, useEffect, Component } from "react";
  8. import styles from "../style.less";
  9. import { useHistory, useLocation, withRouter } from "react-router-dom";
  10. import mod from '../mod';
  11. import {
  12. twoService,
  13. } from "../api";
  14. @withRouter
  15. class MoodSendView extends Component {
  16. // 构造函数,组件的实例创建时,最先执行
  17. constructor(props, context) {
  18. super(props, context);
  19. this.store = mod;
  20. this.state = {
  21. budgetSalesQty: [],
  22. year: [],
  23. budgetProdQty: [],
  24. };
  25. }
  26. componentDidMount() {
  27. this.getUrl()
  28. }
  29. async getUrl() {
  30. await twoService().then(({ data = [], resultCode }) => {
  31. if (+resultCode === 0) {
  32. let year = [], budgetSalesQty = [], budgetProdQty = [];
  33. data.map((x, i) => {
  34. year.push(x.bMonth);
  35. budgetSalesQty.push(x.budgetSalesQty || 0)
  36. budgetProdQty.push(x.budgetProdQty || 0)
  37. });
  38. this.setState({ year, budgetProdQty, budgetSalesQty });
  39. this.setData();
  40. }
  41. });
  42. }
  43. setData() {
  44. setTimeout(() => {
  45. var data = [220, 182, 191, 234, 290, 330, 310, 123, 442, 321, 90, 149, 210, 122, 200];
  46. var yMax = 500;
  47. var dataShadow = [];
  48. for (var i = 0; i < data.length; i++) {
  49. dataShadow.push(yMax);
  50. }
  51. var option = {
  52. grid: {
  53. left: '2%',
  54. top: '18%',
  55. right: '0%',
  56. bottom: '8%',
  57. containLabel: true
  58. },
  59. tooltip: {
  60. trigger: 'axis',
  61. axisPointer: {
  62. type: 'shadow'
  63. },
  64. borderColor: "rgba(105, 255, 222, 0.5)",
  65. borderWidth: 2,
  66. padding: 5,
  67. textStyle: {
  68. fontSize: 10,
  69. color: "#ededed"
  70. },
  71. backgroundColor: "#0000008a"
  72. },
  73. legend: {
  74. data: ['计划产量', '实际产量'],
  75. fontFamily: 'DingTalkJinBuTi',
  76. padding: [25, 0, 0, 10],
  77. textStyle: {
  78. color: "#fff"
  79. },
  80. itemWidth: 11,
  81. itemHeight: 11,
  82. },
  83. // toolbox: {
  84. // show: true,
  85. // orient: 'vertical',
  86. // left: 'right',
  87. // top: 'center',
  88. // feature: {
  89. // mark: { show: true },
  90. // dataView: { show: true, readOnly: false },
  91. // magicType: { show: true, type: ['line', 'bar', 'stack'] },
  92. // restore: { show: true },
  93. // saveAsImage: { show: true }
  94. // }
  95. // },
  96. // xAxis: {
  97. // data: dataAxis,
  98. // axisTick: {
  99. // show: false,
  100. // },
  101. // axisLine: {
  102. // show: true,
  103. // symbol: ['none', 'arrow'],
  104. // symbolOffset: 12,
  105. // lineStyle: {
  106. // color: '#fff',
  107. // }
  108. // },
  109. // z: 10
  110. // },
  111. xAxis: [
  112. {
  113. type: 'category',
  114. axisTick: { show: false },
  115. data: this.state.year,
  116. axisLabel: {
  117. /*inside: true,*/
  118. color: "rgba(255,255,255,.6)",
  119. interval: 0,
  120. textStyle: {
  121. color: '#7d7d7d',
  122. fontSize: 10
  123. },
  124. },
  125. axisLine: {
  126. lineStyle: {
  127. color: 'rgba(255,255,255,.1)',
  128. type: 'dashed',
  129. }
  130. },
  131. splitLine: {
  132. show: true,
  133. lineStyle: {
  134. color: '#3b3b3b',
  135. type: 'dashed',
  136. }
  137. }
  138. }
  139. ],
  140. yAxis: [
  141. {
  142. type: 'value',
  143. axisLine: {
  144. lineStyle: {
  145. color: '#7d7d7d',
  146. type: 'dashed',
  147. },
  148. },
  149. axisTick: { show: false },
  150. axisLabel: {
  151. formatter: "{value}吨",
  152. textStyle: {
  153. color: '#7d7d7d',
  154. fontSize: 12
  155. }
  156. },
  157. splitLine: {
  158. show: true,
  159. lineStyle: {
  160. color: '#3b3b3b',
  161. type: 'dashed',
  162. }
  163. }
  164. }
  165. ],
  166. series: [
  167. {
  168. name: '计划产量',
  169. type: 'bar',
  170. animation: true,
  171. animationDuration: 3000,
  172. "smooth": true,
  173. emphasis: {
  174. focus: 'series'
  175. },
  176. barWidth: 10,
  177. itemStyle: {
  178. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  179. { offset: 0, color: 'rgba(255, 206, 0, 1)' },
  180. { offset: 0.7, color: 'rgba(255, 206, 0, 1)' },
  181. { offset: 1, color: 'rgba(255, 206, 0, 0.3)' },
  182. ])
  183. },
  184. data: this.state.budgetSalesQty
  185. },
  186. {
  187. name: '实际产量',
  188. type: 'bar',
  189. animation: true,
  190. animationDuration: 3000,
  191. "smooth": true,
  192. barGap: 0,
  193. barWidth: 10,
  194. emphasis: {
  195. focus: 'series'
  196. },
  197. itemStyle: {
  198. labelLine: {
  199. show: false
  200. },
  201. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  202. { offset: 0, color: 'rgba(105, 255, 222, 1)' },
  203. { offset: 0.7, color: 'rgba(105, 255, 222, 1)' },
  204. { offset: 1, color: 'rgba(105, 255, 222, 0.3)' },
  205. ])
  206. },
  207. data: this.state.budgetProdQty
  208. }
  209. ]
  210. }
  211. var myChart = echarts.init(document.getElementById('chartProduct'));
  212. // 使用刚指定的配置项和数据显示图表。
  213. myChart.setOption(option);
  214. }, 3000)
  215. }
  216. render() {
  217. return (
  218. <div className={["eacharView cbMoodSendView"]}>
  219. <div id="chartProduct"></div>
  220. </div>
  221. )
  222. }
  223. }
  224. export default MoodSendView;