From a7223a5dfc7c83c7fe3894e65d1fed84cae61a8e Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 15 二月 2023 08:45:38 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/pipeline.html |   87 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 69 insertions(+), 18 deletions(-)

diff --git a/src/main/webapp/views/pipeline.html b/src/main/webapp/views/pipeline.html
index d8500fc..3f86480 100644
--- a/src/main/webapp/views/pipeline.html
+++ b/src/main/webapp/views/pipeline.html
@@ -15,7 +15,7 @@
     <style>
         .io-mode-box {
             float: left;
-            width: 25%;
+            /*width: 25%;*/
             text-align: center;
         }
         .io-mode-box label {
@@ -23,7 +23,7 @@
         }
         .ioModeBtn {
             vertical-align: middle;
-            width: 50%;
+            width: 25%;
             height: 30px;
             left: 0;
             top: 0;
@@ -58,33 +58,23 @@
                     <!-- 璁惧浠诲姟鎿嶄綔 -->
                     <div class="io-mode-oper">
                         <fieldset>
-                            <legend>鍏ュ嚭搴撴ā寮忥紙IO-Mode锛�</legend>
+                            <legend>鍏呯數鎺у埗锛圕harge-Mode锛�</legend>
                             <div class="io-mode-box">
-                                <label>1F</label>
+                                <label>1#</label>
                                 <button id="io-mode-1" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
                             </div>
                             <div class="io-mode-box">
-                                <label>3F</label>
+                                <label>2#</label>
                                 <button id="io-mode-2" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
                             </div>
-                            <div class="io-mode-box">
-                                <label>4F</label>
-                                <button id="io-mode-3" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
-                            </div>
-                            <div class="io-mode-box">
-                                <label>5F</label>
-                                <button id="io-mode-4" class="ioModeBtn" onclick="ioModeSwitch(this.id)"> - </button>
-                            </div>
                         </fieldset>
-                    </div>
-
-
-                    <div>
-                        <span style="color: #1E9FFF">PLC寮傚父淇℃伅琛�:</span>
                     </div>
                 </div>
                 <!-- 涓讳綋 -->
                 <div class="plc-log-body">
+                    <div>
+                        <span style="color: #1E9FFF">PLC寮傚父淇℃伅琛�:</span>
+                    </div>
                     <table id="plc-error-table">
                         <thead>
                         <tr>
@@ -175,6 +165,7 @@
     var siteTableFullRows = 0;
     var outputDom = document.getElementById("output");
     $(document).ready(function() {
+        getIoModeInfo();
         initPlcErrorTable();
         getPlcError();
         initSiteTable();
@@ -184,11 +175,71 @@
     setInterval(function () {
         getPlcError();
         getSite();
+        getIoModeInfo();
     }, 1000);
     setInterval(function () {
         getSiteOutput();
     },500);
 
+    var ioModeData;
+    function getIoModeInfo() {
+        $.ajax({
+            url: baseUrl+ "/site/io/mode/info/site",
+            headers: {'token': localStorage.getItem('token')},
+            method: 'GET',
+            success: function (res) {
+                if (res.code === 200){
+                    ioModeData = res.data;
+                    ioModeData.forEach(function (e) {
+                        $("#io-mode-"+e.floor).html(e.modeDesc);
+                    })
+                } else if (res.code === 403){
+                    window.location.href = baseUrl+"/login";
+                }  else {
+                    console.log(res.msg);
+                }
+            }
+        });
+    }
+
+    /**
+     * 寮哄埗鍒囨崲鍏ュ嚭搴撴ā寮�
+     */
+    function ioModeSwitch(el) {
+        var floor = el.split("-")[2];
+        if (ioModeData != null && ioModeData.length > 1) {
+            ioModeData.forEach(function(e) {
+                if (e.floor === Number(floor)) {
+                    if (e.modeVal) {
+                        layer.confirm('纭畾鏂紑鍏呯數骞跺浣嶅悧锛�',function () {
+                            $.ajax({
+                                url: baseUrl+ "/site/io/mode/action/site",
+                                headers: {'token': localStorage.getItem('token')},
+                                data: {
+                                    floor: e.floor,
+                                    charge: !e.modeVal
+                                },
+                                method: 'POST',
+                                success: function (res) {
+                                    if (res.code === 200){
+                                        layer.msg(res.msg, {icon: 1})
+                                    } else if (res.code === 403){
+                                        window.location.href = baseUrl+"/login";
+                                    }  else {
+                                        layer.msg(res.msg, {icon: 2})
+                                    }
+                                }
+                            });
+                            layer.closeAll();
+                        })
+                    }
+                }
+            });
+        }
+
+
+    }
+
     // plc寮傚父淇℃伅琛ㄨ幏鍙�
     function getPlcError() {
         var tableEl = $('#plc-error-table');

--
Gitblit v1.9.1