|
1
|
<template>
|
|
2
|
<div>
|
|
3
4
|
<div>
<el-card shadow="always">
|
|
5
6
7
8
9
|
<el-button
type="success"
size="small"
icon="el-icon-video-play"
:disabled="startDeal"
|
|
10
|
@click="resume"
|
|
11
|
>{{ $t("main.startProcessing") }}</el-button
|
|
12
|
>
|
|
13
14
15
16
17
|
<el-button
type="danger"
size="small"
icon="el-icon-video-pause"
:disabled="!startDeal"
|
|
18
|
@click="pause"
|
|
19
|
>{{ $t("main.pauseProcessing") }}</el-button
|
|
20
|
>
|
|
21
|
<el-divider direction="vertical" />
|
|
22
|
<el-tag :type="startDeal ? 'success' : 'info'" effect="dark">
|
|
23
24
|
<i v-if="startDeal" class="el-icon-loading" />
<i v-else class="el-icon-warning-outline" />
|
|
25
26
27
|
{{
startDeal == true ? $t("main.running") : $t("main.notRunning")
}}</el-tag
|
|
28
|
>
|
|
29
|
<el-divider direction="vertical" />
|
|
30
|
<el-switch
|
|
31
32
33
|
v-model="autoSend"
active-color="#13ce66"
inactive-color="#909399"
|
|
34
|
:active-text="$t('main.autoSend')"
|
|
35
|
@change="autoSendStatusChanged"
|
|
36
|
/>
|
|
37
38
|
</el-card>
</div>
|
|
39
|
<div class="app-container">
|
|
40
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
|
41
|
<el-tab-pane :label="$t('main.deviceMonitor')" name="deviceMonitor">
|
|
42
|
<DeviceMonitor ref="deviceMonitor" :start-deal="startDeal" />
|
|
43
|
</el-tab-pane>
|
|
44
|
<el-tab-pane :label="$t('main.deviceData')" name="deviceData">
|
|
45
|
<DeviceData ref="deviceData" :start-deal="startDeal" />
|
|
46
|
</el-tab-pane>
|
|
47
|
<el-tab-pane :label="$t('main.stationData')" name="stationData">
|
|
48
|
<StationData ref="stationData" :start-deal="startDeal" />
|
|
49
|
</el-tab-pane>
|
|
50
51
52
53
|
<el-tab-pane
:label="$t('main.taskCompensation')"
name="taskCompensation"
>
|
|
54
|
<TaskCompensation ref="taskCompensation" />
|
|
55
56
57
|
</el-tab-pane>
</el-tabs>
</div>
|
|
58
59
60
61
|
</div>
</template>
<script>
|
|
62
|
import {
|
|
63
64
65
66
|
getAutoSendStatus,
getExecuteStatus,
pause,
resume,
|
|
67
68
69
70
71
72
73
|
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"; // 定时任务补偿组件
|
|
74
75
|
export default {
|
|
76
|
name: "MainPage",
|
|
77
78
79
80
|
components: {
DeviceMonitor,
DeviceData,
StationData,
|
|
81
|
TaskCompensation,
|
|
82
|
},
|
|
83
84
85
86
|
data() {
return {
startDeal: false, // 开始处理中
autoSend: false, // 是否自动下发
|
|
87
88
89
|
activeName: "deviceMonitor", // 默认显示
interval: null,
};
|
|
90
|
},
|
|
91
|
computed: {
|
|
92
|
...mapGetters(["name"]),
|
|
93
|
},
|
|
94
|
mounted() {
|
|
95
|
this.interval = setInterval(() => {
|
|
96
97
98
99
|
this.refreshExecuteStatus();
this.refreshAutoSendStatus();
}, 5000);
this.$refs.deviceMonitor.start();
|
|
100
101
|
},
beforeDestroy() {
|
|
102
|
clearInterval(this.interval);
|
|
103
|
},
|
|
104
|
methods: {
|
|
105
|
// 开始处理
|
|
106
|
resume() {
|
|
107
|
resume()
|
|
108
|
.then((response) => {
|
|
109
|
this.refreshExecuteStatus();
|
|
110
|
})
|
|
111
|
.catch((err) => {
|
|
112
113
|
console.log(err);
});
|
|
114
115
|
},
|
|
116
|
// 暂停处理
|
|
117
|
pause() {
|
|
118
|
pause()
|
|
119
|
.then((response) => {
|
|
120
|
this.refreshExecuteStatus();
|
|
121
|
})
|
|
122
|
.catch((err) => {
|
|
123
124
|
console.log(err);
});
|
|
125
|
},
|
|
126
|
|
|
127
|
// 刷新执行状态
|
|
128
129
130
|
refreshExecuteStatus() {
getExecuteStatus()
.then((response) => {
|
|
131
|
this.startDeal = response.data.status == "Running";
|
|
132
133
|
})
.catch((err) => {
|
|
134
135
|
console.log(err);
});
|
|
136
|
},
|
|
137
|
|
|
138
|
// 刷新自动下发状态
|
|
139
|
refreshAutoSendStatus() {
|
|
140
|
// 获取自动下发状态
|
|
141
142
|
getAutoSendStatus()
.then((response) => {
|
|
143
|
this.autoSend = response.data;
|
|
144
145
|
})
.catch((err) => {
|
|
146
147
|
console.log(err);
});
|
|
148
149
|
},
|
|
150
|
// 自动下发状态改变事件
|
|
151
|
autoSendStatusChanged(e) {
|
|
152
|
// 获取自动下发状态
|
|
153
|
setAutoSendStatus(e)
|
|
154
|
.then((response) => {
|
|
155
|
this.refreshAutoSendStatus();
|
|
156
|
})
|
|
157
|
.catch((err) => {
|
|
158
159
|
console.log(err);
});
|
|
160
161
|
},
|
|
162
|
handleClick(tab, event) {
|
|
163
164
165
166
|
this.$refs.deviceMonitor.stop();
this.$refs.deviceData.stop();
this.$refs.stationData.stop();
this.$refs.taskCompensation.stop();
|
|
167
|
switch (this.activeName) {
|
|
168
169
170
171
172
173
174
175
176
177
178
179
|
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;
|
|
180
|
default:
|
|
181
|
break;
|
|
182
|
}
|
|
183
184
185
|
},
},
};
|
|
186
187
188
|
</script>
<style lang="scss" scoped>
|
|
189
|
.main {
|
|
190
191
192
193
194
195
196
197
198
|
&-container {
margin: 30px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
</style>
|