168 lines
9.6 KiB
HTML
Executable File
168 lines
9.6 KiB
HTML
Executable File
<!-- Content Wrapper. Contains page content -->
|
|
<div class="content-wrapper">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
编辑角色
|
|
</h1>
|
|
<ol class="breadcrumb">
|
|
<li><a href="<?php echo url('/admin/index/index');?>"><i class="fa fa-dashboard"></i> 首页</a></li>
|
|
<li><a href="<?php echo url('/admin/user_role/lists');?>"> 角色列表</a></li>
|
|
<li class="active"> 角色</li>
|
|
</ol>
|
|
</section>
|
|
|
|
<!-- Main content -->
|
|
<section class="content">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="nav-tabs-custom">
|
|
<ul class="nav nav-tabs">
|
|
<li class="active">
|
|
<a data-toggle="tab" href="#tabfirst">编辑角色</a>
|
|
</li>
|
|
<li class="pull-right"><a href="" class="text-muted"><i class="fa fa-refresh"></i></a></li>
|
|
</ul>
|
|
<div class="tab-content">
|
|
<!-- /.tab-pane -->
|
|
<div class="tab-pane active" id="tabfirst">
|
|
<form class="form-horizontal" action="<?php echo url('/admin/user_role/update');?>" method="post">
|
|
<div class="form-group">
|
|
<label for="name" class="col-sm-2 control-label">角色名称<em style="color:red;">*</em></label>
|
|
<div class="col-sm-5">
|
|
<input type="text" class="form-control" name="name" id="name" required value="<?php echo $user_role['name'];?>">
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<span class="help-block">(角色名称)</span>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="description" class="col-sm-2 control-label">角色描述</label>
|
|
<div class="col-sm-5">
|
|
<textarea class="form-control" name="description"><?php echo $user_role['description'];?></textarea>
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<span class="help-block">(角色描述)</span>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="yesorno" class="col-sm-2 control-label">权限类型</label>
|
|
<div class="col-sm-5">
|
|
<label class="radio-inline">
|
|
<input type="radio" name="yesorno" value="1" <?php if($user_role['yesorno']):?>checked<?php endif;?>> 拥有以下权限
|
|
</label>
|
|
<label class="radio-inline">
|
|
<input type="radio" name="yesorno" value="0" <?php if(!$user_role['yesorno']):?>checked<?php endif;?>> 否认以下权限
|
|
</label>
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<span class="help-block">(权限类型)</span>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="col-sm-2 control-label">权限分配</label>
|
|
<div class="col-sm-10">
|
|
<div class="box box-solid no-shadow" id="rbac_acl">
|
|
<div class="box-header">
|
|
<h3 class="box-title">
|
|
<input type="checkbox" class="check-all"> 全选
|
|
</h3>
|
|
<div class="box-tools">
|
|
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
|
|
</div>
|
|
</div>
|
|
<div class="box-body">
|
|
<?php foreach($group_list as $group):?>
|
|
<div class="row margin-bottom">
|
|
<div class="col-sm-2">
|
|
<div class="text-center">
|
|
<?php echo $group['name'];?> <input type="checkbox" class="check-group">
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-10">
|
|
<?php if(array_key_exists($group['id'],$access_list)):?>
|
|
<ul class="list-inline">
|
|
<?php foreach($access_list[$group['id']] as $access):?>
|
|
<li class="col-sm-2">
|
|
<input type="checkbox" name="acl[]" value="<?php echo $access['id'];?>" class="check-access" <?php if(in_array($access['id'],$user_role['rbac_acl'])):?>checked<?php endif;?>> <?php echo $access['name'];?>
|
|
</li>
|
|
<?php endforeach;?>
|
|
</ul>
|
|
<?php endif;?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach;?>
|
|
</div>
|
|
<!-- /.box-body -->
|
|
</div>
|
|
<!-- /.box -->
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-sm-offset-2 col-sm-10">
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" name="agree"> 确认更新
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<input type="hidden" name="id" value="<?php echo $user_role['id'];?>">
|
|
<div class="col-sm-offset-2 col-sm-10">
|
|
<button type="reset" class="btn btn-warning">重置</button>
|
|
<button type="submit" class="btn btn-danger">提交</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<!-- /.tab-pane -->
|
|
</div>
|
|
<!-- /.tab-content -->
|
|
</div>
|
|
<!-- /.nav-tabs-custom -->
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<!-- /.content -->
|
|
</div>
|
|
<!-- /.content-wrapper -->
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
//Enable check and uncheck all functionality
|
|
$(".check-all").click(function() {
|
|
var clicks = $(this).prop("checked");
|
|
//Uncheck all checkboxes
|
|
//Check all checkboxes
|
|
$.each($("#rbac_acl .check-access[name='acl[]']"), function() {
|
|
//$(this).attr("checked", flag);
|
|
$(this).prop("checked", clicks);
|
|
});
|
|
});
|
|
$(".check-group").click(function() {
|
|
var clicks = $(this).prop("checked");
|
|
//Uncheck all checkboxes
|
|
//Check all checkboxes
|
|
$.each($(".check-access[name='acl[]']", $(this).parent().parent().siblings("div")), function() {
|
|
//$(this).attr("checked", flag);
|
|
$(this).prop("checked", clicks);
|
|
});
|
|
});
|
|
$("form.form-horizontal").submit(function(e) {
|
|
var nameObj = document.getElementById('name');
|
|
if (isNull(nameObj.value)) {
|
|
alert('名称必须填写');
|
|
nameObj.focus();
|
|
return false;
|
|
}
|
|
var agree = $("input[name='agree']", this).prop('checked');
|
|
if (agree) {
|
|
//alert("Submitted");
|
|
//e.preventDefault();
|
|
} else {
|
|
e.preventDefault();
|
|
alert("请勾选确认");
|
|
}
|
|
});
|
|
});
|
|
</script> |