{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
	<div class="content">
        <!-- form start -->
        <form class="am-form form-validation view-save" action="{{:MyUrl('admin/role/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/role/index', $params)}}">
        	<legend>
				<span class="am-text-default">角色{{if empty($data['id'])}}添加{{else /}}编辑{{/if}}</span>
				<a href="{{:MyUrl('admin/role/index', $params)}}" class="am-fr am-text-sm am-margin-top-xs am-icon-mail-reply"> 返回</a>
			</legend>
        	<div class="am-form-group">
				<label>角色名称</label>
				<input type="text" placeholder="角色名称" name="name" minlength="2" maxlength="16" data-validation-message="角色名称格式 2~8 个字符之间" class="am-radius" {{if !empty($data)}}value="{{$data.name}}"{{/if}} required />
			</div>
			
			<div class="am-form-group">
				<label>拥有权限</label>
				<ul class="tree-list p-0">
					{{foreach $power as $v}}
						<li {{if $v['is_show'] eq 0}}class="bk-cr-ffd"{{/if}}>
							{{if !empty($v['item'])}}
								<i class="am-icon-minus-square c-p am-margin-right-xs"></i>
								<label class="c-p">
							{{else /}}
								<label class="c-p m-l-2">
							{{/if}}
								<input type="checkbox" name="power_id" value="{{$v.id}}" class="node-choice" {{if $v['is_power'] eq 'ok'}}checked{{/if}} />
								<span>{{$v.name}}</span>
							</label>
						</li>
						{{if !empty($v['item'])}}
							<ul class="list-find p-0 am-margin-top-xs">
								{{foreach $v.item as $vs}}
									<li {{if $vs['is_show'] eq 0}}class="bk-cr-ffd"{{/if}}>
										<label class="c-p">
											<input type="checkbox" name="power_id" value="{{$vs.id}}" {{if $vs['is_power'] eq 'ok'}}checked{{/if}} />
											<span>{{$vs.name}}</span>
										</label>
									</li>
								{{/foreach}}
							</ul>
						{{/if}}
					{{/foreach}}
				</ul>
			</div>

			<div class="am-form-group">
			    <label class="block">是否启用</label>
			    <input name="is_enable" value="1" type="checkbox" data-off-text="否" data-on-text="是" data-size="xs" data-on-color="success" data-off-color="default" data-handle-width="50" data-am-switch {{if (isset($data['is_enable']) and $data['is_enable'] eq 1) or !isset($data['is_enable'])}}checked="true"{{/if}} />
			</div>

			<!-- 插件扩展数据 start -->
			{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                <div class="plugins-tag">
                    <span>plugins_view_admin_role_save</span>
                </div>
            {{/if}}
			{{if !empty($plugins_view_admin_role_save_data) and is_array($plugins_view_admin_role_save_data)}}
				<div class="am-alert am-alert-secondary">
					<label class="am-text-sm am-text-warning">该区域为插件扩展数据，请按照插件文档填写相应的值</label>
					<div>
						{{foreach $plugins_view_admin_role_save_data as $hook}}
		                    {{if is_string($hook) or is_int($hook)}}
		                        {{$hook|raw}}
		                    {{/if}}
		                {{/foreach}}
					</div>
				</div>
			{{/if}}
			<!-- 插件扩展数据 end -->

			<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
				<input type="hidden" name="id" {{if !empty($data)}}value="{{$data.id}}"{{/if}} />
				<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
			</div>
		</form>
		<!-- right form end  -->
	</div>
</div>
<!-- right content end  -->
		
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->