window.I = {}
|
var basic=getpath();
|
var modelview=function() {
|
var self=this;
|
self.roleid=ko.observable($('#roleid').val());
|
self.filter=ko.observable();
|
self.type=ko.observable();
|
self.ops=ko.observableArray();
|
self.res=ko.observable({
|
url:ko.observable()
|
});
|
self.ress1=ko.observableArray();
|
self.change=function(item){
|
ress(0,15,self.type(),self.filter(),self.roleid(),1);
|
};
|
self.opsel1=function(item){
|
var roleid=self.roleid();
|
var resid=item.id();
|
md.res(item);
|
var oval=parseInt(item.ov());
|
jQuery.each(self.ops(), function(index, val) {
|
val.value=parseInt(val.value);
|
var tt=oval&(val.value);
|
if(tt>0)
|
val.check(true);
|
else
|
val.check(false);
|
});
|
$('#modal1').modal('show');
|
};
|
|
self.ressel=function(item){
|
var roleid=self.roleid();
|
var resid=item.id();
|
var op=item.perm();
|
jQuery.post(basic+'/admin/rolepercon/ressel.htm', {roleid:roleid,resid:resid,op:op}, function(data, textStatus, xhr) {
|
if(data==null)
|
return;
|
if(data.code>0)
|
{
|
alert(data.ermsg);
|
item.perm(op==true?false:true);
|
item.ov(0);
|
}else{
|
item.perm(op);
|
}
|
},'json');
|
return true;
|
};
|
};
|
|
jQuery(document).ready(function($) {
|
var md=window.md=new modelview();
|
ko.applyBindings(md);
|
var pagesize=15;
|
ress(0,pagesize,md.type(),md.filter(),md.roleid(),1);
|
ops();
|
$('#searcha').click(function(){
|
ress(0,pagesize,1,md.filter(),md.roleid(),1);
|
});
|
$('#tjbtn').click(function(){
|
var obj={};
|
obj.roleid=md.roleid();
|
obj.resid=md.res().id;
|
obj.op=0;
|
jQuery.each(md.ops(), function(index, val) {
|
if(val.check()==true)
|
{
|
obj.op=obj.op+val.value;
|
}
|
});
|
jQuery.post(basic+'/admin/rolepercon/valueset.htm', obj, function(data, textStatus, xhr) {
|
if(data==null)
|
return;
|
if(data.code>0)
|
{
|
alert(data.errmsg);
|
}else{
|
md.res().perm(true);
|
md.res().ov(obj.op);
|
}
|
$('#modal1').modal('hide');
|
},'json');
|
});
|
});
|
|
|
function ress(page,pagesize,type,filter,roleid,pages)
|
{
|
jQuery.post(basic+'/admin/rolepercon/ress.htm', {page:page,pagesize:pagesize,type:type,filter:filter,roleid:roleid,pages:pages}, function(data, textStatus, xhr) {
|
if(data==null)
|
return;
|
if(pages>0)
|
{
|
$('#pagdiv').unbind('page').empty();
|
if(data.pages>1)
|
{
|
$('#pagdiv').bootpag({total:data.pages,maxVisible:10,page:page+1}).on('page',function(event,num){
|
ress(num-1,pagesize,type,filter,roleid,0);
|
});
|
}
|
}
|
if(data.items!=null)
|
{
|
//ress:id,url,value(0,1,..,NULL)
|
window.md.ress1.removeAll();
|
jQuery.each(data.items, function(index, val) {
|
var obj={};
|
obj.id=val[0];
|
obj.url=val[1];
|
if(val[2]==null||val[2]=='null'||val[2]<0)
|
{
|
obj.perm=false;
|
}else{
|
obj.perm=true;
|
}
|
obj.ov=val[2];
|
obj.note=val[3];
|
window.md.ress1.push(ko.mapping.fromJS(obj));
|
});
|
}
|
},'json');
|
}
|
|
function ops()
|
{
|
jQuery.post(basic+'/admin/opercon/opers.htm', {}, function(data, textStatus, xhr) {
|
if(data==null)
|
return;
|
window.md.ops.removeAll();
|
jQuery.each(data.items, function(index, val) {
|
val.check=ko.observable(false);
|
window.md.ops.push(val);
|
});
|
},'json');
|
}
|