You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
7.7 KiB

11 months ago
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>增加菜单</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="../../static/css/font.css">
<link rel="stylesheet" href="../../static/css/weadmin.css">
<link rel="stylesheet" href="../../lib/layui/css/layui.css">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.layui-form-label {
width: 100px!important;
}
input[type='text'] {
width: 320px!important;
}
</style>
</head>
<body>
<div class="weadmin-body">
<form class="layui-form">
<div class="layui-form-item">
<label for="name" class="layui-form-label">
<span class="we-red">*</span>菜单名称:
</label>
<div class="layui-input-inline ">
<input type="text" id="name" name="name" lay-verify="required|contentLength" max="64" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="url" class="layui-form-label">
<span class="we-red">*</span>url地址
</label>
<div class="layui-input-inline ">
<input type="text" id="url" name="url" lay-verify="required|contentLength" max="64" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="sort_id" class="layui-form-label">
<span class="we-red">*</span>排序号:
</label>
<div class="layui-input-inline ">
<input type="text" id="sort_id" name="sort_id" lay-verify="required|number" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="memo" class="layui-form-label">
<span class="we-red">*</span>描述信息:
</label>
<div class="layui-input-inline ">
<input type="text" id="memo" name="memo" lay-verify="required|contentLength" max="64" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label for="memo" class="layui-form-label">
<span class="we-red">*</span>可用身份:
</label>
<div class="layui-input-item" style="width: 70%;float: left;padding-top:8px;margin-left: -10px">
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" name="chk" title="超级管理员" value="1"></span>
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" name="chk" title="市级管理员" value="2"></span>
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" name="chk" title="县区管理员" value="3"></span>
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" name="chk" lay-filter="chk" title="单位管理员" value="4"></span>
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" name="chk" title="普通教师" value="5"></span>
</div>
</div>
<div class="layui-form-item" id="school" style="display: none">
<label for="" class="layui-form-label">
<span class="we-red">*</span>学校管理员:
</label>
<div class="layui-input-item" style="width: 70%;float: left;padding-top:8px;margin-left: -10px">
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" lay-filter="school" title="学校管理员" ></span>
<span style="display: inline-block;margin:0 10px 8px 10px"><input type="checkbox" lay-filter="bureau" title="非学校管理员"></span>
</div>
</div>
<div class="layui-form-item">
<label for="" class="layui-form-label">
</label>
<button class="layui-btn" lay-filter="add" lay-submit="">确定</button>
</div>
</form>
</div>
<script src="../../lib/layui/layui.js" charset="utf-8"></script>
<script>
layui.extend({
admin: '{/}../../static/js/admin'
});
layui.use(['form','jquery','admin', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
admin = layui.admin,
layer = layui.layer;
var id;
$(function () {
id=GetQueryString("id");
form.render();
})
verifyLength();
var for_school=0;
var for_bureau=0;
form.on('checkbox(school)', function(data){
if(data.elem.checked){
for_school=1;
}else{
for_school=0;
}
});
form.on('checkbox(bureau)', function(data){
if(data.elem.checked){
for_bureau=1;
}else{
for_bureau=0;
}
});
// 点击单位管理员 显示是否学校
form.on('checkbox(chk)', function(data){
if(data.elem.checked){
$("#school").show();
}else{
$("#school").hide();
}
});
//监听提交
form.on('submit(add)', function(data) {
var arr = new Array();
$("input:checkbox[name='chk']:checked").each(function(i){
arr[i] = $(this).val();
});
data.field.chk = arr.join(",");//将数组合并成字符串
var f=data.field;
if(f.chk==""){
layer.msg("请选择可用身份",{icon:5})
return false;
}
if($("#school").is(":visible")){
if(for_school==0&&for_bureau==0){
layer.msg("请选择是否为学校管理员",{icon:5})
return false;
}
}
$.ajax({
type : "POST",
async : false,
dataType : "json",
11 months ago
url :"/dsBase/menu/AddMenu",
11 months ago
data:{
parent_id:id,
sort_id:f.sort_id,
menu_name:f.name,
url:f.url,
memo:f.memo,
identity_ids:f.chk,
for_school:for_school,
for_bureau:for_bureau
},
success : function(data) {
if(data.success){
var nodeId=data.result["menu_id"];
layer.msg("增加成功", {icon: 1,time:1000,shade : [0.5 , '#000' , true]},function() {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
window.parent.reloadTree(id,nodeId);
});
}else{
layer.alert(data.message, {icon: 0});
return false;
}
}
})
return false;
});
});
</script>
</body>
</html>