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
$(function () {
    initSystemName();
    var appid = getAppId()!=null?getAppId():null;
    $("#jqGrid").jqGrid({
        url: restServerBaseURL + 'sys/resource/list',
        datatype: "json",
        colModel: [            
            { label: 'resourceid', name: 'resourceid', index: 'RESOURCEID', width: 50, key: true,hidden:true },
            { label: '所属系统', name: 'systemName', index: 'systemName', width: 50,align:'center' }, 
            { label: '资源名称', name: 'resourcername', index: 'RESOURCERNAME', width: 50,align:'center' }, 
            { label: '资源编码', name: 'resourcercode', index: 'RESOURCERCODE', width: 50,align:'center' },                     
            { label: '操作', width: 40,align:'center',sortable:false,formatter:function(value,grid,rows,state){
                var resourceid=rows.resourceid,html="";
                if(hasPermission('sys:resource:edit')){
                    html += '<input type="button" id="action"  class="btn btn-warning" value="编辑" style="margin-right:5px;padding:3px 6px;" onclick=vm.update("'+resourceid+'")>';
                    html += '<input type="button" id="del"  class="btn btn-danger" value="删除" style="padding:3px 6px;" onclick="vm.del(\'' + resourceid + '\')">';
                }
                return html;
              }
            }        
        ],
        postData:{'appid':appid},
        viewrecords: true,
        height: "auto",
        rowNum: 10,
        //rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 50, 
        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" }); 
        },
        onSortCol:function(index,colindex,sortorder){
            jQuery("#jqGrid").jqGrid('setGridParam',{
                page:$(".ui-pg-input").val()
            });
        }
    });
    $("#jqGrid").jqGrid('setLabel','rn','序号',{'text-align':'left'},'');
});
 
var local=window.location.href;
var resourceid=local.substring(local.lastIndexOf('=')+1,local.length);
 
var vm = new Vue({
    el:'#rapp',
    data:{
        showList: true,
        title: null,
        resource: {}
    },
    methods: {
        query: function () {
            vm.resource.resourcername = $("#resourcername").val();
            vm.resource.appid =  $("#selectId").val();
            vm.resource.resourcercode =  $("#resourcercode").val();
            vm.reload();
        },
        add: function(){
            vm.title = "新增";
            window.open(baseURL + "admin/modules/sys/resource_edit.html", "_blank");
        },
        update: function (resourceid) {
            vm.title = "修改";
            window.open(baseURL + "admin/modules/sys/resource_edit.html?Id=" + resourceid, "_blank");
        },
        
        back:function(){
            window.location.href=baseURL+"/admin/modules/sys/systeminfo.html";
        },
        
        saveOrUpdate: function () {
            var url = vm.resource.resourceid == null ? "sys/resource/save" : "sys/resource/update";
            $.ajax({
                type: "POST",
                url: restServerBaseURL + url,
                contentType: "application/json",
                data: JSON.stringify(vm.resource),
                success: function(r){
                    if(r.code === 0){
                        alert('操作成功', function(){
                            vm.reload();
                        });
                    }else{
                        alert(r.msg);
                    }
                }
            });
        },
        del: function (resourceid) {
            confirm('确定要删除选中的记录?', function(){
                $.ajax({
                    type: "POST",
                    url: restServerBaseURL + "sys/resource/delete",
                    contentType: "application/json",
                    data: "["+resourceid+"]",
                    success: function(r){
                        if(r.code == 0){
                            alert('操作成功', function(){
                                vm.reload(1);
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            });
        },
        getInfo: function(resourceid){
            $.get(restServerBaseURL + "sys/resource/info/"+resourceid, function(r){
                vm.resource = r.resource;
            });
        },
        reload: function (type) {
            if (type == 1) {
                $(":input").val('');
            }
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            //点击查询时,当前页设置为第一页
            $("#jqGrid").jqGrid('setGridParam',{ 
                postData:{
                    'resourcername':vm.resource.resourcername,
                    'appid':vm.resource.appid,
                    'resourcercode':vm.resource.resourcercode
                },
                page:1
            }).trigger("reloadGrid");
        },
        refresh: function () {
            vm.showList = true;
            window.location.reload();
        }
    }
});
 
function initSystemName() {
    var local=window.location.href;
    $.ajax({
        type: "GET",
        url: restServerBaseURL + "sys/systeminfo/queryListAll",
        contentType: "application/json",
        success: function(msg) {
            var systemList = msg.systemList;
            jQuery("#selectId").append("<option value=''>--请选择--</option>");
            jQuery.each(systemList, function(i, item) {
                jQuery("#selectId").append("<option value=" + item.appid + ">" + item.appfullname + "</option>");
            });
            if (getAppId()!=null) {
                jQuery("#selectId").val(getAppId());
            }
        }
    });
}