提交 | 用户 | 时间
|
58d006
|
1 |
window.I = {} |
A |
2 |
var basic=getpath(); |
|
3 |
pagesize=15; |
|
4 |
var modelview=function() { |
|
5 |
var self=this; |
|
6 |
self.role=ko.observable($('#role').val()); |
|
7 |
self.opers=ko.observableArray(); |
|
8 |
self.rolemodules=ko.observableArray(); |
|
9 |
self.opcheck=function(item){ |
|
10 |
var obj={}; |
|
11 |
obj.module=item.module; |
|
12 |
obj.role=self.role(); |
|
13 |
obj.value=item.value(); |
|
14 |
obj.check=item.check(); |
|
15 |
|
|
16 |
jQuery.post(basic+'/admin/modulecon/rolemodule.htm', obj, function(data, textStatus, xhr) { |
|
17 |
if(data==null) |
|
18 |
return; |
|
19 |
if(data.code>0){ |
|
20 |
alert(data.hint); |
|
21 |
}else{ |
|
22 |
if((obj.value&data.item.value)>0){ |
|
23 |
item.check(true) |
|
24 |
}else{ |
|
25 |
item.check(false); |
|
26 |
} |
|
27 |
} |
|
28 |
},'json'); |
|
29 |
|
|
30 |
}; |
|
31 |
}; |
|
32 |
|
|
33 |
|
|
34 |
jQuery(document).ready(function($) { |
|
35 |
var md=window.md=new modelview(); |
|
36 |
ko.applyBindings(md); |
|
37 |
init(md.role()) |
|
38 |
}); |
|
39 |
|
|
40 |
function init(role){ |
|
41 |
jQuery.post(basic+'/admin/opercon/opers.htm', function(data, textStatus, xhr) { |
|
42 |
if(data==null) |
|
43 |
return; |
|
44 |
if(data.items!=null){ |
|
45 |
jQuery.each(data.items, function(index, val) { |
|
46 |
md.opers.push(val); |
|
47 |
}); |
|
48 |
rolemodules(0,pagesize,1,role); |
|
49 |
} |
|
50 |
},'json'); |
|
51 |
} |
|
52 |
|
|
53 |
function rolemodules(page,pagesize,pages,role){ |
|
54 |
jQuery.post(basic+'/admin/modulecon/rolemodules.htm', {role: role,page:page,pagesize:pagesize,pages:pages}, function(data, textStatus, xhr) { |
|
55 |
if(data==null) |
|
56 |
return; |
|
57 |
if(pages>0){ |
|
58 |
var pagediv=$('#pagdiv'); |
|
59 |
pagediv.unbind('page').empty(); |
|
60 |
if(data.pages>1){ |
|
61 |
$('#pagdiv').bootpag({total:data.pages,maxVisible:10,page:page+1}).on('page',function(event,num){ |
|
62 |
rolemodules(num-1,pagesize,0,role); |
|
63 |
}); |
|
64 |
} |
|
65 |
md.rolemodules.removeAll(); |
|
66 |
if(data.items!=null){ |
|
67 |
var opers=md.opers(); |
|
68 |
jQuery.each(data.items, function(index, rm) { |
|
69 |
rm.ops=[]; |
|
70 |
jQuery.each(opers, function(index, val) { |
|
71 |
var op={}; |
|
72 |
op.id=val.id; |
|
73 |
op.module=rm.id; |
|
74 |
op.title=val.title; |
|
75 |
op.value=val.value; |
|
76 |
if(val&&rm.opvalue>0){ |
|
77 |
op.check=true; |
|
78 |
}else{ |
|
79 |
op.check=false; |
|
80 |
} |
|
81 |
rm.ops.push(op); |
|
82 |
}); |
|
83 |
md.rolemodules.push(ko.mapping.fromJS(rm)); |
|
84 |
}); |
|
85 |
|
|
86 |
} |
|
87 |
} |
|
88 |
},'json'); |
|
89 |
} |