1+ <template >
2+ <div class =" common-layout" >
3+ <el-container >
4+ <el-header >
5+ <el-row >
6+ <el-col :span =" 8" >
7+ <el-switch
8+ v-model =" showswitch"
9+ class =" mb-2"
10+ style =" --el-switch-on-color : #13ce66 ; --el-switch-off-color : #ff4949 "
11+ active-text =" 表格"
12+ inactive-text =" 图表"
13+ />
14+ </el-col >
15+
16+ <el-col :span =" 4" :offset =" 6" >
17+ <el-form-item label =" 是否自动更新" >
18+ <el-switch
19+ @change =" autoChange"
20+ v-model =" autoupdate"
21+ inline-prompt
22+ active-text =" 是"
23+ inactive-text =" 否"
24+ />
25+ </el-form-item >
26+ </el-col >
27+
28+ <el-col :span =" 3" >
29+ <el-form-item label =" 更新间隔" >
30+ <el-select @change =" intervalChange" v-model =" interval" placeholder =" 间隔" >
31+ <el-option label =" 5s" value =" 5" />
32+ <el-option label =" 10s" value =" 10" />
33+ <el-option label =" 30s" value =" 30" />
34+ <el-option label =" 1min" value =" 60" />
35+ <el-option label =" 5min" value =" 300" />
36+ </el-select >
37+ </el-form-item >
38+ </el-col >
39+
40+ <el-col :span =" 2" :offset =" 1" >
41+ <el-button type =" success" title =" 重载" circle ><i class =" iconfont icon-zhongqi" ></i ></el-button >
42+ </el-col >
43+
44+ </el-row >
45+ </el-header >
46+ <el-main >
47+ <div v-show =" !showswitch" >chart</div >
48+ <div v-show =" showswitch" >data list</div >
49+ </el-main >
50+ </el-container >
51+ </div >
52+ </template >
53+
54+ <script >
55+ import { onMounted , ref } from ' @vue/runtime-core'
56+ import { useRoute } from ' vue-router'
57+ import { serInfo } from " @/api/index.js"
58+ export default {
59+ name: " MonitorView" ,
60+ setup () {
61+ const route = new useRoute ()
62+ let timer = null
63+
64+ const intervalChange = (val )=> {
65+ clearTimeout (timer)
66+ timer = setInterval (()=> {
67+ console .log (new Date ().getMinutes (),new Date ().getSeconds ())
68+ },val * 1000 )
69+ }
70+
71+ const autoChange = (val ) => {
72+ console .log (val)
73+ if (val == false ){
74+ clearTimeout (timer)
75+ timer = null
76+ }else {
77+ timer = setInterval (()=> {
78+ console .log (new Date ().getMinutes (),new Date ().getSeconds ())
79+ },interval .value * 1000 )
80+ }
81+ }
82+
83+ let showswitch = ref (false )
84+ let autoupdate = ref (true )
85+ let interval = ref (5 )
86+
87+
88+ if (autoupdate .value ){
89+ timer = setInterval (()=> {
90+ console .log (new Date ().getMinutes (),new Date ().getSeconds ())
91+ },interval .value * 1000 )
92+ }
93+
94+ onMounted (() => {
95+ // 打印
96+ console .log (route .params .sk )
97+ serInfo ({key: " 8e7eca1f7079c6a7861b3dcaa2dc8c05" }).then ((res )=> {
98+ console .log (res)
99+ })
100+ })
101+
102+ return {
103+ showswitch,
104+ interval,
105+ autoupdate,
106+ autoChange,
107+ intervalChange
108+ }
109+ },
110+ }
111+ </script >
112+
113+ <style scoped>
114+ .el-header {
115+ background-color : #EBEDF0 ;
116+ }
117+ </style >
0 commit comments