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
| $(function () {
| $("#jqGrid").jqGrid({
| url: restServerBaseURL + 'sys/roleresource/list',
| datatype: "json",
| colModel: [
| { label: 'roleId', name: 'roleId', index: 'ROLEID', width: 50,align:'center' },
| { label: '资源ID', name: 'resourceId', index: 'RESOURCEID', width: 80,key: true,align:'center' },
| { label: '记录添加人中文名', name: 'rCreateUser', index: 'RCREATEUSER', width: 80,align:'center' },
| { label: '记录添加时间', name: 'rCreateDate', index: 'RCREATEDATE', width: 80,align:'center' },
| { label: '操作', width: 40,align:'center',
| formatter: function(value, grid, rows, state) {
| var resourceId = rows.resourceId;
| var html = '';
| //if(hasPermission('sys:userrole:update')) {
| html += '<input type="button" style="padding:2px;margin-left: 5px;" class="btn btn-warning" onclick="vm.update(\'' + resourceId + '\')" value="编辑">';
| //}
| //if(hasPermission('sys:userrole:delete')) {
| html += '<input type="button" style="padding:2px;margin-left: 5px;" class="btn btn-danger" onclick="vm.del(\'' + resourceId + '\')" value="删除">';
| //}
| return html;
| }
| }
| ],
| postData:{roleId:roleId},
| viewrecords: true,
| height: "auto",
| rowNum: 10,
| //rowList : [10,30,50],
| rownumbers: true,
| rownumWidth: 25,
| 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" });
| }
| });
| });
|
| var local = window.location.href;
| var roleId = local.substring(local.lastIndexOf('=') + 1, local.length);
|
| var vm = new Vue({
| el:'#rapp',
| data:{
| showList: true,
| title: null,
| roleResource: {roleId : roleId}
| },
| methods: {
| query: function () {
| vm.reload();
| },
| add: function(){
| vm.showList = false;
| vm.title = "新增";
| vm.roleResource = {roleId : roleId};
| },
| update: function (resourceId) {
| //var resourceId = getSelectedRow();
| if(resourceId == null){
| return ;
| }
| vm.showList = false;
| vm.title = "编辑";
|
| vm.getInfo(resourceId);
| },
| saveOrUpdate: function () {
| var url = vm.roleResource.rCreateUser == null ? "sys/roleresource/save" : "sys/roleresource/update";
| $.ajax({
| type: "POST",
| url: restServerBaseURL + url,
| contentType: "application/json",
| data: JSON.stringify(vm.roleResource),
| success: function(r){
| if(r.code === 0){
| alert('操作成功', function(){
| vm.reload();
| });
| }else{
| alert(r.msg);
| }
| }
| });
| },
| del: function (resourceIds) {
| //var resourceIds = getSelectedRows();
| if(resourceIds == null){
| return ;
| }
| var resourcesRoleIds = [resourceIds]; //规则:除了最后一个存放roleId外,其余的都是resourceId
| resourcesRoleIds.push(roleId);
| confirm('确定要删除选中的记录?', function(){
| $.ajax({
| type: "POST",
| url: restServerBaseURL + "sys/roleresource/delete",
| contentType: "application/json",
| data: JSON.stringify(resourcesRoleIds),
| success: function(r){
| if(r.code == 0){
| alert('操作成功', function(){
| vm.reload();
| });
| }else{
| alert(r.msg);
| }
| }
| });
| });
| },
| getInfo: function(resourceId,roleId){
| $.get(restServerBaseURL + "sys/roleresource/info?resourceid=" + resourceId + "&roleid=" + vm.roleResource.roleId, function(r){
| vm.roleResource = r.roleResource;
| });
| },
| reload: function () {
| vm.showList = true;
| var page = $("#jqGrid").jqGrid('getGridParam','page');
| //点击查询时,当前页设置为第一页
| $("#jqGrid").jqGrid('setGridParam',{
| page:1
| }).trigger("reloadGrid");
| },
| refresh: function () {
| vm.showList = true;
| window.location.reload();
| }
| }
| });
|
|