Administrator
2023-04-19 eeb08a586132f489c10e12551c6479b13c9def5e
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
window.I = {}
var basic=getpath();
var modelview=function() {
    var self=this;
    self.groupid=ko.observable($('#groupid').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.groupid(),1);
    };
    self.opsel1=function(item){
        var groupid=self.groupid();
        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 groupid=self.groupid();
        var resid=item.id();
        var op=item.perm();
        jQuery.post(basic+'/admin/grouppermcon/ressel.htm', {groupid:groupid,resid:resid,op:op}, function(data, textStatus, xhr) {
            if(data==null)
                return;
            if(data.code>0)
            {
                alert(data.errmsg);
                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.groupid(),1);
    ops();
    $('#tjbtn').click(function(){
        var obj={};
        obj.groupid=md.groupid();
        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/grouppermcon/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,groupid,pages)
{
    jQuery.post(basic+'/admin/grouppermcon/ress.htm', {page:page,pagesize:pagesize,type:type,filter:filter,groupid:groupid}, function(data, textStatus, xhr) {
        if(data==null)
            return;
        if(data.pages!=null)
        {
            $('#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,groupid,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]
                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');    
}