chart.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div>
  3. <!-- 年度开工率 -->
  4. <Echart
  5. :options="options"
  6. id="bottom1Chart"
  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. grid: {
  28. left: '3%',
  29. right: '4%',
  30. bottom: '3%',
  31. containLabel: true
  32. },
  33. xAxis: [
  34. {
  35. type: 'category',
  36. data:[]
  37. }
  38. ],
  39. yAxis: [
  40. {
  41. type: 'value',
  42. },
  43. {
  44. type: 'value',
  45. name: 'rate',
  46. min: 0,
  47. max: 100,
  48. interval: 20,
  49. axisLabel: {
  50. formatter: '{value}%'
  51. }
  52. }
  53. ],
  54. series: [
  55. {
  56. name: '生产计划数',
  57. type: 'bar',
  58. barWidth: 20,
  59. emphasis: {
  60. focus: 'series'
  61. },
  62. data:[],
  63. /*label: {
  64. show: true
  65. }*/
  66. },
  67. {
  68. name: '良品',
  69. type: 'bar',
  70. barWidth: 20,
  71. stack: 'Ad',
  72. emphasis: {
  73. focus: 'series'
  74. },
  75. data:[]
  76. },
  77. {
  78. name: '不良',
  79. type: 'bar',
  80. stack: 'Ad',
  81. barWidth: 10,
  82. data:[],
  83. emphasis: {
  84. focus: 'series'
  85. }
  86. },
  87. {
  88. name: '完成率%',
  89. type: 'line',
  90. data:[],
  91. yAxisIndex: 1,
  92. tooltip: {
  93. valueFormatter: function (value) {
  94. return value + '%';
  95. }
  96. },
  97. itemStyle: {
  98. normal: {
  99. barBorderRadius: 5,
  100. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
  101. { offset: 0, color: "rgba(156,107,211,0.8)" },
  102. { offset: 0.2, color: "rgba(156,107,211,0.5)" },
  103. { offset: 1, color: "rgba(156,107,211,0.2)" }
  104. ])
  105. }
  106. },
  107. emphasis: {
  108. focus: 'series'
  109. }
  110. }
  111. ]
  112. },
  113. timing :null
  114. };
  115. },
  116. components: {
  117. Echart, //子组件
  118. },
  119. props: {
  120. cdata: {
  121. type: Object,
  122. default: () => ({})
  123. },
  124. },
  125. mounted() {
  126. this.refreshdata();
  127. },
  128. beforeDestroy () {
  129. clearInterval(this.timing)
  130. },
  131. methods: {
  132. refreshdata() {
  133. this.setData(); //获取数据
  134. this.timing = setInterval(() => {
  135. this.setData(); //获取--数据
  136. }, 30000);
  137. },
  138. async setData() {
  139. //20220211 -+formatDate(new Date()
  140. await this.$http.get("kanban/datalist.action?caller=KB!OFFICE!WCDAYTURNOUT&_noc=1&page=1&pageSize=100",{
  141. params: {
  142. condition: "1=1",
  143. }
  144. }).then((result)=>{
  145. let dataList = JSON.parse(result.data.data);
  146. let xAxis0 = new Array();
  147. let series0 = new Array();
  148. let series1 = new Array();
  149. let series2 = new Array();
  150. let series3 = new Array();
  151. for (let index = 0; index < dataList.length; index++) {
  152. const element = dataList[index];
  153. xAxis0.push(element.v_wcname);
  154. //生产计划数
  155. series0.push(element.v_planqty);
  156. //良数
  157. series1.push(element.v_okqty);
  158. //不良
  159. series2.push(element.v_ngqty);
  160. //完成比例 = 良数/生产计划数
  161. series3.push(element.v_okrate);
  162. }
  163. this.options.xAxis[0].data = xAxis0;
  164. this.options.series[0].data = series0;
  165. this.options.series[1].data = series1;
  166. this.options.series[2].data = series2;
  167. this.options.series[3].data = series3;
  168. },(result)=>{
  169. console.error(result)
  170. }
  171. );
  172. }
  173. }
  174. }
  175. </script>