forked from shuzheng/zheng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/topic/create.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<%@ 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="title">标题</label> | ||
<input id="title" type="text" class="form-control" name="title" maxlength="100"> | ||
</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"> | ||
<label for="url">链接</label> | ||
<input id="url" type="text" class="form-control" name="url" maxlength="100"> | ||
</div> | ||
<div class="form-group text-right dialog-buttons"> | ||
<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/topic/create', | ||
data: $('#createForm').serialize(), | ||
beforeSend: function() { | ||
if ($('#title').val() == '') { | ||
$('#title').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> |
216 changes: 216 additions & 0 deletions
216
zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/manage/topic/index.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
<%@ 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}"/> | ||
<!DOCTYPE HTML> | ||
<html lang="zh-cn"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>专题管理</title> | ||
<jsp:include page="/resources/inc/head.jsp" flush="true"/> | ||
</head> | ||
<body> | ||
<div id="main"> | ||
<div id="toolbar"> | ||
<shiro:hasPermission name="cms:topic:create"><a class="waves-effect waves-button" href="javascript:;" onclick="createAction()"><i class="zmdi zmdi-plus"></i> 新增专题</a></shiro:hasPermission> | ||
<shiro:hasPermission name="cms:topic:update"><a class="waves-effect waves-button" href="javascript:;" onclick="updateAction()"><i class="zmdi zmdi-edit"></i> 编辑专题</a></shiro:hasPermission> | ||
<shiro:hasPermission name="cms:topic:delete"><a class="waves-effect waves-button" href="javascript:;" onclick="deleteAction()"><i class="zmdi zmdi-close"></i> 删除专题</a></shiro:hasPermission> | ||
</div> | ||
<table id="table"></table> | ||
</div> | ||
<jsp:include page="/resources/inc/footer.jsp" flush="true"/> | ||
<script> | ||
var $table = $('#table'); | ||
$(function() { | ||
// bootstrap table初始化 | ||
$table.bootstrapTable({ | ||
url: '${basePath}/manage/topic/list', | ||
height: getHeight(), | ||
striped: true, | ||
search: true, | ||
showRefresh: true, | ||
showColumns: true, | ||
minimumCountColumns: 2, | ||
clickToSelect: true, | ||
detailView: true, | ||
detailFormatter: 'detailFormatter', | ||
pagination: true, | ||
paginationLoop: false, | ||
sidePagination: 'server', | ||
silentSort: false, | ||
smartDisplay: false, | ||
escape: true, | ||
searchOnEnterKey: true, | ||
idField: 'pageId', | ||
maintainSelected: true, | ||
toolbar: '#toolbar', | ||
columns: [ | ||
{field: 'ck', checkbox: true}, | ||
{field: 'topicId', title: '编号', sortable: true, align: 'center'}, | ||
{field: 'title', title: '标题'}, | ||
{field: 'description', title: '描述'}, | ||
{field: 'url', title: '链接'}, | ||
{field: 'ctime', title: '创建时间', formatter: 'timeFormatter'}, | ||
{field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents', clickToSelect: false} | ||
] | ||
}); | ||
}); | ||
// 格式化操作按钮 | ||
function actionFormatter(value, row, index) { | ||
return [ | ||
'<a class="update" href="javascript:;" onclick="updateAction()" data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a> ', | ||
'<a class="delete" href="javascript:;" onclick="deleteAction()" data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>' | ||
].join(''); | ||
} | ||
// 格式化时间 | ||
function timeFormatter(value , row, index) { | ||
return new Date(value).toLocaleString(); | ||
} | ||
// 新增 | ||
var createDialog; | ||
function createAction() { | ||
createDialog = $.dialog({ | ||
animationSpeed: 300, | ||
title: '新增专题', | ||
content: 'url:${basePath}/manage/topic/create', | ||
onContentReady: function () { | ||
initMaterialInput(); | ||
} | ||
}); | ||
} | ||
// 编辑 | ||
var updateDialog; | ||
function updateAction() { | ||
var rows = $table.bootstrapTable('getSelections'); | ||
if (rows.length != 1) { | ||
$.confirm({ | ||
title: false, | ||
content: '请选择一条记录!', | ||
autoClose: 'cancel|3000', | ||
backgroundDismiss: true, | ||
buttons: { | ||
cancel: { | ||
text: '取消', | ||
btnClass: 'waves-effect waves-button' | ||
} | ||
} | ||
}); | ||
} else { | ||
updateDialog = $.dialog({ | ||
animationSpeed: 300, | ||
title: '编辑专题', | ||
content: 'url:${basePath}/manage/topic/update/' + rows[0].topicId, | ||
onContentReady: function () { | ||
initMaterialInput(); | ||
} | ||
}); | ||
} | ||
} | ||
// 删除 | ||
var deleteDialog; | ||
function deleteAction() { | ||
var rows = $table.bootstrapTable('getSelections'); | ||
if (rows.length == 0) { | ||
$.confirm({ | ||
title: false, | ||
content: '请至少选择一条记录!', | ||
autoClose: 'cancel|3000', | ||
backgroundDismiss: true, | ||
buttons: { | ||
cancel: { | ||
text: '取消', | ||
btnClass: 'waves-effect waves-button' | ||
} | ||
} | ||
}); | ||
} else { | ||
deleteDialog = $.confirm({ | ||
type: 'red', | ||
animationSpeed: 300, | ||
title: false, | ||
content: '确认删除该专题吗?', | ||
buttons: { | ||
confirm: { | ||
text: '确认', | ||
btnClass: 'waves-effect waves-button', | ||
action: function () { | ||
var ids = new Array(); | ||
for (var i in rows) { | ||
ids.push(rows[i].topicId); | ||
} | ||
$.ajax({ | ||
type: 'get', | ||
url: '${basePath}/manage/topic/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: { | ||
text: '取消', | ||
btnClass: 'waves-effect waves-button' | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.