funtion.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. var _menus;
  2. var obj = {};
  3. var arr = [];
  4. $(function() {
  5. alert(1);
  6. imbodyObj(arr);
  7. // $('#loading-mask').fadeOut();
  8. //setInterval('realSysTime()',1000);
  9. });
  10. function exit(){
  11. var hint = document.getElementById("hint").value;
  12. var exit_hint = document.getElementById("exit_hint").value;
  13. $.messager.confirm(hint, exit_hint, function(r) {
  14. if (r) {
  15. $.ajax({
  16. type:"POST",
  17. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  18. url:"exit",
  19. success:function (data){
  20. }
  21. });
  22. window.location.href = './';
  23. window.event.returnValue = false;
  24. }
  25. });
  26. }
  27. function realSysTime(){
  28. var now=new Date(); //创建Date对象
  29. var year=now.getFullYear(); //获取年份
  30. var month=now.getMonth(); //获取月份
  31. var date=now.getDate(); //获取日期
  32. var day=now.getDay(); //获取星期
  33. var hour=now.getHours(); //获取小时
  34. var minu=now.getMinutes(); //获取分钟
  35. var sec=now.getSeconds(); //获取秒钟
  36. //month=month+1;
  37. if (hour >= 0 && hour <= 9) {
  38. hour = "0" + hour;
  39. }
  40. if (minu >= 0 && minu <= 9) {
  41. minu = "0" + minu;
  42. }
  43. if (sec >= 0 && sec <= 9) {
  44. sec = "0" + sec;
  45. }
  46. //var arr_mon =new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");
  47. var arr_mon =new Array("1","2","3","4","5","6","7","8","9","10","11","12");
  48. month = arr_mon[month];
  49. //var arr_week=new Array("周日","周一","周二","周三","周四","周五","周六");
  50. //var week=arr_week[day]; //获取中文的星期
  51. var time=date+"/"+month+"/"+year+" "+hour+":"+minu+":"+sec; //组合系统时间
  52. document.getElementById("clock").innerHTML = time;
  53. }
  54. function imbodyObj(arr){
  55. var stationm1={};
  56. stationm1.menuid ="56";
  57. stationm1.menuname =document.getElementById("price_curve").value;
  58. stationm1.icon ="icon-curve";
  59. stationm1.url ="curveJumppriceCurve";
  60. var stationm=[];
  61. stationm.push(stationm1);
  62. var stationman={};
  63. stationman.menuid ="56";
  64. stationman.menuname =document.getElementById("price_curve").value;
  65. stationman.icon ="icon-curve";
  66. stationman.menus =stationm;
  67. arr.push(stationman);
  68. obj.menus = arr;
  69. _menus = obj;
  70. initPage();
  71. }
  72. function initPage(){
  73. InitLeftMenu();
  74. tabClose();
  75. tabCloseEven();
  76. }
  77. var onlyOpenTitle="欢迎使用";//不允许关闭的标签的标题
  78. //初始化左侧
  79. function InitLeftMenu() {
  80. $("#nav").accordion({animate:false,fit:true,border:false});
  81. var selectedPanelname = '';
  82. $.each(_menus.menus, function(i, n) {
  83. var menulist ='';
  84. menulist +='<ul class="navlist">';
  85. $.each(n.menus, function(j, o) {
  86. menulist += '<li><div ><a ref="'+o.menuid+'" href="#" rel="' + o.url + '" ><span class="icon '+o.icon+'" >&nbsp;</span><span class="nav">' + o.menuname + '</span></a></div> ';
  87. if(o.child && o.child.length>0)
  88. {
  89. //li.find('div').addClass('icon-arrow');
  90. menulist += '<ul class="third_ul">';
  91. $.each(o.child,function(k,p){
  92. menulist += '<li><div><a ref="'+p.menuid+'" href="#" rel="' + p.url + '" ><span class="icon '+p.icon+'" >&nbsp;</span><span class="nav">' + p.menuname + '</span></a></div> </li>'
  93. });
  94. menulist += '</ul>';
  95. }
  96. menulist+='</li>';
  97. })
  98. menulist += '</ul>';
  99. $('#nav').accordion('add', {
  100. title: n.menuname,
  101. content: menulist,
  102. border:false,
  103. iconCls: 'icon ' + n.icon
  104. });
  105. if(i==0)
  106. selectedPanelname =n.menuname;
  107. });
  108. $('#nav').accordion('select',selectedPanelname);
  109. $('.navlist li a').click(function(){
  110. var tabTitle = $(this).children('.nav').text();
  111. var url = $(this).attr("rel");
  112. var menuid = $(this).attr("ref");
  113. var icon = $(this).find('.icon').attr('class');
  114. var third = find(menuid);
  115. if(third && third.child && third.child.length>0)
  116. {
  117. $('.third_ul').slideUp();
  118. var ul =$(this).parent().next();
  119. if(ul.is(":hidden"))
  120. ul.slideDown();
  121. else
  122. ul.slideUp();
  123. }
  124. else{
  125. addTab(tabTitle,url,icon);
  126. $('.navlist li div').removeClass("selected");
  127. $(this).parent().addClass("selected");
  128. }
  129. }).hover(function(){
  130. $(this).parent().addClass("hover");
  131. },function(){
  132. $(this).parent().removeClass("hover");
  133. });
  134. //选中第一个
  135. //var panels = $('#nav').accordion('panels');
  136. //var t = panels[0].panel('options').title;
  137. //$('#nav').accordion('select', t);
  138. }
  139. //获取左侧导航的图标
  140. function getIcon(menuid){
  141. var icon = 'icon ';
  142. $.each(_menus.menus, function(i, n) {
  143. $.each(n.menus, function(j, o) {
  144. if(o.menuid==menuid){
  145. icon += o.icon;
  146. }
  147. })
  148. })
  149. return icon;
  150. }
  151. function find(menuid){
  152. var obj=null;
  153. $.each(_menus.menus, function(i, n) {
  154. $.each(n.menus, function(j, o) {
  155. if(o.menuid==menuid){
  156. obj = o;
  157. }
  158. });
  159. });
  160. return obj;
  161. }
  162. function addTab(subtitle,url,icon){
  163. if(!$('#tabs').tabs('exists',subtitle)){
  164. $('#tabs').tabs('add',{
  165. title:subtitle,
  166. content:createFrame(url),
  167. closable:true,
  168. icon:icon
  169. });
  170. }else{
  171. $('#tabs').tabs('select',subtitle);
  172. $('#mm-tabupdate').click();
  173. }
  174. tabClose();
  175. }
  176. function createFrame(url)
  177. {
  178. var s = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
  179. return s;
  180. }
  181. function tabClose()
  182. {
  183. /*双击关闭TAB选项卡*/
  184. $(".tabs-inner").dblclick(function(){
  185. var subtitle = $(this).children(".tabs-closable").text();
  186. $('#tabs').tabs('close',subtitle);
  187. })
  188. /*为选项卡绑定右键*/
  189. $(".tabs-inner").bind('contextmenu',function(e){
  190. $('#mm').menu('show', {
  191. left: e.pageX,
  192. top: e.pageY
  193. });
  194. var subtitle =$(this).children(".tabs-closable").text();
  195. $('#mm').data("currtab",subtitle);
  196. $('#tabs').tabs('select',subtitle);
  197. return false;
  198. });
  199. }
  200. //绑定右键菜单事件
  201. function tabCloseEven() {
  202. $('#mm').menu({
  203. onClick: function (item) {
  204. closeTab(item.id);
  205. }
  206. });
  207. return false;
  208. }
  209. function closeTab(action)
  210. {
  211. var alltabs = $('#tabs').tabs('tabs');
  212. var currentTab =$('#tabs').tabs('getSelected');
  213. var allTabtitle = [];
  214. $.each(alltabs,function(i,n){
  215. allTabtitle.push($(n).panel('options').title);
  216. })
  217. switch (action) {
  218. case "refresh":
  219. var iframe = $(currentTab.panel('options').content);
  220. var src = iframe.attr('src');
  221. $('#tabs').tabs('update', {
  222. tab: currentTab,
  223. options: {
  224. content: createFrame(src)
  225. }
  226. })
  227. break;
  228. case "close":
  229. var currtab_title = currentTab.panel('options').title;
  230. $('#tabs').tabs('close', currtab_title);
  231. break;
  232. case "closeall":
  233. $.each(allTabtitle, function (i, n) {
  234. if (n != onlyOpenTitle){
  235. $('#tabs').tabs('close', n);
  236. }
  237. });
  238. break;
  239. case "closeother":
  240. var currtab_title = currentTab.panel('options').title;
  241. $.each(allTabtitle, function (i, n) {
  242. if (n != currtab_title && n != onlyOpenTitle)
  243. {
  244. $('#tabs').tabs('close', n);
  245. }
  246. });
  247. break;
  248. case "closeright":
  249. var tabIndex = $('#tabs').tabs('getTabIndex', currentTab);
  250. if (tabIndex == alltabs.length - 1){
  251. alert('后边没有了 ^@^!!');
  252. return false;
  253. }
  254. $.each(allTabtitle, function (i, n) {
  255. if (i > tabIndex) {
  256. if (n != onlyOpenTitle){
  257. $('#tabs').tabs('close', n);
  258. }
  259. }
  260. });
  261. break;
  262. case "closeleft":
  263. var tabIndex = $('#tabs').tabs('getTabIndex', currentTab);
  264. if (tabIndex == 1) {
  265. alert('左边没有了 ^@^!!');
  266. return false;
  267. }
  268. $.each(allTabtitle, function (i, n) {
  269. if (i < tabIndex) {
  270. if (n != onlyOpenTitle){
  271. $('#tabs').tabs('close', n);
  272. }
  273. }
  274. });
  275. break;
  276. case "exit":
  277. $('#mm').menu('hide');
  278. break;
  279. }
  280. }
  281. //弹出信息窗口 title:标题 msgString:提示信息 msgType:信息类型 [error,info,question,warning]
  282. function msgShow(title, msgString, msgType) {
  283. $.messager.alert(title, msgString, msgType);
  284. }
  285. /**
  286. * EasyUI DataGrid根据字段动态合并单元格
  287. * 参数 tableID 要合并table的id
  288. * 参数 colList 要合并的列,用逗号分隔(例如:"name,department,office");
  289. */
  290. function mergeCellsByField(tableID, colList) {
  291. alert(2);
  292. var ColArray = colList.split(",");
  293. var tTable = $("#" + tableID);
  294. var TableRowCnts = tTable.datagrid("getRows").length;
  295. var tmpA;
  296. var tmpB;
  297. var PerTxt = "";
  298. var CurTxt = "";
  299. var buyprocode = "";
  300. var newbuyprocode = "";
  301. var alertStr = "";
  302. for (j = ColArray.length - 1; j >= 0; j--) {
  303. PerTxt = "";
  304. buyprocode = "";
  305. tmpA = 1;
  306. tmpB = 0;
  307. for (i = 0; i <= TableRowCnts; i++) {
  308. if (i == TableRowCnts) {
  309. CurTxt = "";
  310. newbuyprocode = "";
  311. }
  312. else {
  313. CurTxt = tTable.datagrid("getRows")[i][ColArray[j]];
  314. newbuyprocode = tTable.datagrid("getRows")[i]["buyprojectCode"];
  315. }
  316. if (PerTxt == CurTxt && buyprocode == newbuyprocode) {
  317. tmpA += 1;
  318. }
  319. else {
  320. tmpB += tmpA;
  321. tTable.datagrid("mergeCells", {
  322. index: i - tmpA,
  323. field: ColArray[j],//合并字段
  324. rowspan: tmpA,
  325. colspan: null
  326. });
  327. tTable.datagrid("mergeCells", { //根据ColArray[j]进行合并
  328. index: i - tmpA,
  329. field: "Ideparture",
  330. rowspan: tmpA,
  331. colspan: null
  332. });
  333. tmpA = 1;
  334. }
  335. PerTxt = CurTxt;
  336. buyprocode = newbuyprocode;
  337. }
  338. }
  339. }