严智鑫
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
 
<title>添加机器</title>
<style type="text/css">
* {
    padding: 0px;
    margin: 0px;
    font-family: "microsoft yahei", "Helvetica Neue", Helvetica, Arial,
        sans-serif;
}
 
#Top {
    display: block;
    margin-bottom: 10px;
    padding: 5px;
    padding-left: 6px;
    padding-right: 15px;
    line-height: 22px;
    border-radius: 0 2px 2px 0;
    background-color: #f2f2f2;
}
 
.btn {
    height: 35px;
    line-height: 35px;
    background-color: #0dc316;
    padding: 0 15px;
    color: #fff;
    border: none;
    border-radius: 2px;
}
 
table thead tr {
    background-color: #f2f2f2;
}
 
table {
    width: 100%;
    border-collapse: collapse;
}
 
table th {
    border: 1px solid #f2f2f2;
    height: 20px;
    line-height: 20px;
    padding: 9px 15px 9px 15px;
}
 
.One td {
    border: 1px solid #f2f2f2;
    height: 38px;
    line-height: 38px;
}
 
#checkbox{
    border: 1px solid #f2f2f2;
    height: 20px;
    line-height: 20px;
    padding: 9px 15px 9px 15px;
}
 
.two td {
    border: 1px solid #f2f2f2;
    height: 20px;
    line-height: 20px;
    padding: 9px 15px 9px 15px;
}
</style>
<script type="text/javascript" src="${ctx}/static/jquery/jquery-3.1.0.min.js"></script>
<script>
var interval = setInterval('refreshStatus()', 20000);
// 设备页面自动刷新
function refreshStatus() {
    window.location.reload();
}
// 停止页面自动刷新
function disableAutoRefresh() {
    clearInterval(interval);
}
 
  function modifyraw(){
          disableAutoRefresh()
         $("#add-fix-info").modal('show');
 }
  
  function cloes(obj){
          var RowHtml=obj.parentNode.parentNode;
        var PlcFontType=RowHtml.getElementsByClassName("PlcFontType")[0].value;
         var PlcFontValue=RowHtml.getElementsByClassName("PlcFontValue")[0].value;
         var MesFontType=RowHtml.getElementsByClassName("MesFontType")[0].value;
         var MesFontValue=RowHtml.getElementsByClassName("MesFontValue")[0].value;
         var ReturnValue=RowHtml.getElementsByClassName("ReturnValue")[0].value;
         var ExeLogic=RowHtml.getElementsByClassName("ExeLogic")[0].value;
         var Describ=RowHtml.getElementsByClassName("Describ")[0].value;
         document.getElementById("plctype1").innerHTML=PlcFontType;
         document.getElementById("plcvalue1").innerHTML=PlcFontValue;
         document.getElementById("mestype1").innerHTML=MesFontType;
         document.getElementById("mesvalue1").innerHTML=MesFontValue;
         document.getElementById("returnvalue1").innerHTML=ReturnValue;
         document.getElementById("exelogin1").innerHTML=ExeLogic;
         document.getElementById("decsiribe1").innerHTML=Describ;
         disableAutoRefresh()
        $("#add-fix-info1").modal('show');
}
  
  function put(){
    var plctype1=document.getElementById("plctype1").innerHTML;
       var plcvalue1=document.getElementById("plcvalue1").innerHTML;
       var mestype1=document.getElementById("mestype1").innerHTML;
       var mesvalue1=document.getElementById("mesvalue1").innerHTML;
       var returnvalue1=document.getElementById("returnvalue1").innerHTML;
       var exelogin1=document.getElementById("exelogin1").innerHTML;
       var decsiribe1=document.getElementById("decsiribe1").innerHTML;
       var checkboxs=document.getElementsByClassName("radios"); 
       var machineId;
    for(var i=0;i<checkboxs.length;i++){
        var checkbox=checkboxs[i];
        if(checkbox.checked){
            var RowHtml=checkbox.parentNode.parentNode;
               machineId=RowHtml.getElementsByClassName("radios")[0].value;
              
        }
    }
    $.ajax({
          cache:false,
            type:"POST",
            dataType : "json", 
             url:"${ctx}/Config/addconfig1",
             data:{
                 "machineId":machineId,
                 "plctype1":plctype1,
                 "plcvalue1":plcvalue1,
                 "mestype1":mestype1,
                 "mesvalue1":mesvalue1,
                 "returnvalue1":returnvalue1,
                 "exelogin1":exelogin1,
                 "decsiribe1":decsiribe1
             }
    });
    window.location.reload();
    interval;
       
  }
  
  
  function onSearch(obj){//js函数开始
      setTimeout(function(){//因为是即时查询,需要用setTimeout进行延迟,让值写入到input内,再读取
        var storeId = document.getElementById('one');//获取table的id标识
        var rowsLength = storeId.rows.length;//表格总共有多少行
        var key = obj.value;//获取输入框的值
        var searchCol = 2;//要搜索的哪一列,这里是第一列,从0开始数起
        for(var i=1;i<rowsLength;i++){//按表的行数进行循环,本例第一行是标题,所以i=1,从第二行开始筛选(从0数起)
          var searchText = storeId.rows[i].cells[searchCol].innerHTML;//取得table行,列的值
          if(searchText.match(key)){//用match函数进行筛选,如果input的值,即变量 key的值为空,返回的是ture,
            storeId.rows[i].style.display='';//显示行操作,
          }else{
            storeId.rows[i].style.display='none';//隐藏行操作
            storeId.rows[1].style.display='';//显示行操作,
          }
        }
      },200);//200为延时时间
    }
  
  
  /*删除  */
    function delAll(){
        var checkboxs=document.getElementsByClassName("checkboxs"); 
      for(var i=0;i<checkboxs.length;i++){
          var checkbox=checkboxs[i];
          if(checkbox.checked){               
              var RowHtml=checkbox.parentNode.parentNode;
              var machineDisposeId=RowHtml.getElementsByClassName("machineDisposeId")[0].value;
               $.ajax({
                  cache:false,
                  type:"POST",
                  dataType : "json", 
                   url:"${ctx}/Config/machineDisposedelete",
                   data:{
                       "machineDisposeId":machineDisposeId
                   },success:function(data){ 
                       window.location.href="${ctx}/Config/config";
                  }
              });
          }         
      } 
    }
  
  /*修改保存  */
    function Updates(obj){
                       
              var RowHtml=obj.parentNode.parentNode;
              var machineDisposeId=RowHtml.getElementsByClassName("machineDisposeId")[0].value;
               var machineId=RowHtml.getElementsByClassName("machineId")[0].value;
               var machineType=RowHtml.getElementsByClassName("machineType")[0].value;
               var PlcFontType=RowHtml.getElementsByClassName("PlcFontType")[0].value;
               var PlcFontValue=RowHtml.getElementsByClassName("PlcFontValue")[0].value;
               var MesFontType=RowHtml.getElementsByClassName("MesFontType")[0].value;
               var MesFontValue=RowHtml.getElementsByClassName("MesFontValue")[0].value;
               var ReturnValue=RowHtml.getElementsByClassName("ReturnValue")[0].value;
               var ExeLogic=RowHtml.getElementsByClassName("ExeLogic")[0].value;
               var Describ=RowHtml.getElementsByClassName("Describ")[0].value;
               $.ajax({
                  cache:false,
                  type:"POST",
                  dataType : "json", 
                   url:"${ctx}/Config/machineDisposeUpdates",
                   data:{
                       "machineDisposeId":machineDisposeId,
                       "machineId":machineId,
                       "machineType":machineType,
                       "PlcFontType":PlcFontType,
                       "PlcFontValue":PlcFontValue,
                       "MesFontType":MesFontType,
                       "MesFontValue":MesFontValue,
                       "ReturnValue":ReturnValue,
                       "ExeLogic":ExeLogic,
                       "Describ":Describ
                   },success:function(data){   
                       alert("修改成功");
                      window.location.href="${ctx}/Config/config";
                  }
              });
                  
       
    }
</script>
</head>
<body>
    <div class="content-wrapper" style="background-color: white;">
        <section class="content-header">
            <div id="Top" style="margin-bottom: 0px;">
                <button class="btn" style="background-color: #fd5f56;"
                    onclick="delAll()">批量删除</button>
                <button class="btn" onclick="modifyraw()">添加</button>
                <span style="float: right; line-height: 40px"></span>
            </div>
            <div class="modal fade" id="add-fix-info" tabindex="-1" role="dialog"
                aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 100%; height: 100%;">
                    <div class="modal-content"
                        style="width: 1000px; margin: auto;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true" data-backdrop="static">&times;</button>
                            <h3 class="modal-title" id="myModalLabel" style="font-weight: bolder;">添加机器</h3>
                        </div>
                        <!--提交-->
                        <form class="form-horizontal" role="form" id="category_add"
                            action="${ctx}/Config/addconfig" method="post">
                            <input type="hidden" id="add-fix" name="Ids">
                            <div>
                                <table id="machine" class="One">
                                    <thead>
                                        <tr >
                                            <th>选择</th>
                                            <th>机器编号</th>
                                            <th>机器类型</th>
                                            <th>端口号</th>
                                            <th>IP地址</th>
                                        </tr>
                                    </thead>
                                    <tbody>${Machinehtml}</tbody>
                                </table>
                            </div>
                            <div style="margin-top: 20px;">
                                <!-- 机器逻辑配置添加 -->
                                <table class="two">
                                    <thead>
                                        <tr>
                                            <th>PLC字类型</th>
                                            <th>值</th>
                                            <th>MES字类型</th>
                                            <th>值</th>
                                            <th>返回结果</th>
                                            <th>执行逻辑</th>
                                            <th>描述</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td><select name="plctype" style="text-align-last: center; vertical-align: middle;">
                                                    <option value="请求字">请求字</option>
                                                    <option value="完成字">完成字</option>
                                                    <option value="发送字">发送字</option>
                                                    <option value="完成确认字">完成确认字</option>
                                            </select></td>
                                            <td><input name="plcvalue" type='text' style="width: 60px;"></td>
                                            <td><select name="mestype">
                                                    <option value="请求字">请求字</option>
                                                    <option value="完成字">完成字</option>
                                                    <option value="发送字">发送字</option>
                                                    <option value="完成确认字">完成确认字</option>
                                            </select></td>
                                            <td><input name="mesvalue" type='text' style="width: 60px;"></td>
                                            <td><input name="returnvalue" type='text' style="width: 60px;"></td>
                                            <td><select name="exelogin">
                                                    <option value="任务发送">任务发送</option>
                                                    <option value="请求清除">请求清除</option>
                                                    <option value="任务完成">任务完成</option>
                                                    <option value="完成清除">完成清除</option>
                                                    <option value="任务破损">任务破损</option>
                                                    <option value="破损清除">破损清除</option>
                                            </select></td>
                                            <td><input type='text' name="decsiribe"></td>
                                            <td><input type="button" value="确认"></td>
                                        </tr>
                                    </tbody>
 
                                </table>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default btn-lg"
                                    data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary btn-lg"
                                    id="addbtnsubmit">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            
            <div class="modal fade" id="add-fix-info1" tabindex="-1" role="dialog"
                aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 100%; height: 100%;">
                    <div class="modal-content"
                        style="width: 1000px; margin: auto;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"
                                aria-hidden="true" data-backdrop="static">&times;</button>
                            <h3 class="modal-title" id="myModalLabel" style="font-weight: bolder;">添加机器</h3>
                        </div>
                        <!--提交-->
                        
                            <input type="hidden" id="add-fix" name="Ids">
                            <div>
                                <table id="machine" class="One">
                                    <thead>
                                        <tr >
                                            <th>选择</th>
                                            <th>机器编号</th>
                                            <th>机器类型</th>
                                            <th>端口号</th>
                                            <th>IP地址</th>
                                        </tr>
                                    </thead>
                                    <tbody>${Machinehtml}</tbody>
                                </table>
                            </div>
                            <div style="margin-top: 20px;">
                                <!-- 机器逻辑配置添加 -->
                                <table class="two">
                                    <thead>
                                        <tr>
                                            <th>PLC字类型</th>
                                            <th>值</th>
                                            <th>MES字类型</th>
                                            <th>值</th>
                                            <th>返回结果</th>
                                            <th>执行逻辑</th>
                                            <th>描述</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                        <td id="plctype1"></td>
                                        <td id="plcvalue1"></td>
                                        <td id="mestype1"></td>
                                        <td id="mesvalue1"></td>
                                        <td id="returnvalue1"></td>
                                        <td id="exelogin1"></td>
                                        <td id="decsiribe1"></td>
                                            <!-- <td><input name="plctype1" type='text' style="width: 60px;"></td>
                                            <td><input name="plcvalue1" type='text' style="width: 60px;"></td>
                                            <td><input name="mestype1" type='text' style="width: 60px;"></td>        
                                            <td><input name="mesvalue1" type='text' style="width: 60px;"></td>
                                            <td><input name="returnvalue1" type='text' style="width: 60px;"></td>
                                            <td><input name="exelogin1" type='text' style="width: 60px;"></td>
                                            <td><input type='text' name="decsiribe"></td> -->
                                        </tr>
                                    </tbody>
 
                                </table>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default btn-lg"
                                    data-dismiss="modal">关闭</button>
                                <button type="submit" onclick="put()" class="btn btn-primary btn-lg"
                                    id="addbtnsubmit">提交</button>
                            </div>
                    </div>
                </div>
            </div>
        </section>
        
        <section class="content container-fluid">
            <div style="overflow-x: auto;height: 750px;">
                <table class="One" id="one">
                    <thead>
                        <tr style="background-color: #00BFFF;font-weight: 800;">
                            <td style="text-align: center;width:5%"><input type="checkbox" /></td>
                            <th style="width:7%">ID</th>
                            <th style="width:9%">机器ID</th>
                            <th style="width:9%">机器类型</th>
                            <th style="width:9%">PLC字类型</th>
                            <th style="width:9%">值</th>
                            <th style="width:9%">MES字类型</th>
                            <th style="width:9%">值</th>
                            <th style="width:9%">返回结果</th>
                            <th style="width:9%">执行逻辑</th>
                            <th style="width:9%">描述</th>
                            <th style="width:7%">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    <tr>
                            <td style="text-align: center;"></td>
                            <th></th>
                            <th><input name="key" type="text" id="key" style="width: 100%;border: none;outline: none;" onkeydown="onSearch(this)" value="" /></th>    
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>
                    ${MachineDisposeshtml}
                    </tbody>
 
                </table>
            </div>
        </section>
    </div>
</body>
</html>