完成组织管理
This commit is contained in:
parent
f8cf93aebd
commit
fd92c9d9cc
|
@ -0,0 +1,92 @@
|
||||||
|
<%@ page contentType="text/html; charset=utf-8"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ 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="createDialog" class="crudDialog">
|
||||||
|
<form id="createForm" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">名称</label>
|
||||||
|
<input id="name" type="text" class="form-control" name="name" maxlength="20">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description">描述</label>
|
||||||
|
<input id="description" type="text" class="form-control" name="description" maxlength="300">
|
||||||
|
</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>
|
||||||
|
<script>
|
||||||
|
function createSubmit() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
url: '${basePath}/manage/organization/create',
|
||||||
|
data: $('#createForm').serialize(),
|
||||||
|
beforeSend: function() {
|
||||||
|
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>
|
|
@ -29,19 +29,6 @@
|
||||||
</div>
|
</div>
|
||||||
<table id="table"></table>
|
<table id="table"></table>
|
||||||
</div>
|
</div>
|
||||||
<!-- 新增 -->
|
|
||||||
<div id="createDialog" class="crudDialog" hidden>
|
|
||||||
<form>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="input1">名称</label>
|
|
||||||
<input id="input1" type="text" class="form-control">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="input2">描述</label>
|
|
||||||
<input id="input2" type="text" class="form-control">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<script src="${basePath}/resources/zheng-ui/plugins/jquery.1.12.4.min.js"></script>
|
<script src="${basePath}/resources/zheng-ui/plugins/jquery.1.12.4.min.js"></script>
|
||||||
<script src="${basePath}/resources/zheng-ui/plugins/bootstrap-3.3.0/js/bootstrap.min.js"></script>
|
<script src="${basePath}/resources/zheng-ui/plugins/bootstrap-3.3.0/js/bootstrap.min.js"></script>
|
||||||
<script src="${basePath}/resources/zheng-ui/plugins/bootstrap-table-1.11.0/bootstrap-table.min.js"></script>
|
<script src="${basePath}/resources/zheng-ui/plugins/bootstrap-table-1.11.0/bootstrap-table.min.js"></script>
|
||||||
|
@ -82,15 +69,12 @@ $(function() {
|
||||||
maintainSelected: true,
|
maintainSelected: true,
|
||||||
toolbar: '#toolbar',
|
toolbar: '#toolbar',
|
||||||
columns: [
|
columns: [
|
||||||
{field: 'state', checkbox: true},
|
{field: 'ck', checkbox: true},
|
||||||
{field: 'organizationId', title: '编号', sortable: true, align: 'center'},
|
{field: 'organizationId', title: '编号', sortable: true, align: 'center'},
|
||||||
{field: 'name', title: '组织名称'},
|
{field: 'name', title: '组织名称'},
|
||||||
{field: 'description', title: '组织描述'},
|
{field: 'description', title: '组织描述'},
|
||||||
{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false}
|
{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();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// 格式化操作按钮
|
// 格式化操作按钮
|
||||||
|
@ -101,34 +85,22 @@ function actionFormatter(value, row, index) {
|
||||||
].join('');
|
].join('');
|
||||||
}
|
}
|
||||||
// 新增
|
// 新增
|
||||||
|
var createDialog;
|
||||||
function createAction() {
|
function createAction() {
|
||||||
$.confirm({
|
createDialog = $.dialog({
|
||||||
type: 'dark',
|
|
||||||
animationSpeed: 300,
|
animationSpeed: 300,
|
||||||
title: '新增组织',
|
title: '新增组织',
|
||||||
content: $('#createDialog').html(),
|
content: 'url:${basePath}/manage/organization/create'
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
text: '确认',
|
|
||||||
btnClass: 'waves-effect waves-button',
|
|
||||||
action: function () {
|
|
||||||
$.alert('确认');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
text: '取消',
|
|
||||||
btnClass: 'waves-effect waves-button'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 编辑
|
// 编辑
|
||||||
|
var updateDialog;
|
||||||
function updateAction() {
|
function updateAction() {
|
||||||
var rows = $table.bootstrapTable('getSelections');
|
var rows = $table.bootstrapTable('getSelections');
|
||||||
if (rows.length == 0) {
|
if (rows.length != 1) {
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: false,
|
title: false,
|
||||||
content: '请至少选择一条记录!',
|
content: '请选择一条记录!',
|
||||||
autoClose: 'cancel|3000',
|
autoClose: 'cancel|3000',
|
||||||
backgroundDismiss: true,
|
backgroundDismiss: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
@ -139,28 +111,15 @@ function updateAction() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.confirm({
|
updateDialog = $.dialog({
|
||||||
type: 'blue',
|
|
||||||
animationSpeed: 300,
|
animationSpeed: 300,
|
||||||
title: '编辑组织',
|
title: '编辑组织',
|
||||||
content: $('#createDialog').html(),
|
content: 'url:${basePath}/manage/organization/update/' + rows[0].organizationId
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
text: '确认',
|
|
||||||
btnClass: 'waves-effect waves-button',
|
|
||||||
action: function () {
|
|
||||||
$.alert('确认');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
text: '取消',
|
|
||||||
btnClass: 'waves-effect waves-button'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除
|
// 删除
|
||||||
|
var deleteDialog;
|
||||||
function deleteAction() {
|
function deleteAction() {
|
||||||
var rows = $table.bootstrapTable('getSelections');
|
var rows = $table.bootstrapTable('getSelections');
|
||||||
if (rows.length == 0) {
|
if (rows.length == 0) {
|
||||||
|
@ -177,7 +136,7 @@ function deleteAction() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.confirm({
|
deleteDialog = $.confirm({
|
||||||
type: 'red',
|
type: 'red',
|
||||||
animationSpeed: 300,
|
animationSpeed: 300,
|
||||||
title: false,
|
title: false,
|
||||||
|
@ -191,7 +150,63 @@ function deleteAction() {
|
||||||
for (var i in rows) {
|
for (var i in rows) {
|
||||||
ids.push(rows[i].organizationId);
|
ids.push(rows[i].organizationId);
|
||||||
}
|
}
|
||||||
$.alert('删除:id=' + ids.join("-"));
|
$.ajax({
|
||||||
|
type: 'get',
|
||||||
|
url: '${basePath}/manage/organization/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: {
|
cancel: {
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
<%@ page contentType="text/html; charset=utf-8"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||||
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ 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 id="updateForm" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="name">名称</label>
|
||||||
|
<input id="name" type="text" class="form-control" name="name" maxlength="20" value="${organization.name}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description">描述</label>
|
||||||
|
<input id="description" type="text" class="form-control" name="description" maxlength="300" value="${organization.description}">
|
||||||
|
</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>
|
||||||
|
<script>
|
||||||
|
function createSubmit() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'post',
|
||||||
|
url: '${basePath}/manage/organization/update/${organization.organizationId}',
|
||||||
|
data: $('#updateForm').serialize(),
|
||||||
|
beforeSend: function() {
|
||||||
|
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>
|
Loading…
Reference in New Issue