提交 | 用户 | 时间
|
58d006
|
1 |
window.I = {} |
A |
2 |
var basic=getpath(); |
|
3 |
var modelview=function() { |
|
4 |
var self=this; |
|
5 |
self.groupid=ko.observable($('#groupid').val()); |
|
6 |
self.filter=ko.observable(); |
|
7 |
self.type=ko.observable(); |
|
8 |
self.ops=ko.observableArray(); |
|
9 |
self.res=ko.observable({ |
|
10 |
url:ko.observable() |
|
11 |
}); |
|
12 |
self.ress1=ko.observableArray(); |
|
13 |
self.change=function(item){ |
|
14 |
ress(0,15,self.type(),self.filter(),self.groupid(),1); |
|
15 |
}; |
|
16 |
self.opsel1=function(item){ |
|
17 |
var groupid=self.groupid(); |
|
18 |
var resid=item.id(); |
|
19 |
md.res(item); |
|
20 |
var oval=parseInt(item.ov()); |
|
21 |
jQuery.each(self.ops(), function(index, val) { |
|
22 |
val.value=parseInt(val.value); |
|
23 |
var tt=oval&(val.value); |
|
24 |
if(tt>0) |
|
25 |
val.check(true); |
|
26 |
else |
|
27 |
val.check(false); |
|
28 |
}); |
|
29 |
$('#modal1').modal('show'); |
|
30 |
}; |
|
31 |
|
|
32 |
self.ressel=function(item){ |
|
33 |
var groupid=self.groupid(); |
|
34 |
var resid=item.id(); |
|
35 |
var op=item.perm(); |
|
36 |
jQuery.post(basic+'/admin/grouppermcon/ressel.htm', {groupid:groupid,resid:resid,op:op}, function(data, textStatus, xhr) { |
|
37 |
if(data==null) |
|
38 |
return; |
|
39 |
if(data.code>0) |
|
40 |
{ |
|
41 |
alert(data.errmsg); |
|
42 |
item.perm(op==true?false:true); |
|
43 |
item.ov(0); |
|
44 |
}else{ |
|
45 |
item.perm(op); |
|
46 |
} |
|
47 |
},'json'); |
|
48 |
return true; |
|
49 |
}; |
|
50 |
}; |
|
51 |
|
|
52 |
jQuery(document).ready(function($) { |
|
53 |
var md=window.md=new modelview(); |
|
54 |
ko.applyBindings(md); |
|
55 |
var pagesize=15; |
|
56 |
ress(0,pagesize,md.type(),md.filter(),md.groupid(),1); |
|
57 |
ops(); |
|
58 |
$('#tjbtn').click(function(){ |
|
59 |
var obj={}; |
|
60 |
obj.groupid=md.groupid(); |
|
61 |
obj.resid=md.res().id; |
|
62 |
obj.op=0; |
|
63 |
jQuery.each(md.ops(), function(index, val) { |
|
64 |
if(val.check()==true) |
|
65 |
{ |
|
66 |
obj.op=obj.op+val.value; |
|
67 |
} |
|
68 |
}); |
|
69 |
jQuery.post(basic+'/admin/grouppermcon/valueset.htm', obj, function(data, textStatus, xhr) { |
|
70 |
if(data==null) |
|
71 |
return; |
|
72 |
if(data.code>0) |
|
73 |
{ |
|
74 |
alert(data.errmsg); |
|
75 |
}else{ |
|
76 |
md.res().perm(true); |
|
77 |
md.res().ov(obj.op); |
|
78 |
} |
|
79 |
$('#modal1').modal('hide'); |
|
80 |
},'json'); |
|
81 |
}); |
|
82 |
}); |
|
83 |
function ress(page,pagesize,type,filter,groupid,pages) |
|
84 |
{ |
|
85 |
jQuery.post(basic+'/admin/grouppermcon/ress.htm', {page:page,pagesize:pagesize,type:type,filter:filter,groupid:groupid}, function(data, textStatus, xhr) { |
|
86 |
if(data==null) |
|
87 |
return; |
|
88 |
if(data.pages!=null) |
|
89 |
{ |
|
90 |
$('#pagdiv').unbind('page').empty(); |
|
91 |
if(data.pages>1) |
|
92 |
{ |
|
93 |
$('#pagdiv').bootpag({total:data.pages,maxVisible:10,page:page+1}).on('page',function(event,num){ |
|
94 |
ress(num-1,pagesize,type,filter,groupid,0); |
|
95 |
}); |
|
96 |
} |
|
97 |
} |
|
98 |
if(data.items!=null) |
|
99 |
{ |
|
100 |
//ress:id,url,value(0,1,..,NULL) |
|
101 |
window.md.ress1.removeAll(); |
|
102 |
jQuery.each(data.items, function(index, val) { |
|
103 |
var obj={}; |
|
104 |
obj.id=val[0]; |
|
105 |
obj.url=val[1]; |
|
106 |
if(val[2]==null||val[2]=='null'||val[2]<0) |
|
107 |
{ |
|
108 |
obj.perm=false; |
|
109 |
}else{ |
|
110 |
obj.perm=true; |
|
111 |
} |
|
112 |
obj.ov=val[2] |
|
113 |
window.md.ress1.push(ko.mapping.fromJS(obj)); |
|
114 |
}); |
|
115 |
} |
|
116 |
},'json'); |
|
117 |
} |
|
118 |
|
|
119 |
function ops() |
|
120 |
{ |
|
121 |
jQuery.post(basic+'/admin/opercon/opers.htm', {}, function(data, textStatus, xhr) { |
|
122 |
if(data==null) |
|
123 |
return; |
|
124 |
window.md.ops.removeAll(); |
|
125 |
jQuery.each(data.items, function(index, val) { |
|
126 |
val.check=ko.observable(false); |
|
127 |
window.md.ops.push(val); |
|
128 |
}); |
|
129 |
},'json'); |
|
130 |
} |