Browse Source

Added QIngkongshuju

jason.lu 6 years ago
parent
commit
182cc20f43
3 changed files with 126 additions and 1 deletions
  1. 15 0
      js/basic.js
  2. 85 0
      js/lazhang-data.js
  3. 26 1
      lazhang.html

+ 15 - 0
js/basic.js

@@ -218,11 +218,25 @@ function on_document_load() {
     }
 }
 
+var AlertClosingTimeout = 0;
+
 function send_alert(a, b){
 
     if(Queue.shouldStop) return;
     $("#mpAlert").html(a);
     $("#mpAlert").show();
+
+    if(AlertClosingTimeout > 0) {
+        clearTimeout(AlertClosingTimeout);
+    }
+
+    AlertClosingTimeout = setTimeout(function(){
+        if ($("#mpAlert").html().indexOf("<") >= 0) {
+            return;
+        }
+        $("#mpAlert").hide();
+    }, 10000);
+
     return;
 
     var q = "<!-- Modal 部分开始 -->\n<div class=\"modal fade\" id=\"alertModal\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">\n    <div class=\"modal-dialog\" role=\"document\">\n        <div class=\"modal-content\">\n            <div class=\"modal-header\">\n                <h5 class=\"modal-title\" id=\"alertModalLabel\">New message</h5>\n                <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">\n                    <span aria-hidden=\"true\">&times;</span>\n                </button>\n            </div>\n            <div class=\"modal-body\">\n                <form>\n                    <div class=\"form-group\">\n                        <label for=\"recipient-name\" class=\"col-form-label\">Recipient:</label>\n                        <input type=\"text\" class=\"form-control\" id=\"recipient-name\">\n                    </div>\n                    <div class=\"form-group\">\n                        <label for=\"message-text\" class=\"col-form-label\">Message:</label>\n                        <textarea class=\"form-control\" id=\"message-text\"></textarea>\n                    </div>\n                </form>\n            </div>\n            <div class=\"modal-footer\">\n                <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Close</button>\n                <button type=\"button\" class=\"btn btn-primary\">Send message</button>\n            </div>\n        </div>\n    </div>\n</div>";
@@ -240,6 +254,7 @@ function send_alert(a, b){
         $("#message-text").text(b);
         modalO.modal('show');
     }
+
 }
 
 function getUserName(uid){

+ 85 - 0
js/lazhang-data.js

@@ -132,6 +132,91 @@ function get_stop_scheudle1() {
     }
 }
 
+function show_clear_panel(){
+    $("#clearModal").modal('show');
+}
+
+var executed = false;
+var finished = true;
+var directCount = -1;
+
+function clear_one_data(){
+    executed = false;
+    directCount = -1;
+    finished = true;
+    var hand = $("#handInput").val();
+    if(hand.length > 0){
+        var hd = parseInt(hand);
+    }
+    get_data("endpoint/clearBoard?flowId="+flowId+"&handheldId=" + hd, clearSuccess);
+}
+
+function clearSuccess(obj, sta){
+    console.warn("-------  手持设备清空  ----------");
+    console.warn(this);
+    send_alert("发送清空请求成功, 正在等待采集端进行处理...");
+    finished = false;
+    setTimeout(on_timeout_clear, 5000);
+    setTimeout(recurseget,300);
+    //var output = first_success(this, obj);
+}
+
+function recurseget(){
+    if(finished) return;
+    get_data("endpoint/heartbeat?flowId=" + flowId, onheart);
+    setTimeout(recurseget,100);
+}
+
+function onheart(obj,sta){
+    var ouy = {};
+    if(typeof(obj) === "string"){
+        ouy = JSON.parse(obj);
+    }
+
+
+    if(typeof(obj) === "object"){
+        if(ouy.ret === "10000"){
+            //ok
+            if(ouy.model == null || ouy.model === undefined){
+                executed = true;
+                finished = true;
+            }else if(typeof(obj.model) === "object"){
+                // 没有拿到,继续
+                if(obj.model.list != null && obj.model.list.length > 0){
+                    var direct = obj.model.list[0];
+                    if(direct.eventType+"" !== "500"){
+                        // OK
+                        executed = true;
+                        finished = true;
+                    }else if(direct.arg2+"" !== ""+$("#handInput").val()){
+                        // OK
+                        executed = true;
+                        finished = true;
+                    }else{
+                        directCount = direct.counter;
+                    }
+                }
+            }
+        }
+    }
+}
+
+function on_timeout_clear(){
+    finished = true;
+    if(executed){
+        // 执行成功
+    }else{
+        if(directCount >= 0){
+            get_data("endpoint/ack?counter="+directCount,function(){console.log("撤销操作成功");console.log(this);});
+            directCount = -1;
+            send_alert("请求已经超时!请注意,采集端可能没有执行成功。即将撤销您的请求。");
+        }else{
+            send_alert("请求已经超时!请注意,采集端可能没有执行成功。");
+        }
+    }
+}
+
+
 function get_stop_scheudle() {
     get_data("fcWorkSchedule/stopSchedule?userId="+userId+"scheduleId=" + scheduleId, stopSuccess);
 

+ 26 - 1
lazhang.html

@@ -101,14 +101,39 @@
         <div style="color:#fff" class="text-center" id="test1"> 深圳市度彼电子有限公司——激光厂产线1</div>
 
         <font color="#ffffff"><span id="nowDateTimeSpan"></span></font>
-        <!--<div onclick="clear_data()" class="btn btn-warning"> 下班 </div>-->
+        <div onclick="show_clear_panel()" class="btn btn-warning"> 清除数据 </div>
         <div onclick="get_stop_scheudle1()" class="btn btn-warning"> 下班 </div>
     </div>
 
 </nav>
+
 <div class="container" style="max-width:none; !important; padding-top:100px;">
     <div class="alert alert-warning" id="mpAlert" style="display:none">
     </div>
+    <!-- Modal -->
+    <div class="modal fade" id="clearModal" tabindex="-1" role="dialog" aria-labelledby="clearModalLabel" aria-hidden="true">
+        <div class="modal-dialog modal-dialog-centered" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title" id="clearModalLabel">清空手持机</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    请输入清除的手持机ID(编码):
+                    <input size="10" type="text" id="handInput">
+                    <div class="progress" style="display: none;" id="clearProgress">
+                        <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                    <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="clear_one_data()">确认清除</button>
+                </div>
+            </div>
+        </div>
+    </div>
     <div class="text-white row middle-font">
         <div class="col-md-5">
             <div class="text-center big-letter">本拉产能统计</div>