chart.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. icon:"rect"
  34. },
  35. grid: {
  36. left: '3%',
  37. right: '4%',
  38. bottom: '3%',
  39. containLabel: true
  40. },
  41. xAxis: [
  42. {
  43. type: 'category',
  44. data:[],
  45. axisLabel: {
  46. fontSize: 16,
  47. fontWeight: "bold"
  48. }
  49. }
  50. ],
  51. yAxis: [
  52. {
  53. type: 'value',
  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(209, 52, 56,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. barWidth: 15,
  153. data:[],
  154. //data: [12, 22, 32, 12, 32, 12, 32],
  155. emphasis: {
  156. focus: 'series'
  157. },lineStyle: {
  158. width: 4
  159. },
  160. label: {
  161. show: true,
  162. position: 'top',
  163. fontSize:14,
  164. fontWeight: "bold"
  165. }
  166. },
  167. {
  168. name: 'UPPH',
  169. type: 'bar',
  170. barWidth: 15,
  171. emphasis: {
  172. focus: 'series'
  173. },
  174. data:[],
  175. label: {
  176. show: true,
  177. position: 'inside',
  178. fontSize:14,
  179. fontWeight: "bold"
  180. },
  181. },
  182. ]
  183. },
  184. };
  185. },
  186. components: {
  187. Echart, //子组件
  188. },
  189. props: {
  190. cdata: {
  191. type: Object,
  192. default: () => ({})
  193. },
  194. },
  195. mounted() {
  196. this.getdata();
  197. this.refreshdata();
  198. },
  199. beforeDestroy () {
  200. clearInterval(this.timing)
  201. },
  202. methods: {
  203. refreshdata() {
  204. this.timing = setInterval(() => {
  205. this.getdata(); //获取-数据
  206. }, 30000);
  207. },
  208. async getdata() {
  209. //20220211 -+formatDate(new Date()
  210. var caller = 'WCDAYTURNOUT!ZZ';
  211. if (sessionStorage.getItem('li_code') == '所有'){
  212. caller = 'ZZ!WCDAYTURNOUT!ALL';
  213. }
  214. await this.$http.get("kanban/datalist.action?caller="+caller+"&_noc=1&page=1&pageSize=100",{
  215. params: {
  216. condition: "1=1",
  217. }
  218. }).then((result)=>{
  219. let dataList = JSON.parse(result.data.data);
  220. let xAxis0 = new Array();
  221. let series0 = new Array();
  222. let series1 = new Array();
  223. let series2 = new Array();
  224. let series3 = new Array();
  225. let series4 = new Array();
  226. let series5 = new Array();
  227. var maxnumber=0;
  228. for (let index = 0; index < dataList.length; index++) {
  229. const element = dataList[index];
  230. xAxis0.push(element.sp_wccode);
  231. //投入
  232. series0.push(element.v_inqty);
  233. if(element.v_inqty>maxnumber){
  234. maxnumber= element.v_inqty;
  235. }
  236. //产出
  237. series1.push(element.v_outqty);
  238. if(element.v_outqty>maxnumber){
  239. maxnumber= element.v_outqty;
  240. }
  241. //不良
  242. series2.push(element.v_ngqty);
  243. //良率
  244. series3.push(element.v_okrate);
  245. //UPH
  246. series4.push(element.uph);
  247. if(element.uph>maxnumber){
  248. maxnumber= element.uph;
  249. }
  250. series5.push(element.v_upph);
  251. }
  252. this.options.xAxis[0].data = xAxis0;
  253. this.options.series[0].data = series0;
  254. this.options.series[1].data = series1;
  255. this.options.series[2].data = series2;
  256. this.options.series[3].data = series3;
  257. this.options.series[4].data = series4;
  258. this.options.series[5].data = series5;
  259. this.options.yAxis[0].max = (maxnumber*1.2).toFixed();
  260. /*let myChart = this.$children[0].chart;
  261. myChart.setOption({
  262. xAxis: {
  263. data: xAxis0
  264. },
  265. series: [
  266. {
  267. // 根据名字对应到相应的系列
  268. name: '投入',
  269. data: series0
  270. },
  271. {
  272. name: '产出',
  273. data: series2
  274. }, {
  275. name: '不良',
  276. data: series3
  277. },
  278. {
  279. name: '不良率%',
  280. data: series4
  281. },
  282. ]
  283. });*/
  284. },(result)=>{
  285. console.error(result)
  286. }
  287. );
  288. }
  289. }
  290. }
  291. </script>