1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
| <template>
| <div>
| <Chart :cdata="cdata" />
| </div>
| </template>
|
| <script>
| import Chart from './chart1.vue'
| export default {
| data () {
| return {
| cdata: {
| colors:[
| '#C33531', '#EFE42A', '#64BD3D', '#EE9201', '#29AAE3', '#B74AE5', '#0AAF9F', '#E89589'
| ],
| category: [
| "OP070",
| "OP100",
| "OP140",
| "OP150",
| "EOP080",
| "EOP090",
| ],
| lineData: [
| 30,
| 30,
| 30,
| 30,
| 30,
| 30,
| ],
| barData: [
| 2,
| 1,
| 0,
| 0,
| 0,
| 0,
|
| ],
| rateData: [],
| percentage: [0,67,100,100,100,100,100],
| },
| value:'',
| };
| },
| components: {
| Chart,
| },
| mounted () {
| this.tops();
| this.changeTiming();
| this.setData();
| },
| methods: {
| // 根据自己的业务情况修改
| setData () {
| this.cdata.rateData = [];
| for (let i = 0; i < this.cdata.barData.length; i++) {
| let rate = 0;
| if(this.cdata.lineData[i] === 0|| this.cdata.barData[i] === 0){
| //console.log("满足this.cdata.lineData[i]"+this.cdata.lineData[i]);
| rate = 1
| }else {
| //console.log("满足this.cdata.barData[i] / this.cdata.lineData[i]----"+ (this.cdata.lineData[i]-this.cdata.barData[i]) / this.cdata.lineData[i])
| rate = (this.cdata.lineData[i]-this.cdata.barData[i]) / this.cdata.lineData[i];
| }
| console.log("满足this.cdata.lineData[i]"+rate);
| this.cdata.rateData.push(rate.toFixed(2));
| console.log(this.cdata.rateData);
| }
| },
| tops(){
| this.$bus.$on('refresh-components', (value) => {
| // 刷新初始化方法
| this.value = value;
| this.initData()
|
| })
| this.$http.get('http://172.20.1.10:8080/productionOrdeInfo/centerLeftData?workOrderNo='+this.value)
| // this.$http.get('http://127.0.0.1:8080/productionOrdeInfo/centerLeftData?workOrderNo='+this.value)
| .then((response)=>{
| console.log(response.data.data.category);
| this.cdata.category = response.data.data.category;
| this.cdata.lineData = response.data.data.lineData;
| this.cdata.barData = response.data.data.barData;
| this.cdata.percentage = response.data.data.percentage;
| // console.log(this.cdata.lineData);
| // console.log(this.cdata.barData);
| this.setData();
| })
| },
| initData(){
| this.$http.get('http://172.20.1.10:8080/productionOrdeInfo/centerLeftData?workOrderNo='+this.value)
| // this.$http.get('http://127.0.0.1:8080/productionOrdeInfo/centerLeftData?workOrderNo='+this.value)
| .then((response)=>{
| console.log(response.data.data.category);
| this.cdata.category = response.data.data.category;
| this.cdata.lineData = response.data.data.lineData;
| this.cdata.barData = response.data.data.barData;
| this.cdata.percentage = response.data.data.percentage;
| this.setData();
| })
| },
| changeTiming() {
| setInterval(() => {
| this.tops();
| }, 300000)
| },
| }
| };
| </script>
|
| <style lang="scss" scoped>
| </style>
|
|