浏览代码

修改闸机操控为js调用

ZhangJunQuan 5 月之前
父节点
当前提交
b1bd1a2d3d
共有 1 个文件被更改,包括 21 次插入19 次删除
  1. 21 19
      src/gate/ControlGate.vue

+ 21 - 19
src/gate/ControlGate.vue

@@ -11,12 +11,12 @@
         <span>主页</span>
       </button>
       <h1 class="page-title">闸机控制</h1>
-      <div class="header-actions">
+      <!-- <div class="header-actions">
         <button class="action-btn refresh-btn" @click="getStatus">
           <i class="fas fa-sync-alt" />
           <span>获取状态</span>
         </button>
-      </div>
+      </div> -->
     </div>
 
     <!-- 主内容区域 -->
@@ -73,7 +73,7 @@
           </button>
 
           <!-- 左闸机开门 -->
-          <button class="control-btn left-btn" :disabled="loading" @click="handleControl('LEFTOPEN', '左闸机开门', false)">
+          <button class="control-btn left-btn" :disabled="loading" @click="handleControl('SHOTOPEN', '左闸机开门', false)">
             <div class="btn-icon">
               <i class="fas fa-arrow-left" />
             </div>
@@ -169,22 +169,24 @@ const handleControl = async (command, actionName, isBigInv) => {
         let res = null;
         if (isBigInv) {
             res = await controlGateByBigInv(command);
-        } else {
-            res = await controlGate(command);
-        }
-        // plugin.gateConfig.controlGate(command);
-        if (res.errorCode === 0) {
-            showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
-            if (actionName.includes('开')) {
-                plugin.soundPlay.playOpen();
-            } else if (actionName.includes('关')) {
-                plugin.soundPlay.playClose();
-            } else if (actionName.includes('报')) {
-                plugin.soundPlay.playAlarm();
-            }
-        } else {
-            showNotify({ type: 'danger', message: res.errorMessage || `${actionName}操作失败`, duration: 3000 });
         }
+        // } else {
+        //     res = await controlGate(command);
+        // }
+        plugin.gateConfig.controlGate(command);
+        showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
+        // if (res.errorCode === 0) {
+        //     showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
+        //     if (actionName.includes('开')) {
+        //         plugin.soundPlay.playOpen();
+        //     } else if (actionName.includes('关')) {
+        //         plugin.soundPlay.playClose();
+        //     } else if (actionName.includes('报')) {
+        //         plugin.soundPlay.playAlarm();
+        //     }
+        // } else {
+        //     showNotify({ type: 'danger', message: res.errorMessage || `${actionName}操作失败`, duration: 3000 });
+        // }
     } catch (error) {
         console.error('闸机控制失败:', error);
         showNotify({ type: 'danger', message: `${actionName}操作失败`, duration: 3000 });
@@ -213,7 +215,7 @@ const getStatus = async () => {
 };
 
 onMounted(() => {
-    getStatus();
+    // getStatus();
 });
 </script>