Browse Source

服务启动、停止修改

zhongxiaoyu 2 years ago
parent
commit
680c5de790
2 changed files with 39 additions and 4 deletions
  1. 1 0
      public/config.js
  2. 38 4
      src/components/Table/index.vue

+ 1 - 0
public/config.js

@@ -54,6 +54,7 @@ const DATACONTENT_ID = {
   sysServiceEditId: 23, //系统设置-服务管理-编辑服务-根据id获取服务
   sysServiceTopId: 32, //系统设置-服务管理-服务拓扑-根据id获取拓扑图
   sysServiceTopTableId: 31, //系统设置-服务管理-服务拓扑-查看日志id
+  sysServiceNodeListId: 89,
 
   /***-----进港管理------***/
   arrivalAirId: 67, //进港管理-机场选择-id

+ 38 - 4
src/components/Table/index.vue

@@ -134,7 +134,7 @@
                       <el-button
                         type="text"
                         v-if="scope.row.runState == '停止'"
-                        @click="chanheState(scope.row)"
+                        @click="stateChangeHandler(scope.row)"
                         size="small"
                         class="rmScs"
                         >启动</el-button
@@ -142,7 +142,7 @@
                       <el-button
                         type="text"
                         v-if="scope.row.runState == '运行'"
-                        @click="chanheState(scope.row)"
+                        @click="stateChangeHandler(scope.row)"
                         size="small"
                         class="rmScs"
                         >停止</el-button
@@ -307,6 +307,7 @@
 </template>
 
 <script>
+import request from '@/utils/request'
 import { setTableFilters } from "@/utils/table";
 import Dialog from "@/layout/components/Dialog/index.vue";
 import NoData from "@/components/nodata";
@@ -931,10 +932,11 @@ export default {
       });
     },
     // 表格-启动/停止
-    async chanheState(row) {
+    async stateChangeHandler(row) {
       const runState = row.runState == "运行" ? 0 : 1;
       const serviceID = row.serviceID;
-      this.changeBtn(runState, serviceID);
+      // this.changeBtn(runState, serviceID);
+      this.changeState(runState, serviceID)
     },
     // 表格-选中行
     selectHandler(selection, row) {
@@ -963,6 +965,38 @@ export default {
         this.$message.error(res.message);
       }
     },
+    async changeState(runState, serviceID) {
+      try {
+        const operate = runState ? 'start' : 'stop'
+        const { code, returnData: { listValues } } = await Query({
+          id: DATACONTENT_ID.sysServiceNodeListId,
+          dataContent: [serviceID]
+        })
+        if (Number(code) === 0) {
+          console.log(listValues)
+          // if (listValues.length) {
+          //   Promise.all(
+          //     listValues.map(node =>
+          //       request({
+          //         url: `${node.serviceURL}/${operate}`,
+          //         method: 'post'
+          //       })
+          //     )
+          //   ).then(results => {
+          //     if (results.every(result => Number(result.code) === 0)) {
+          //       this.$message.success('操作成功')
+          //     } else {
+          //       this.$message.error('操作失败')
+          //     }
+          //   })
+          // }
+        } else {
+          this.$message.error('查询节点失败')
+        }
+      } catch (error) {
+        console.log('出错了', error.message || error)
+      }
+    }
   },
 };
 </script>