chart.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <!-- 年度开工率 -->
  4. <Echart
  5. :options="options"
  6. id="bottomLeft2Chart"
  7. height="480px"
  8. width="100%"
  9. ref="column-board"
  10. ></Echart>
  11. </div>
  12. </template>
  13. <script>
  14. import Echart from '@/common/echart'
  15. //import { formatDate } from '../../../../utils/index.js'
  16. export default {
  17. data () {
  18. return {
  19. timing :null,
  20. options:{
  21. tooltip: {
  22. trigger: 'axis',
  23. axisPointer: {
  24. type: 'shadow'
  25. }
  26. },
  27. legend: {
  28. textStyle: {
  29. fontSize: 18
  30. },
  31. itemWidth: 29,
  32. itemHeight: 19
  33. },
  34. grid: {
  35. left: '3%',
  36. right: '4%',
  37. bottom: '3%',
  38. containLabel: true
  39. },
  40. xAxis: [
  41. {
  42. type: 'category',
  43. data:[],
  44. axisLabel: {
  45. fontSize: 16,
  46. fontWeight: "bold"
  47. }
  48. }
  49. ],
  50. yAxis: [
  51. {
  52. type: 'value',
  53. max:500,
  54. axisLabel: {
  55. fontSize: 16
  56. }
  57. },
  58. {
  59. type: 'value',
  60. name: 'rate',
  61. min: 0,
  62. max: 100,
  63. interval: 20,
  64. nameTextStyle: {
  65. fontSize: 20
  66. },
  67. axisLabel: {
  68. formatter: '{value}%',
  69. fontSize: 16
  70. }
  71. }
  72. ],
  73. series: [
  74. {
  75. name: '投入',
  76. type: 'bar',
  77. barWidth: 15,
  78. emphasis: {
  79. focus: 'series'
  80. },
  81. data:[],
  82. label: {
  83. show: true,
  84. position: 'top',
  85. fontSize:14,
  86. fontWeight: "bold"
  87. },
  88. },
  89. {
  90. name: '产出',
  91. type: 'bar',
  92. barWidth: 15,
  93. stack: 'Ad',
  94. emphasis: {
  95. focus: 'series'
  96. },
  97. data:[],
  98. label: {
  99. show: true,
  100. position: 'inside',
  101. fontSize:14,
  102. fontWeight: "bold"
  103. },
  104. },
  105. {
  106. name: '不良',
  107. type: 'bar',
  108. stack: 'Ad',
  109. barWidth: 10,
  110. data:[],
  111. //data: [12, 22, 32, 12, 32, 12, 32],
  112. emphasis: {
  113. focus: 'series'
  114. }
  115. },
  116. {
  117. name: '良率%',
  118. type: 'line',
  119. data:[],
  120. yAxisIndex: 1,
  121. symbolSize: 8,
  122. label: {
  123. show: true,
  124. position: 'top',
  125. color:'#fff'
  126. },
  127. tooltip: {
  128. valueFormatter: function (value) {
  129. return value + '%';
  130. }
  131. },
  132. lineStyle: {
  133. width: 4
  134. },
  135. itemStyle: {
  136. normal: {
  137. barBorderRadius: 6,
  138. color: "rgba(156,107,211,0.8)"
  139. /* color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
  140. { offset: 0, color: "rgba(156,107,211,0.8)" },
  141. { offset: 0.2, color: "rgba(156,107,211,0.5)" },
  142. { offset: 1, color: "rgba(156,107,211,0.2)" }
  143. ])*/
  144. }
  145. },
  146. emphasis: {
  147. focus: 'series'
  148. }
  149. }, {
  150. name: 'UPH',
  151. type: 'line',
  152. symbolSize: 8,
  153. barWidth: 15,
  154. data:[],
  155. //data: [12, 22, 32, 12, 32, 12, 32],
  156. emphasis: {
  157. focus: 'series'
  158. },
  159. lineStyle: {
  160. width: 4
  161. },
  162. label: {
  163. show: true,
  164. position: 'top',
  165. fontSize:14,
  166. fontWeight: "bold"
  167. }
  168. }
  169. ]
  170. },
  171. };
  172. },
  173. components: {
  174. Echart, //子组件
  175. },
  176. props: {
  177. cdata: {
  178. type: Object,
  179. default: () => ({})
  180. },
  181. },
  182. mounted() {
  183. this.getdata();
  184. this.refreshdata();
  185. },
  186. beforeDestroy () {
  187. clearInterval(this.timing)
  188. },
  189. methods: {
  190. refreshdata() {
  191. this.timing = setInterval(() => {
  192. this.getdata(); //获取-数据
  193. }, 30000);
  194. },
  195. async getdata() {
  196. //20220211 -+formatDate(new Date()
  197. var caller = 'WCDAYTURNOUT';
  198. if (sessionStorage.getItem('li_code') == '所有'){
  199. caller = 'WCDAYTURNOUT!ALL';
  200. }
  201. await this.$http.get("kanban/datalist.action?caller="+caller+"&_noc=1&page=1&pageSize=100",{
  202. params: {
  203. condition: "1=1",
  204. }
  205. }).then((result)=>{
  206. let dataList = JSON.parse(result.data.data);
  207. let xAxis0 = new Array();
  208. let series0 = new Array();
  209. let series1 = new Array();
  210. let series2 = new Array();
  211. let series3 = new Array();
  212. let series4 = new Array();
  213. var maxnumber=0;
  214. for (let index = 0; index < dataList.length; index++) {
  215. const element = dataList[index];
  216. xAxis0.push(element.sp_wccode);
  217. //投入
  218. series0.push(element.v_inqty);
  219. if(element.v_inqty>maxnumber){
  220. maxnumber= element.v_inqty;
  221. }
  222. //产出
  223. series1.push(element.v_outqty);
  224. if(element.v_outqty>maxnumber){
  225. maxnumber= element.v_outqty;
  226. }
  227. //不良
  228. series2.push(element.v_ngqty);
  229. //良率
  230. series3.push(element.v_okrate);
  231. //UPH
  232. series4.push(element.uph);
  233. if(element.uph>maxnumber){
  234. maxnumber= element.uph;
  235. }
  236. }
  237. this.options.xAxis[0].data = xAxis0;
  238. this.options.series[0].data = series0;
  239. this.options.series[1].data = series1;
  240. this.options.series[2].data = series2;
  241. this.options.series[3].data = series3;
  242. this.options.series[4].data = series4;
  243. this.options.yAxis[0].max = maxnumber*1.2;
  244. /*let myChart = this.$children[0].chart;
  245. myChart.setOption({
  246. xAxis: {
  247. data: xAxis0
  248. },
  249. series: [
  250. {
  251. // 根据名字对应到相应的系列
  252. name: '投入',
  253. data: series0
  254. },
  255. {
  256. name: '产出',
  257. data: series2
  258. }, {
  259. name: '不良',
  260. data: series3
  261. },
  262. {
  263. name: '不良率%',
  264. data: series4
  265. },
  266. ]
  267. });*/
  268. },(result)=>{
  269. console.error(result)
  270. }
  271. );
  272. }
  273. }
  274. }
  275. </script>