懒羊羊
2023-12-12 776fbe36aec576c164c9edfe6be13d833eaef7b9
提交 | 用户 | 时间
776fbe 1 <template>
2   <div>
3     <Chart :cdata="cdata" />
4   </div>
5 </template>
6
7 <script>
8 import Chart from './chart.vue'
9 export default {
10   data () {
11     return {
12       cdata: {
13         // category: [
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         // lineData: [
49         //   18092,
50         //   20728,
51         //   24045,
52         //   28348,
53         //   32808,
54         //   36097,
55         //   39867,
56         //   44715,
57         //   48444,
58         //   50415,
59         //   56061,
60         //   62677,
61         //   59521,
62         //   67560,
63         //   18092,
64         //   20728,
65         //   24045,
66         //   28348,
67         //   32808,
68         //   36097,
69         //   39867,
70         //   44715,
71         //   48444,
72         //   50415,
73         //   36097,
74         //   39867,
75         //   44715,
76         //   48444,
77         //   50415,
78         //   50061,
79         //   32677,
80         //   49521,
81         //   32808
82         // ],
83         // barData: [
84         //   4600,
85         //   5000,
86         //   5500,
87         //   6500,
88         //   7500,
89         //   8500,
90         //   9900,
91         //   12500,
92         //   14000,
93         //   21500,
94         //   23200,
95         //   24450,
96         //   25250,
97         //   33300,
98         //   4600,
99         //   5000,
100         //   5500,
101         //   6500,
102         //   7500,
103         //   8500,
104         //   9900,
105         //   22500,
106         //   14000,
107         //   21500,
108         //   8500,
109         //   9900,
110         //   12500,
111         //   14000,
112         //   21500,
113         //   23200,
114         //   24450,
115         //   25250,
116         //   7500
117         // ],
118         category: ['2023-11-8','2023-11-7','2023-11-6','2023-11-5','2023-11-4','2023-11-3',],
119         lineData: [50,34,56,22,79,32],
120         barData: [22,10,22,3,50,15],
121         rateData: [] //完成率
122       }
123     };
124   },
125   components: {
126     Chart,
127   },
128   mounted () {
129     this.setData();
130     this.tops();
131     this.changeTiming();
132   },
133   methods: {
134     // 根据自己的业务情况修改
135     setData () {
136       for (let i = 0; i < this.cdata.barData.length ; i++) {
137         let rate = this.cdata.barData[i] / this.cdata.lineData[i];
138         this.cdata.rateData.push(rate.toFixed(2));
139       }
140     },
141
142     tops(){
143       // let that = this;
144       this.$http.get('http://192.168.0.249:8083/productionOrdeInfo/bottomLeftChart')
145           .then((response)=>{
146             this.cdata = {
147               barData: response.data.data.barData,
148               lineData: response.data.data.lineData,
149               category: response.data.data.category,
150               rateData: []
151             }
152             for (let i = 0; i < this.cdata.barData.length ; i++) {
153               let rate = this.cdata.barData[i] / this.cdata.lineData[i];
154               this.cdata.rateData.push(rate.toFixed(2));
155             }
156           })
157     },
158     changeTiming() {
159       setInterval(() => {
160         this.cdata.rateData = [];
161         this.tops();
162       }, 60000)
163     },
164   }
165 };
166 </script>
167
168 <style lang="scss" scoped>
169 </style>