45fc5511 by renchao@pashanhoo.com

style:首页增加定时器

1 parent 59e5c23d
1 <!--
2 * @Description:
3 * @Autor: renchao
4 * @LastEditTime: 2023-07-04 13:48:00
5 -->
1 <template> 6 <template>
2 <!-- 登记类型总量 --> 7 <!-- 登记类型总量 -->
3 <Chart :cdata="cdata" /> 8 <Chart :cdata="cdata" />
4 </template> 9 </template>
5 10
6 <script> 11 <script>
7 import Chart from "./Chart"; 12 import Chart from "./Chart";
8 import work from "@/api/work"; 13 import work from "@/api/work";
9 export default { 14 export default {
10 data () { 15 data () {
11 return { 16 return {
12 cdata: { 17 cdata: {
18 timer: null,
13 category: [], 19 category: [],
14 lineData: [], 20 lineData: [],
15 }, 21 },
...@@ -19,7 +25,10 @@ export default { ...@@ -19,7 +25,10 @@ export default {
19 Chart, 25 Chart,
20 }, 26 },
21 mounted () { 27 mounted () {
22 this.getDjlxtotal(); 28 this.getDjlxtotal()
29 this.timer = setInterval(() => {
30 this.getDjlxtotal()
31 }, 10000) // 10s
23 }, 32 },
24 methods: { 33 methods: {
25 getDjlxtotal () { 34 getDjlxtotal () {
...@@ -42,8 +51,11 @@ export default { ...@@ -42,8 +51,11 @@ export default {
42 } 51 }
43 }); 52 });
44 } 53 }
54 },
55 destroyed () {
56 clearInterval(this.timer)
45 } 57 }
46 }; 58 };
47 </script> 59 </script>
48 <style lang="scss" scoped> 60 <style lang="scss" scoped>
49 </style> 61 </style>
......
1 <!-- 1 <!--
2 * @Author: xiaomiao 1158771342@qq.com 2 * @Author: xiaomiao 1158771342@qq.com
3 * @Date: 2023-03-09 15:24:53 3 * @Date: 2023-03-09 15:24:53
4 * @LastEditors: xiaomiao 1158771342@qq.com 4 * @LastEditors: Please set LastEditors
5 * @LastEditTime: 2023-03-16 15:58:03 5 * @LastEditTime: 2023-07-04 13:45:56
6 * @FilePath: \上报\bdcjg-web\src\components\Echart\Rose\index.vue 6 * @FilePath: \上报\bdcjg-web\src\components\Echart\Rose\index.vue
7 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8 --> 8 -->
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
18 export default { 18 export default {
19 data () { 19 data () {
20 return { 20 return {
21 timer: null,
21 cdata: [], 22 cdata: [],
22 getdata: [], 23 getdata: [],
23 }; 24 };
...@@ -25,13 +26,17 @@ ...@@ -25,13 +26,17 @@
25 components: { 26 components: {
26 Chart, 27 Chart,
27 }, 28 },
29 created () {
30 this.addhousetotal()
31 this.timer = setInterval(() => {
32 this.addhousetotal()
33 }, 10000) // 10s
34 },
28 mounted () { 35 mounted () {
29 this.addhousetotal();
30 window.addEventListener("resize", () => { 36 window.addEventListener("resize", () => {
31 this.cdata = []; 37 this.cdata = [];
32 this.addhousetotal(); 38 this.addhousetotal();
33 }); 39 });
34
35 }, 40 },
36 methods: { 41 methods: {
37 async addhousetotal () { 42 async addhousetotal () {
...@@ -53,12 +58,9 @@ ...@@ -53,12 +58,9 @@
53 console.log("error", error); 58 console.log("error", error);
54 } 59 }
55 } 60 }
56
57
58 }, 61 },
59 // 处理数据方法 62 // 处理数据方法
60 setadat (delarr) { 63 setadat (delarr) {
61
62 this.cdata = delarr.splice(0, 6); 64 this.cdata = delarr.splice(0, 6);
63 let sum = 0 65 let sum = 0
64 for (var i = 0; i < delarr.length; i++) { 66 for (var i = 0; i < delarr.length; i++) {
...@@ -73,9 +75,10 @@ ...@@ -73,9 +75,10 @@
73 }, 75 },
74 // 排序方法 76 // 排序方法
75 up (x, y) { return y.value - x.value } 77 up (x, y) { return y.value - x.value }
76 78 },
79 destroyed () {
80 clearInterval(this.timer)
81 }
77 } 82 }
78 };
79 </script> 83 </script>
80 84
81 <style lang="scss" scoped></style>
......