qinchulong
2025-03-29 039a4a5433e7f80adc88b491b549e5d9486e4f9a
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>