From 6f78dd91ffd0544b5fd3993d5f7d316ee08264d4 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 17 三月 2026 15:50:46 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/dashboard/dashboard.js |  134 ++++++++++++++++++++++++++++++++++++++++++++
 src/main/webapp/views/index.html                 |    2 
 src/main/webapp/views/dashboard/dashboard.html   |    9 ++
 3 files changed, 143 insertions(+), 2 deletions(-)

diff --git a/src/main/webapp/static/js/dashboard/dashboard.js b/src/main/webapp/static/js/dashboard/dashboard.js
index 42e63df..6a3cd1a 100644
--- a/src/main/webapp/static/js/dashboard/dashboard.js
+++ b/src/main/webapp/static/js/dashboard/dashboard.js
@@ -14,6 +14,7 @@
         rawPayload: null,
         loading: true,
         refreshing: false,
+        switchingSystem: false,
         countdown: REFRESH_SECONDS,
         countdownTimer: null,
         resizeHandler: null,
@@ -631,6 +632,16 @@
       displayText: function (value, fallback) {
         return value == null || value === "" ? (fallback || "") : value;
       },
+      showMessage: function (message, type) {
+        if (this.$message && typeof this.$message === "function") {
+          this.$message({
+            message: message,
+            type: type || "info"
+          });
+          return;
+        }
+        console[type === "error" ? "error" : "log"](message);
+      },
       networkSamplingText: function () {
         var config = this.network && this.network.samplingConfig ? this.network.samplingConfig : {};
         return this.i18n("dashboard.networkSampling", "閲囨牱 {0} ms / 瓒呮椂 {1} ms / 姣忔牱鏈� {2} 娆� / 鍖呭ぇ灏� {3}", [
@@ -771,6 +782,129 @@
           this.translateLegacyText("鐩戞帶绯荤粺")
         );
       },
+      syncParentSystemRunning: function (status) {
+        try {
+          if (window.parent && window.parent !== window) {
+            window.parent.systemRunning = !!status;
+          }
+        } catch (e) {
+        }
+      },
+      requestSystemSwitch: function (operatorType, password) {
+        var self = this;
+        this.switchingSystem = true;
+        $.ajax({
+          url: baseUrl + "/console/system/switch",
+          headers: {
+            token: localStorage.getItem("token")
+          },
+          data: {
+            operatorType: operatorType,
+            password: password || ""
+          },
+          method: "POST",
+          success: function (res) {
+            var status;
+            if (res && res.code === 200) {
+              status = !!(res.data && res.data.status);
+              self.overview = Object.assign({}, self.overview, {
+                systemRunning: status
+              });
+              self.syncParentSystemRunning(status);
+              self.showMessage(
+                status
+                  ? self.i18n("dashboard.systemStarted", "绯荤粺宸插惎鍔�")
+                  : self.i18n("dashboard.systemStopped", "绯荤粺宸插仠姝�"),
+                "success"
+              );
+              self.loadDashboard(false);
+              return;
+            }
+            if (res && res.code === 403) {
+              window.location.href = baseUrl + "/login";
+              return;
+            }
+            self.showMessage(
+              (res && res.msg) || self.i18n("dashboard.systemSwitchFailed", "绯荤粺鐘舵�佸垏鎹㈠け璐�"),
+              "error"
+            );
+          },
+          error: function () {
+            self.showMessage(
+              self.i18n("dashboard.systemSwitchFailedDetail", "绯荤粺鐘舵�佸垏鎹㈠け璐ワ紝璇锋鏌ユ帴鍙g姸鎬�"),
+              "error"
+            );
+          },
+          complete: function () {
+            self.switchingSystem = false;
+          }
+        });
+      },
+      startSystem: function () {
+        if (this.overview.systemRunning || this.switchingSystem) {
+          return;
+        }
+        this.requestSystemSwitch(1);
+      },
+      maskStopSystemPromptInput: function () {
+        setTimeout(function () {
+          var input = document.querySelector(".el-message-box__wrapper .el-message-box__input input");
+          if (!input) {
+            return;
+          }
+          input.setAttribute("type", "text");
+          input.setAttribute("name", "dashboard-stop-code");
+          input.setAttribute("autocomplete", "new-password");
+          input.setAttribute("autocapitalize", "off");
+          input.setAttribute("autocorrect", "off");
+          input.setAttribute("spellcheck", "false");
+          input.setAttribute("data-form-type", "other");
+          input.style.webkitTextSecurity = "disc";
+        }, 30);
+      },
+      stopSystem: function () {
+        var self = this;
+        var proceed = function (password) {
+          var cleanPassword = String(password == null ? "" : password).trim();
+          if (!cleanPassword) {
+            self.showMessage(self.i18n("dashboard.stopSystemPasswordRequired", "璇疯緭鍏ュ仠姝㈢郴缁熷彛浠�"), "warning");
+            return;
+          }
+          self.requestSystemSwitch(0, cleanPassword);
+        };
+
+        if (!this.overview.systemRunning || this.switchingSystem) {
+          return;
+        }
+
+        if (typeof this.$prompt === "function") {
+          this.$prompt(
+            this.i18n("dashboard.stopSystemPrompt", "璇疯緭鍏ュ彛浠わ紝骞跺仠姝� WCS 绯荤粺"),
+            this.i18n("dashboard.stopSystemTitle", "鍋滄绯荤粺"),
+            {
+              confirmButtonText: this.i18n("common.confirm", "纭畾"),
+              cancelButtonText: this.i18n("common.cancel", "鍙栨秷"),
+              inputType: "text",
+              inputPattern: /\S+/,
+              inputErrorMessage: this.i18n("dashboard.stopSystemPasswordRequired", "璇疯緭鍏ュ仠姝㈢郴缁熷彛浠�")
+            }
+          ).then(function (result) {
+            proceed(result && result.value);
+          }).catch(function () {
+          });
+          this.maskStopSystemPromptInput();
+          return;
+        }
+
+        proceed(window.prompt(this.i18n("dashboard.stopSystemPrompt", "璇疯緭鍏ュ彛浠わ紝骞跺仠姝� WCS 绯荤粺"), ""));
+      },
+      toggleSystem: function () {
+        if (this.overview.systemRunning) {
+          this.stopSystem();
+          return;
+        }
+        this.startSystem();
+      },
       openDevicePingAnalysis: function () {
         this.openParentMenuView(
           "/views/devicePingLog/devicePingLog.html",
diff --git a/src/main/webapp/views/dashboard/dashboard.html b/src/main/webapp/views/dashboard/dashboard.html
index 1a806a2..6e51310 100644
--- a/src/main/webapp/views/dashboard/dashboard.html
+++ b/src/main/webapp/views/dashboard/dashboard.html
@@ -717,6 +717,13 @@
       </div>
       <div class="hero-actions">
         <el-button size="small" plain @click="openMonitor">{{ i18n('dashboard.openMonitor', '鎵撳紑鐩戞帶鐢婚潰') }}</el-button>
+        <el-button
+            size="small"
+            :type="overview.systemRunning ? 'danger' : 'success'"
+            plain
+            :disabled="switchingSystem"
+            :loading="switchingSystem"
+            @click="toggleSystem">{{ overview.systemRunning ? i18n('dashboard.stopSystem', '鍋滄绯荤粺') : i18n('dashboard.startSystem', '鍚姩绯荤粺') }}</el-button>
         <el-button size="small" type="primary" :loading="refreshing" @click="loadDashboard(true)">{{ i18n('dashboard.refreshNow', '绔嬪嵆鍒锋柊') }}</el-button>
       </div>
     </div>
@@ -1054,6 +1061,6 @@
 <script type="text/javascript" src="../../static/vue/js/vue.min.js"></script>
 <script type="text/javascript" src="../../static/vue/element/element.js"></script>
 <script type="text/javascript" src="../../static/js/echarts/echarts.min.js"></script>
-<script type="text/javascript" src="../../static/js/dashboard/dashboard.js?v=20260317-dashboard-network-i18n"></script>
+<script type="text/javascript" src="../../static/js/dashboard/dashboard.js?v=20260317-dashboard-stop-password-mask"></script>
 </body>
 </html>
diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html
index 2fdcc81..64c2d53 100644
--- a/src/main/webapp/views/index.html
+++ b/src/main/webapp/views/index.html
@@ -862,7 +862,7 @@
 <script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
 <script type="text/javascript" src="../static/vue/element/element.js"></script>
 <script>
-  var DASHBOARD_VIEW_VERSION = "20260317-dashboard-network-balanced-columns";
+  var DASHBOARD_VIEW_VERSION = "20260317-dashboard-stop-password-mask";
   var HOME_TAB_CONFIG = {
     title: "绯荤粺浠〃鐩�",
     url: baseUrl + "/views/dashboard/dashboard.html?layoutVersion=" + encodeURIComponent(DASHBOARD_VIEW_VERSION),

--
Gitblit v1.9.1