严智鑫
2024-05-13 cedce4883f0d204f5bf7bf87c0bf4858dabb0c23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.northglass.Globel.mes"%>
<%@page import="com.northglass.SqlHelper.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <script src="/gmms2/static/js/ng/layout.js"></script>
    <script src="gmms2/static/jquery/jquery-3.1.0.min.js" type="text/javascript"></script>
        <style>
            .rect{
                background-color: lightblue;
                border:  1px solid blue;
                grid-row-start: 1;
                overflow:auto
            }
    </style>
</head>
<body>
<div  class="content-wrapper">
    <div style="display:flex;">
    <span >炉号:</span>
    <span id="luhao" style="font-weight:900;font-size:18px"></span>
        <button style="margin-left:100px;width:80px" onclick="comit();">提交</button>
    </div>
    <div  id="abc" style="width:800px;height:450px;display:grid;background-color: gray;display:grid;text-align: center;">
        
   </div>
   </div>
   <script>
           <%
               String p=request.getParameter("l");
           if(p!=null)
               out.print("var line="+p+";\r\n");
           else
               out.print("var line=null;\r\n");
           %>
   
        var lay=createLayout(document.getElementById("abc"));
        var item=[
                    {x:10,y:10,width:200,height:200,id:1},
                    {x:10,y:215,width:200,height:150,id:2},
                    {x:215,y:10,width:200,height:200,id:1},
                    {x:215,y:215,width:200,height:150,id:2},
                ];
   
        var opt=lay.createOption(6000,3000);
        var flag=0;
        var lastF=0;
        var lastData=null;
        function updateLayout(data){
               var d=JSON.parse(data);
               if(d.result!="ok"){
                   alert(d.message);
                   if(flag==0)
                       beginUpdate();
                   return;
               }
               var data=d.data;
               var f=null;
               if(lastData!=null){
                   f=lastData.number;
               }
               
               if(f!=data.number){
                   lastData=data;
                   document.getElementById("luhao").innerText=data.number;
                   opt.items=lastData.data;
                   for(var i=0;i<lastData.data.length;i++){
                       lastData.data[i].remove=lastData.data[i].status!=0;
                   }
                   lay.layout(opt);
                   
               }
       
               
               if(flag==0)
                   setTimeout(update,3000);
        }
        
        function fail(data){
              if(flag==0)
                   setTimeout(update,3000);          
        }
        
        function update(){
            if(flag==0){
                $.ajax({
                    url:"/gmms2/mesview/data/_layout",
                    type:"post",
                    data:{
                        a:"update",
                        b:line
                    },
                    async:true,
                    success:updateLayout,
                    error:fail
                });
            }
        }
        
      function comit(){
          if(lastData!=null){
              var ids="";
              for(var i=0;i<lastData.data.length;i++){
                  if(lastData.data[i].remove==true)
                      if(ids=="")
                          ids+=lastData.data[i].id;
                      else
                          ids+=","+lastData.data[i].id;
              }
              $.ajax({
                 url:"/gmms2/mesview/data/_layout",
                 type:"post",
                 data:{
                     a:"comit",
                     b:ids
                 },
                 async:false,
                 success:function(data){
                     data= JSON.parse(data);
                     if(data.result=="ok")
                    
                         alert("提交完成");
                     else
                         alert(data.message);
                     window.location.reload();
                       
                 },
                 error:function(data){
                     alert("提交失败");
                     window.location.reload();
                 }
                 
              });
          }
      }  
        
      function beginUpdate(delay){
            if(delay==false){
                setTimeout(update,3000);
            }
            else
                update();
        }
        
        beginUpdate(true);
 
   </script>
</body>
</html>