123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- var conditionJson;
- var param={};
- var $dom=null;
- /**
- * 页面加载完成后执行
- */
- $(function() {
- init();
- });
- /**
- * 初始化方法
- */
- function init(){
- conditionJson = resolveUrl();
- loadMaticList();
- bindEventOnOkayAndCancle();
- }
- /**
- *
- */
- function bindEventOnOkayAndCancle(){
- /**
- * 确定事件
- */
- $("#i_submit").on("click",function(){
- /* function fn1(){
-
- alt.destory();
- return;
- }
- function fn2(){
- alt.destory();
- top.destoryIframeContent("i_index_maticlist");
- }
- if($dom==null){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"请您选择视图!"});
- //创建节点
- alt.create("");
- }*/
- /* console.log("data========"+JSON.stringify($dom.data("data")));*/
- top.changeSite(conditionJson["contentId"], $dom.data("data"));
- top.destoryIframeContent("i_index_maticlist");
- });
- /**
- * 销毁本页面
- */
- $("#i_cancle").on("click",function(){
- top.destoryIframeContent("i_index_maticlist");
- });
- /**
- * 筛选功能的text获取焦点事件
- */
- $("#i_searchtext").on("focus",function(){
- $(this).attr("value","").css({color:"#000000",border:"none"});
- });
- $("#i_searchtext").on("keyup",function(e){
- if(e.keyCode==13){
- search();
- }
- });
- /**
- * 筛选功能绑定点击事件
- */
- $("#i_search_b").on("click",search);
- $(".c_ul_li_topdiv_p").each(function(){
- $(this).on("mouseenter",function(){
- $(this).css({color:"red","background-color": "yellow"});
- }).on("mouseleave",function(){
- $(this).css({color:"#000000","background-color": "#e5e5e7"});
-
- });
- });
-
- }
- /**
- * 筛选功能查询方法
- */
- function search(){
- if($("#i_searchtext").val()=="" || $("#i_searchtext").val()==null){
- function fn1(){
- alt.destory();
- return;
- }
- function fn2(){
- alt.destory();
- top.destoryMenu();
- }
- if($dom==null){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"请您输入查询条件!"});
- //创建节点
- alt.create("");
- }
- }else{
- postSearch({comId:conditionJson["dept_id"],name:$("#i_searchtext").val().trim()},createInfo);
-
- }
- }
- /**
- * 发送post请求,请求查询筛选的数据
- * @param param
- * @param callFunction
- */
- function postSearch(param,callFunction){
- $.post(path + "ws/MaticService/MaticService/getMaticMapInfoThroughLikeInfo",{like:param.name,comId:param.comId},function(result){
- callFunction(result.rows);
- bindEventOnMaticView();
- },"json");
- }
- /**
- * 加载页面数据
- */
- function loadMaticList() {
- var _this=arguments.callee;
- $.post(path + "ws/MaticService/MaticService/getMaticMapInfo", {comId:conditionJson["dept_id"]}, function(
- result) {
- $div = $("<div></div>");
- if (result.state == "SUCCESS") {
- loadListItem(result);
- //accordionMenu($("#i_matic_content"), result.rows);
- } else {
- function fn1(){
- _this();
- return;
- }
- function fn2(){
- alt.destory();
-
- }
- if($dom==null){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"加载失败!是否需要继续加载?"});
- //创建节点
- alt.create("");
- }
- }
- }, "json");
- };
- /**
- * 加载左侧列表
- * @param data 后台查询的数据
- */
- function loadListItem(data){
- createList(data);
- for(var item in param){
- createInfo(param[item]);
- break;
- }
- /*createInfo(param[0]);*/
- bindEventOnMaticView();
- }
- /**
- * 加载左侧列表
- * @param data
- */
- function createList(data){
- var htmlStr="<ul class='c_item_list_ul'>";
- htmlStr+="<h2>全部<span class='c_amout'>("+data.total+")</span></h2>";
- var temData=data.rows.sort(function(item1,item2){
- if(parseInt(item1.rows[0]["SORT1"])>parseInt(item2.rows[0]["SORT1"])){
- return 1;
- }else if(parseInt(item1.rows[0]["SORT1"])<parseInt(item2.rows[0]["SORT1"])){
- return -1;
- }else{
- return 0;
- };
- });
- data.rows=temData;
- for(var index=0,len=data.rows.length;index<len;index++){
- param[data.rows[index].name]=data.rows[index].rows;
- if(data.rows[index].rows[0]["FD_OBJECTID"]!=0){
- 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>";
- }else{
- 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>";
- }
- }
- htmlStr+="</ul>";
- $("#i_left").append(htmlStr);
- htmlStr=null;
- bindItemEvent();
- }
- /**
- * 左侧列表绑定点击事件
- * 绑定列表事件
- */
- function bindItemEvent(){
- $("#i_left").find("ul").find("li").each(function(i,item){
- $(this).on("click",function(){
- createInfo(param[$(this).attr("data")]);
- bindEventOnMaticView();
- if($(this).siblings(".c_item_list_li_click").size()>0){
- $(this).siblings(".c_item_list_li_click").removeClass("c_item_list_li_click");
- }
- $(this).addClass("c_item_list_li_click");
- }).on("mouseenter",function(){
- /*var $dom=$(this).find("div");
- $dom.animate({"margin-top":"-30px"},200,"",function(){
- $dom.css({"margin-top":"-30px"}).animate({"margin-top":"0px"},200,"",function(){
- $dom.animate({"font-size":"20px"},200,"",function(){
- $dom.animate({"font-size":"12px"},200);
- $dom=null;
- });
- });
- });*/
- //_this=null;
- });
- });
-
- /* $("#i_left").find("ul").on("click","li",function(){
- alert("===");
- alert(JSON.stringify(param[$(this).attr("data")]));
- createInfo(param[$(this).attr("data")]);
- bindEventOnMaticView();
- }).on("mouseenter","li",function(){
- var $dom=$(this).find("div");
- $dom.animate({"margin-top":"-30px"},200,"",function(){
- $dom.css({"margin-top":"-30px"}).animate({"margin-top":"0px"},200,"",function(){
- $dom.animate({"font-size":"20px"},200,"",function(){
- $dom.animate({"font-size":"12px"},200);
- $dom=null;
- });
- });
- });
- //_this=null;
- });*/
- }
- /**
- * 创建视图详情
- * @param param
- * @returns {Boolean}
- */
- function createInfo(param){
- $("#i_content_info").empty();
- if(param[0]["FD_OBJECTID"]==0){
- $("#i_content_info").append("<div style='margin-top: 40px;text-align: center;color: #141414;'>暂未配置外部系统!</div>");
- return false;
- }
- $("#i_content_info").append("<ul class='c_ul'></ul>");
- for(var index=0,len=param.length;index<len;index++){
- $("#i_content_info").find("ul").append(
- "<li class='c_ul_li'><div class='c_ul_li_topdiv'><p class='c_ul_li_topdiv_p'>"
- + param[index]["TM_NAME"]
- + "</p></div><div class='"+param[index]["TM_IMGURL"]+" c_ul_li_bottomdiv _background_position' title='"
- + param[index]["TM_NAME"] + "'></div></li>");
- $("#i_content_info").find("ul").find("li").last().data("data", param[index]);
- }
- return false;
- }
- /**
- * 给单个选项绑定点击事件
- */
- function bindEventOnMaticView(){
- $("#i_content_info").find("ul").on("click","li",function(){
- $dom=$(this);
- }).on("mouseenter","li",function(){
- /* console.log("====");*/
- var $dom=$(this).on("click",function(){
- $(this).siblings(".c_has_click").removeClass("c_has_click");
- $(this).addClass("c_has_click");
- }).find(".c_ul_li_bottomdiv");
- $dom.animate({"background-size":"103px"},200,"",function(){
- $dom.animate({"background-size":"50px"},200,"",function(){
- $dom.animate({"background-size":"75px"},200);
- $dom=null;
- });
- });
- });
- }
- /******************************************无用代码************************************************************/
- /**
- *
- * @param $dom
- * @param data
- */
- function accordionMenu($dom, data) {
- var $divCon = $("<div class='_ul_count_content'></div>");
- if (data.length == 0)
- throw Error("accordionMenu($dom,data)中data的长度为0或者空");
- if ($dom == null || $dom == undefined)
- throw new Error("accordionMenu($dom,data)中容器节点不能为空");
- for ( var item in data) {
- if (data[item].rows.length == 0)
- continue;
- $div = $("<div class='_ul_content'></div>");
- menuItem($div, data[item]);
- $divCon.append($div);
- }
- ;
- $dom.append($divCon);
- $dom.append("<div class='_jsc_close'></div>");
- $dom.find("._jsc_close").on("click", function() {
- top.destoryMenu();
- }).on("mouseenter", function() {
- $(this).addClass("_jsc_close_changeImg");
- }).on("mouseleave", function() {
- $(this).removeClass("_jsc_close_changeImg");
- });
- }
- // 创建单个选择list
- function menuItem($dom, data) {
- $ul = $("<ul></ul>");
- $h2 = $("<div class='_ul_head'><div class='_view_list_line'></div><div class='_view_list'><h2>"
- + data.name + "</h2></div></div>");
- // 点击隐藏选择项
- $ul.append($h2);
- $dom.append($ul);
- for ( var item1 in data.rows) {
- $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>");
- $dom.find("ul").last().find("li").last().data("data", data.rows[item1]);
- inAndLeaveAndClick($dom.find("ul").last().find("li").last(), function(
- $dom) {
- top.changeSite(conditionJson["iframeId"], $dom.data("data"));
- top.destoryMenu();
- }, moveIn, moveOut);
- }
- $dom.find("._view_list").click(function() {
- $(this).parents("._ul_content").toggleClass("_ul_content_hide");
- });
- }
|