Files
wehub-resource-sync a21fa4e11b
Go / Build (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:30:21 +08:00

165 lines
9.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<div class="container-fluid">
{{if eq .mode "dev"}}
<div id="failedBox" class="hide"></div>
{{else}}
<div id="failedBox" class="">
<div class="alert alert-danger" style="margin-bottom: 8px">
<a class="close" href="#" onclick="$(this).parent().hide();">×</a><strong>
<i class="glyphicon glyphicon-warning-sign"></i> 警告</strong>只允许在开发模式下添加权限
</div>
</div>
{{end}}
<div class="panel panel-default">
<br>{{$privilege := .privilege}}{{$menus := .menus}}
<div class="panel-body">
<form class="form-horizontal" method="post" action="{{if $privilege}} /system/privilege/modify {{else}}/system/privilege/save {{end}}" onsubmit="return false">
<input type="hidden" name="privilege_id" value="{{$privilege.privilege_id}}">
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>权限名称</label>
<div class="col-sm-4">
<input type="text" name="name" class="form-control" value="{{$privilege.name}}" placeholder="请输入权限名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>所属导航</label>
<div class="col-sm-4">
<input type="text" name="module" class="form-control" value="系统(system)" placeholder="" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>权限类型</label>
<div class="col-sm-4">
<div class="radio radio-inline radio-primary">
{{if $privilege}}
<input type="radio" name="type" id="radio-menu" value="menu" {{if eq $privilege.type "menu"}} checked="checked" {{end}}>
{{else}}
<input type="radio" name="type" id="radio-menu" value="menu" checked="checked">
{{end}}
<label for="radio-menu">菜单</label>
</div>
<div class="radio radio-inline radio-primary">
{{if $privilege}}
<input type="radio" name="type" id="radio-controller" value="controller" {{if eq $privilege.type "controller"}} checked="checked" {{end}}>
{{else}}
<input type="radio" name="type" id="radio-controller" value="controller">
{{end}}
<label for="radio-controller">控制器</label>
</div>
</div>
</div>
<div class="form-group controller-type hidden">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>上级菜单</label>
<div class="col-sm-4">
<select name="parent_id" class="form-control">
{{range $menu := $menus}}
{{if $privilege}}
<option value="{{$menu.privilege_id}}" {{if eq $privilege.parent_id $menu.privilege_id}} selected="selected" {{end}}>{{$menu.name}}</option>
{{else}}
<option value="{{$menu.privilege_id}}">{{$menu.name}}</option>
{{end}}
{{end}}
</select>
</div>
<div class="col-md-4">
<span class="text-danger"></span>
</div>
</div>
<div class="form-group controller-type hidden">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>控制器名称</label>
<div class="col-sm-4">
<input type="text" name="controller" class="form-control" value="{{$privilege.controller}}" placeholder="请输入控制器名称">
</div>
</div>
<div class="form-group controller-type hidden">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>方法名称</label>
<div class="col-sm-4">
<input type="text" name="action" class="form-control" value="{{$privilege.action}}" placeholder="请输入方法名称">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>选择图标</label>
<div class="col-sm-4">
<div class="input-group">
<input type="text" class="form-control" name="icon" value="{{if $privilege}}{{$privilege.icon}}{{else}}glyphicon-list{{end}}" placeholder="选择菜单图标">
<span class="input-group-btn">
<button class="btn btn-default" id="icon" data-icon="{{if $privilege}}{{$privilege.icon}}{{else}}glyphicon-list{{end}}" role="iconpicker"></button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>是否显示</label>
<div class="col-sm-4">
{{if $privilege}}
<input type="checkbox" name="is_display" value="1" {{if eq $privilege.is_display "1"}} checked="checked"{{end}}>
{{else}}
<input type="checkbox" name="is_display" value="1">
{{end}}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>排序数字</label>
<div class="col-sm-4">
<div class="input-group spinner">
<input type="text" class="form-control" name="sequence" value="{{$privilege.sequence}}" placeholder="数字越小的显示越靠前">
<div class="input-group-btn-vertical">
<button class="btn btn-default" type="button"><i class="fa fa-caret-up"></i></button>
<button class="btn btn-default" type="button"><i class="fa fa-caret-down"></i></button>
</div>
</div>
</div>
</div>
<div class="form-group controller-type hidden">
<label class="col-sm-2 control-label"><span class="text-danger"></span>目标地址</label>
<div class="col-sm-4">
<input type="text" name="target" class="form-control" value="{{$privilege.target}}" placeholder="链接到外部的地址">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
{{if eq .mode "dev"}}
<button type="button" onclick="Form.ajaxSubmit(this.form, {{if $privilege}} true {{else}} false {{end}});" class="btn btn-primary">保存</button>
{{else}}
<button type="button" class="btn btn-primary" disabled="disabled">保存</button>
{{end}}
</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
// is_display
$("input[name='is_display']").bootstrapSwitch({
size: 'small',
onText: '是',
offText: '否'
});
// icon
$("#icon").iconpicker({
searchText: '搜索',
cols: 6,
rows: 3
});
$('#icon').on('change', function(e) {
$("input[name='icon']").val(e.icon)
});
var defaultType = "{{$privilege.type}}";
changeSelect(defaultType);
// privilege type
$("input[name='type']").each(function () {
$(this).bind('change', function () {
var privilegeType = $("input[name='type']:checked").val();
changeSelect(privilegeType);
});
});
function changeSelect(privilegeType) {
if (privilegeType == "controller") {
$(".controller-type").each(function () {$(this).removeClass("hidden");});
}else {
$(".controller-type").each(function () {$(this).addClass("hidden");});
}
}
});
</script>