322 lines
11 KiB
Plaintext
322 lines
11 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||
<style type="text/css">
|
||
.select2-container .select2-selection--single {
|
||
height: 34px;
|
||
line-height: 34px;
|
||
}
|
||
|
||
.select2-selection__arrow {
|
||
margin-top: 3px;
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
var showMenu4SelectFun = function () {
|
||
$.post(ext.contextPath + '/user/showMenu4Select.do', { formId: "subForm", hiddenId: "pid", textId: "_pname" }, function (data) {
|
||
$("#menu4SelectDiv").html(data);
|
||
openModal("menu4SelectModal")
|
||
});
|
||
};
|
||
function dosave() {
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/user/updateMenu.do", $("#subForm").serialize(), function (result) {
|
||
if (result == 1) {
|
||
showAlert('s', '保存成功');
|
||
} else {
|
||
showAlert('d', '保存失败');
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
$("#subForm").bootstrapValidator({
|
||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||
fields: {
|
||
name: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '名称不能为空'
|
||
}
|
||
}
|
||
},
|
||
_pname: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '上级菜单不能为空'
|
||
}
|
||
}
|
||
},
|
||
morder: {
|
||
validators: {
|
||
notEmpty: {
|
||
message: '顺序不能为空'
|
||
},
|
||
regexp: {
|
||
regexp: /^[0-9]*$/,
|
||
message: '顺序必须为数字'
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
function saveDefault() {
|
||
if ($("#location").val() == '') {
|
||
showAlert('i', '请先填写菜单地址')
|
||
} else {
|
||
//if ($(".form").form('validate')) {
|
||
$.post(ext.contextPath + "/user/saveDefaultFunc.do", $("#subForm").serialize(), function (result) {
|
||
if (result > 0) {
|
||
$("#table").bootstrapTable('refresh');
|
||
} else {
|
||
showAlert('d', '默认权限添加失败', 'alertDiv_power');
|
||
}
|
||
});
|
||
//}
|
||
}
|
||
}
|
||
|
||
function dodel() {
|
||
|
||
swal({
|
||
text: "您确定要删除此记录?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function (willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/user/deleteMenu.do', $("#subForm").serialize(), function (data) {
|
||
if (data.res > 0) {
|
||
initTreeView();
|
||
} else {
|
||
showAlert('d', '删除失败');
|
||
}
|
||
}, 'json');
|
||
|
||
}
|
||
});
|
||
}
|
||
function delPowerFun(id) {
|
||
|
||
swal({
|
||
text: "您确定要删除此记录?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function (willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/user/deleteMenu.do', { id: id }, function (data) {
|
||
if (data.res > 0) {
|
||
$("#table").bootstrapTable('refresh');
|
||
} else {
|
||
showAlert('d', '删除失败', 'alertDiv_power');
|
||
}
|
||
}, 'json');
|
||
|
||
}
|
||
});
|
||
}
|
||
var addPowerFun = function () {
|
||
$.post(ext.contextPath + '/user/showFuncAdd.do', { pid: "${menu.id}" }, function (data) {
|
||
$("#powerDiv").html(data);
|
||
openModal('powerModal')
|
||
});
|
||
};
|
||
var editPowerFun = function (id) {
|
||
$.post(ext.contextPath + '/user/showFuncEdit.do', { id: id }, function (data) {
|
||
$("#powerDiv").html(data);
|
||
openModal('powerModal')
|
||
});
|
||
};
|
||
$(function () {
|
||
$("#active").select2({ minimumResultsForSearch: 10 }).val("${menu.active}").trigger("change");
|
||
//$("#target").select2({ minimumResultsForSearch: 10 }).val("${menu.target}").trigger("change");
|
||
$("#table").bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/user/getFuncJson.do?id=${menu.id}', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20, 50], // 设置页面可以显示的数据条数
|
||
pageSize: 50, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
queryParams: function (params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||
return {
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order // 排序规则
|
||
}
|
||
},
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
field: 'name', // 返回json数据中的name
|
||
title: '名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, {
|
||
field: 'location', // 返回json数据中的name
|
||
title: '路径', // 表格表头显示文字
|
||
align: 'left', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, {
|
||
field: 'pid', // 返回json数据中的name
|
||
title: '所属菜单', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
formatter: function (value, row, index) {
|
||
return row._pname;
|
||
},
|
||
}, {
|
||
field: 'active', // 返回json数据中的name
|
||
title: '状态', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, {
|
||
title: "操作",
|
||
align: 'center',
|
||
valign: 'middle',
|
||
width: 100, // 定义列的宽度,单位为像素px
|
||
formatter: function (value, row, index) {
|
||
return '<div class="btn-group"><button class="btn btn-default btn-sm" onclick="editPowerFun(\'' + row.id + '\')"><i class="fa fa-edit"></i></button>' +
|
||
'<button class="btn btn-default btn-sm" onclick="delPowerFun(\'' + row.id + '\')"><i class="fa fa-trash-o"></i></button></div>';
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
$(".bs-checkbox").css({ 'text-align': 'center', 'vertical-align': 'middle' })
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
})
|
||
});
|
||
</script>
|
||
<div class="box box-primary">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">详情</h3>
|
||
|
||
<div class="box-tools pull-right">
|
||
<a onclick="dosave()" class="btn btn-box-tool" data-toggle="tooltip" title="保存"><i
|
||
class="glyphicon glyphicon-floppy-disk"></i></a>
|
||
<a onclick="dodel()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i
|
||
class="glyphicon glyphicon-trash"></i></a>
|
||
</div>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body ">
|
||
<form class="form-horizontal " id="subForm">
|
||
<input id="id" name="id" type="hidden" value="${menu.id}" />
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<div id="menu4SelectDiv"></div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">名称</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="name" name="name" placeholder="名称" value="${menu.name }">
|
||
</div>
|
||
<label class="col-sm-2 control-label">上级菜单</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="_pname" name="_pname" placeholder="上级菜单"
|
||
onclick="showMenu4SelectFun();" value="${menu._pname}">
|
||
<input id="pid" name="pid" type="hidden" value="${menu.pid}" />
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">地址</label>
|
||
|
||
<div class="col-sm-10">
|
||
<input type="text" class="form-control" id="location" name="location" placeholder="地址"
|
||
value="${menu.location}">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">顺序</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="morder" name="morder" placeholder="顺序" value="${menu.morder}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">启用</label>
|
||
<div class="col-sm-4">
|
||
<select id="active" name="active" class="form-control select2">
|
||
<option value="启用">启用</option>
|
||
<option value="禁用">禁用</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">图片</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="image" name="image" placeholder="fa图片" value="${menu.image}">
|
||
</div>
|
||
<!--<label class="col-sm-2 control-label">目标</label>
|
||
<div class="col-sm-4">
|
||
<select id="target" name="target" class="form-control select2">
|
||
<option value="inside">内部</option>
|
||
<option value="external">外部</option>
|
||
</select>
|
||
</div>-->
|
||
</div>
|
||
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<div class="box box-solid">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">按钮及数据权限</h3>
|
||
|
||
<div class="box-tools pull-right">
|
||
</div>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body ">
|
||
<div>
|
||
<div id="alertDiv_power"></div>
|
||
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
|
||
<button type="button" class="btn btn-default" onclick="addPowerFun();"><i class="fa fa-plus"></i> 新增</button>
|
||
<button type="button" class="btn btn-default" onclick="saveDefault();"><i class="fa fa-plus-square"></i>
|
||
默认</button>
|
||
|
||
</div>
|
||
<div id="powerDiv"></div>
|
||
<div id="menu4SelectDiv_func"></div>
|
||
<br>
|
||
<table id="table"></table>
|
||
</div>
|
||
</div>
|
||
</div> |