var App=function(){var h={idField:"catid",treeCellIndex:0,template:'<tr id="catepriv_{catid}">\t<td class="t_l">\t\t<label><input type="checkbox" class="checkbox_style" name="catid[]" value="{catid}" /> {name}</label>\t</td></tr>',rowIdPrefix:"catepriv_",collapsed:1,baseUrl:"?app=system&controller=administrator&action=catetree",rowReady:function(a,b,c){a=b.find("input:checkbox");a.click(function(){this.checked?b.getDescendants().find("input:checkbox").attr("disabled","disabled").attr("checked",true):
b.getDescendants().find("input:checkbox").removeAttr("disabled")});c.checked&&a.attr("checked",true);(c=b.data("parentTr"))&&c.find("input:checkbox").is(":checked,:disabled")&&a.attr("disabled","disabled")}},i={idField:"sectionid",treeCellIndex:0,template:'<tr id="sectionpriv_{sectionid}">\t<td class="t_l">\t\t<label><input type="checkbox" class="checkbox_style" name="sectionid[]" value="{sectionid}" /> {name}</label>\t</td></tr>',rowIdPrefix:"sectionpriv_",collapsed:1,baseUrl:"?app=system&controller=administrator&action=sectiontree",
rowReady:function(a,b,c){if(c.parent){c=b.find("label");c.html("<b>"+c.text()+"</b>")}else{a=b.find("input:checkbox");c.checked&&a.attr("checked",true)}}},m=function(a,b){b.find(">td>img.edit").click(function(){d.edit(a,b)});b.find(">td>img.delete").click(function(){d.del(a)})},j,k,l,d={table:null,init:function(a,b){j=a+"&action=edit";l=a+"&action=add";k=a+"&action=delete";d.table=new ct.table("#item_list",{pageSize:b,dblclickHandler:d.edit,rowCallback:m,template:'<tr id="row_{userid}">\t<td class="t_c">\t   <input type="checkbox" class="checkbox_style" value="{userid}" />\t</td>\t<td class="t_r">{userid}</td>\t<td><a href="javascript: url.member({userid});">{username}</a></td>\t<td>{name}</td>\t<td class="t_c">{role}</td>\t<td class="t_c">{department}</td>\t<td class="t_c">{state}</td>\t<td class="t_c">\t   <img class="manage edit" height="16" width="16" alt="\u7f16\u8f91" src="images/edit.gif"/>       <img class="manage delete" height="16" width="16" alt="\u5220\u9664" src="images/delete.gif"/>\t</td></tr>',
baseUrl:a+"&action=page"});d.table.load();$("select[name=departmentid],#roleid").dropdown({departmentid:{onchange:function(c){d.table.load("departmentid="+c+"&roleid="+$("input[name=roleid]").val())}},roleid:{onchange:function(c){d.table.load("roleid="+c+"&departmentid="+$("input[name=departmentid]").val())}}})},stat:function(a){ct.assoc.open("?app=system&controller=administrator&action=stat&userid="+a,"newtab")},priv:function(a){ct.assoc.open("?app=system&controller=administrator&action=priv&userid="+
a,"newtab")},clonepriv:function(a){ct.form("\u514b\u9686\u6743\u9650","?app=system&controller=administrator&action=clonepriv&srcuserid="+a,400,200,function(b){b.state?ct.tips("\u514b\u9686\u6210\u529f","success"):ct.error(b.error);return true},function(b){$(b[0].taruserid).suggest()})},edit:function(a,b){var c=j+"&userid="+a;b.trigger("check");ct.form("\u7f16\u8f91\u7ba1\u7406\u5458",c,420,"90%",function(g){if(g.state){d.table.updateRow(a,g.data);return true}},function(g,e){var f=e.find("div.part");
e.find("div.tabs>ul").tabnav({dataType:null,forceFocus:true,focused:function(n){f.hide();f.eq(n.attr("index")).show()}});var o=new ct.treeTable(f.eq(1).find("table.treeTable"),h),p=new ct.treeTable(f.eq(2).find("table.treeTable"),i);o.load("userid="+a);p.load("userid="+a);e.find("select[name=departmentid]").change(function(){e.find("select[name=roleid]").parent().load("?app=system&controller=role&action=dropdown&departmentid="+this.value)})})},add:function(){ct.form("\u6dfb\u52a0\u7ba1\u7406\u5458",
l,420,"90%",function(a){if(a.state){d.table.addRow(a.data);ct.tips("\u6dfb\u52a0\u7ba1\u7406\u5458\u6210\u529f","success");return true}},function(a,b){var c=b.find("div.part");b.find("div.tabs>ul").tabnav({dataType:null,forceFocus:true,focused:function(f){c.hide();c.eq(f.attr("index")).show()}});var g=new ct.treeTable(c.eq(1).find("table.treeTable"),h),e=new ct.treeTable(c.eq(2).find("table.treeTable"),i);g.load();e.load();b.find("select[name=departmentid]").change(function(){b.find("select[name=roleid]").parent().load("?app=system&controller=role&action=dropdown&departmentid="+
this.value)})})},del:function(a){var b;if(a===undefined){a=d.table.checkedIds();if(!a.length){ct.warn("\u8bf7\u9009\u4e2d\u8981\u5220\u9664\u9879");return}b='\u786e\u5b9a\u5220\u9664\u9009\u4e2d\u7684<b style="color:red">'+a.length+"</b>\u6761\u8bb0\u5f55\u5417\uff1f"}else b='\u786e\u5b9a\u5220\u9664\u7f16\u53f7\u4e3a<b style="color:red">'+a+"</b>\u7684\u8bb0\u5f55\u5417\uff1f";ct.confirm(b,function(){$.post(k,"id="+a,function(c){c.state?(ct.warn("\u5220\u9664\u5b8c\u6bd5"),d.table.deleteRow(a)):
ct.warn(c.error)},"json")})}};return d}();
