cockpitIndex.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  1. /**********************************************************************************一。解析传递的参数***************************************************************************/
  2. /**
  3. * 解析查询条件
  4. * @returns {___anonymous229_230}
  5. */
  6. function resolveUrl(){
  7. var encondeCondition=window.location.search;
  8. var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
  9. var conditionArr=condition.split("&");
  10. var condJson={};
  11. for(var item in conditionArr){
  12. var temArr=conditionArr[item].split("=");
  13. condJson[temArr[0]]=temArr[1];
  14. }
  15. return condJson;
  16. }
  17. /**********************************************************************************二。保存布局***************************************************************************/
  18. /**********************************************************************************1。解析布局参数*************************************************************************/
  19. /**********************************************************************************2。矫正布局参数参数**********************************************************************/
  20. /**********************************************************************************3.保存布局****************************************************************************/
  21. /**********************************************************************************4.删除视图****************************************************************************/
  22. /**********************************************************************************3.设置默认视图*************************************************************************/
  23. /**********************************************************************************3.修改视图****************************************************************************/
  24. //layoutData:[{column:"50%",row:[{id:"a1",value:"50%"},{id:"content1",value:"50%"}]},
  25. // {column:"50%",row:[{id:"content2",value:"50%"},{id:"content3",value:"50%"}]}]},
  26. //获取布局后的layout参数列表
  27. function LayoutItem(){
  28. this.column=null;
  29. this.row=null;
  30. }
  31. function Layout() {
  32. this.layoutItem=[];
  33. }
  34. /**
  35. * 逆向解析布局后的数据
  36. * @params:$conDom,布局容器
  37. */
  38. function resolveLayout($conDom){
  39. var _this=arguments.callee;
  40. var layout=[];
  41. //初次加载时为列布局
  42. if($conDom.children("div ._column_content").not("._column_move").size()>0){
  43. $conDom.children("div ._column_content").not("._column_move").each(function () {
  44. var layoutItem=new LayoutItem();
  45. if($conDom.find("._column_content ").size()===1){
  46. //获取像素
  47. layoutItem.column=$(this).width();
  48. //layoutItem.column=Math.floor($(this).css("width")); //获取百分比
  49. }else if($conDom.find("._column_content ").size()>1){
  50. //获取像素
  51. layoutItem.column=$(this).width();
  52. //获取百分比
  53. //layoutItem.column=Math.floor($(this).width()*0.999/($(this).parent().width()-($conDom.find("._column_content ").size()-1)/**$(window).height()*0.003*/)*100).toFixed(2)+"%";
  54. }
  55. layoutItem.row=[];
  56. $(this).children("div ._row_content").not("._row_move").each(function(){
  57. var item=new Object();
  58. if($(this).attr("id")!=null){
  59. item.id=$(this).attr("id");
  60. }
  61. //获取像素
  62. item.value=$(this).height();
  63. //获取百分比
  64. //item.value=Math.floor($(this).height()*0.998/($(this).parent().height()-($conDom.find("._row_content ").size()-1)/*$(window).height()*0.003*/)*100).toFixed(2)+"%";
  65. //递归
  66. if($(this).children("div ._row_content").size()>0){
  67. item.layoutData=_this($(this));
  68. }
  69. if($(this).children("div ._column_content").size()>0){
  70. item.layoutData=_this($(this));
  71. }
  72. layoutItem.row.push(item);
  73. });
  74. layout.push(layoutItem);
  75. });
  76. }
  77. //初次加载时为行布局
  78. if($conDom.children("div ._row_content").not("._row_move").size()>0){
  79. $conDom.children("div ._row_content").not("._row_move").each(function () {
  80. var layoutItem=new LayoutItem();
  81. if($conDom.find("._row_content ").size()===1){
  82. //获取像素
  83. layoutItem.row=$(this).height();
  84. //获取百分比
  85. //layoutItem.row=Math.floor($(this).height()/$(this).parent().height()*100)+"%";
  86. }else if($conDom.find("._row_content ").size()>1){
  87. //获取像素
  88. layoutItem.row=$(this).height();
  89. //获取百分比
  90. //layoutItem.row=Math.floor(($(this).height()/($(this).parent().height()-($conDom.find("._column_content ").size()-1)/**$(window).height()*0.003*/)*100)).toFixed(2)+"%";
  91. }
  92. layoutItem.column=[];
  93. $(this).children("div ._column_content").not("._column_move").each(function(){
  94. var item=new Object();
  95. if($(this).attr("id")!=null){
  96. item.id=$(this).attr("id");
  97. }
  98. //获取像素
  99. item.value=$(this).width();
  100. //获取百分比
  101. //item.value=($(this).width()/($(this).parent().width()-($conDom.find("._row_content ").size()-1)/**$(window).height()*0.003*/)*100).toFixed(2)+"%";
  102. //递归
  103. if($(this).children("div ._row_content").size()>0){
  104. item.layoutData=_this($(this));
  105. }
  106. if($(this).children("div ._column_content").size()>0){
  107. item.layoutData=_this($(this));
  108. }
  109. layoutItem.column.push(item);
  110. });
  111. layout.push(layoutItem);
  112. });
  113. }
  114. return layout;
  115. }
  116. //数据等比率矫正方法
  117. //[{"column":"25.00%","row":[{"id":"content1","value":"33.00%"},{"id":"content2","value":"33.00%"},{"id":"content2","value":"33.00%"}]},
  118. // {"column":"75.00%","row":[{"id":"a1","value":"67.00%"},{"id":"a2","value":"33.00%","
  119. //layoutData":[{"row":"100%","column":[{"id":"content4","value":"33.30%"},{"id":"content5","value":"33.20%"},{"id":"content6","value":"33.30%"}],"row":"100%"}]}]}]}
  120. /**
  121. * 逆向解析后的布局数据存在四舍五入的误差,误差会影响再次布局的结构
  122. * 该方法通过对误差的矫正,保证布局结构的完整。
  123. * @param dataParams:逆向解析布局后的数据
  124. */
  125. function proportionalCorrectionData(dataParams){
  126. var _this=arguments.callee;
  127. //列布局
  128. if(dataParams[0].row instanceof Array){
  129. var colSum=0;
  130. //矫正column值
  131. $.each(dataParams,function(index,item){
  132. colSum+=parseFloat(item.column);
  133. });
  134. $.each(dataParams,function (colIndex,item) {
  135. dataParams[colIndex].column=parseFloat(item.column)/colSum*100+"%";
  136. var colRowSum=0;
  137. //矫正row值
  138. $.each(dataParams[colIndex].row,function(rowIndex,rowItem){
  139. colRowSum+=parseFloat(rowItem.value);
  140. });
  141. $.each(dataParams[colIndex].row,function(rowIndex,rowItem){
  142. dataParams[colIndex].row[rowIndex].value=parseFloat(rowItem.value)/colRowSum*100+"%";
  143. if( dataParams[colIndex].row[rowIndex].hasOwnProperty("layoutData")){
  144. _this(dataParams[colIndex].row[rowIndex].layoutData);
  145. }
  146. });
  147. });
  148. }
  149. //行布局
  150. if(dataParams[0].column instanceof Array){
  151. //矫正row值
  152. var rowSum=0;
  153. $.each(dataParams,function(index,item){
  154. rowSum+=parseFloat(item.row);
  155. });
  156. $.each(dataParams,function (rowIndex,item) {
  157. dataParams[rowIndex].row=parseFloat(item.row)/rowSum*100+"%";
  158. var rowColSum=0;
  159. //矫正column值
  160. $.each(dataParams[rowIndex].column,function(colIndex,colItem){
  161. rowColSum+=parseFloat(colItem.value);
  162. });
  163. $.each(dataParams[rowIndex].column,function(rowColIndex,rowColItem){
  164. dataParams[rowIndex].column[rowColIndex].value=parseFloat(rowColItem.value)/rowColSum*100+"%";
  165. if( dataParams[rowIndex].column.hasOwnProperty("layoutData")){
  166. _this(dataParams[rowIndex].column.layoutData);
  167. }
  168. });
  169. });
  170. }
  171. //console.log("+++++++++++++++++++"+JSON.stringify(dataParams));
  172. return dataParams;
  173. }
  174. /**
  175. * 保存视图方法
  176. * @param param:保存视图名称
  177. * 将容器的id作为指定的容器编号
  178. */
  179. function saveLayout(param) {
  180. //视图布局参数
  181. var layoutParam=JSON.stringify(proportionalCorrectionData(resolveLayout($("#main_content"))));
  182. //视图制定的模块的链接地址
  183. var saveMatic=eachCon($("#main_content"));
  184. var saveView={name:param,userId:conditionJson["user_id"],roleId:conditionJson["role_id"],param:layoutParam,conId:saveMatic["OL_CONID"],maticId:saveMatic["OL_MATICID"]};
  185. $.post(http_path+"ws/SysLayoutService/SysLayoutService/saveView",saveView,function(result){
  186. if(result["state"]=="SUCCESS"){
  187. loadAside($("#view_list_content"));
  188. $("._add").removeClass("_devide");
  189. var alt=new Alert({ok:fn1,cancle:fn2},
  190. {text:"保存成功!!",
  191. input:"true",
  192. });
  193. //创建节点
  194. alt.create("");
  195. alt=null;
  196. }else{
  197. var alt=new Alert({ok:fn1,cancle:fn2},
  198. {text:"保存失败!",
  199. input:"true",
  200. });
  201. //创建节点
  202. alt.create("");
  203. alt=null;
  204. }
  205. },"json");
  206. }
  207. //获取视图中的链接地址的Id
  208. function eachCon($dom){
  209. var OL_CONID=[];
  210. var OL_MATICID=[];
  211. $dom.find("div[id^='content']").each(function () {
  212. OL_CONID.push($(this).attr("id"));
  213. OL_MATICID.push($(this).data("data"));
  214. });
  215. return {OL_CONID:OL_CONID.join("-"),OL_MATICID:OL_MATICID.join("-")};
  216. }
  217. //删除视图
  218. function deleteView(params){
  219. var alt=new Alert({ok:fn1,cancle:fn2},
  220. {text:"是否需要删除该专题?"
  221. });
  222. //创建节点
  223. alt.create("");
  224. alt=null;
  225. /**
  226. * 确定删除
  227. */
  228. function fn1(){
  229. $.post(http_path+"ws/SysLayoutService/SysLayoutService/deleteSysLayout",{FD_OBJECTID:params},function(result){
  230. if(result["state"]=="success"){
  231. loadAside($("#view_list_content"));
  232. }else{
  233. }
  234. },"json");
  235. }
  236. function fn2(){
  237. return;
  238. }
  239. }
  240. //设置默认的视图
  241. function setDefault(user_Id,objectId){
  242. var alt=new Alert({ok:fn1,cancle:fn2},
  243. {text:"是否设置为默认视图"});
  244. //创建节点
  245. alt.create("");
  246. alt=null;
  247. function fn1(){
  248. $.post(http_path+"ws/SysLayoutService/SysLayoutService/setDefaultLayout",{fd_objectId:objectId,userId:user_Id,roleId:conditionJson["role_id"]},function(result){
  249. if(result["state"]=="SUCCESS"){
  250. loadAside($("#view_list_content"));
  251. }
  252. },"json");
  253. return;
  254. }
  255. function fn2(){
  256. return ;
  257. }
  258. }
  259. //修改默认视图
  260. function editView(name,objectId,callFunction){
  261. var maticParams=eachCon($("#main_content"));
  262. var alt=new Alert({ok:fn1,cancle:fn2},
  263. {text:"是否修改视图!"});
  264. //创建节点
  265. alt.create("");
  266. alt=null;
  267. function fn1(){
  268. $.post(http_path+"ws/SysLayoutService/SysLayoutService/updateName",{objectId:objectId,name:name,conId:maticParams["OL_CONID"],maticId:maticParams["OL_MATICID"]},function(result){
  269. if(result["state"]=="SUCCESS"){
  270. loadAside($("#view_list_content"));
  271. }
  272. },"json");
  273. }
  274. function fn2(){
  275. callFunction();
  276. return;
  277. }
  278. }
  279. /******************************************************************************三。初始化加载页面***************************************************************************/
  280. /******************************************************************************1。初始化页面************************************************************************/
  281. /******************************************************************************1。为容器加载iframe************************************************************************/
  282. /******************************************************************************1。为容器加载iframe************************************************************************/
  283. /******************************************************************************1。为容器加载iframe************************************************************************/
  284. /******************************************************************************1。为容器加载iframe************************************************************************/
  285. /******************************************************************************1。为容器加载iframe************************************************************************/
  286. /**
  287. * 初始化加载页面
  288. */
  289. function loadPage($conDom){
  290. /*$($conDom).find("*").each(function(){
  291. $(this).get(0).
  292. })*/
  293. $conDom.find("div[id^='content']").each(function(e) {
  294. var conDom=this;
  295. $(this).append("<iframe class='_iframe' scrolling='no' src='"+path+"page/cockpit/background.html' name='test' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe>");
  296. create_bar($(conDom));//创建浮动工具条
  297. });
  298. }
  299. function iframeTYLoadPage(){
  300. loadPage($("#main_content"));
  301. }
  302. //初始化iframe中的数据
  303. /**
  304. * 初始化加载引用页面的地址
  305. * @params:url:后台查询引用地址的路径
  306. * @params:params查询条件
  307. * 通过查询条件的控制,更改后台返回的结果
  308. */
  309. function changeLayout(url,params){
  310. //初始化动态iframe设置路径
  311. $.post(url,params,function(result){
  312. $("#main_content").find("div[id^='content']").find("iframe").each(function (i) {
  313. for(var index in result.rows){
  314. if(result.rows[index]["OL_CONID"]==$(this).parent().attr("id")){
  315. if(result.rows[i]["OL_MATICURL"].indexOf("http://")==0){
  316. $(this).attr("src",result.rows[i]["OL_MATICURL"]);
  317. }else{
  318. $(this).attr("src",http_path+result.rows[i]["OL_MATICURL"]+window.location.search+"&&conId="+$(this).parent().attr("id"));
  319. }
  320. $(this).parents("div[id^='content']").data("charMenuInfo",result.rows[i]);
  321. $(this).parents("div[id^='content']").data("data",result.rows[i]["OL_MATICID"]);
  322. }
  323. }
  324. });
  325. },"json");
  326. };
  327. /*******************************************************************************************************************************************************************/
  328. /* //创建组选择项list
  329. function accordionMenu($dom,data){
  330. var $divCon=$("<div class='_ul_count_content'></div>");
  331. if(data.length==0)throw Error("accordionMenu($dom,data)中data的长度为0或者空");
  332. if($dom==null||$dom==undefined)throw new Error("accordionMenu($dom,data)中容器节点不能为空");
  333. for(var item in data){
  334. if(data[item].rows.length==0) continue;
  335. $div=$("<div class='_ul_content'></div>");
  336. menuItem($div,data[item]);
  337. $divCon.append($div);
  338. };
  339. $dom.append($divCon);
  340. $dom.append("<div class='_jsc_close'></div>");
  341. $dom.find("._jsc_close").on("click",function(){
  342. top.destoryMenu();
  343. }).on("mouseenter",function(){
  344. $(this).addClass("_jsc_close_changeImg");
  345. }).on("mouseleave",function(){
  346. $(this).removeClass("_jsc_close_changeImg");
  347. })
  348. }*/
  349. //创建单个选择list
  350. /* function menuItem($dom,data){
  351. $ul=$("<ul></ul>");
  352. $h2=$("<div class='_ul_head'><div class='_view_list_line'></div><div class='_view_list'><h2>"+data.name+"</h2></div></div>");
  353. //点击隐藏选择项
  354. $ul.append($h2);
  355. $dom.append($ul);
  356. for(var item1 in data.rows){
  357. $dom.find("ul").last().append("<li class='_ul_li'><div class='_matic_title'><p >"+data.rows[item1]["TM_NAME"]+"</p></div><div class='_matic_img' title='"+data.rows[item1]["TM_NAME"]+"'><img src='"+(path+data.rows[item1]["TM_IMGURL"])+"'/></div></li>");
  358. $dom.find("ul").last().find("li").last().data("data",data.rows[item1]);
  359. inAndLeaveAndClick($dom.find("ul").last().find("li").last(),function($dom){
  360. top.changeSite(conditionJson["iframeId"],$dom.data("data"));
  361. top.destoryMenu();
  362. },moveIn,moveOut);
  363. }
  364. $dom.find("._view_list").click(function(){
  365. $(this).parents("._ul_content").toggleClass("_ul_content_hide");
  366. });
  367. }*/
  368. //点击事件增加样式
  369. function click($dom){
  370. if($("._ul_count_content").find("._click_li").size()>0){
  371. $("._ul_count_content").find("._click_li").removeClass("_click_li");
  372. }
  373. $dom.addClass("_click_li");
  374. }
  375. //移入增加样式
  376. function moveIn($dom){
  377. var _this=$dom;
  378. _this.addClass("_movein_li");
  379. }
  380. //移出增加样式
  381. function moveOut($dom){
  382. var _this=$dom;
  383. _this.removeClass("_movein_li");
  384. }
  385. //绑定点击,移入,移出事件
  386. function inAndLeaveAndClick($dom,fn_click,fn_enter,fn_leave){
  387. $dom.on("click",function(){
  388. fn_click($(this));
  389. return false;
  390. });
  391. $dom.on("mouseenter",function(){
  392. fn_enter($(this));
  393. return false;
  394. });
  395. $dom.on("mouseleave",function(){
  396. fn_leave($(this));
  397. return false;
  398. });
  399. }
  400. /**
  401. * 设置浮动容器的高度
  402. * @param $dom
  403. * @param top
  404. * @param left
  405. */
  406. function setPosition($dom,top,left){
  407. if((parseInt($dom.width())+parseInt(left))<$(window).width()){
  408. $dom.css({left:left+"px"});
  409. }else{
  410. $dom.css({left:parseInt($(window).width())-parseInt($dom.width())-5+"px"});
  411. }
  412. if((parseInt($dom.height())+parseInt(top))<$(window).height()){
  413. $dom.css({top:top+"px"});
  414. }else{
  415. $dom.css({top:parseInt($(window).height())-parseInt($dom.height())+"px"});
  416. }
  417. }
  418. /**
  419. * 更改引用页面的引用地址,并保存到数据库
  420. * @params:conDom引用页面的容器,绑定有初始加载数据,通过绑定的数据进行更改
  421. */
  422. function changeSite(conId,data){
  423. if(data["TM_URL"].indexOf("http://")==0){
  424. $("#"+conId).find("iframe").attr("src",data["TM_URL"]+window.location.search);
  425. }else{
  426. $("#"+conId).find("iframe").attr("src",http_path+data["TM_URL"]+window.location.search+"&&conId=conId");
  427. }
  428. $("#"+conId).data("data",data["FD_OBJECTID"]);
  429. return false;
  430. }
  431. //展开引用页面的查询状态
  432. //***************************************全屏*************************************************************
  433. /**
  434. * 鼠标点击放大图表事件
  435. * 无二次加载放大
  436. */
  437. function allScreen($dom){
  438. if( $("body").find("div[class='_zoom']").size()==0){
  439. $conDiv=$("<div class='_zoom'></div>");
  440. $dom.children().each(function(){
  441. $(this).appendTo($conDiv);
  442. });
  443. $conDiv.data("swapData",$dom);
  444. $("body").prepend($conDiv);
  445. $conDiv.find("._toolBarContent").width($conDiv.width());
  446. }else{
  447. $("body").find("div[class='_zoom']").each(function(){
  448. var _dom=$(this).data("swapData");
  449. $(this).children().each(function(){
  450. $(this).appendTo(_dom);
  451. });
  452. $(this).remove();
  453. });
  454. }
  455. }
  456. //展开布局菜单
  457. /**
  458. * 展开布局控制菜单
  459. * createSetMenu(dataParam):布局选择菜单
  460. */
  461. /**
  462. * @param
  463. */
  464. function openLayout(dataParam){
  465. if($("#layout_list_iframe").size()>0){
  466. $("#layout_list_iframe").remove();
  467. }
  468. var htmlStr="<div id='layout_list_iframe' class='_layout_list_iframe'><iframe class='_list_iframe' stytle='position:absolute;' scrolling='no' " +
  469. "src=/nwyj/page/cockpit/cockpit_layout/matic_layout.html name='n_layou_list' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe></div>";
  470. $("body").append(htmlStr);
  471. htmlStr=null;
  472. /*
  473. $("#menu_content").createSetMenu(dataParam);
  474. $("#menu_content").show();
  475. $("#menu_content").css({display:"inline-block"});
  476. $("#content").css({height:(parseInt($(window).height())-parseInt($("#menu_content").height()))/parseInt($(window).height())*100+"%"});*/
  477. }
  478. /**
  479. * 创建浮动工具条:1.展开浮动菜单:(e.data.options,this)
  480. * 2。锁定图层;
  481. * 3,控制查询条件的隐现,changeState(e.data.conDomParam);
  482. * 4,全屏放大
  483. */
  484. function create_bar(conDom){
  485. //工具条隐藏事件绑定
  486. conDom.on("mouseenter",function(){
  487. //获取子页面配置的工具栏参数
  488. var childToolBar=conDom.find("iframe").get(0).contentWindow.customMadeTool;
  489. var _toolBar=getToolBar(toolBar,childToolBar);
  490. if(conDom.find("._toolBarContent").size()>0){
  491. conDom.find("._toolBarContent").each(function(){
  492. $(this).remove();
  493. });
  494. }
  495. conDom.prepend("<div class='_toolBarContent'><div class='_toolBar'></div></div>");
  496. for(var index in _toolBar){
  497. //添加toolbar按钮
  498. conDom.find("._toolBar").append("<div class='"+_toolBar[index]["classIcon"]+" _opacity_90'>&nbsp;<div>");
  499. //为按钮绑定动作
  500. conDom.find("._toolBar").find("."+_toolBar[index]["classIcon"]).on("click",{index:index,win:conDom.find("iframe").get(0).contentWindow},function(e){
  501. _toolBar[e.data.index]["fn"](e.data.win,conDom);
  502. }).on("mouseenter",function(){
  503. $(this).addClass("_opacity_100");
  504. }).on("mouseleave",function(){
  505. $(this).removeClass("_opacity_100");
  506. });
  507. }
  508. //设置toolbar容器的宽度
  509. conDom.find("._toolBarContent").width(conDom.width());
  510. }).on("mouseleave",function(){
  511. if(conDom.find("._toolBarContent").size()>0){
  512. conDom.find("._toolBarContent").each(function(){
  513. $(this).remove();
  514. });
  515. }
  516. });
  517. /* //按钮3绑定事件:展开浮动菜单
  518. conDom.find("._content_set_menu").eq(2)
  519. .on("click",function(e){
  520. $("#float_menu_content").createMenu($(this).parent().parent().parent(),e);})
  521. .on("mouseleave",function(){
  522. //鼠标移除,启动自动关闭浮动菜单
  523. setTimeout(function(){
  524. if($("#float_menu_content").data("data")=="0"||$("#float_menu_content").data("data")==undefined){
  525. $("#float_menu_content").css("display","none");
  526. }
  527. },5000);
  528. });
  529. //按钮2绑定事件:放大容器
  530. conDom.find("._content_set_menu").eq(1).on("click",function(e){allScreen(conDom,123);});
  531. //按钮3绑定事件:查询状态
  532. */
  533. }
  534. /*
  535. * 展开查询条件面板
  536. */
  537. function fn_search(win,$dom){
  538. //如果存在展开/关闭方法则触发该动作
  539. if( win.switchSearchPlane!=undefined){
  540. win.switchSearchPlane();
  541. }
  542. }
  543. /*
  544. * 页面携带数据刷新
  545. */
  546. function fn_render(win,$dom){
  547. //如果存在刷新方法则触发刷新方法的动作
  548. if(win.rend!=undefined){
  549. win.rend();
  550. }
  551. }
  552. /**
  553. * 展开专题选择菜单
  554. * @param win
  555. * @param $dom
  556. */
  557. function fn_list(win,$dom){
  558. $("#float_menu_content").createMenu($dom);
  559. }
  560. /**
  561. * 销毁菜单
  562. */
  563. function destoryMenu(){
  564. $("#float_menu_content").empty();
  565. $("#float_menu_content").css({display:"none"});
  566. };
  567. /**
  568. * 关闭父页面子页面的id
  569. * @param id iframe页面容器的id
  570. */
  571. function destoryIframeContent(id){
  572. $(id).empty();
  573. $(id).css({display:"none"});
  574. }
  575. function fn_resource(win,$dom){
  576. $("._tool_peo").toggleClass("_tool_sys");
  577. }
  578. function fn_enlarge(win,$dom){
  579. if($dom.attr("class").indexOf("_zoom_div")==-1?false:true){
  580. $dom.removeClass("_zoom_div");
  581. $dom.css(zoomDiv);
  582. if($("._toolBarContent")!=undefined){
  583. $("._toolBarContent").find("._tool_enlarge").addClass("_tool_narrow");
  584. }
  585. }else{
  586. zoomDiv={width: parseInt($dom.css("width"))/$dom.parent().width()*100+"%",height:parseInt($dom.css("height"))/$dom.parent().height()*100+"%"};
  587. $dom.css({width:$(window).width(),height:$(window).height()});
  588. $dom.addClass("_zoom_div");
  589. if($("._toolBarContent")!=undefined){
  590. $("._toolBarContent").find("._tool_enlarge").removeClass("_tool_narrow");
  591. }
  592. }
  593. $dom.find("._toolBarContent").width($dom.width());
  594. }
  595. //横向移动放大
  596. //代码待删除
  597. function moveDomY(e1){
  598. var flag = true;
  599. if(e1==null)e1 = e1||window.event;
  600. var $conDom=$(this);
  601. var proxyConDom=$conDom.clone();
  602. proxyConDom.addClass("_proxy").width(5).css({top:$conDom.offset().top,left:$conDom.offset().left,width:$conDom.width(),height:$conDom.height(),id:'proxy'});
  603. proxyConDom.appendTo($("body"));
  604. $(document).mousemove(function (e) {
  605. if(e==null)e = e||window.event;
  606. if (flag) { proxyConDom.css({left:e.clientX+"px"});}
  607. });
  608. $("iframe").each(function () {
  609. var _iframe=$(this);
  610. $($(this).get(0).contentWindow.document).mousemove(function (e) {
  611. if(e==null)e = e||window.event;
  612. if (flag) {proxyConDom.css({left:e.clientX+_iframe.offset().left+"px"});}
  613. });
  614. });
  615. $("iframe").each(function () {
  616. $($(this).get(0).contentWindow.document).on("mouseup",function(){
  617. dragResizeY($conDom,proxyConDom.offset().left-$conDom.offset().left);
  618. $("body").remove(proxyConDom);
  619. flag = false;return false;});
  620. });
  621. $(document).on("mouseup",function(){
  622. dragResizeY($conDom,proxyConDom.offset().left-$conDom.offset().left);
  623. proxyConDom.remove();
  624. flag = false;return false;});
  625. return false;
  626. }
  627. /**
  628. * 宗向移动放大
  629. * @param e
  630. */
  631. function moveDomX(e){
  632. var flag = true;
  633. if(e==null)e = e||window.event;
  634. var $conDom=$(this);
  635. var proxyConDom=$conDom.clone();
  636. proxyConDom.addClass("_proxy").width(5).css({top:$conDom.offset().top,left:$conDom.offset().left,width:$conDom.width(),height:$conDom.height(),id:'proxy'});
  637. proxyConDom.appendTo($("body"));
  638. $(document).mousemove(function (e) {
  639. if(e==null)e = e||window.event;
  640. if (flag) { proxyConDom.css({top:e.clientY+"px"});}
  641. });
  642. $("iframe").each(function () {
  643. var _iframe=$(this);
  644. $($(this).get(0).contentWindow.document).mousemove(function (e) {
  645. if(e==null)e = e||window.event;
  646. if (flag) {proxyConDom.css({top:e.clientY+_iframe.offset().top+"px"});}
  647. });
  648. });
  649. $("iframe").each(function () {
  650. $($(this).get(0).contentWindow.document).on("mouseup",function(){
  651. dragResizeX($conDom,proxyConDom.offset().top-$conDom.offset().top);
  652. proxyConDom.remove();
  653. flag = false;
  654. return false;
  655. });
  656. });
  657. $(document).on("mouseup",function(){
  658. dragResizeX($conDom,proxyConDom.offset().top-$conDom.offset().top);
  659. proxyConDom.remove();
  660. flag = false;return false;});
  661. return false;
  662. }
  663. //移动事件----------------------------------结束
  664. function moveDom1(e){
  665. if(e==null)e = e||window.event;
  666. $("#float_menu_content").css({left:e.clientX+5+ "px" ,top:e.clientY +5+ "px"});
  667. if(($(window).width()-$("#float_menu_content").offset().left-$("#float_menu_content").width())<0){
  668. $("#float_menu_content").css({left:($(window).width()-$("#float_menu_content").width())*0.95+"px"});
  669. }
  670. $("#float_menu_content").height(($(window).height()-$("#float_menu_content").offset().top)*0.9);
  671. // isInContent();
  672. return false;
  673. }
  674. //水平改变尺寸
  675. function dragResizeY($conDom,distance) {
  676. if(distance>0){
  677. if(distance< $conDom.next('._column_content ').width()){
  678. $conDom.next('._column_content ').css("width",(parseFloat($conDom.next('._column_content ').css("width"))-distance)/parseFloat($conDom.parent().css("width"))*100+"%");
  679. $conDom.prev('._column_content ').css("width",(parseFloat($conDom.prev('._column_content ').css("width"))+distance)/parseFloat($conDom.parent().css("width"))*100+"%");
  680. }
  681. }else{
  682. if((-distance)<$conDom.prev('._column_content').width()){
  683. $conDom.prev('._column_content ').css("width",(parseFloat($conDom.prev('._column_content ').css("width"))+distance)/parseFloat($conDom.parent().css("width"))*100+"%");
  684. $conDom.next('._column_content ').css("width",(parseFloat($conDom.next('._column_content ').css("width"))-distance)/parseFloat($conDom.parent().css("width"))*100+"%");
  685. }
  686. }
  687. }
  688. //垂直改变尺寸
  689. function dragResizeX($conDom,distance) {
  690. if((distance)>0){
  691. if(distance< $conDom.next('._row_content ').height()){
  692. $conDom.next('._row_content').css("height",(parseFloat($conDom.next('._row_content ').css("height"))-distance)/parseFloat($conDom.parent().css("height"))*100+"%");
  693. $conDom.prev('._row_content').css("height",(parseFloat($conDom.prev('._row_content ').css("height"))+distance)/parseFloat($conDom.parent().css("height"))*100+"%");
  694. }
  695. }else{
  696. if((-distance)< $conDom.prev('._row_content ').height()){
  697. $conDom.prev('._row_content').css("height",(parseFloat($conDom.prev('._row_content ').css("height"))+distance)/parseFloat($conDom.parent().css("height"))*100+"%");
  698. $conDom.next('._row_content').css("height",(parseFloat($conDom.next('._row_content ').css("height"))-distance)/parseFloat($conDom.parent().css("height"))*100+"%");
  699. }
  700. }
  701. }
  702. /**
  703. * 生成布局
  704. * @param $dom 布局作用的容器
  705. * @param params 布局的参数
  706. * @param interSpace 子容器间的间隔
  707. */
  708. function createLayout($dom,params,interSpace){
  709. params=$.parseJSON(JSON.stringify(params));
  710. if(interSpace==""&& $dom==""){
  711. console.log(JSON.stringify({params:params}));
  712. $("#main_content").createLayout(params ,$(window).width()*0.003);
  713. }else if(interSpace==""&& $dom!=""){
  714. $dom.createLayout(params,$(window).width()*0.003);
  715. }else if(interSpace!=""&& $dom!=""){
  716. $dom.createLayout(params,interSpace);
  717. }
  718. $("._column_move").each(function(){$(this).on("mousedown",moveDomY).addClass("_drag");});
  719. $("._row_move").each(function(){$(this).on("mousedown",moveDomX).addClass("_drag");});
  720. // loadPage($("#main_content"),"");
  721. }
  722. (function ($) {
  723. //创建布局功能------------------------开始
  724. /**
  725. * @param params 参数格式:[{column:"50%",row:[{id:"content1",value:"100%"}]},{column:"50%",row:[{id:"content2",value:"100%"}]}]
  726. * @param interSpace 间距
  727. */
  728. $.fn.createLayout=function(params,interSpace){
  729. console.log(JSON.stringify({params:params}));
  730. //制定dom对象
  731. var selfDom=this;
  732. //清空dom对象
  733. $(selfDom).empty();
  734. //@params:layolayoutData:[{row:70%,column:[20%,40%,40%]},{row:50%,column:[30%,50%,20%]}]}
  735. $(selfDom).removeClass("_single_content");
  736. if(!(params[0].row instanceof Array)){
  737. console.log("行布局");
  738. for(var index=0 ,len=params.length;index<len;index++){
  739. $(selfDom).append("<div class='_row_content'></div>");
  740. if(len!==1){
  741. $(selfDom).find("._row_content").last().css("height",(parseFloat(params[index].row)*(1-(len-1)*interSpace/$(selfDom).height()))+"%").css("width","100%");
  742. }else{
  743. $(selfDom).find("._row_content").last().css("height",params[index].row).css("width","100%");
  744. }
  745. /* $(selfDom).find("._row_content").last().css("height",params[index].row).css("width","100%");*/
  746. console.log(JSON.stringify({paramsArr:params}));
  747. console.log("index="+index);
  748. console.log(JSON.stringify(params[index]));
  749. $(selfDom).find("._row_content").last().createColumn(params[index].column,interSpace);
  750. if(index<len-1){
  751. $(selfDom).append("<div class='_row_content _row_move'></div>");
  752. $(selfDom).find("._row_content").last().css("height",(interSpace/ $(selfDom).height()*100)+"%").css("width","100%");
  753. }
  754. }
  755. }else if(!(params[0].column instanceof Array)){
  756. console.log("列布局");
  757. for(var index=0 ,len=params.length;index<len;index++){
  758. $(selfDom).append("<div class='_column_content _inline_block'></div>");
  759. if(len!==1){
  760. $(selfDom).find("._column_content").last().css("width",(parseFloat(params[index].column)*(1-(len-1)*interSpace/$(selfDom).width()))+"%").css("height","100%");
  761. }else{
  762. $(selfDom).find("._column_content").last().css("width",params[index].column).css("height","100%");
  763. }
  764. $(selfDom).find("._column_content").last().createRow(params[index].row,interSpace);
  765. if(index<len-1){
  766. $(selfDom).append("<div class='_column_content _column_move _inline_block'></div>");
  767. $(selfDom).find("._column_content").last().css("width",(interSpace/ $(selfDom).width()*100)+"%").css("height","100%");
  768. }
  769. }
  770. }
  771. return false;
  772. };
  773. //创建布局功能------------------------结束
  774. //创建行----------------------------结束
  775. // @parames:{row:[20%,40%,40%]};
  776. $.fn.createRow=function(e,interSpace){
  777. var selfDom=this;
  778. var params=null;
  779. params=e;
  780. //添加节点
  781. $(selfDom).removeClass("_single_content");
  782. for(var index=0,len=params.length;index<len;index++){
  783. if(params[index].id===undefined){
  784. $(selfDom).append("<div class='_row_content _single_content '></div>");
  785. }else{
  786. $(selfDom).append("<div id="+params[index].id+" class='_row_content _single_content '></div>");
  787. $(selfDom).find("#"+params[index].id).data("data",params[index].id.substring(1,params[index].id.length));
  788. }
  789. if(len!==1){
  790. $(selfDom).find("._row_content").last().css("height",(parseFloat(params[index].value)*(1-(len-1)*interSpace/$(selfDom).height()))+"%").css("width","100%");
  791. }else{
  792. $(selfDom).find("._row_content").last().css("height",params[index].value).css("width","100%");
  793. }
  794. if(index<len-1){
  795. $(selfDom).append("<div class='_row_content _row_move'></div>");
  796. $(selfDom).find("._row_content").last().css("height",(interSpace/ $(selfDom).height()*100)+"%").css("width","100%");
  797. }
  798. if(params[index].layoutData instanceof Array){
  799. $(selfDom).find("._row_content").last().createLayout(params[index].layoutData,interSpace);
  800. }
  801. };
  802. };
  803. //创建行---------------------------结束
  804. //创建列---------------------------开始
  805. // @parames:{column:[20%,40%,40%]};
  806. $.fn.createColumn=function(params,interSpace){
  807. var selfDom=this;
  808. $(selfDom).removeClass("_single_content");
  809. console.log(JSON.stringify({column:params}));
  810. //添加节点
  811. for(var index=0,len=params.length;index<len;index++){
  812. if(params[index].id===undefined){
  813. $(selfDom).append("<div class='_column_content _single_content _inline_block'></div>");
  814. }else{
  815. $(selfDom).append("<div id="+params[index].id+" class='_column_content _single_content _inline_block'></div>");
  816. $(selfDom).find("#"+params[index].id).data("data",params[index].id.substring(1,params[index].id.length));
  817. }
  818. // $(selfDom).find("._column_content").last().css("width",params[index].value).css("height","100%");
  819. if(len!==1){
  820. $(selfDom).find("._column_content").last().css("width",(parseFloat(params[index].value)*(1-(len-1)*interSpace/$(selfDom).width()))+"%").css("height","100%");
  821. }else{
  822. $(selfDom).find("._column_content").last().css("width",params[index].value).css("height","100%");
  823. }
  824. if(index<len-1){
  825. $(selfDom).append("<div class='_column_content _column_move _inline_block'></div>");
  826. $(selfDom).find("._column_content").last().css("height","100%").css("width",(interSpace/ $(selfDom).width()*100)+"%");
  827. }
  828. if(params[index].layoutData instanceof Array){
  829. $(selfDom).find("._column_content").last().createLayout(params[index].layoutData,interSpace);
  830. }
  831. };
  832. };
  833. //创建列---------------------------开始
  834. //创建生成li功能-----------------------------开始
  835. $.fn.createLi=function(dataParams,fn_option){
  836. var selfDom=this;
  837. $(selfDom).append("<ul></ul>");
  838. for(var index=0,len=dataParams.items.length;index<len;index++){
  839. $(selfDom).find("ul").append("<li class='_img_content'><img src='"+dataParams.items[index].url+"' title='"+dataParams.items[index].text+"'/></li>");
  840. $(selfDom).find("ul").find("li").last().data("layouParams",dataParams.items[index].layoutData)
  841. .on("click",function(){fn_option($(this).data("layouParams"));});
  842. $(selfDom).find("li").last().on("mouseenter",function(){
  843. $(this).addClass("_fn_mouse");}).on("mouseleave",function(){
  844. $(this).removeClass("_fn_mouse");}).on("click",function(){
  845. $(this).siblings().each(function() {
  846. $(this).removeClass("_fn_click_layout");
  847. });
  848. $(this).addClass("_fn_click_layout");
  849. });;
  850. }
  851. return false;
  852. };
  853. //创建生成li功能-----------------------------结束
  854. //创建选择菜单/销毁菜单-------------------------------开始
  855. $.fn.createMenu=function($dom){
  856. $("#float_menu_content").empty();
  857. $("#float_menu_content").append("<div class='_matic_list'><iframe class='_iframe' scrolling='no' src='"
  858. +path+"page/cockpit/maticList/maticList.html"+window.location.search+"&&contentDivId="+$dom.attr("id")+"&&iframeId="+$dom.attr("id")+"' name='test' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe></div>")
  859. $("#float_menu_content").css({display:"inline-block"});
  860. };
  861. //创建选择菜单-------------------------------结束
  862. //创建自定义布局菜单------------------------------开始
  863. $.fn.createSetMenu=function(e){
  864. var options=e;
  865. $(this).empty();
  866. $(this).append("<div class='_set_menu'></div>");
  867. /*$("#menu_switch").show();布局菜单按钮开关控制*/
  868. $(this).find("._set_menu").createLi(options.layoutParams,function(a){
  869. $("#"+options.layoutParams.dom).createLayout(a,$(window).width()*0.003);
  870. $("._column_move").each(function(){$(this).on("mousedown",moveDomY).addClass("_drag");});
  871. $("._row_move").each(function(){$(this).on("mousedown",moveDomX).addClass("_drag");});
  872. loadPage($("#"+options.layoutParams.dom));
  873. return false;
  874. });
  875. $(this).find("._set_menu").append("<div><input type='button' value='保 存'/></div>");
  876. $(this).find("._set_menu").find("input[type='button']").on("click",{$dom: $(this)},function(e){
  877. var alt=new Alert({ok:fn1,cancle:fn2},
  878. {text:"视图名称:!",
  879. input:"true",
  880. });
  881. //创建节点
  882. alt.create("");
  883. alt=null;
  884. /* var diag = new top.Dialog();
  885. diag.Title = "视图名称";
  886. diag.Height=100;
  887. diag.Width=300;
  888. diag.URL = path+"page/cockpit/webgis/layoutName.jsp";
  889. diag.OKEvent = function(){
  890. var inputValue = diag.innerFrame.contentWindow.document.getElementById('layoutName').value;
  891. diag.close();
  892. saveLayout(inputValue);
  893. $("#menu_content").empty();
  894. $("#menu_content").hide();
  895. $("#content").css({height:"100%"});
  896. };
  897. diag.CancelEvent=function(){
  898. diag.close();
  899. }
  900. diag.show();*/
  901. });
  902. return false;
  903. };
  904. //创建自定义菜单------------------------------结束
  905. })(jQuery);