init
This commit is contained in:
241
app/admin/view/auth_access/edit.html
Executable file
241
app/admin/view/auth_access/edit.html
Executable file
@@ -0,0 +1,241 @@
|
||||
<!-- 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/auth_access/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/auth_access/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 $auth_access['name'];?>">
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<span class="help-block">(权限名称)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="gid" class="col-sm-2 control-label">所属分组</label>
|
||||
<div class="col-sm-5">
|
||||
<select class="form-control" name="gid" id="gid">
|
||||
<option value="0">默认值</option>
|
||||
<?php echo $groupOption;?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<span class="help-block">(所属分组)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="selModule" class="col-sm-2 control-label">所属模块</label>
|
||||
<div class="col-sm-5">
|
||||
<select class="form-control" name="module" id="selModule" onchange="moduleChanged(this, 'selCtrl', 'selAction')">
|
||||
<option value="">默认值</option>
|
||||
<option value="admin" <?php if($auth_access['module']=='admin'):?>selected<?php endif;?>>admin</option>
|
||||
<option value="index" <?php if($auth_access['module']=='index'):?>selected<?php endif;?>>index</option>
|
||||
</select>
|
||||
</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-2"><!--onblur="ctrlChanged(this, 'selAction')"-->
|
||||
<select class="form-control" name="ctrl" id="selCtrl" onchange="ctrlChanged(this, 'selAction')">
|
||||
<option value="">默认值</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<select class="form-control" name="action" id="selAction">
|
||||
<option value="">默认值</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-1">
|
||||
<button type="button" class="btn btn-danger" onclick="addAuth();">添加</button>
|
||||
</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-5">
|
||||
<div class="table-responsive">
|
||||
<table id="table-auth" class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="text-center">权限码</td>
|
||||
<td class="text-center">操作</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $calists=explode(',',$auth_access['access']);
|
||||
foreach($calists as $ca):?>
|
||||
<tr>
|
||||
<td class="text-center"><input name="access[]" value="<?php echo $ca;?>" class="form-control" type="text"></td>
|
||||
<td class="text-center"><a href="javascript:void(0);" class="btn btn-danger" onclick="$(this).parent().parent().remove();">删除</a></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<span class="help-block">(权限格式:controller/action)</span>
|
||||
</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 $auth_access['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 addAuth() {
|
||||
var ca = [];
|
||||
$('#table-auth .form-control').each(function(i, o) {
|
||||
if ($(o).val() != '') {
|
||||
ca.push($(o).val());
|
||||
}
|
||||
})
|
||||
var ctrl = $('#selCtrl').val();
|
||||
var action = $('#selAction').val();
|
||||
if (ctrl !== '' && action !== '') {
|
||||
var temp = ctrl + '@' + action;
|
||||
if ($.inArray(temp, ca) != -1) {
|
||||
alert('此权限码已经添加!');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var html = '<tr>';
|
||||
if (ctrl !== '' && action !== '') {
|
||||
html += '<td class="text-center"><input type="text" name="access[]" value="' + ctrl + '@' + action + '" class="form-control"/></td>';
|
||||
} else {
|
||||
html += '<td class="text-center"><input type="text" name="access[]" value="" class="form-control"/></td>';
|
||||
}
|
||||
html += '<td class="text-center"><a href="javascript:void(0);" class="btn btn-danger" onclick="$(this).parent().parent().remove();">删除</a></td></tr>';
|
||||
$('#table-auth').append(html);
|
||||
}
|
||||
$(function() {
|
||||
$('select[name=\'module\']').trigger('change');
|
||||
$("form.form-horizontal").submit(function(e) {
|
||||
var nameObj = document.getElementById('name');
|
||||
if (isNull(nameObj.value)) {
|
||||
alert('名称必须填写');
|
||||
nameObj.focus();
|
||||
return false;
|
||||
}
|
||||
var moduleObj = document.getElementById('selModule');
|
||||
if (isNull(moduleObj.value)) {
|
||||
alert('所属模块值无效');
|
||||
moduleObj.focus();
|
||||
return false;
|
||||
}
|
||||
var gidObj = document.getElementById('gid');
|
||||
if (isNaN(gidObj.value) || !parseInt(gidObj.value)) {
|
||||
alert('所属分类值无效');
|
||||
gidObj.focus();
|
||||
return false;
|
||||
}
|
||||
if ($('input[name="access[]"]').length == 0) {
|
||||
alert('权限码不能为空!');
|
||||
return false;
|
||||
}
|
||||
var agree = $("input[name='agree']", this).prop('checked');
|
||||
if (agree) {
|
||||
//alert("Submitted");
|
||||
//e.preventDefault();
|
||||
} else {
|
||||
e.preventDefault();
|
||||
alert("请勾选确认");
|
||||
}
|
||||
});
|
||||
});
|
||||
//类型changed事件
|
||||
function moduleChanged(obj, target, target2) {
|
||||
var module_val = obj.options[obj.selectedIndex].value;
|
||||
if (module_val && target && target2) {
|
||||
$.ajax({
|
||||
url: "<?php echo url('/admin/tool/getajaxctrl');?>",
|
||||
dataType: 'html',
|
||||
data: {"module": module_val},
|
||||
beforeSend: function(XMLHttpRequest) {
|
||||
$('#' + target).html('<option value="">加载中...</option>');
|
||||
$('#' + target2).html('<option value="">默认值</option>');
|
||||
},
|
||||
success: function(html) {
|
||||
$('#' + target).html('<option value="">默认值</option>' + html);
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("上传失败,请检查网络后重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//控制器changed事件
|
||||
function ctrlChanged(obj, target) {
|
||||
var ctrl_val = obj.options[obj.selectedIndex].value;
|
||||
if (ctrl_val && target) {
|
||||
$.ajax({
|
||||
url: "<?php echo url('/admin/tool/getajaxaction');?>",
|
||||
dataType: 'html',
|
||||
data: {"controller": ctrl_val, "module": 'admin'},
|
||||
beforeSend: function(XMLHttpRequest) {
|
||||
$('#' + target).html('<option value="">加载中...</option>');
|
||||
},
|
||||
success: function(html) {
|
||||
$('#' + target).html(html);
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
alert("上传失败,请检查网络后重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user