var _menus; var obj = {}; var arr = []; $(function() { alert(1); imbodyObj(arr); // $('#loading-mask').fadeOut(); //setInterval('realSysTime()',1000); }); function exit(){ var hint = document.getElementById("hint").value; var exit_hint = document.getElementById("exit_hint").value; $.messager.confirm(hint, exit_hint, function(r) { if (r) { $.ajax({ type:"POST", contentType: "application/x-www-form-urlencoded; charset=UTF-8", url:"exit", success:function (data){ } }); window.location.href = './'; window.event.returnValue = false; } }); } function realSysTime(){ var now=new Date(); //创建Date对象 var year=now.getFullYear(); //获取年份 var month=now.getMonth(); //获取月份 var date=now.getDate(); //获取日期 var day=now.getDay(); //获取星期 var hour=now.getHours(); //获取小时 var minu=now.getMinutes(); //获取分钟 var sec=now.getSeconds(); //获取秒钟 //month=month+1; if (hour >= 0 && hour <= 9) { hour = "0" + hour; } if (minu >= 0 && minu <= 9) { minu = "0" + minu; } if (sec >= 0 && sec <= 9) { sec = "0" + sec; } //var arr_mon =new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"); var arr_mon =new Array("1","2","3","4","5","6","7","8","9","10","11","12"); month = arr_mon[month]; //var arr_week=new Array("周日","周一","周二","周三","周四","周五","周六"); //var week=arr_week[day]; //获取中文的星期 var time=date+"/"+month+"/"+year+" "+hour+":"+minu+":"+sec; //组合系统时间 document.getElementById("clock").innerHTML = time; } function imbodyObj(arr){ var stationm1={}; stationm1.menuid ="56"; stationm1.menuname =document.getElementById("price_curve").value; stationm1.icon ="icon-curve"; stationm1.url ="curveJumppriceCurve"; var stationm=[]; stationm.push(stationm1); var stationman={}; stationman.menuid ="56"; stationman.menuname =document.getElementById("price_curve").value; stationman.icon ="icon-curve"; stationman.menus =stationm; arr.push(stationman); obj.menus = arr; _menus = obj; initPage(); } function initPage(){ InitLeftMenu(); tabClose(); tabCloseEven(); } var onlyOpenTitle="欢迎使用";//不允许关闭的标签的标题 //初始化左侧 function InitLeftMenu() { $("#nav").accordion({animate:false,fit:true,border:false}); var selectedPanelname = ''; $.each(_menus.menus, function(i, n) { var menulist =''; menulist +='
'; $('#nav').accordion('add', { title: n.menuname, content: menulist, border:false, iconCls: 'icon ' + n.icon }); if(i==0) selectedPanelname =n.menuname; }); $('#nav').accordion('select',selectedPanelname); $('.navlist li a').click(function(){ var tabTitle = $(this).children('.nav').text(); var url = $(this).attr("rel"); var menuid = $(this).attr("ref"); var icon = $(this).find('.icon').attr('class'); var third = find(menuid); if(third && third.child && third.child.length>0) { $('.third_ul').slideUp(); var ul =$(this).parent().next(); if(ul.is(":hidden")) ul.slideDown(); else ul.slideUp(); } else{ addTab(tabTitle,url,icon); $('.navlist li div').removeClass("selected"); $(this).parent().addClass("selected"); } }).hover(function(){ $(this).parent().addClass("hover"); },function(){ $(this).parent().removeClass("hover"); }); //选中第一个 //var panels = $('#nav').accordion('panels'); //var t = panels[0].panel('options').title; //$('#nav').accordion('select', t); } //获取左侧导航的图标 function getIcon(menuid){ var icon = 'icon '; $.each(_menus.menus, function(i, n) { $.each(n.menus, function(j, o) { if(o.menuid==menuid){ icon += o.icon; } }) }) return icon; } function find(menuid){ var obj=null; $.each(_menus.menus, function(i, n) { $.each(n.menus, function(j, o) { if(o.menuid==menuid){ obj = o; } }); }); return obj; } function addTab(subtitle,url,icon){ if(!$('#tabs').tabs('exists',subtitle)){ $('#tabs').tabs('add',{ title:subtitle, content:createFrame(url), closable:true, icon:icon }); }else{ $('#tabs').tabs('select',subtitle); $('#mm-tabupdate').click(); } tabClose(); } function createFrame(url) { var s = ''; return s; } function tabClose() { /*双击关闭TAB选项卡*/ $(".tabs-inner").dblclick(function(){ var subtitle = $(this).children(".tabs-closable").text(); $('#tabs').tabs('close',subtitle); }) /*为选项卡绑定右键*/ $(".tabs-inner").bind('contextmenu',function(e){ $('#mm').menu('show', { left: e.pageX, top: e.pageY }); var subtitle =$(this).children(".tabs-closable").text(); $('#mm').data("currtab",subtitle); $('#tabs').tabs('select',subtitle); return false; }); } //绑定右键菜单事件 function tabCloseEven() { $('#mm').menu({ onClick: function (item) { closeTab(item.id); } }); return false; } function closeTab(action) { var alltabs = $('#tabs').tabs('tabs'); var currentTab =$('#tabs').tabs('getSelected'); var allTabtitle = []; $.each(alltabs,function(i,n){ allTabtitle.push($(n).panel('options').title); }) switch (action) { case "refresh": var iframe = $(currentTab.panel('options').content); var src = iframe.attr('src'); $('#tabs').tabs('update', { tab: currentTab, options: { content: createFrame(src) } }) break; case "close": var currtab_title = currentTab.panel('options').title; $('#tabs').tabs('close', currtab_title); break; case "closeall": $.each(allTabtitle, function (i, n) { if (n != onlyOpenTitle){ $('#tabs').tabs('close', n); } }); break; case "closeother": var currtab_title = currentTab.panel('options').title; $.each(allTabtitle, function (i, n) { if (n != currtab_title && n != onlyOpenTitle) { $('#tabs').tabs('close', n); } }); break; case "closeright": var tabIndex = $('#tabs').tabs('getTabIndex', currentTab); if (tabIndex == alltabs.length - 1){ alert('后边没有了 ^@^!!'); return false; } $.each(allTabtitle, function (i, n) { if (i > tabIndex) { if (n != onlyOpenTitle){ $('#tabs').tabs('close', n); } } }); break; case "closeleft": var tabIndex = $('#tabs').tabs('getTabIndex', currentTab); if (tabIndex == 1) { alert('左边没有了 ^@^!!'); return false; } $.each(allTabtitle, function (i, n) { if (i < tabIndex) { if (n != onlyOpenTitle){ $('#tabs').tabs('close', n); } } }); break; case "exit": $('#mm').menu('hide'); break; } } //弹出信息窗口 title:标题 msgString:提示信息 msgType:信息类型 [error,info,question,warning] function msgShow(title, msgString, msgType) { $.messager.alert(title, msgString, msgType); } /** * EasyUI DataGrid根据字段动态合并单元格 * 参数 tableID 要合并table的id * 参数 colList 要合并的列,用逗号分隔(例如:"name,department,office"); */ function mergeCellsByField(tableID, colList) { alert(2); var ColArray = colList.split(","); var tTable = $("#" + tableID); var TableRowCnts = tTable.datagrid("getRows").length; var tmpA; var tmpB; var PerTxt = ""; var CurTxt = ""; var buyprocode = ""; var newbuyprocode = ""; var alertStr = ""; for (j = ColArray.length - 1; j >= 0; j--) { PerTxt = ""; buyprocode = ""; tmpA = 1; tmpB = 0; for (i = 0; i <= TableRowCnts; i++) { if (i == TableRowCnts) { CurTxt = ""; newbuyprocode = ""; } else { CurTxt = tTable.datagrid("getRows")[i][ColArray[j]]; newbuyprocode = tTable.datagrid("getRows")[i]["buyprojectCode"]; } if (PerTxt == CurTxt && buyprocode == newbuyprocode) { tmpA += 1; } else { tmpB += tmpA; tTable.datagrid("mergeCells", { index: i - tmpA, field: ColArray[j],//合并字段 rowspan: tmpA, colspan: null }); tTable.datagrid("mergeCells", { //根据ColArray[j]进行合并 index: i - tmpA, field: "Ideparture", rowspan: tmpA, colspan: null }); tmpA = 1; } PerTxt = CurTxt; buyprocode = newbuyprocode; } } }