indexscript.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. function initbody(){
  2. objcont = $('#content_allmainview');
  3. objtabs = $('#tabs_title');
  4. menubadge = hongbadge = menutopid = {};//角标数组
  5. resizewh();
  6. $(window).resize(resizewh);
  7. clickhome();
  8. if(show_key!='')jm.setJmstr(jm.base64decode(show_key));
  9. var a = $("li[pmenuid]");
  10. a.click(function(){
  11. if(js.ajaxbool)return;
  12. a.removeClass();
  13. loadmenu(this);
  14. });
  15. loadmenu($("li[pmenuid]")[0]);
  16. if(typeof(FormData)=='undefined'){
  17. js.msg('msg','您的浏览器太低了无法达到想要的预览效果<br>建议使用IE10+,Firefox,Chrome等高级点的',60);
  18. }
  19. if(get('indexuserl')){
  20. var ddsata=[{
  21. name:'<i class="icon-cog"></i> 个人设置',num:'grcog','icon':'cog',url:'system,geren,cog',names:'个人设置'
  22. },{
  23. name:'<i class="icon-bell"></i> 提醒信息',num:'todo','icon':'bell',url:'system,geren,todo',names:'提醒信息'
  24. },{
  25. name:'<i class="icon-picture"></i> 修改头像',num:'face','icon':'picture'
  26. },{
  27. name:'<i class="icon-adjust"></i> 切换主题',num:'theme','icon':'adjust'
  28. },{
  29. name:'<i class="icon-certificate"></i> 背景首页',num:'jiu','icon':'laptop'
  30. },{
  31. name:'<i class="icon-list"></i> 列表首页',num:'jiu2','icon':'laptop'
  32. },{
  33. name:'<i class="icon-user"></i> 帐号('+adminuser+')',num:'user'
  34. }];
  35. if(js.request('afrom')=='')ddsata.push({name:'<i class="icon-signout"></i> 退出',num:'exit'});
  36. $('#indexuserl').rockmenu({
  37. width:150,top:get('topheaderid').offsetHeight,
  38. data:ddsata,
  39. itemsclick:function(d){
  40. if(d.num=='exit'){
  41. js.confirm('确定要退出系统吗?',function(bn){
  42. if(bn=='yes')js.location('?m=login&a=exit');
  43. });
  44. return;
  45. }
  46. if(d.num=='face'){
  47. editfacechang(adminid, adminname);
  48. return;
  49. }
  50. if(d.num=='jiu'){
  51. js.location('?a=home');
  52. return;
  53. }
  54. if(d.num=='jiu2'){
  55. js.location('?a=new');
  56. return;
  57. }
  58. if(d.num=='theme'){
  59. changetheme();
  60. return;
  61. }
  62. if(d.num=='user')return;
  63. addtabs({num:d.num,url:d.url,name:d.names,icons:d.icon});
  64. }
  65. });
  66. }
  67. $('#reordershla').click(function(){
  68. $('#indexmenu').hide();
  69. $('#indexmenuss').show();
  70. resizewh();
  71. });
  72. $('#indexmenuss').click(function(){
  73. $('#indexmenu').show();
  74. $('#indexmenuss').hide();
  75. resizewh();
  76. });
  77. _addbodykey();
  78. $('#indesearchmenu').click(function(){
  79. _searchmenus();
  80. });
  81. function _loadjsurl(){
  82. js.importjs('web/res/mode/echarts/echarts.common.min.js');
  83. }
  84. setTimeout(_loadjsurl,100);
  85. //禁止后退
  86. $(document.body).keydown(function(e){
  87. var lxs = e.target.nodeName.toLowerCase();
  88. var bo = (lxs=='input' || lxs=='textarea');
  89. if(e.keyCode==8 && !bo)return false;
  90. });
  91. try{
  92. history.pushState(null, null, document.URL);
  93. window.addEventListener('popstate', function (){
  94. history.pushState(null, null, document.URL);
  95. });
  96. }catch(e){}
  97. }
  98. function changetheme(){
  99. var zys = ['#1389D3','#99cc66','#003366','#6666CC','#CC3333','#009966','#333333','#990066','#333300','#333366','#99CC99','#663366','#003399','#338899'];
  100. var h = '<div style="padding:10px"><table height="20px" class="cursor"><tr>';
  101. var nst = '';
  102. for(var i=0;i<zys.length;i++){
  103. nst = (zys[i]==maincolor) ? '✔':'&nbsp;';
  104. h+='<td width="20px" style="color:white;font-size:12px" align="center" onclick="js.location(\'?apptheme='+zys[i].substr(1)+'\')" bgcolor="'+zys[i]+'">'+nst+'</td>';
  105. }
  106. h+='</tr></table></div>';
  107. js.tanbody('color','切换主题',310,200,{
  108. html:h
  109. });
  110. }
  111. function _searchmenus(){
  112. js.prompt('搜索菜单','请输入搜索菜单名:',function(jg,txt){
  113. if(jg=='yes' && txt){
  114. $('#menulisttop').html('搜索结果');
  115. $('#menulist').html('<div style="padding:30px;" align="center">'+js.ling(30)+'</div>');
  116. js.ajax(js.getajaxurl('getmenusou','index'),{key:txt}, function(da){
  117. showmenula(da);
  118. },'post,json');
  119. }
  120. });
  121. }
  122. var loadmenuci=0;
  123. function loadmenu(o){
  124. var o1 = $(o),id,s1,ico;
  125. o1.addClass('active');id = o1.attr('pmenuid');ico = o1.attr('icon');
  126. if(!id)return;
  127. loadmenuci++;
  128. s1 = o.title;
  129. if(ico)s1='<i class="icon-'+ico+'"></i> '+s1+'';
  130. $('#menulisttop').html(s1);
  131. showmenupid = id;
  132. $('#menulist').html('<div style="padding:30px;" align="center">'+js.ling(30)+'</div>');
  133. js.ajax(js.getajaxurl('getmenu','index'),{pid:id,loadci:loadmenuci}, function(da){
  134. if(da.menutopid)menutopid=da.menutopid;
  135. showmenula(da.menuarr);
  136. },'get,json');
  137. }
  138. function showmenula(a){
  139. menuarr = a;
  140. var i,s='',j,k,child,hhild,css1,to,sid,o;
  141. hongbadge={};
  142. for(i=0; i<a.length; i++){
  143. o = a[i];
  144. css1='cursor:pointer;TEXT-DECORATION:none;padding:15px 10px';
  145. s+='<div class="hover" onClick="clickmenu(this,'+i+',-1,-1)" style="'+css1+'"><i class="icon-'+o.icons+'"></i> '+o.name+'';
  146. if(o.bh && o.stotal==0)s+=' <span class="badge" badge="'+o.bh+'" style="float:none;display:none;background:red;color:white"></span>';
  147. if(o.stotal>0)s+='<font color="red" id="hongdian_'+o.num+'" style="display:none">●</font><span style="float:right" id="menu_down_isons_'+o.num+'" class="icon-caret-down"></span>';
  148. s+='</div>';
  149. if(o.stotal>0){
  150. child = o.children;
  151. s+='<div downmenu="'+i+'_0" style="display:none;background:rgba(var(--rgb-r),var(--rgb-g),var(--rgb-b),0.05)">'
  152. for(j=0; j<child.length; j++){
  153. o = child[j];
  154. s+='<div class="hover" style="'+css1+';padding-left:30px;" id="menu_list_'+o.num+'" onClick="clickmenu(this,'+i+','+j+',-1)"><i class="icon-'+o.icons+'"></i> '+o.name+'';
  155. if(o.bh){
  156. hongbadge[o.bh]=a[i].num;
  157. s+=' <span class="badge" badge="'+o.bh+'" style="float:none;display:none;background:red;color:white"></span>';
  158. }
  159. if(o.stotal>0)s+='<span style="float:right" id="menu_down_isons_'+o.num+'" class="icon-caret-down"></span>';
  160. s+='</div>';
  161. if(o.stotal>0){
  162. hhild = o.children;
  163. s+='<div downmenu="'+i+'_'+j+'_0" style="display:none;background:rgba(var(--rgb-r),var(--rgb-g),var(--rgb-b),0.02)">'
  164. for(k=0; k<hhild.length; k++){
  165. o = hhild[k];
  166. s+='<div class="hover" style="'+css1+';padding-left:60px;" id="menu_list_'+o.num+'" onClick="clickmenu(this,'+i+','+j+','+k+')"><i class="icon-'+o.icons+'"></i> '+o.name+'</div>';
  167. }
  168. s+='</div>';
  169. }
  170. }
  171. s+='</div>';
  172. }
  173. }
  174. if(s=='')s='<div style="padding:30px;color:#cccccc" align="center">暂无</div>';
  175. $('#menulist').html(s);
  176. showmenubadge();
  177. }
  178. //显示角标处理
  179. function showmenubadge(){
  180. var o,sid,to,tnu,tid,o1;
  181. $('li[pmenuid] font').remove();
  182. for(sid in menubadge){
  183. to = menubadge[sid];
  184. o = $('span[badge="'+sid+'"]');
  185. tnu= hongbadge[sid];
  186. if(o){if(to<=0){
  187. o.hide();
  188. if(tnu)$('#hongdian_'+tnu+'').hide();
  189. }else{
  190. o.show();o.html(to);
  191. if(tnu)$('#hongdian_'+tnu+'').show();
  192. tid= menutopid[sid];
  193. if(tid){
  194. o1 = $('li[pmenuid="'+tid+'"]');
  195. o1.find('font').remove();
  196. o1.find('a').append('<font color="red">●</font>');
  197. }
  198. }}
  199. }
  200. }
  201. function removetadge(num){
  202. if(typeof(menubadge[num])=='undefined')return;
  203. $('span[badge="'+num+'"]').hide();
  204. menubadge[num]=0;
  205. showmenubadge();
  206. }
  207. function opentixiang(){
  208. addtabs({num:'todo',url:'system,geren,todo',icons:'bell',name:'提醒信息'});
  209. return false;
  210. }
  211. function clickhome(){
  212. var ad = {num:'home',url:'home,index',icons:'home',name:'首页',hideclose:true};
  213. if(homeurl!='')ad.url= homeurl;
  214. if(homename!='')ad.name= homename;
  215. addtabs(ad);
  216. return false;
  217. }
  218. var fistwk=0;
  219. function resizewh(){
  220. var _lw = 0;
  221. if(get('indexmenu')){
  222. _lw = $('#indexmenu').width()+5;
  223. if(get('indexmenu').style.display=='none'){
  224. _lw = $('#indexmenuss').width()+5;
  225. }
  226. }
  227. var w = winWb()-_lw;
  228. var h = winHb(),_ht=0;
  229. if(get('topheaderid'))_ht=get('topheaderid').offsetHeight;
  230. viewwidth = w;
  231. viewheight = h-_ht-50;
  232. $('#indexcontent').css({width:''+viewwidth+'px',height:''+(viewheight)+'px'});
  233. $('#tabsindexm').css({width:''+viewwidth+'px'});
  234. var nh = h-_ht;
  235. $('#indexmenu').css({height:''+nh+'px'});
  236. $('#indexsplit').css({height:''+nh+'px'});
  237. $('#indexmenuss').css({height:''+nh+'px'});
  238. $('#menulist').css({height:''+(viewheight)+'px'});
  239. _pdleftirng();
  240. if(fistwk==0){
  241. $('#topmenudiv span[pmenuid]').each(function(){
  242. fistwk+=$(this).width()+30;
  243. });
  244. }
  245. var lw=$('#logodiv').width();
  246. var rw = $('#topheaderright').width();
  247. var kj = winWb()-lw-rw;
  248. $('#topmenudiv').css('width',''+kj+'px');
  249. var o1 = $('#donwrigthw').css('right',''+rw+'px');
  250. o1.hide();
  251. if(fistwk>kj){
  252. o1.show();
  253. $('#topmenudiv').css('width',''+(kj-20)+'px');
  254. }
  255. }
  256. function clickmenu(o, i, j,k){
  257. var a = menuarr[i];
  258. if(j>-1)a=a.children[j];
  259. if(k>-1)a=a.children[k];
  260. var oi = a.stotal,dxu=''+i+'_';
  261. if(oi>0){
  262. $('#hongdian_'+a.num+'').hide();//隐藏红点
  263. if(j>-1){
  264. dxu+=''+j+'_';
  265. $('div[downmenu^="'+dxu+'"]').toggle();
  266. }
  267. var o1 = get('menu_down_isons_'+a.num+'');
  268. if(o1.className.indexOf('down')>0){
  269. o1.className='icon-caret-up';
  270. if(j==-1)$('div[downmenu^="'+dxu+'"]').show();
  271. }else{
  272. o1.className='icon-caret-down';
  273. if(j==-1)$('div[downmenu^="'+dxu+'"]').hide();
  274. }
  275. }else{
  276. addtabs(a);
  277. }
  278. }
  279. var coloebool = false;
  280. function closetabs(num){
  281. tabsarr[num] = false;
  282. $('#content_'+num+'').remove();
  283. $('#tabs_'+num+'').remove();
  284. if(num == nowtabs.num){
  285. var now ='home',i,noux;
  286. for(i=opentabs.length-1;i>=0;i--){
  287. noux= opentabs[i];
  288. if(get('content_'+noux+'')){
  289. now = noux;
  290. break;
  291. }
  292. }
  293. changetabs(now);
  294. }
  295. coloebool = true;
  296. _pdleftirng();
  297. setTimeout('coloebool=false',10);
  298. }
  299. function closenowtabs(){
  300. var nu=nowtabs.num;
  301. if(nu=='home')return;
  302. closetabs(nu);
  303. }
  304. function nowtabssettext(srt,icos){
  305. var num=nowtabs.num;
  306. var txt = srt;
  307. tabsarr[num].name = srt;
  308. nowtabs.name = srt;
  309. if(!icos)icos=nowtabs.icons;
  310. if(icos)txt='<i class="icon-'+icos+'"></i> '+txt+'';
  311. $('#tabs_'+num+' font').html(txt);
  312. }
  313. function changetabs(num,lx){
  314. if(coloebool)return;
  315. if(!lx)lx=0;
  316. $("div[temp='content']").hide();
  317. $("[temp='tabs']").removeClass();
  318. var bo = false;
  319. if(get('content_'+num+'')){
  320. $('#content_'+num+'').show();
  321. $('#tabs_'+num+'').addClass('active');
  322. nowtabs = tabsarr[num];
  323. if(typeof(nowtabs.onshow)=='function')nowtabs.onshow();
  324. bo = true;
  325. }
  326. opentabs.push(num);
  327. if(lx==0)_changhhhsv(num);
  328. return bo;
  329. }
  330. function _changhhhsv(num){
  331. var o=$("[temp='tabs']"),i,w1=0;
  332. for(i=0;i<o.length;i++){
  333. if(o[i].id=='tabs_'+num+'')break;
  334. w1=w1+o[i].scrollWidth;
  335. }
  336. $('#tabsindexm').animate({scrollLeft:w1});
  337. }
  338. function _changesrcool(lx){
  339. var l = $('#tabsindexm').scrollLeft();
  340. var w = l+200*lx;
  341. $('#tabsindexm').animate({scrollLeft:w});
  342. }
  343. function _pdleftirng(){
  344. var mw=get('tabs_title').scrollWidth;
  345. if(mw>viewwidth){$('.jtcls').show();}else{$('.jtcls').hide();}
  346. }
  347. function addiframe(a){
  348. a.url = 'index,iframe,url='+jm.base64encode(a.url)+'';
  349. addtabs(a);
  350. }
  351. //选择卡右键
  352. function tabsright(num,e){
  353. function _closeother(nu){
  354. var nus,d1;
  355. for(nus in tabsarr){
  356. d1 = tabsarr[nus];
  357. if(d1 && !d1.hideclose && nus!=nu)closetabs(nus);
  358. }
  359. }
  360. if(typeof(tabsrights)=='undefined')tabsrights=$.rockmenu({
  361. width:150,
  362. data:[],
  363. itemsclick:function(d){
  364. var lx = d.lx,num=d.num;
  365. if(lx==0)closetabs(num);
  366. if(lx==1){
  367. var d1 = tabsarr[num],s1=''+PROJECT+'/'+d1.urlpath+'';
  368. var s = '['+d1.name+']页面地址是:'+s1+'<div style="word-wrap:break-word;">,在[系统→基础管理→菜单管理]设置URL地址为:'+d1.url+'';
  369. if(HOST=='127.0.0.1' || HOST=='localhost')s+='&nbsp;<a onclick="_openfile(\''+jm.base64encode(s1)+'\')" href="javascript:;">[打开]</a>';
  370. s+='</div>';
  371. js.alert(s);
  372. }
  373. if(lx==2)_closeother(num);
  374. if(lx==3)location.reload();
  375. if(lx==4)_opentabls(d.tobj);
  376. }
  377. });
  378. var to= tabsarr[num],d = [];
  379. if(!to.hideclose)d.push({'name':'关闭','num':num,lx:0});
  380. if(num==nowtabs.num)d.push({'name':'关闭其它页面','num':num,lx:2});
  381. if(admintype==1)d.push({'name':'查看页面地址','num':num,lx:1});
  382. if(homeurl=='' && to.id)d.push({'name':'新窗口打开',tobj:to,'num':num,lx:4});
  383. d.push({'name':'全部刷新','num':num,lx:3});
  384. tabsrights.setData(d);
  385. tabsrights.showAt(e.clientX,e.clientY+5);
  386. }
  387. function _opentabls(d){
  388. var url = '?homeurl='+jm.base64encode(d.url)+'&homename='+jm.base64encode(d.name)+'&menuid='+jm.base64encode(d.id)+'';
  389. window.open(url);
  390. }
  391. //开发时打开文件
  392. function _openfile(s){
  393. js.ajax(js.getajaxurl('openfile','index'),{file:s},function(ds){
  394. if(ds!='ok')js.msg('msg', ds);
  395. },'get');
  396. }
  397. /**
  398. * 添加选择卡
  399. */
  400. function addtabs(a){
  401. var url = a.url,
  402. num = a.num;
  403. if(isempt(url))return false;
  404. removetadge(num);
  405. if(url.indexOf('add,')==0){openinput(a.name,url.substr(4));return;}
  406. if(url.indexOf('open:')==0){window.open(url.substr(5));return;}
  407. if(url.indexOf('http')==0 || url.substr(0,1)=='?'){addiframe(a);return;}
  408. if(nowtabs && nowtabs.id && !a.id)a.id=nowtabs.id;
  409. nowtabs = a;
  410. if(changetabs(num))return true;
  411. var s = '<td temp="tabs" oncontextmenu="tabsright(\''+num+'\',event);return false;"; nowrap onclick="changetabs(\''+num+'\',1)" id="tabs_'+num+'" class="active"><font>';
  412. if(a.icons)s+='<i class="icon-'+a.icons+'"></i> ';
  413. s+=a.name+'</font>';
  414. if(!a.hideclose)s+='<span onclick="closetabs(\''+num+'\')">x</span>';
  415. s+='</td>';
  416. objtabs.append(s);
  417. _changhhhsv(num);
  418. _pdleftirng();
  419. var rand = js.getrand(),i,oi=2,
  420. ura = url.split(','),
  421. dir = ura[0],
  422. mode= ura[1];
  423. url =''+dir+'/'+mode+'/rock_'+mode+'';
  424. if(ura[2]){
  425. if(ura[2].indexOf('=')<0){
  426. oi=3;
  427. url+='_'+ura[2]+'';
  428. }
  429. }
  430. var urlpms= '';
  431. for(i=oi;i<ura.length;i++){
  432. var nus = ura[i].split('=');
  433. urlpms += ",'"+nus[0]+"':'"+nus[1]+"'";
  434. }
  435. if(urlpms!='')urlpms = urlpms.substr(1);
  436. var bgs = '<div id="mainloaddiv" style="width:'+viewwidth+'px;height:'+viewheight+'px;overflow:hidden;background:#000000;color:white;filter:Alpha(opacity=20);opacity:0.2;z-index:3;position:absolute;left:0px;line-height:'+viewheight+'px;top:0px;" align="center">'+js.ling(30)+'&nbsp;加载中...</div>';
  437. $('#indexcontent').append(bgs);
  438. a.urlpath = url+'.php';
  439. objcont.append('<div temp="content" style="margin:10px;" id="content_'+num+'"></div>');
  440. $.ajax({
  441. url:'?m=index&a=getshtml&surl='+jm.base64encode(url)+'&num='+num+'&menuname='+jm.base64encode(a.name)+'&urlpms='+jm.base64encode(urlpms)+'',
  442. type:'get',
  443. success: function(da){
  444. $('#mainloaddiv').remove();
  445. var s = da;
  446. s = s.replace(/\{rand\}/gi, rand);
  447. s = s.replace(/\{adminid\}/gi, adminid);
  448. s = s.replace(/\{adminname\}/gi, adminname);
  449. s = s.replace(/\{mode\}/gi, mode);
  450. s = s.replace(/\{dir\}/gi, dir);
  451. s = s.replace(/\{params\}/gi, "var params={"+urlpms+"};");
  452. var obja = $('#content_'+num+'');
  453. if(num!='home')s='<div style="background:var(--main-bgcolor);overflow:auto;border-radius:5px"><div style="padding:10px">'+s+'</div></div>';
  454. obja.html(s);
  455. },
  456. error:function(){
  457. $('#mainloaddiv').remove();
  458. var s = 'Error:加载出错喽,'+url+'';
  459. $('#content_'+num+'').html(s);
  460. }
  461. });
  462. tabsarr[num] = a;
  463. return false;
  464. }
粤ICP备19079148号