完成系统管理

This commit is contained in:
shuzheng 2017-02-19 00:16:50 +08:00
parent d75111734b
commit e42fa328b6
3 changed files with 263 additions and 57 deletions

View File

@ -7,22 +7,110 @@
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<div id="createDialog" class="crudDialog">
<form action="${basePath}/manage/system/create" method="post">
<form id="createForm" method="post">
<div class="form-group">
<label for="input1">标</label>
<input id="input1" type="text" class="form-control">
<label for="icon">标</label>
<input id="icon" type="text" class="form-control" name="icon" maxlength="20">
</div>
<div class="form-group">
<label for="input2">名称</label>
<input id="input2" type="text" class="form-control">
<label for="title">标题</label>
<input id="title" type="text" class="form-control" name="title" maxlength="20">
</div>
<div class="form-group">
<label for="input3">根目录</label>
<input id="input3" type="text" class="form-control">
<label for="name">名称</label>
<input id="name" type="text" class="form-control" name="name" maxlength="20">
</div>
<div class="form-group">
<label for="input4">图标</label>
<input id="input4" type="text" class="form-control">
<label for="description">描述</label>
<input id="description" type="text" class="form-control" name="description" maxlength="300">
</div>
<div class="form-group">
<label for="basepath">根目录</label>
<input id="basepath" type="text" class="form-control" name="basepath" maxlength="100">
</div>
<div>
<label class="checkbox-inline">
<label for="status_1"><input id="status_1" type="radio" name="status" value="1" checked> 正常</label>
</label>
<label class="checkbox-inline">
<label for="status_0"><input id="status_0" type="radio" name="status" value="-1"> 锁定</label>
</label>
</div>
<div class="form-group text-right">
<a class="waves-effect waves-button" href="javascript:;" onclick="createSubmit();">保存</a>
<a class="waves-effect waves-button" href="javascript:;" onclick="createDialog.close();">取消</a>
</div>
</form>
</div>
</div>
<script>
function createSubmit() {
$.ajax({
type: 'post',
url: '${basePath}/manage/system/create',
data: $('#createForm').serialize(),
beforeSend: function() {
if ($('#title').val() == '') {
$('#title').focus();
return false;
}
if ($('#name').val() == '') {
$('#name').focus();
return false;
}
},
success: function(result) {
if (result.code != 1) {
if (result.data instanceof Array) {
$.each(result.data, function(index, value) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: value.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
});
} else {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: result.data.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
} else {
createDialog.close();
$table.bootstrapTable('refresh');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: textStatus,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
});
}
</script>

View File

@ -69,7 +69,7 @@ $(function() {
maintainSelected: true,
toolbar: '#toolbar',
columns: [
{field: 'state', checkbox: true},
{field: 'ck', checkbox: true},
{field: 'systemId', title: '编号', sortable: true, align: 'center'},
{field: 'icon', title: '图标', sortable: true, align: 'center', formatter: 'iconFormatter'},
{field: 'title', title: '系统标题'},
@ -78,9 +78,6 @@ $(function() {
{field: 'status', title: '状态', sortable: true, align: 'center', formatter: 'statusFormatter'},
{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
]
}).on('all.bs.table', function (e, name, args) {
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
});
});
// 格式化操作按钮
@ -103,27 +100,16 @@ function statusFormatter(value, row, index) {
}
}
// 新增
var createDialog;
function createAction() {
$.confirm({
createDialog = $.dialog({
animationSpeed: 300,
title: '新增系统',
content: 'url:${basePath}/manage/system/create',
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button',
action: function () {
console.log(this.find('form').html());
}
},
cancel: {
text: '取消',
btnClass: 'waves-effect waves-button'
}
}
content: 'url:${basePath}/manage/system/create'
});
}
// 编辑
var updateDialog;
function updateAction() {
var rows = $table.bootstrapTable('getSelections');
if (rows.length != 1) {
@ -140,27 +126,15 @@ function updateAction() {
}
});
} else {
$.confirm({
updateDialog = $.dialog({
animationSpeed: 300,
title: '编辑系统',
content: 'url:${basePath}/manage/system/update/' + rows[0].systemId,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button',
action: function () {
$.alert('确认');
}
},
cancel: {
text: '取消',
btnClass: 'waves-effect waves-button'
}
}
content: 'url:${basePath}/manage/system/update/' + rows[0].systemId
});
}
}
// 删除
var deleteDialog;
function deleteAction() {
var rows = $table.bootstrapTable('getSelections');
if (rows.length == 0) {
@ -177,7 +151,7 @@ function deleteAction() {
}
});
} else {
$.confirm({
deleteDialog = $.confirm({
type: 'red',
animationSpeed: 300,
title: false,
@ -191,7 +165,63 @@ function deleteAction() {
for (var i in rows) {
ids.push(rows[i].systemId);
}
$.alert('删除id=' + ids.join("-"));
$.ajax({
type: 'get',
url: '${basePath}/manage/system/delete/' + ids.join("-"),
success: function(result) {
if (result.code != 1) {
if (result.data instanceof Array) {
$.each(result.data, function(index, value) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: value.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
});
} else {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: result.data.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
} else {
deleteDialog.close();
$table.bootstrapTable('refresh');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: textStatus,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
});
}
},
cancel: {

View File

@ -6,23 +6,111 @@
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<div id="updateDialog" class="crudDialog">
<form action="${basePath}/manage/system/update" method="post">
<div id="createDialog" class="crudDialog">
<form id="createForm" method="post">
<div class="form-group">
<label for="input1">标</label>
<input id="input1" type="text" class="form-control">
<label for="icon">标</label>
<input id="icon" type="text" class="form-control" name="icon" maxlength="20" value="${system.icon}">
</div>
<div class="form-group">
<label for="input2">名称</label>
<input id="input2" type="text" class="form-control">
<label for="title">标题</label>
<input id="title" type="text" class="form-control" name="title" maxlength="20" value="${system.title}">
</div>
<div class="form-group">
<label for="input3">根目录</label>
<input id="input3" type="text" class="form-control">
<label for="name">名称</label>
<input id="name" type="text" class="form-control" name="name" maxlength="20" value="${system.name}">
</div>
<div class="form-group">
<label for="input4">图标</label>
<input id="input4" type="text" class="form-control">
<label for="description">描述</label>
<input id="description" type="text" class="form-control" name="description" maxlength="300" value="${system.description}">
</div>
<div class="form-group">
<label for="basepath">根目录</label>
<input id="basepath" type="text" class="form-control" name="basepath" maxlength="100" value="${system.basepath}">
</div>
<div>
<label class="checkbox-inline">
<label for="status_1"><input id="status_1" type="radio" name="status" value="1" <c:if test="${system.status==1}">checked</c:if>> 正常</label>
</label>
<label class="checkbox-inline">
<label for="status_0"><input id="status_0" type="radio" name="status" value="-1" <c:if test="${system.status!=1}">checked</c:if>> 锁定</label>
</label>
</div>
<div class="form-group text-right">
<a class="waves-effect waves-button" href="javascript:;" onclick="createSubmit();">保存</a>
<a class="waves-effect waves-button" href="javascript:;" onclick="updateDialog.close();">取消</a>
</div>
</form>
</div>
</div>
<script>
function createSubmit() {
$.ajax({
type: 'post',
url: '${basePath}/manage/system/update/${system.systemId}',
data: $('#createForm').serialize(),
beforeSend: function() {
if ($('#title').val() == '') {
$('#title').focus();
return false;
}
if ($('#name').val() == '') {
$('#name').focus();
return false;
}
},
success: function(result) {
if (result.code != 1) {
if (result.data instanceof Array) {
$.each(result.data, function(index, value) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: value.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
});
} else {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: result.data.errorMsg,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
} else {
updateDialog.close();
$table.bootstrapTable('refresh');
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$.confirm({
theme: 'dark',
animation: 'rotateX',
closeAnimation: 'rotateX',
title: false,
content: textStatus,
buttons: {
confirm: {
text: '确认',
btnClass: 'waves-effect waves-button waves-light'
}
}
});
}
});
}
</script>