var LKSortZJSY={data:{sel_data:{},cur_data:0,nor_data:["最近使用分类"],sel_count:0,inp_count:0,max:15,close_fn:function(){}},get_STData:function(){for(var c=this.data.nor_data,b={},a=0;a<c.length;a++)b[c[a]]=[];return b},init_data:function(d,c){var a=this.data;a.max=d||a.max;a.close_fn=c||a.close_fn;this.set_button();var b=this.get_STData(),a=this.data;a.sel_data=GlobalManage.clone(b);if(a.cur_data==0)a.cur_data=GlobalManage.clone(b);return this},get_sel_data:function(){for(var e=this.data,g=e.nor_data,i=GlobalManage.clone(e.sel_data),d,h,j,c={},b=0,a=0;a<g.length;a++){d=i[g[a]]||[];for(var f=0;f<d.length;f++){h=d[f];c[b]={分类名:h.分类名,类型:""};b++}}for(var a=b;a<e.inp_count;a++){c[a]={分类名:"",类型:""};b++}if(b==0)for(var a=0;a<2;a++)c[a]={分类名:"",类型:""};return c},isbutton:false,set_button:function(){if(this.isbutton)return;var a=this;$("#ZJSY_ID_Sure").replaceWith($('<input id="ZJSY_ID_Sure" type="button" title="确定" value="确 定" />').click(function(){a.data.close_fn()}));this.isbutton=true},set_sel_data:function(b){var c,a,f,d=this.data,g=d.sel_data,e={};d.inp_count=0;b=b||{};for(var h in b){c=b[h];a=c.分类名;if(!e[a]){e[a]=true;f=c.类型;GlobalManage.trim(a)!=""&&g["最近使用分类"].push({分类名:a,类型:"最近使用分类"})}d.inp_count++}return this},switch_options:function(i){var a=$(i),f=a.attr("state"),d=a.attr("sname"),g=a.attr("stype"),b=this.data,h=b.sel_data,c=[];a.removeClass().blur();if(f=="no"){if(b.sel_count>=b.max){a.attr({"class":"un-finish"});alert("引用分类的个数不能超过 "+b.max+" 个");return}a.attr({state:"yes","class":"finish",title:"点击删除分类:'"+d+"'"});b.sel_count++}else if(f=="yes"){a.attr({state:"no","class":"un-finish",title:"点击添加分类:'"+d+"'"});b.sel_count--}this.update_count(b);c=h[g]||[];for(var e=0;e<c.length;e++)if(c[e].分类名==d){c.splice(e,1);return}c.push({分类名:d,类型:g})},cut_sname:function(a){a=GlobalManage.trim(a);return a.length>8?a.substring(0,8)+"...":a},get_option:function(b,e,h){for(var a=false,f=this.data.sel_data,d=f[e]||[],c=0;c<d.length;c++)if(d[c].分类名==b){a=true;break}var g='<a href="javascript:void(0)" onclick="LKSortZJSY.switch_options(this);" class="'+(a?"finish":"un-finish")+'"  stype="'+e+'" state="'+(a?"yes":"no")+'" sname="'+b+'" title="点击'+(a?"删除":"添加")+"分类:'"+b+"'\">"+this.cut_sname(b)+"</a>";h({html:g,isfinish:a})},setContent:function(a){$("#ZJSY_ID_Body").html(a)},update_count:function(a){$("#ZJSY_ID_Count_0").text(a.sel_count);$("#ZJSY_ID_Count_1").text(a.inp_count)},update_options:function(){var e="",a=this.data,i=a.cur_data,b,c,j=a.sel_data,h=a.nor_data,d;a.sel_count=0;for(var f=0;f<h.length;f++){d=h[f];b=i[d]||[];c=b.length;if(c==0)e+='<span class="no-use" title="无最近使用分类" >无最近使用分类</span>';else for(var g=0;g<c;g++)this.get_option(b[g].分类名,d,function(b){e+=b.html;b.isfinish&&a.sel_count++})}this.setContent(e);this.update_count(a)},exe凑合:function(k){var l=this.data,f,j=GlobalManage.clone(l.sel_data),e,h=this.get_STData(),i,g,c={},a;for(var d in j){e=j[d]||[];for(var b=0;b<e.length;b++){a=e[b];if(a)c[a.分类名]="最近使用分类"}}for(var d in k){f=k[d]||[];for(var b=0;b<f.length;b++){a=f[b];if(a)c[a.分类名]="最近使用分类"}}for(var d in c){g=c[d];i=h[g]||[];i.push({分类名:d,类型:g})}l.cur_data=h;this.update_options()},exeError:function(b){var a='<div style="color:#666;margin:10px;">对不起,查找使用分类发生错误:'+b+'<br /><div style="padding-top:10px;">给您带来的不便敬请谅解！谢谢。</div></div>';this.setContent(a)},check_data:function(a){var d=this.data.nor_data,b;a=a||{};for(var c=0;c<d.length;c++){b=d[c];if(a[b]&&a[b].length!=0)return true}return false},search:function(){var b=this.data.cur_data,a=this;if(this.check_data(b)){this.exe凑合(b);return}$("#ZJSY_ID_Body").html('<div class="loading">数据正在加载中...</div>');$.post(LKConfig.URLAssembly.LKSort.Server.get("ZJSY"),{},function(b){if(b.result){a.exe凑合(b.info);$("#ZJSY_ID_Head").show();$("#ZJSY_ID_Foot").show()}else a.exeError(b.info)},"json");return;$.ajax({type:"POST",url:LKConfig.URLAssembly.LKSort.Server.get("ZJSY"),cache:false,timeout:6e4,data:{action:"分类管理_查询最近使用分类",guid:GlobalManage.get_cookie_uid()},dataType:"json",success:function(b){if(b.result){a.exe凑合(b.info);$("#ZJSY_ID_Head").show();$("#ZJSY_ID_Foot").show()}else a.exeError(b.info)},error:function(d,b){a.exeError(b)}})}}