1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
$(function () {
    $("#jqGridWithSelected").jqGrid({
        url: restServerBaseURL + 'sys/rolegroup/selectedList',
        datatype: "json",
        colModel: [
            { label: '群组ID', name: 'groupId', index: 'groupId', width: 40,align:'center',hidden:true,key:true },
            { label: '群组名称', name: 'groupName', index: 'groupName', width: 40,align:'center'},
            { label: '描述', name: 'description', index: 'description', width: 70,align:'center' },
            { label: '删除', width: 20,align:'center',
                formatter: function(value, grid, rows, state) {
                    var groupId = rows.groupId;
                    var html = '';
                    if(hasPermission('sys:role:edit')) {
                        html = '<a href="#"><span style="color: red;font-size:20px" onmousemove="minusWithOrange(this)" onmouseout="minusWithRed(this)" class="glyphicon glyphicon-minus-sign" onclick="vm.del(\'' + groupId + '\')"></span></a> ';
                    }
                    return html;
                }
            }
        ],
        postData:{roleId:roleId},
        viewrecords: true,
        height: "auto",
        rowNum: 10,
        //rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 30,
        autowidth: true,
        multiselect: false,
        pager: "#jqGridPagerWithSelected",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount",
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGridWithSelected").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
            var totalResocrds = $("#jqGridWithSelected").getGridParam("records");
            $("#totalSelectedUsers").html(totalResocrds);
        }
    });
    $("#jqGridWithSelected").setGridWidth($(window).width()-20);
    $("#exitsUser a").trigger('click');
    $("title").text("角色管理 - " + systemTitle);
});
 
var roleId = window.T.p('roleid');
 
var vm = new Vue({
    el:'#rapp',
    data: {
        title:null,
        rolegroup: { roleId: roleId }
    },
    methods: {
        query: function () {
            vm.reload(0);
        },
        add: function(groupId){
            $.ajax({
                type: "POST",
                url: restServerBaseURL + 'sys/rolegroup/save',
                contentType: "application/json",
                data:  JSON.stringify({roleId:roleId,groupId:groupId}),
                success: function(r){
                    if(r.code === 0){
                        alert('操作成功', function(){
                            vm.reload(1);
                            if(parent.opener.vm && parent.opener.vm.reload){
                                parent.opener.vm.reload();
                            }
                        });
                    }else{
                        alert(r.msg);
                    }
                }
            });
        },
        del: function (groupId) {
            confirm('确定要删除选中的记录?', function(){
                $.ajax({
                    type: "POST",
                    url: restServerBaseURL + "sys/rolegroup/delete",
                    contentType: "application/json",
                    data: JSON.stringify({roleId:roleId,groupId:groupId}),
                    success: function(r){
                        if(r.code == 0){
                            alert('操作成功', function(){
                                vm.reload(1);
                                if(parent.opener.vm && parent.opener.vm.reload){
                                    parent.opener.vm.reload();
                                }
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        reload: function (type) {
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            var selectedPage =  $("#jqGridWithSelected").jqGrid('getGridParam','page');
            var groupNameWithSelected = $("#groupNameWithSelected").val();  //已选中列表的登陆名称
            var groupName = $("#groupName").val(); //选择列表的登陆名称
            $("#jqGrid").jqGrid('setGridParam',{
                page:(type == 1?page:1),
                postData:{roleId:roleId,groupName:groupName}
            }).trigger("reloadGrid");
            $("#jqGridWithSelected").jqGrid('setGridParam',{
                page:(type == 1?selectedPage:1),
                postData:{roleId:roleId,groupNameWithSelected:groupNameWithSelected}
            }).trigger("reloadGrid");
        },
        resetQueryMsg: function(){
            $("#groupName").val('');
            $("#groupNameWithSelected").val('');
        }
    }
});
 
function jqgridInit(){
    $("#jqGrid").jqGrid({
        url: restServerBaseURL + 'sys/rolegroup/list',
        datatype: "json",
        colModel: [
            { label: '群组ID', name: 'groupId', index: 'groupId', width: 40,align:'center',hidden:true,key:true },
            { label: '群组名称', name: 'groupName', index: 'groupName', width: 40,align:'center'},
            { label: '描述', name: 'description', index: 'description', width: 70,align:'center' },
            { label: '添加', width: 15,align:'center',
                formatter: function(value, grid, rows, state) {
                    var groupId = rows.groupId;
                    var html = '';
                    if(hasPermission('sys:role:edit')) {
                        html = '<a href="#"><span  onmouseover="plusWithYellow(this)" onmouseout="plusWithGreen(this)" style="color: green;font-size:20px" class="glyphicon glyphicon-plus-sign" onclick="vm.add(\'' + groupId + '\')"></span></a> ';
                    }
                    return html;
                }
            }
        ],
        postData:{roleId:roleId},
        viewrecords: true,
        height: "100%",
        rowNum: 10,
        //rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 30,
        autowidth: true,
        multiselect: false,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
    $("#jqGrid").setGridWidth($(window).width()-20);
}
 
function jqgridWithSelectedItemToInit(){
    $("#jqGridWithSelected").setGridWidth($(window).width()-20);
}
 
function plusWithYellow(element){
    $(element).attr("style","color:yellowgreen;font-size:20px");
}
 
function plusWithGreen(element){
    $(element).attr("style","color:green;font-size:20px");
}
 
function minusWithOrange(element){
    $(element).attr("style","color:orange;font-size:20px");
}
 
function minusWithRed(element){
    $(element).attr("style","color:red;font-size:20px");
}