$(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());
|
}
|
}
|
});
|
}
|