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