CJJ
2018-12-19 fd6d6cd32f67ed272f071666da57949e360f4674
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
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML>
<html>
    <head>
        <base href="<%=basePath%>">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <title>基站安装审批</title>
        <link rel="stylesheet" type="text/css" href="pages/css/base.css">
        <link rel="stylesheet" type="text/css" href="jqueryui/jquery-ui.css">
        <link rel="stylesheet" type="text/css" href="src/css/layui.css">
        <link rel="stylesheet" type="text/css" href="pages/css/mylayui.css">
        <style>
            .dataTypeCont {
                width: 160px;
                text-align: center;
            }
            .dataTypeCont .layui-form-switch {
                min-width: 70px;
                margin-top: 4px;
            }
        </style>
    </head>
     <body>
         <!--头部内容开始-->
        <jsp:include page="Top.jsp" flush="true"/>
        <!--头部内容结束-->
        <!--导航开始-->
        <jsp:include page="nav.jsp" flush="true"/>
        <!-- 主体内容 -->
        <div class="layui-page-container">
            <!-- 页面主题内容 -->
            <div class="layui-page-content" style="position: relative;">
                <div class="tbl-filter" lay-filter="tblFilter" style="position: absolute;z-index: 891;top: 8px; left: 15px">
                    <div class="layui-form layui-form-pane"  lay-filter="tblFilter">
                        <button class="layui-btn layui-btn-sm layui-btn-normal" id="exBattGroups">批量审批</button>
                        <button class="layui-btn layui-btn-sm layui-btn-danger" id="reBattGroups">批量拒绝</button>
                        <!-- <button class="layui-btn layui-btn-sm layui-btn-normal" id="reTbl">刷新表格</button> -->
                    </div>
                </div>
                <!-- 表格内容 -->
                <table id="pageTbl" lay-filter="pageTbl"></table>
            </div>
            <div class="data-footer">
                <!-- 分页内容 -->
                <div id="paging">
                    <a href="javascript:" class="search"><s:text name="Search"/></a>        <!-- 查询 -->
                    <a href="javascript:" id="export_table"><s:text name="Export"/></a>        <!-- 导出 -->
                    <span id="current">1/1</span>
                    <span><s:text name="Each_page"/><input type="text" id="number" value="10"/><s:text name="Item"/></span>
                    <s:text name="Total_data"/><!-- 数据总量 --><span id="total">0</span>&nbsp;
                    <a href="javascript:" id="page_home"><s:text name="HomePage"/></a> 
                    <a href="javascript:" id="page_pre"><s:text name="Page_Up"/></a>
                    <a href="javascript:" id="page_next_p"><s:text name="Page_Down"/></a>
                    <a href="javascript:" id="page_last"><s:text name="End_Page"/></a>
                    <span id="cont">
                        <s:text name="Goto"/><input type="text" id="page_num" value="1"/>
                        <a href="javascript:" id="page_go"><s:text name="Jump"/></a>
                    </span>
                </div>
            </div>
        </div>
        <script type="text/html" id="battGrouptools">
            <a class="layui-btn layui-btn-xs" lay-event="adopt">通过</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="refuse">拒绝</a>
        </script>
        <script type="text/html" id="applyEn">
            {{# if(d.apply_en){ }}
                <a class="layui-btn layui-btn-xs">已通过</a>
            {{# }else{ }}
                <a class="layui-btn layui-btn-danger layui-btn-xs">待审核</a>
            {{# } }}
        </script>
        <script type="text/html" id="produceTime">
            {{= d.BattProductDate.substr(0,10)}}
        </script>
        <script type="text/html" id="useTime">
            {{= d.BattInUseDate.substr(0,10)}}
        </script>
        <script type="text/html" id="isInstall">
            {{# if(d.Station_install) { }}
                <button class="layui-btn layui-btn-normal layui-btn-xs">已安装</button>
            {{# }else { }}
                <button class="layui-btn layui-btn-disabled layui-btn-xs">未安装</button>
            {{# } }}
        </script>
        <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
        <script type="text/javascript" src="jqueryui/jquery-ui.min.js"></script>
        <script type="text/javascript" src="src/layui.js"></script>
        <script type="text/javascript" src="pages/js/mylayui.js"></script>
        <script type="text/javascript" src="pages/js/common.js"></script>
        <script type="text/javascript">
            layui.use(['form', 'table', 'layer', 'element'], function() {
                var table = layui.table;        // 获取表格模块
                var form = layui.form;            // 获取表单模块
                var layer = layui.layer;        // 获取弹出框模块
                var element = layui.element;    // 获取元素操作模块
                
                // 表格模块
                var tOptions = {
                    elem: '#pageTbl'
                    ,toolbar: true
                    ,defaultToolbar: []
                    ,cellMinWidth: 80
                    ,cols: [[
                        {type:'checkbox',fixed: 'left'}
                        ,{field:'StationId', title:'机房编号', align:'center', width: 120}
                        ,{field:'StationName1', title:'省', align:'center', width: 100}
                        ,{field:'StationName2', title:'市', align:'center', width: 100}
                        ,{field:'StationName5', title:'区县', align:'center', width: 100}
                        ,{field:'StationName3', title:'机房名称', align:'center', width: 360}
                        ,{field:'StationName4', title:'设备名称', align:'center', width: 150}
                        ,{field:'StationIp', title:'机房ip', align:'center', width: 160}
                        ,{field: 'FBSDeviceId', title: 'FBS设备ID(重要)', align: 'center', width: 160}
                        ,{field:'FbsDeviceIp', title:'FBS设备IP(重要)', align:'center', width: 160}
                        ,{field:'FbsDeviceIp_YM', title:'子网掩码', align:'center', width: 160}
                        ,{field:'FbsDeviceIp_WG', title:'网关', align:'center', width: 160}
                        ,{field:'FBSDeviceName', title:'FBS设备名称', align:'center', width: 160}
                        ,{field:'GroupIndexInFBSDevice', title:'FBS设备索引', align:'center', width: 160}
                        ,{field:'BattGroupId', title:'电池组ID', align:'center', width: 160}
                        ,{field:'BattGroupNum', title:'机房内电池组编号', align:'center', width: 160}
                        ,{field:'BattGroupName', title:'电池组名称', align:'center', width: 160}
                        ,{field:'FloatVolLevel', title:'浮充电压阀值', align:'center', width: 160}
                        ,{field:'OfflineVolLevel', title:'离线电压阀值', align:'center', width: 160}
                        ,{field:'BattFloatCurrent', title:'浮充阀值', align:'center', width: 100}
                        ,{field:'MonCount', title:'单体数量', align:'center', width: 100}
                        ,{field:'MonCapStd', title:'标称容量', align:'center', width: 100}
                        ,{field:'MonVolStd', title:'标称单体电压', align:'center', width: 140}
                        ,{field:'MonResStd', title:'标称单体内阻', align:'center', width: 140}
                        ,{field:'MonSerStd', title:'标称单体电导', align:'center', width: 140}
                        ,{field:'MonVolLowToAvg', title:'单体电压次低偏移量', align:'center', width: 140}
                        ,{field:'Load_curr', title:'负载电流', align:'center', width: 140}
                        ,{field:'DisCurrMax', title:'最大核容电流', align:'center', width: 140}
                        ,{field:'station_phone', title:'基站手机号码', align:'center', width: 140}
                        ,{field:'BattProducer', title:'电池品牌', align:'center', width: 140}
                        ,{field:'BattModel', title:'电池型号', align:'center', width: 260}
                        ,{field:'productDate', title:'电池生产日期', templet: '#produceTime', align:'center', width: 140}
                        ,{field:'useDate', title:'投入使用日期', templet: '#useTime', align:'center', width: 140}
                        ,{field:'isInstall', title:'安装状态', templet: '#isInstall', align:'center', width: 140}
                        ,{field:'install_user', title:'设备安装人员', align:'center', width: 260}
                        ,{field:'apply_uid', title:'申请人', align:'center', width: 120}
                        ,{field:'apply_en', title:'申请状态', align:'center', templet: '#applyEn',width: 120}
                        ,{field:'apply_date', title:'申请日期', align:'center', width: 260}
                        ,{fixed: 'right', title:'审批操作', align: 'center', toolbar: '#battGrouptools', width:160}
                    ]]
                    ,data:[]
                    ,limit: 10000
                    ,page: false
                    ,height: 'full-190'
                };
                
                // 生成表格数据
                table.render(tOptions);
                
                // 审批操作栏
                table.on('tool(pageTbl)', function(obj) {
                    switch(obj.event) {
                        case 'adopt':
                            exBattGroup(obj.data);
                        break;
                        case 'refuse':
                            reBattGroup(obj.data);
                        break;
                        default:
                            layer.msg('功能开发中...');
                        break;
                    };
                });
                
                
                // 批量申请
                $('#exBattGroups').click(function() {
                    var checkStatus = table.checkStatus('pageTbl'); //idTest 即为基础参数 id 对应的值
                    
                    if(checkStatus.data.length == 0) {
                        layer.msg('请选择需要审批通过的机房!');
                        return;
                    }
                    var temp = [];
                    // 遍历选择的结果
                    for(var i=0; i<checkStatus.data.length; i++) {
                        var _data = checkStatus.data[i]; 
                        temp.push(createExParam(_data));
                    }
                    
                    // console.log(temp);
                    // 提示框
                    layer.confirm('是否确认审批通过', {icon: 3, title: '提示'}, function(index) {
                        layer.close(index);            // 关闭确认框
                        
                        exBattGroupAjax(temp);        // 根据构造的数据结果,请求后台
                    });
                });
                
                // 通过审批
                function exBattGroup(data) {
                    // 构造审批通过机房的信息
                    var temp = [createExParam(data)];
                    
                    // console.log(temp);
                    layer.confirm('是否确认审批通过', {icon: 3, title: '提示'}, function(index) {
                        layer.close(index);            // 关闭确认框
                        
                        exBattGroupAjax(temp);        // 根据构造的数据结果,请求后台
                    });
                }
                
                // 构造审批通过的对象
                function createExParam(data) {
                    // 遍历data对象并返回指定格式的对象
                    var temp = {};
                    temp.binf = {};
                    Object.keys(data).forEach(function(key) {
                        if(key == 'num') {
                            temp.num = data[key];
                        }else {
                            temp.binf[key] = data[key];
                        }
                    });
                    
                    return temp;
                }
                
                // 通过审批请求
                function exBattGroupAjax(data) {
                    var load = layer.load(1);        // 添加等待框
                    // 请求后台
                    $.ajax({
                        type: 'post'
                        ,async: true
                        ,url: "Battinf_applyAction!update"
                        ,data: "json="+JSON.stringify(data)
                        ,dataType: 'json'
                        ,success: function(res) {
                            var rs = JSON.parse(res.result);
                            // console.log(rs);
                            if(rs.code == 1) {
                                layer.msg('确认审核成功!');
                                // 查询后台数据
                                search(createSearchParam(), true);
                            }else {
                                layer.msg('确认审核失败!');
                            }
                            
                        }
                        ,complete: function() {
                            layer.close(load);
                        }
                    });
                }
                
                // 实例化TblPage对象
                var Page = new TblPage();
                Page.set(1, 0, 20);
                 
                // 查询后台数据
                search(createSearchParam(), true);
                function search(temp, newLoad) {
                    var load;
                    if(newLoad) {
                        load = layer.load(1);
                    }
                    // 查询后台
                    $.ajax({
                        type: 'post'
                        ,async: true
                        ,url: "Battinf_applyAction!serchByCondition"
                        ,data: "json="+JSON.stringify(temp)
                        ,dataType: 'json'
                        ,success: function(res) {
                            //console.log(res);
                            var rs = JSON.parse(res.result);
                            var resData = [];
                            if(rs.code == 1) {
                                var data = rs.data;
                                console.log(data);
                                // 遍历数据的值
                                for(var i=0; i<data.length; i++) {
                                    var _data = data[i];
                                    var _tmp = formaterResData(_data);
                                    resData.push(_tmp);
                                    Page.setAll(_data.apply_note);
                                }
                            }
                            // console.log(resData);
                            setPageVal(Page);
                            tOptions.data = resData;
                            
                            // 生成表格数据
                            table.render(tOptions);
                            
                        }
                        ,complete: function() {
                            layer.close(load);
                        }
                    });
                }
                
                // 构造查询条件
                function createSearchParam() {
                    var temp = Page.getPage();
                    return temp;
                }
                
                // 构造结果集
                function formaterResData(data) {
                    // 遍历结果集
                    var temp = {};
                    Object.keys(data).forEach(function(key) {
                        if(key == 'binf') {
                            var binf = data.binf;
                            // 遍历binf内容内容
                            Object.keys(binf).forEach(function(_key) {
                                temp[_key] = binf[_key];
                            });
                        }else {
                            temp[key] = data[key];
                        }
                    });
                    
                    return temp;
                }
                
                //点击查询按钮
                $('#paging .search').click(function(){
                    search(createSearchParam(), false);
                });
                
                //首页
                $('#page_home').click(function(){
                    if(Page != undefined){
                        if(Page.curr != 1){
                            Page.setCurr(1);
                            search(createSearchParam(), true);
                        }
                    }        
                });
                
                //点击上一页
                $("#page_pre").click(function(){
                    if(Page != undefined){
                        if(Page.curr > 1){
                            Page.setCurr(Page.curr-1);
                            search(createSearchParam(), true);
                        }
                    }
                });
                
                //点击下一页
                $("#page_next_p").click(function(){                
                    if(Page != undefined){
                        if(Page.num > Page.curr){
                            Page.setCurr(Page.curr+1);
                            search(createSearchParam(), true);
                        }
                    }
                });
                
                //尾页
                $('#page_last').click(function(){
                    if(Page != undefined){
                        if(Page.curr < Page.num){
                            Page.setCurr(Page.num);
                            search(createSearchParam(), true);
                        }
                    }
                });
                
                //设置每页行数
                $('#number').blur(function(){
                    var value=$('#number').val();
                    //当输入的数大于0时
                    if(value>0){
                        if(value != Page.size){
                            Page.setSize(parseInt(value));
                            Page.setCurr(1);
                        }
                    }else{
                        //当输入非法数字时
                        alert("请输入合法的数字");                        /* 请输入合法的整数 */
                        $('#number').val(Page.size);                    
                    }
                });
                
                //点击跳转
                $('#page_go').click(function(){
                    var tarpage=$('#page_num').attr('value');
                    if(tarpage > Page.num){
                        Page.setCurr(Page.num);
                        search(createSearchParam(), true);
                    }else if(tarpage > 0 && tarpage!= Page.curr){
                        Page.setCurr(parseInt(tarpage));
                        search(createSearchParam(), true);
                    }
                    
                });
                
                // 设置页面Page
                function setPageVal(page) {
                    $('#current').text(page.curr+'/'+page.num);
                    $('#total').text(page.all);
                    $('#number').val(page.size);
                }
            });
        </script>
    </body>
</html>