chart.vue 6.4 KB

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