index.vue
3.91 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
<div>
<div>
<el-card shadow="always">
<el-button
type="success"
@click="resume"
size="small"
icon="el-icon-video-play"
:disabled="startDeal"
>开始处理</el-button
>
<el-button
type="danger"
@click="pause"
size="small"
icon="el-icon-video-pause"
:disabled="!startDeal"
>暂停处理</el-button
>
<el-divider direction="vertical"></el-divider>
<el-tag :type="startDeal ? 'success' : 'info'" effect="dark">
<i v-if="startDeal" class="el-icon-loading"></i>
<i v-else="startDeal" class="el-icon-warning-outline"></i>
{{ startDeal == true ? "运行中" : "未运行" }}</el-tag
>
<el-divider direction="vertical"></el-divider>
<el-switch
v-model="autoSend"
active-color="#13ce66"
inactive-color="#909399"
active-text="自动下发"
@change="autoSendStatusChanged"
>
</el-switch>
</el-card>
</div>
<el-tabs v-model="activeName" type="card" @tab-click="handleClick">
<el-tab-pane label="设备监控" name="first">
<DeviceMonitor />
</el-tab-pane>
<el-tab-pane label="设备数据" name="second">
<DeviceData />
</el-tab-pane>
<el-tab-pane label="站台数据" name="third">
<StationData />
</el-tab-pane>
<el-tab-pane label="执行与日志" name="fourth">
<TaskCompensation />
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import {
getAutoSendStatus,
getExecuteStatus,
pause,
resume,
setAutoSendStatus,
} from "@/api/main";
import { mapGetters } from "vuex";
import DeviceData from "./components/DeviceData.vue"; // 设备数据组件
import DeviceMonitor from "./components/DeviceMonitor.vue"; // 设备监控组件
import StationData from "./components/StationData.vue"; // 站台数据组件
import TaskCompensation from "./components/TaskCompensation.vue"; // 定时任务补偿组件
export default {
name: "mainPage",
components: {
DeviceMonitor,
DeviceData,
StationData,
TaskCompensation,
},
data() {
return {
startDeal: false, // 开始处理中
autoSend: false, // 是否自动下发
activeName: "first", //默认显示
interval: null,
};
},
computed: {
...mapGetters(["name"]),
},
mounted() {
this.interval = setInterval(() => {
this.refreshExecuteStatus();
this.refreshAutoSendStatus();
}, 1000);
},
beforeDestroy() {
clearInterval(this.interval);
},
methods: {
//开始处理
resume() {
resume()
.then((response) => {})
.catch((err) => {
console.log(err);
});
},
//暂停处理
pause() {
pause()
.then((response) => {})
.catch((err) => {
console.log(err);
});
},
//刷新执行状态
refreshExecuteStatus() {
getExecuteStatus()
.then((response) => {
this.startDeal = response.data.status == "Running";
})
.catch((err) => {
console.log(err);
});
},
//刷新自动下发状态
refreshAutoSendStatus() {
//获取自动下发状态
getAutoSendStatus()
.then((response) => {
this.autoSend = response.data;
})
.catch((err) => {
console.log(err);
});
},
//自动下发状态改变事件
autoSendStatusChanged(e) {
//获取自动下发状态
setAutoSendStatus(e)
.then((response) => {})
.catch((err) => {
console.log(err);
});
},
handleClick(tab, event) {
console.log(tab, event);
},
},
};
</script>
<style lang="scss" scoped>
.main {
&-container {
margin: 30px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
</style>