wangxinhui
2024-11-06 8f392cc88b0768b74efca3b68785cf5aa1c38e70
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
<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>