chart.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div>
  3. <!-- 年度开工率 -->
  4. <Echart
  5. :options="options"
  6. id="centerLeft1ALLChart"
  7. height="250px"
  8. width="450px"
  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: '0%',
  36. right: '0%',
  37. bottom: '3%',
  38. containLabel: true
  39. },
  40. xAxis: [
  41. {
  42. type: 'category',
  43. axisLabel: {
  44. show: false,
  45. fontSize: 16,
  46. fontWeight: "bold"
  47. }
  48. }
  49. ],
  50. yAxis: [
  51. {
  52. type: 'value',
  53. axisLabel: {
  54. fontSize: 16
  55. }
  56. },
  57. ],
  58. series: [
  59. {
  60. name: '计划数',
  61. type: 'bar',
  62. barWidth: 70,
  63. emphasis: {
  64. focus: 'series'
  65. },
  66. data:[],
  67. label: {
  68. show: true,
  69. position: 'top',
  70. fontSize:14,
  71. fontWeight: "bold"
  72. },
  73. },
  74. {
  75. name: '投入数',
  76. type: 'bar',
  77. barWidth: 70,
  78. emphasis: {
  79. focus: 'series'
  80. },
  81. data:[],
  82. label: {
  83. show: true,
  84. position: 'top',
  85. color:'#fff'
  86. },
  87. },
  88. {
  89. name: '产出数',
  90. type: 'bar',
  91. stack: 'Ad',
  92. barWidth: 70,
  93. data:[],
  94. emphasis: {
  95. focus: 'series'
  96. },
  97. label: {
  98. show: true,
  99. position: 'top',
  100. color:'#fff'
  101. }
  102. },
  103. {
  104. name: '不良数',
  105. type: 'bar',
  106. barWidth: 70,
  107. data:[],
  108. label: {
  109. show: true,
  110. position: 'top',
  111. color:'#fff'
  112. },
  113. emphasis: {
  114. focus: 'series'
  115. }
  116. }
  117. ]
  118. },
  119. };
  120. },
  121. components: {
  122. Echart, //子组件
  123. },
  124. props: {
  125. cdata: {
  126. type: Object,
  127. default: () => ({})
  128. },
  129. },
  130. mounted() {
  131. this.getdata();
  132. this.refreshdata();
  133. },
  134. beforeDestroy () {
  135. clearInterval(this.timing)
  136. },
  137. methods: {
  138. refreshdata() {
  139. this.timing = setInterval(() => {
  140. this.getdata(); //获取-数据
  141. }, 30000);
  142. },
  143. async getdata() {
  144. //20220211 -+formatDate(new Date()
  145. var caller = 'MAKEQTY';
  146. if (sessionStorage.getItem('li_code') == '所有'){
  147. caller = 'SMT!MAKEQTY!ALL';
  148. }
  149. await this.$http.get("kanban/datalist.action?caller="+caller+"&_noc=1&page=1&pageSize=100",{
  150. params: {
  151. condition: "1=1",
  152. }
  153. }).then((result)=>{
  154. let dataList = JSON.parse(result.data.data);
  155. let series0 = new Array();
  156. let series1 = new Array();
  157. let series2 = new Array();
  158. let series3 = new Array();
  159. let xAxis0 = new Array();
  160. for (let index = 0; index < dataList.length; index++) {
  161. const element = dataList[index];
  162. xAxis0.push(element.inqty);
  163. series0.push(element.planqty);
  164. //投入
  165. series1.push(element.inqty);
  166. //产出
  167. series2.push(element.outqty);
  168. //不良
  169. series3.push(element.ngqty);
  170. }
  171. this.options.xAxis[0].data = xAxis0;
  172. this.options.series[0].data = series0;
  173. this.options.series[1].data = series1;
  174. this.options.series[2].data = series2;
  175. this.options.series[3].data = series3;
  176. },(result)=>{
  177. console.error(result)
  178. }
  179. );
  180. }
  181. }
  182. }
  183. </script>