index.vue
4.83 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<template>
<div>
<div>
<el-card shadow="always">
<el-button
type="success"
size="small"
icon="el-icon-video-play"
:disabled="startDeal"
@click="resume"
>开始处理</el-button
>
<el-button
type="danger"
size="small"
icon="el-icon-video-pause"
:disabled="!startDeal"
@click="pause"
>暂停处理</el-button
>
<el-divider direction="vertical" />
<el-tag :type="startDeal ? 'success' : 'info'" effect="dark">
<i v-if="startDeal" class="el-icon-loading" />
<i v-else class="el-icon-warning-outline" />
{{ startDeal == true ? "运行中" : "未运行" }}</el-tag
>
<el-divider direction="vertical" />
<el-switch
v-model="autoSend"
active-color="#13ce66"
inactive-color="#909399"
active-text="自动下发"
@change="autoSendStatusChanged"
/>
</el-card>
</div>
<div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="设备监控" name="deviceMonitor">
<DeviceMonitor ref="deviceMonitor" :start-deal="startDeal" />
</el-tab-pane>
<el-tab-pane label="设备数据" name="deviceData">
<DeviceData ref="deviceData" :start-deal="startDeal" />
</el-tab-pane>
<el-tab-pane label="站台数据" name="stationData">
<StationData ref="stationData" :start-deal="startDeal" />
</el-tab-pane>
<el-tab-pane label="执行与日志" name="taskCompensation">
<TaskCompensation ref="taskCompensation" />
</el-tab-pane>
</el-tabs>
</div>
</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: "deviceMonitor", // 默认显示
interval: null,
};
},
computed: {
...mapGetters(["name"]),
},
mounted() {
this.interval = setInterval(() => {
this.refreshExecuteStatus();
this.refreshAutoSendStatus();
}, 5000);
this.$refs.deviceMonitor.start();
},
beforeDestroy() {
clearInterval(this.interval);
},
methods: {
// 开始处理
resume() {
resume()
.then((response) => {
this.refreshExecuteStatus();
})
.catch((err) => {
console.log(err);
});
},
// 暂停处理
pause() {
pause()
.then((response) => {
this.refreshExecuteStatus();
})
.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) => {
this.refreshAutoSendStatus();
})
.catch((err) => {
console.log(err);
});
},
handleClick(tab, event) {
this.$refs.deviceMonitor.stop();
this.$refs.deviceData.stop();
this.$refs.stationData.stop();
this.$refs.taskCompensation.stop();
switch (this.activeName) {
case "deviceMonitor":
this.$refs.deviceMonitor.start();
break;
case "deviceData":
this.$refs.deviceData.start();
break;
case "stationData":
this.$refs.stationData.start();
break;
case "taskCompensation":
this.$refs.taskCompensation.start();
break;
default:
break;
}
},
},
};
</script>
<style lang="scss" scoped>
.main {
&-container {
margin: 30px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
</style>