if($('a').is('.btn-field-set')) { showTable = $("a.btn-field-set").attr("data-id"); listAll = [];//鎵€鏈夊瓧娈 $(".ajax-list-table").find("thead tr th").each(function (e) { f_name = $(this).find("span").html(); if(f_name != null ) { listAll[e] = f_name; } }); //瀛樻墍鏈夊瓧娈 log(showTable); localStorage.setItem("listAll" + showTable, JSON.stringify(listAll)); //鏈缃樉绀哄叏閮 if (localStorage.getItem("listSave" + showTable) == null) { localStorage.setItem("listSave" + showTable, JSON.stringify(listAll)); } }; $("body").on("click", ".btn-field-set", function() { a=JSON.parse(localStorage.getItem("listAll"+showTable)); b=JSON.parse(localStorage.getItem("listSave"+showTable)); listHtml="
"; for(var i =0; i=0){ chk="checked"; }else{ chk=""; } listHtml +="
"+a[i]+"
"; log(a[i]); } } listHtml +="
鍏抽棴椤甸潰
淇濆瓨璁剧疆
"; layer.open({ type: 1, title:"鍒楄〃瀛楁璁剧疆", scrollbar: false, skin: 'layui-layer-demo', //鍔犱笂杈规 area: ['80%', '60%'], //瀹介珮 content: listHtml }); }); //淇濆瓨璁剧疆鐨勫瓧娈 $("body").on("click", ".save-list-field", function() { listSave=[]; $(".list-all-field input[name='listFieldCheckbox']:checked").each(function(e) { if (true == $(this).prop("checked")) { value = $(this).prop('value'); listSave[e]=value } }); localStorage.setItem("listSave"+showTable,JSON.stringify(listSave)); log(listSave); }); var index = layer.getFrameIndex(window.name); //鑾峰彇绐楀彛绱㈠紩 //淇濆瓨璁剧疆鐨勫瓧娈 $("body").on("click", ".close-list-field", function() { alert(index); layer.close(index); }); //鍒濆鍖栭殣钘忚〃鐨勫垪 function initTableCell(){ $(".ajax-list-table").find("thead tr th").each(function(index) { listSave =JSON.parse(localStorage.getItem("listSave"+showTable)); f_name= $(this).find("span").html(); var cell=index+1 var item = $.inArray(f_name, listSave); //log(item); if(item>=0 || typeof(f_name)=='undefined'){ var strth = ".ajax-list-table thead tr th:nth-child(" var strtd = ".ajax-list-table tbody tr td:nth-child(" $(strtd+cell+")").show(); $(strth+cell+")").show(); //log(cell); }else{ var strth = ".ajax-list-table thead tr th:nth-child(" var strtd = ".ajax-list-table tbody tr td:nth-child(" $(strtd+cell+")").hide(); $(strth+cell+")").hide(); } }); }