|
|
@@ -29,19 +29,6 @@
|
|
|
</div>
|
|
|
<table id="table"></table>
|
|
|
</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/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>
|
|
|
@@ -82,15 +69,12 @@ $(function() {
|
|
|
maintainSelected: true,
|
|
|
toolbar: '#toolbar',
|
|
|
columns: [
|
|
|
- {field: 'state', checkbox: true},
|
|
|
+ {field: 'ck', checkbox: true},
|
|
|
{field: 'roleId', title: '编号', sortable: true, align: 'center'},
|
|
|
{field: 'name', title: '角色名称'},
|
|
|
{field: 'description', title: '角色描述'},
|
|
|
{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('');
|
|
|
}
|
|
|
// 新增
|
|
|
+var createDialog;
|
|
|
function createAction() {
|
|
|
- $.confirm({
|
|
|
- type: 'dark',
|
|
|
+ createDialog = $.dialog({
|
|
|
animationSpeed: 300,
|
|
|
title: '新增角色',
|
|
|
- content: $('#createDialog').html(),
|
|
|
- buttons: {
|
|
|
- confirm: {
|
|
|
- text: '确认',
|
|
|
- btnClass: 'waves-effect waves-button',
|
|
|
- action: function () {
|
|
|
- $.alert('确认');
|
|
|
- }
|
|
|
- },
|
|
|
- cancel: {
|
|
|
- text: '取消',
|
|
|
- btnClass: 'waves-effect waves-button'
|
|
|
- }
|
|
|
- }
|
|
|
+ content: 'url:${basePath}/manage/role/create'
|
|
|
});
|
|
|
}
|
|
|
// 编辑
|
|
|
+var updateDialog;
|
|
|
function updateAction() {
|
|
|
var rows = $table.bootstrapTable('getSelections');
|
|
|
- if (rows.length == 0) {
|
|
|
+ if (rows.length != 1) {
|
|
|
$.confirm({
|
|
|
title: false,
|
|
|
- content: '请至少选择一条记录!',
|
|
|
+ content: '请选择一条记录!',
|
|
|
autoClose: 'cancel|3000',
|
|
|
backgroundDismiss: true,
|
|
|
buttons: {
|
|
|
@@ -139,28 +111,15 @@ function updateAction() {
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- $.confirm({
|
|
|
- type: 'blue',
|
|
|
+ updateDialog = $.dialog({
|
|
|
animationSpeed: 300,
|
|
|
title: '编辑角色',
|
|
|
- content: $('#createDialog').html(),
|
|
|
- buttons: {
|
|
|
- confirm: {
|
|
|
- text: '确认',
|
|
|
- btnClass: 'waves-effect waves-button',
|
|
|
- action: function () {
|
|
|
- $.alert('确认');
|
|
|
- }
|
|
|
- },
|
|
|
- cancel: {
|
|
|
- text: '取消',
|
|
|
- btnClass: 'waves-effect waves-button'
|
|
|
- }
|
|
|
- }
|
|
|
+ content: 'url:${basePath}/manage/role/update/' + rows[0].roleId
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
// 删除
|
|
|
+var deleteDialog;
|
|
|
function deleteAction() {
|
|
|
var rows = $table.bootstrapTable('getSelections');
|
|
|
if (rows.length == 0) {
|
|
|
@@ -177,7 +136,7 @@ function deleteAction() {
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- $.confirm({
|
|
|
+ deleteDialog = $.confirm({
|
|
|
type: 'red',
|
|
|
animationSpeed: 300,
|
|
|
title: false,
|
|
|
@@ -191,7 +150,63 @@ function deleteAction() {
|
|
|
for (var i in rows) {
|
|
|
ids.push(rows[i].roleId);
|
|
|
}
|
|
|
- $.alert('删除:id=' + ids.join("-"));
|
|
|
+ $.ajax({
|
|
|
+ type: 'get',
|
|
|
+ url: '${basePath}/manage/role/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: {
|