chart.vue 6.7 KB

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