whyclj
2019-10-29 1c0469e45346d464e0c5672ee68f9ecd4fb6be7c
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
//屏蔽浏览器右键菜单功能
$(document).ready(function(){
        document.oncontextmenu=function(){
                return false;
        };
});
// 鼠标右键菜单显示
$(document).ready(function(){
        $('#lside').on('mousedown','.thr',function(e){
            //利用jquery的方式获取当前点击的是否是右键
            if(e.which==3)
            {
                    $(this).click();
                    var disX=(e||event).clientX+10;                 //得到鼠标点击X的位置
                    var disY=(e||event).clientY+10;                 //得到鼠标点击Y的位置
                    var scrollY=$(document).scrollTop();               //获取浏览器滚动的高度
                    var realHeight=disY+scrollY;
                    //清除背景色
                    $('.fir').css("background-color",'');
                    $('.sec').css("background-color",'');
                    $('.thr').css("background-color",'');
                    //给当前背景添加颜色
                    $(this).css("background-color",'#9bbaf3');
                    //显示菜单内容
                    $("#right_menu").show();
                    //使菜单跟随鼠标位置
                    $('#right_menu').css('left',disX+'px');
                    $('#right_menu').css('top',realHeight+'px');
                    
            }
        });
        //利用not选中器使不是点击.thr时就隐藏菜单
        $("body:not('.thr')").click(function(){
                if($("#right_menu").is(':hidden'))
                {
                        //屏蔽浏览器右键菜单功能
                        document.oncontextmenu=function(){
                                return false;
                        };
                }else{
                        //隐藏右键菜单
                        $("#right_menu").hide();
                        $('#right_menu .child_menu').hide();
                }
        });
});
//使遮罩层一直处在页面内
$(document).ready(function(){
    $(document).scroll(function(){
        var scrollY=$(document).scrollTop();
        $('#allShade').css('top',scrollY+"px");
    });
});
//查看电池组机历卡
$(document).ready(function(){
        //点击菜单选项显示查看电池组机历卡内容
        $('#right_menu a').eq(0).click(function(){
            $('#card_infor').show();
            $('#allShade').show();
            $('body').css('overflow','hidden');
            findBattinfByBattGroupId(BattGroupId);
            //createMaint_infTable();
        });
        //退出查看电池组机历卡
        $('#out_card_infor').click(function(){
            $('#card_infor').hide();    //隐藏电池组机利卡
            $('#allShade').hide();
            $('body').css('overflow','scroll');
        });
        //电池组机历卡处在浏览器可视区域
        $(document).scroll(function(){
            var scrollY=$(document).scrollTop();    //浏览器滚动高度
            //使电池组机历卡一直在页面内
            $('#card_infor').css('top',scrollY+80+"px");
        });
});
//上传FBO和IDE数据
//$(document).ready(function(){
//        //点击菜单显示上传FBO和IDE数据窗口
//        $('#right_menu a').eq(1).click(function(){
//            $('#upload_fbo').show();
//            $('#allShade').show();
//            $('body').css('overflow','hidden');
//        });
//        //退出上传FBO和IDE数据
//        $('#out_upload_fbo').click(function(){
//            var a=confirm("确定退出上传窗口吗?");
//            if(a==true)
//            {
//                $('#upload_fbo').hide();    //隐藏上传
//                $('#allShade').hide();
//                $('body').css('overflow','scroll');
//            }
//        });
//        $(document).scroll(function(){
//            var scrollY=$(document).scrollTop();
//            //使上传一直在页面内
//            $('#upload_fbo').css('top',scrollY+80+"px");
//        });
//        //点击上传FBO和IDE数据内的显示和隐藏
//        $("#upload_fbo p").click(function(){
//            $("#upload_fbo .show_hide_opt").slideToggle(500);
//        });
//});
// 上传'内阻、电导'数据
//$(document).ready(function(){
//        // 点击菜单选项显示上传’内阻电导数据
//        $('#right_menu a').eq(2).click(function(){
//            $('#upload_resist').show();
//            $('#allShade').show();
//            $('body').css('overflow','hidden');
//        });
//        // 退出上传内阻和电导
//        $('#out_upload_resist').click(function(){
//            var a=confirm("确定退出上传窗口吗?");
//            if(a==true)
//            {
//                $('#upload_resist').hide();    //隐藏上传
//                $('#allShade').hide();
//                $('body').css('overflow','scroll');
//            }
//        });
//        // 点击显示隐藏内容的按钮
//        $('#upload_resist p').click(function(){
//            $('#upload_resist .show_hide_opt').slideToggle(500);
//        });
//        // 是上传界面在浏览器可视区域内
//    $(document).scroll(function(){
//            var scrollY=$(document).scrollTop();    //滚动条滚动的高度
//            $('#upload_resist').css('top',scrollY+80+'px');        //根据滚动条确定窗口的位置
//    });
//});
// 显示右键菜单的子菜单功能
$(document).ready(function(){
        // 鼠标离开子菜单
        $("#right_menu a:not('.child_menu')").mouseover(function(){
                $('#right_menu .more_menu').css('color','#000');
                $('#right_menu .more_menu').css('background-color','#fff');
                $('#right_menu .child_menu').hide();
        });
        // 鼠标经过拥有子菜单的选项
        $('#right_menu .more_menu').mouseover(function(){
                $('#right_menu .more_menu').css('color','#ffffff');
                $('#right_menu .more_menu').css('background-color','#34cd62');
                $('#right_menu .child_menu').show();
        });
        //鼠标离开该选项
        $('#right_menu .more_menu').mouseout(function(){
                $('#right_menu .more_menu').css('color','#000');
                $('#right_menu .more_menu').css('background-color','#fff');
        });
        // 鼠标经过子菜单
        $('#right_menu .child_menu').mouseover(function(){
                $('#right_menu .more_menu').css('color','#ffffff');
                $('#right_menu .more_menu').css('background-color','#34cd62');
        });
});
 
//搜索机房或电池组
$(document).ready(function(){
        //点击搜索机房或电池组的内容
        $('#right_menu a').eq(5).click(function(){
            $('#search_room').show();
            $('#allShade').show();
            $('body').css('overflow','hidden');
        });
        //退出搜索机房或电池组
        $('#out_search').click(function(){
            $('#search_room').hide();
            $('#allShade').hide();
            $('#search_input').val('');
            $('#search_info ul').text('');
            $('body').css('overflow','scroll');
        });
        $(document).scroll(function(){
            var scrollY=$(document).scrollTop();
            //使搜索框一直在页面内
            $('#search_room').css('top',scrollY+80+"px");
        });
        //搜索机房或电池组输入时触发的键盘事件
        $('#search_input').keyup(function(){
            var searchValue=$('#search_input').val();
            console.log(searchValue);
    });
    // 点击查询事件
    $('#search_info').on('li','click',function(){
        var len=$('#search_info li').length;
        for(var i=0;i<len;i++)
        {
            $('#search_info li').css('background-color','');
        }
        $(this).css('background-color','#aae5f7');
    });
});
 
 
//搜索机房或电池组输入时触发的键盘事件
$(document).ready(function(){
    $('#search_input').keyup(function(){
        var searchValue=$('#search_input').val();
        findBattinfByCondition(searchValue);
    });
    
    $('#search-type').change(function(){
        var searchValue=$('#search_input').val();
        findBattinfByCondition(searchValue);        
    });
});
 
//根据关键词查询机房或者电池组
function findBattinfByCondition(keyWords){
    var oSearch_info=$("#search_info");
    oSearch_info.text('');
    loading.showLoading($("#search_info"));
    console.info(keyWords);
    var searchtype = $('#search-type').val();
    $.ajax({     
        type: "post",                 
        url: "BattInfAction!serchStationOrBattgroup",                
        async:true,                
        dataType:'text',
        data:"json = "+JSON.stringify({
            num:$('#search-type').val(),
            StationName9:keyWords
        }),    
        success: function(data){                                        
            data = eval('('+data+')');
            var model = eval('('+data.result+')');
            //console.info(model);
            if(model.code == 1){
                var ul = $("<ul></ul>");
                var li_str = "";
                for(var i=0;i<model.data.length;i++){
                    //console.info(model.data[i]);
                    if(searchtype == 1){
                        li_str += "<li stationid='"+model.data[i].StationId+"' value='"+model.data[i].StationId+"' name='station'>"+model.data[i].StationName+"</li>";
                    }else if(searchtype == 0){
                        li_str += "<li stationid='"+model.data[i].StationId+"' value='"+model.data[i].BattGroupId+"' name='batt'>"+model.data[i].BattGroupName+'-'+model.data[i].BattGroupId+"</li>";
                    }
                }    
                ul.append($(li_str));
                oSearch_info.append(ul);
            }
            loading.hideLoading($("#search_info"));
        }                 
    });
    
    /*//确定按钮点击事件
    $("#en_search").click(function(){
        var target;
        $("#lside li a").each(function(){
            
            if($(this).attr("class")=="fir" && $(this).attr("name")==stationid && text==$(this).text()){
                //一级菜单
                var num=$(".fir").index(this);
                if($(".arrow").eq(num).hasClass("down")){                                       
                    $(this).click();
                    }else{
                        //要去掉其他菜单的背景颜色
                        $("#lside li a").each(function(){
                            $(this).css('background-color','#ffffff');
                        });
                        $(this).css('background-color','#9bbaf3');
                    }
                    console.info(this);
                    target="#"+$(this).attr("id"); 
            }else if($(this).attr("class")=="sec" && $(this).text().substring(1,$(this).text().length)==text && stationid==$(this).attr("id")){
                console.info(this);
                //二级菜单选中时                               
                    var index=$(".sec").index(this);
                if($(this).text().substring(0,1)=="+"){
                    
                    //查看是否需要展开该二级菜单的上一级菜单
                    $("#lside li a").each(function(){
                            if(stationid==$(this).attr("name") && $(this).attr("class")=="fir"){
                                var num=$(".fir").index(this);
                                if($(".arrow").eq(num).hasClass("down")){                                       
                                $(this).click();
                                    //console.info($(this).attr("class"));
                                    
                               }
                            }
                        });
                        
                    $(this).click();
                    
                }else{
                    $("#lside li a").each(function(){
                            $(this).css('background-color','#ffffff');
                    });
                    $(this).css('background-color','#9bbaf3');
                }
                
                target="#"+stationid;
            }else if($(this).attr("class")=="thr" && $(this).text()==text && battgroupid==$(this).attr("id")){
                //三级菜单时                               
                //console.info(this);
                $("#lside li a").each(function(){
                    //判断一级菜单是否展开
                    if($(this).attr("class")=="fir" && $(this).attr("name")==stationid){
                        var num=$(".fir").index(this);
                        if($(".arrow").eq(num).hasClass("down")){                                       
                            $(this).click();
                           }
                    }
                    
                    //判断二级菜单是否展开
                    if($(this).attr("class")=="sec" && stationid==$(this).attr("id") && $(this).text().substring(1,$(this).text().length)==id ){
                        
                        if($(this).text().substring(0,1)=="+"){
                            $(this).click();
                        }
                    }
                });
                $(this).click();
                target="#"+battgroupid;
            }
            
        });
        $("#out_search").click();
        location.hash=target;
    });
    //console.info(stationid+"&&"+id+"&&"+text);
*/    
    
    //根据搜索出来的机房和电池组名定位到指定的菜单
       $(document).ready(function(){
           $("#search_info").unbind('click').on('click','ul li',function(){
               //将未被选中的li背景颜色改为白色
               $("#search_info ul li").css('background-color','#ffffff').removeClass('active');
               //将选中的li改为选中色
               $(this).css('background-color','#9bbaf3').addClass('active');
               var stationid=$(this).attr("value");        //菜单栏中的value值        stationid
               var battgroupid=$(this).attr("name");        //菜单栏的name属性值        battgroupid
               var id=$(this).attr("id");                    //搜索框中菜单id        battgroupName1    
               var text=$(this).text();                    //搜索栏中菜单文本        battgroupName2
           });               
       });                      
}  
 
//滚动左导航右键菜单消失
$(document).ready(function(){
    $('#lside').scroll(function(){
        $('#right_menu').hide();
    });
});
 
 
//查询电池组总数
function searchAllBattNum(ele){
    $.ajax({     
        type: "post",                 
        url: "BattInfAction!serchAllBatt",                
        async:true,                
        dataType:'text',
        data:null,    
        success: function(data){                                        
            data = eval('('+data+')');
            var model = eval('('+data.result+')');
            //console.info(model);
            if(model.code == 1){
                ele.text(model.sum);
            }else{
                ele.text(0);
            }
        }                 
    });
}