8e60a5dea0ce6b1fd5025c51edfefc5edd3bce45.svn-base 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. var conditionJson;
  2. var param={};
  3. var $dom=null;
  4. /**
  5. * 页面加载完成后执行
  6. */
  7. $(function() {
  8. init();
  9. });
  10. /**
  11. * 初始化方法
  12. */
  13. function init(){
  14. conditionJson = resolveUrl();
  15. loadMaticList();
  16. bindEventOnOkayAndCancle();
  17. }
  18. /**
  19. *
  20. */
  21. function bindEventOnOkayAndCancle(){
  22. /**
  23. * 确定事件
  24. */
  25. $("#i_submit").on("click",function(){
  26. /* function fn1(){
  27. alt.destory();
  28. return;
  29. }
  30. function fn2(){
  31. alt.destory();
  32. top.destoryIframeContent("i_index_maticlist");
  33. }
  34. if($dom==null){
  35. var alt=new Alert({ok:fn1,cancle:fn2},
  36. {text:"请您选择视图!"});
  37. //创建节点
  38. alt.create("");
  39. }*/
  40. /* console.log("data========"+JSON.stringify($dom.data("data")));*/
  41. top.changeSite(conditionJson["contentId"], $dom.data("data"));
  42. top.destoryIframeContent("i_index_maticlist");
  43. });
  44. /**
  45. * 销毁本页面
  46. */
  47. $("#i_cancle").on("click",function(){
  48. top.destoryIframeContent("i_index_maticlist");
  49. });
  50. /**
  51. * 筛选功能的text获取焦点事件
  52. */
  53. $("#i_searchtext").on("focus",function(){
  54. $(this).attr("value","").css({color:"#000000",border:"none"});
  55. });
  56. $("#i_searchtext").on("keyup",function(e){
  57. if(e.keyCode==13){
  58. search();
  59. }
  60. });
  61. /**
  62. * 筛选功能绑定点击事件
  63. */
  64. $("#i_search_b").on("click",search);
  65. $(".c_ul_li_topdiv_p").each(function(){
  66. $(this).on("mouseenter",function(){
  67. $(this).css({color:"red","background-color": "yellow"});
  68. }).on("mouseleave",function(){
  69. $(this).css({color:"#000000","background-color": "#e5e5e7"});
  70. });
  71. });
  72. }
  73. /**
  74. * 筛选功能查询方法
  75. */
  76. function search(){
  77. if($("#i_searchtext").val()=="" || $("#i_searchtext").val()==null){
  78. function fn1(){
  79. alt.destory();
  80. return;
  81. }
  82. function fn2(){
  83. alt.destory();
  84. top.destoryMenu();
  85. }
  86. if($dom==null){
  87. var alt=new Alert({ok:fn1,cancle:fn2},
  88. {text:"请您输入查询条件!"});
  89. //创建节点
  90. alt.create("");
  91. }
  92. }else{
  93. postSearch({comId:conditionJson["dept_id"],name:$("#i_searchtext").val().trim()},createInfo);
  94. }
  95. }
  96. /**
  97. * 发送post请求,请求查询筛选的数据
  98. * @param param
  99. * @param callFunction
  100. */
  101. function postSearch(param,callFunction){
  102. $.post(path + "ws/MaticService/MaticService/getMaticMapInfoThroughLikeInfo",{like:param.name,comId:param.comId},function(result){
  103. callFunction(result.rows);
  104. bindEventOnMaticView();
  105. },"json");
  106. }
  107. /**
  108. * 加载页面数据
  109. */
  110. function loadMaticList() {
  111. var _this=arguments.callee;
  112. $.post(path + "ws/MaticService/MaticService/getMaticMapInfo", {comId:conditionJson["dept_id"]}, function(
  113. result) {
  114. $div = $("<div></div>");
  115. if (result.state == "SUCCESS") {
  116. loadListItem(result);
  117. //accordionMenu($("#i_matic_content"), result.rows);
  118. } else {
  119. function fn1(){
  120. _this();
  121. return;
  122. }
  123. function fn2(){
  124. alt.destory();
  125. }
  126. if($dom==null){
  127. var alt=new Alert({ok:fn1,cancle:fn2},
  128. {text:"加载失败!是否需要继续加载?"});
  129. //创建节点
  130. alt.create("");
  131. }
  132. }
  133. }, "json");
  134. };
  135. /**
  136. * 加载左侧列表
  137. * @param data 后台查询的数据
  138. */
  139. function loadListItem(data){
  140. createList(data);
  141. for(var item in param){
  142. createInfo(param[item]);
  143. break;
  144. }
  145. /*createInfo(param[0]);*/
  146. bindEventOnMaticView();
  147. }
  148. /**
  149. * 加载左侧列表
  150. * @param data
  151. */
  152. function createList(data){
  153. var htmlStr="<ul class='c_item_list_ul'>";
  154. htmlStr+="<h2>全部<span class='c_amout'>("+data.total+")</span></h2>";
  155. var temData=data.rows.sort(function(item1,item2){
  156. if(parseInt(item1.rows[0]["SORT1"])>parseInt(item2.rows[0]["SORT1"])){
  157. return 1;
  158. }else if(parseInt(item1.rows[0]["SORT1"])<parseInt(item2.rows[0]["SORT1"])){
  159. return -1;
  160. }else{
  161. return 0;
  162. };
  163. });
  164. data.rows=temData;
  165. for(var index=0,len=data.rows.length;index<len;index++){
  166. param[data.rows[index].name]=data.rows[index].rows;
  167. if(data.rows[index].rows[0]["FD_OBJECTID"]!=0){
  168. htmlStr+="<li class='c_item_list_li' data="+data.rows[index].name+"><div>"+data.rows[index].name+"<span class='c_amout'>("+data.rows[index].rows.length+")</span></div></li>";
  169. }else{
  170. htmlStr+="<li class='c_item_list_li' data="+data.rows[index].name+"><div>"+data.rows[index].name+"<span class='c_amout'>(0)</span></div></li>";
  171. }
  172. }
  173. htmlStr+="</ul>";
  174. $("#i_left").append(htmlStr);
  175. htmlStr=null;
  176. bindItemEvent();
  177. }
  178. /**
  179. * 左侧列表绑定点击事件
  180. * 绑定列表事件
  181. */
  182. function bindItemEvent(){
  183. $("#i_left").find("ul").find("li").each(function(i,item){
  184. $(this).on("click",function(){
  185. createInfo(param[$(this).attr("data")]);
  186. bindEventOnMaticView();
  187. if($(this).siblings(".c_item_list_li_click").size()>0){
  188. $(this).siblings(".c_item_list_li_click").removeClass("c_item_list_li_click");
  189. }
  190. $(this).addClass("c_item_list_li_click");
  191. }).on("mouseenter",function(){
  192. /*var $dom=$(this).find("div");
  193. $dom.animate({"margin-top":"-30px"},200,"",function(){
  194. $dom.css({"margin-top":"-30px"}).animate({"margin-top":"0px"},200,"",function(){
  195. $dom.animate({"font-size":"20px"},200,"",function(){
  196. $dom.animate({"font-size":"12px"},200);
  197. $dom=null;
  198. });
  199. });
  200. });*/
  201. //_this=null;
  202. });
  203. });
  204. /* $("#i_left").find("ul").on("click","li",function(){
  205. alert("===");
  206. alert(JSON.stringify(param[$(this).attr("data")]));
  207. createInfo(param[$(this).attr("data")]);
  208. bindEventOnMaticView();
  209. }).on("mouseenter","li",function(){
  210. var $dom=$(this).find("div");
  211. $dom.animate({"margin-top":"-30px"},200,"",function(){
  212. $dom.css({"margin-top":"-30px"}).animate({"margin-top":"0px"},200,"",function(){
  213. $dom.animate({"font-size":"20px"},200,"",function(){
  214. $dom.animate({"font-size":"12px"},200);
  215. $dom=null;
  216. });
  217. });
  218. });
  219. //_this=null;
  220. });*/
  221. }
  222. /**
  223. * 创建视图详情
  224. * @param param
  225. * @returns {Boolean}
  226. */
  227. function createInfo(param){
  228. $("#i_content_info").empty();
  229. if(param[0]["FD_OBJECTID"]==0){
  230. $("#i_content_info").append("<div style='margin-top: 40px;text-align: center;color: #141414;'>暂未配置外部系统!</div>");
  231. return false;
  232. }
  233. $("#i_content_info").append("<ul class='c_ul'></ul>");
  234. for(var index=0,len=param.length;index<len;index++){
  235. $("#i_content_info").find("ul").append(
  236. "<li class='c_ul_li'><div class='c_ul_li_topdiv'><p class='c_ul_li_topdiv_p'>"
  237. + param[index]["TM_NAME"]
  238. + "</p></div><div class='"+param[index]["TM_IMGURL"]+" c_ul_li_bottomdiv _background_position' title='"
  239. + param[index]["TM_NAME"] + "'></div></li>");
  240. $("#i_content_info").find("ul").find("li").last().data("data", param[index]);
  241. }
  242. return false;
  243. }
  244. /**
  245. * 给单个选项绑定点击事件
  246. */
  247. function bindEventOnMaticView(){
  248. $("#i_content_info").find("ul").on("click","li",function(){
  249. $dom=$(this);
  250. }).on("mouseenter","li",function(){
  251. /* console.log("====");*/
  252. var $dom=$(this).on("click",function(){
  253. $(this).siblings(".c_has_click").removeClass("c_has_click");
  254. $(this).addClass("c_has_click");
  255. }).find(".c_ul_li_bottomdiv");
  256. $dom.animate({"background-size":"103px"},200,"",function(){
  257. $dom.animate({"background-size":"50px"},200,"",function(){
  258. $dom.animate({"background-size":"75px"},200);
  259. $dom=null;
  260. });
  261. });
  262. });
  263. }
  264. /******************************************无用代码************************************************************/
  265. /**
  266. *
  267. * @param $dom
  268. * @param data
  269. */
  270. function accordionMenu($dom, data) {
  271. var $divCon = $("<div class='_ul_count_content'></div>");
  272. if (data.length == 0)
  273. throw Error("accordionMenu($dom,data)中data的长度为0或者空");
  274. if ($dom == null || $dom == undefined)
  275. throw new Error("accordionMenu($dom,data)中容器节点不能为空");
  276. for ( var item in data) {
  277. if (data[item].rows.length == 0)
  278. continue;
  279. $div = $("<div class='_ul_content'></div>");
  280. menuItem($div, data[item]);
  281. $divCon.append($div);
  282. }
  283. ;
  284. $dom.append($divCon);
  285. $dom.append("<div class='_jsc_close'></div>");
  286. $dom.find("._jsc_close").on("click", function() {
  287. top.destoryMenu();
  288. }).on("mouseenter", function() {
  289. $(this).addClass("_jsc_close_changeImg");
  290. }).on("mouseleave", function() {
  291. $(this).removeClass("_jsc_close_changeImg");
  292. });
  293. }
  294. // 创建单个选择list
  295. function menuItem($dom, data) {
  296. $ul = $("<ul></ul>");
  297. $h2 = $("<div class='_ul_head'><div class='_view_list_line'></div><div class='_view_list'><h2>"
  298. + data.name + "</h2></div></div>");
  299. // 点击隐藏选择项
  300. $ul.append($h2);
  301. $dom.append($ul);
  302. for ( var item1 in data.rows) {
  303. $dom.find("ul").last().append(
  304. "<li class='_ul_li'><div class='_matic_title'><p >"
  305. + data.rows[item1]["TM_NAME"]
  306. + "</p></div><div class='_matic_img' title='"
  307. + data.rows[item1]["TM_NAME"] + "'><img src='"
  308. + (path + data.rows[item1]["TM_IMGURL"])
  309. + "'/></div></li>");
  310. $dom.find("ul").last().find("li").last().data("data", data.rows[item1]);
  311. inAndLeaveAndClick($dom.find("ul").last().find("li").last(), function(
  312. $dom) {
  313. top.changeSite(conditionJson["iframeId"], $dom.data("data"));
  314. top.destoryMenu();
  315. }, moveIn, moveOut);
  316. }
  317. $dom.find("._view_list").click(function() {
  318. $(this).parents("._ul_content").toggleClass("_ul_content_hide");
  319. });
  320. }