You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
4.9 KiB
186 lines
4.9 KiB
$(function () {
|
|
$("#jqGrid").jqGrid({
|
|
url: '../${pathName}/list',
|
|
datatype: "json",
|
|
colModel: [
|
|
#foreach($column in $columns)
|
|
#if($column.columnName == $pk.columnName)
|
|
{
|
|
label: '${column.attrname}',
|
|
name: '${column.attrname}',
|
|
index: '${column.columnName}',
|
|
width: 50,
|
|
key: true,
|
|
hidden: true,
|
|
formatter: function (v, a, r) {
|
|
return "<a onclick='vm.info(\"" + r.id + "\")'>" + v + " </a>"
|
|
}
|
|
},
|
|
#elseif($column.columnName == 'user')
|
|
{
|
|
label: '${column.comments}',
|
|
name: 'sysUserEntity.username',
|
|
index: 'sysUserEntity.username',
|
|
width: 80
|
|
},
|
|
#else
|
|
{
|
|
label: '${column.comments}',
|
|
name: '${column.attrname}',
|
|
index: '${column.columnName}',
|
|
width: 80
|
|
}#if($velocityCount != $columns.size()), #end
|
|
|
|
#end
|
|
#end],
|
|
viewrecords: true,
|
|
height: 385,
|
|
rowNum: 10,
|
|
rowList: [10, 30, 50],
|
|
rownumbers: true,
|
|
rownumWidth: 25,
|
|
autowidth: true,
|
|
multiselect: true,
|
|
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 vm = new Vue({
|
|
el: '#rrapp',
|
|
data: {
|
|
q: {
|
|
${columns[1].attrname} : ''
|
|
},
|
|
showAdd : false,
|
|
showInfo : false,
|
|
showList: true,
|
|
title: null,
|
|
${classname}: {
|
|
},
|
|
},
|
|
created:function () {
|
|
|
|
},
|
|
methods: {
|
|
query: function () {
|
|
vm.reload();
|
|
}
|
|
,
|
|
add: function () {
|
|
vm.showAdd = true;
|
|
vm.showList = false;
|
|
vm.title = "新增";
|
|
vm.${classname} = {};
|
|
}
|
|
,
|
|
update: function (event) {
|
|
var $pk.attrname =
|
|
getSelectedRow();
|
|
if ($pk.attrname== null
|
|
)
|
|
{
|
|
return;
|
|
}
|
|
|
|
vm.showAdd = true;
|
|
vm.showList = false;
|
|
vm.title = "修改";
|
|
|
|
vm.getInfo(${pk.attrname})
|
|
}
|
|
,
|
|
saveOrUpdate: function (event) {
|
|
var url = vm
|
|
.${classname}.${pk.attrname} ==
|
|
null ? "../${pathName}/save" : "../${pathName}/update";
|
|
$.ajax({
|
|
type: "POST",
|
|
url: url,
|
|
data: JSON.stringify(vm.${classname}),
|
|
success: function (r) {
|
|
if (r.code === 0) {
|
|
alert('操作成功', function (index) {
|
|
vm.reload();
|
|
});
|
|
} else {
|
|
alert(r.msg);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
,
|
|
del: function (event) {
|
|
var ${pk.attrname}s = getSelectedRows();
|
|
if (${pk.attrname}s == null) {
|
|
return;
|
|
}
|
|
|
|
confirm('确定要删除选中的记录?', function () {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "../${pathName}/delete",
|
|
data: JSON.stringify(${pk.attrname}s),
|
|
success: function (r) {
|
|
if (r.code == 0) {
|
|
alert('操作成功', function (index) {
|
|
$("#jqGrid").trigger("reloadGrid");
|
|
});
|
|
} else {
|
|
alert(r.msg);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
,
|
|
getInfo: function (${pk.attrname}) {
|
|
$.get("../${pathName}/info/" +${pk.attrname}, function (r) {
|
|
vm.${classname} = r.${classname};
|
|
});
|
|
}
|
|
,
|
|
info : function ($pk.attrname) {
|
|
if (isNaN($pk.attrname)) {
|
|
$pk.attrname
|
|
= getSelectedRow();
|
|
if ($pk.attrname== null
|
|
)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
vm.showAdd = false;
|
|
vm.showList = false;
|
|
vm.showInfo = true;
|
|
vm.title = "详情";
|
|
|
|
vm.getInfo(${pk.attrname})
|
|
}
|
|
,
|
|
reload: function (event) {
|
|
vm.showList = true;
|
|
vm.showInfo = false;
|
|
vm.showAdd = false;
|
|
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
|
|
$("#jqGrid").jqGrid('setGridParam', {
|
|
postData: vm.q,
|
|
page: page
|
|
}).trigger("reloadGrid");
|
|
}
|
|
}
|
|
}); |