Browse Source

Merge branch 'master' of http://49.4.49.126:3000/GYEE_R.D/neic

xushili 3 years ago
parent
commit
7120bd8e42
2 changed files with 45 additions and 36 deletions
  1. 3 19
      src/assets/script/BackgroundData.js
  2. 42 17
      src/components/area/ControlArea.vue

+ 3 - 19
src/assets/script/BackgroundData.js

@@ -104,7 +104,6 @@ export default class BackgroundData {
         this.isContains = this.isContains.bind(this);
         this.refreshRecommendData = this.refreshRecommendData.bind(this);
         this.onRDMessage = this.onRDMessage.bind(this);
-        this.showdialog = this.showdialog.bind(this);
         this.windturbineControl = this.windturbineControl.bind(this);
         this.marking = this.marking.bind(this);
         this.removeMarked = this.removeMarked.bind(this);
@@ -281,22 +280,8 @@ export default class BackgroundData {
             .catch(err => action("登录出现错误:" + err.message));
     }
 
-    /* 显示提示框 */
-    showdialog(title, message, detail) {
-        const { remote } = require("electron");
-        const { dialog } = remote;
-        dialog.showMessageBox(remote.getCurrentWindow(), {
-            type: "none",
-            title: title,
-            message: message,
-            detail: detail,
-            buttons: ["确定"],
-            noLink: true,
-        });
-    }
-
     /* 风机控制 */
-    windturbineControl(windturbines, isLockOrUnlock) {
+    windturbineControl(windturbines, isLockOrUnlock,success,error) {
         var pairs = {};
         for (var ind in windturbines) {
             var wb = windturbines[ind];
@@ -314,11 +299,10 @@ export default class BackgroundData {
         }
         axios.post(`http://${config.calcUrl}/api/control/send?isLockOrUnlock=${isLockOrUnlock}`, pairs)
             .then(msg => {
-                console.log(msg);
+                success(msg);
             })
             .catch(err => {
-                this.showdialog("错误", "风机控制出现错误", err.message);
-                console.log(err);
+                error(err);
             });
         console.log(isLockOrUnlock);
     }

+ 42 - 17
src/components/area/ControlArea.vue

@@ -225,9 +225,12 @@ export default {
     menuClicked(msg) {
       var bd = BackgroundData.getInstance();
       if (!bd.LoginUser) {
-        this.$message({
-          message: "<strong>请登录</strong> 控制风机需要先登录!",
+        this.$notify({
+          title: "请登录",
+          message: "控制风机需要先登录!",
           type: "warning",
+          position: "bottom-right",
+          offset: 60,
         });
         return;
       }
@@ -237,11 +240,21 @@ export default {
         for (var id in los) {
           los[id].lockType = msg.value;
         }
-        bd.windturbineControl(los, true);
+        bd.windturbineControl(
+          los,
+          true,
+          this.controlSuccess,
+          this.controlError
+        );
       } else if (msg.type == "send") {
         // 发送
         var vs = this.getSelectedItems(true);
-        bd.windturbineControl(vs, false);
+        bd.windturbineControl(
+          vs,
+          false,
+          this.controlSuccess,
+          this.controlError
+        );
       } else if (msg.type == "marking") {
         // 标注
         var vvs = this.getSelectedItems();
@@ -250,6 +263,22 @@ export default {
       this.clearSelected();
     },
 
+    /* 控制成功 */
+    controlSuccess(msg) {
+      console.log(msg);
+    },
+
+    /* 控制失败 */
+    controlError(err) {
+      this.$notify({
+        title: "控制出现错误",
+        message: err.message,
+        type: "warning",
+        position: "bottom-right",
+        offset: 60,
+      });
+    },
+
     /* 获取选中的项目,isControl:是否是控制 */
     getSelectedItems(isControl) {
       var ls = new Array();
@@ -275,29 +304,25 @@ export default {
       var bd = BackgroundData.getInstance();
       if (isAuto) {
         if (!bd.LoginUser) {
-          this.$message({
-            message: "<strong>请登录</strong>切换为自动控制需要先登录!",
-            type: "warning",
-          });
-          /* this.$notify({
+          this.$notify({
             title: "请登录",
             message: "切换为自动控制需要先登录!",
-            type: 'warning',
-            position: 'bottom-right',
-            offset:60,
-          }); */
+            type: "warning",
+            position: "bottom-right",
+            offset: 60,
+          });
           return;
         }
         this.AutoSendTimer = setInterval(this.AutoSend, 60000);
-        this.$message({
+        /* this.$message({
           message: "已切换为自动控制",
           type: "success",
-        });
+        }); */
       } else {
-        this.$message({
+        /* this.$message({
           message: "已切换为手动控制",
           type: "success",
-        });
+        }); */
         clearInterval(this.AutoSendTimer);
       }
       this.IsAutoControl = isAuto;