up1.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div id="up1">
  3. <div class="bg-color-black">
  4. <div class="d-flex pt-1 pl-2 jc-center">
  5. <span class="fs-xxxl text mx-2 fw-b">近7天来料合格率</span>
  6. </div>
  7. <div class="body-box">
  8. <div class="pt-2 " >
  9. <Bottom1Chart :linedata="linedata" />
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import Bottom1Chart from "../../components/warehousechart/bottom1Chart";
  17. import {mapState} from "vuex";
  18. export default {
  19. components: {
  20. Bottom1Chart
  21. },
  22. computed: {
  23. //数组写法
  24. ...mapState(['user','factoryoptions','factory']),
  25. },
  26. data() {
  27. return {
  28. colorList: {
  29. linearYtoG: {
  30. type: 'linear',
  31. x: 0,
  32. y: 0,
  33. x2: 1,
  34. y2: 1,
  35. colorStops: [
  36. {
  37. offset: 0,
  38. color: '#f5b44d'
  39. },
  40. {
  41. offset: 1,
  42. color: '#28f8de'
  43. }
  44. ]
  45. },
  46. linearGtoB: {
  47. type: 'linear',
  48. x: 0,
  49. y: 0,
  50. x2: 1,
  51. y2: 0,
  52. colorStops: [
  53. {
  54. offset: 0,
  55. color: '#43dfa2'
  56. },
  57. {
  58. offset: 1,
  59. color: '#28f8de'
  60. }
  61. ]
  62. },
  63. linearBtoG: {
  64. type: 'linear',
  65. x: 0,
  66. y: 0,
  67. x2: 1,
  68. y2: 0,
  69. colorStops: [
  70. {
  71. offset: 0,
  72. color: '#1c98e8'
  73. },
  74. {
  75. offset: 1,
  76. color: '#28f8de'
  77. }
  78. ]
  79. },
  80. areaBtoG: {
  81. type: 'linear',
  82. x: 0,
  83. y: 0,
  84. x2: 0,
  85. y2: 1,
  86. colorStops: [
  87. {
  88. offset: 0,
  89. color: 'rgba(35,184,210,.2)'
  90. },
  91. {
  92. offset: 1,
  93. color: 'rgba(35,184,210,0)'
  94. }
  95. ]
  96. }
  97. },
  98. linedata :{
  99. series : null,
  100. xAxiss :null,
  101. interval :15,
  102. min:0
  103. },
  104. timing:null,
  105. }
  106. },
  107. mounted() {
  108. this.refreshdata()
  109. },
  110. beforeDestroy () {
  111. clearInterval(this.timing)
  112. },
  113. methods: {
  114. refreshdata() {
  115. this.getdata(); //获取-数据
  116. this.timing = setInterval(() => {
  117. this.getdata(); //获取--数据
  118. }, 10000);
  119. },
  120. async getdata() {
  121. var caller = 'KB!WHTMONTHIQCRATE';
  122. var cond = "1=1";
  123. await this.$http.get("kanban/datalist.action?caller="+caller+"&_noc=1&page=1&pageSize=100",{
  124. params: {
  125. condition: cond
  126. }
  127. }).then((result)=>{
  128. let dataList = JSON.parse(result.data.data);
  129. let series = new Array();
  130. let xAxis0 = new Array();
  131. let mindata = 100;
  132. let ndata = new Array();
  133. for (let index = 0; index < dataList.length; index++) {
  134. const element = dataList[index];
  135. xAxis0.push(element.v_ymd);
  136. ndata.push(element.v_okrate);
  137. if(mindata>element.v_okrate){
  138. mindata = element.v_okrate;
  139. }
  140. }
  141. //7天内
  142. /* let ndata = new Array();
  143. for (let i =6 ;i>=0;i--){
  144. let formattedDate;
  145. if(i == 0){
  146. formattedDate = this.$moment().format('MM/DD');
  147. }else{
  148. formattedDate = this.$moment().subtract(i, 'days').format('MM/DD')
  149. }
  150. xAxis0.push(formattedDate);
  151. //获取分组当天数据
  152. let dataall = dataList;
  153. let data0 = '-';
  154. if(null != dataall) {
  155. let datam = dataall.filter(item => item.v_ymd == formattedDate);
  156. if(datam.length>0){
  157. data0 = datam[0].v_okrate;
  158. if(mindata>data0){
  159. mindata = data0;
  160. }
  161. }
  162. }
  163. ndata.push(data0);
  164. }*/
  165. series.push({
  166. name: '合格率',
  167. type: 'line',
  168. data: ndata,
  169. symbolSize: 4,
  170. lineStyle: {
  171. normal: {
  172. color: this.colorList.linearBtoG,
  173. width: 4
  174. }
  175. },
  176. label: {
  177. show: true,
  178. position: 'top',
  179. fontSize:15,
  180. color:'inherit',
  181. fontWeight: "bold"
  182. },
  183. emphasis: {
  184. focus: 'series'
  185. },
  186. areaStyle: {
  187. normal: {
  188. color: this.colorList.areaBtoG
  189. }
  190. },
  191. });
  192. this.linedata.series = series;
  193. this.linedata.xAxiss = xAxis0;
  194. //最小值往下取整10的倍数,然后减20
  195. mindata = Math.floor(mindata/10)*10 - 20;
  196. mindata = mindata<0?0:mindata;
  197. this.linedata.min = mindata;
  198. //分7个数据,6段
  199. this.linedata.interval = Math.ceil((100-mindata)/7);
  200. },(result)=>{
  201. console.error(result)
  202. }
  203. );
  204. }
  205. }
  206. };
  207. </script>
  208. <style lang="scss" class>
  209. //$box-height: 520px;
  210. $box-height: 475px;
  211. $box-width: 100%;
  212. #up1 {
  213. padding: 13px;
  214. height: $box-height;
  215. width: $box-width;
  216. border-radius: 5px;
  217. .bg-color-black {
  218. height: $box-height - 25px;
  219. border-radius: 10px;
  220. padding: 5px ;
  221. }
  222. .body-box {
  223. border-radius: 10px;
  224. overflow: hidden;
  225. }
  226. }
  227. </style>