<template>
|
<div>
|
<!-- <el-button type="primary" size="mini">关闭</el-button> -->
|
<el-button size="mini" @click="OpenService" type="primary" style="margin-left: 20px; margin-top: 15px">开启服务
|
</el-button>
|
<el-button size="mini" @click="closeService" type="danger" style="margin-left: 5px; margin-top: 15px">关闭服务
|
</el-button>
|
|
<div class="serverTip">
|
<b>服务状态:</b>
|
<b :class="serveiceState ? 'start' : 'stop'">{{
|
serveiceState ? "已启动" : "未启动"
|
}}</b>
|
</div>
|
</div>
|
</template>
|
<script>
|
import http from "./../api/http.js";
|
|
export default {
|
data() {
|
return {
|
serveiceState: false,
|
};
|
},
|
methods: {
|
//检查服务状态
|
checkServiceState() {
|
http
|
.post("api/WCS/CheckServiceState", null, "服务状态检查中...")
|
.then((x) => {
|
if (x.status) {
|
this.serveiceState = true;
|
} else {
|
this.serveiceState = false;
|
}
|
});
|
},
|
//启动服务
|
OpenService() {
|
if (confirm('确认启动') == true) {
|
this.http
|
.post("api/WCS/StartService", null, "正在开启服务....")
|
.then((x) => {
|
if (!x.status) return this.$message.error(x.message);
|
this.$message.success(x.message);
|
this.serveiceState = true;
|
});
|
}
|
},
|
//关闭服务
|
closeService() {
|
|
if (confirm('确认关闭') == true) {
|
this.http
|
.post("api/WCS/CloseService", null, "正在关闭服务....")
|
.then((x) => {
|
if (!x.status) return this.$message.error(x.message);
|
this.$message.success("服务关闭成功");
|
this.serveiceState = false;
|
});
|
}
|
},
|
},
|
created() {
|
this.checkServiceState();
|
},
|
};
|
</script>
|
|
<style scoped>
|
.serverTip {
|
font-size: 12px;
|
margin-top: 20px;
|
margin-left: 20px;
|
}
|
|
.start {
|
color: greenyellow;
|
}
|
|
.stop {
|
color: red;
|
}
|
</style>
|
|