{{:ModuleInclude('public/header')}}

<!-- right content start  -->
<div class="content-right">
	<div class="content">
        <!-- 温馨提示 -->
        {{if is_array(MyLang('power.top_tips_list'))}}
            <div class="am-operate-stretch-tips">
                <div class="title">
                    <i class="iconfont icon-tips"></i>
                    <strong title="{{:MyLang('operate_list_tips_msg')}}">{{:MyLang('operate_list_tips_button_text')}}</strong>
                    <i class="iconfont icon-retract-diagonal contract" title="{{:MyLang('operate_list_tips_retract_text')}}"></i> 
                </div>
                <p>{{:implode('</p><p>', MyLang('power.top_tips_list'))}}</p>
            </div>
        {{/if}}

        {{if AdminIsPower('power', 'save')}}
            <!-- operation start -->
            <div class="am-g">
                <button class="am-btn am-btn-primary am-radius am-btn-xs tree-submit-add" data-am-modal="{target: '#data-save-win'}">
                    <i class="iconfont icon-add am-show-sm-only"></i>
                    <span>{{:MyLang('add_title')}}</span>
                </button>
                <a href="{{:MyUrl('admin/power/export')}}" target="_blank" rel="noopener noreferrer" class="am-btn am-btn-default-plain am-radius am-btn-xs am-margin-left-sm">
                    <i class="iconfont icon-excel am-show-sm-only"></i>
                    <span>{{:MyLang('form_table_nav_operate_data_export_excel_name')}}</span>
                </a>
            </div>
            <!-- operation end -->

            <!-- save win start -->
            <div class="am-popup am-radius" id="data-save-win">
                <div class="am-popup-inner">
                    <div class="am-popup-hd">
                        <h4 class="am-popup-title" data-add-title="{{:MyLang('power.base_nav_title')}}{{:MyLang('add_title')}}" data-edit-title="{{:MyLang('power.base_nav_title')}}{{:MyLang('edit_title')}}">{{:MyLang('power.base_nav_title')}}{{:MyLang('add_title')}}</h4>
                        <span data-am-modal-close class="am-close">&times;</span>
                    </div>
                    <div class="am-popup-bd">
                        <!-- form start -->
                        <form class="am-form form-validation am-form-full-screen am-form-popup-fixed" action="{{:MyUrl('admin/power/save')}}" method="POST" request-type="ajax-fun" request-value="TreeFormSaveBack">
                            <div class="am-padding-sm">
                                {{if is_array(MyLang('power.content_top_tips_list'))}}
                                    <div class="am-operate-stretch-tips">
                                        <div class="title">
                                            <i class="iconfont icon-tips"></i>
                                            <strong title="{{:MyLang('operate_list_tips_msg')}}">{{:MyLang('operate_list_tips_button_text')}}</strong>
                                            <i class="iconfont icon-retract-diagonal contract" title="{{:MyLang('operate_list_tips_retract_text')}}"></i> 
                                        </div>
                                        <p>{{:implode('</p><p>', MyLang('power.content_top_tips_list'))}}</p>
                                    </div>
                                {{/if}}

                                <div class="am-form-group row">
                                    <label>{{:MyLang('common_service.power.form_item_name')}}<span class="am-form-group-label-tips-must">*</span></label>
                                    <input type="text" placeholder="{{:MyLang('common_service.power.form_item_name_message')}}" name="name" minlength="1" maxlength="60" data-validation-message="{{:MyLang('common_service.power.form_item_name_message')}}" class="am-radius" required />
                                </div>

                                <div class="am-form-group row">
                                    <label>{{:MyLang('common_service.power.form_item_control')}}</label>
                                    <input type="text" placeholder="{{:MyLang('common_service.power.form_item_control_message')}}" name="control" pattern="{{:MyConst('common_regex_control')}}"  data-validation-message="{{:MyLang('common_service.power.form_item_control_message')}}" class="am-radius" />
                                </div>
                                <div class="am-form-group row">
                                    <label>{{:MyLang('common_service.power.form_item_action')}}</label>
                                    <input type="text" placeholder="{{:MyLang('common_service.power.form_item_action_message')}}" name="action" pattern="{{:MyConst('common_regex_action')}}"  data-validation-message="{{:MyLang('common_service.power.form_item_action_message')}}" class="am-radius" />
                                </div>

                                <div class="am-form-group row">
                                    <label>{{:MyLang('common_service.power.form_item_url')}}</label>
                                    <input type="text" name="url" placeholder="{{:MyLang('common_service.power.form_item_url_message')}}" data-validation-message="{{:MyLang('common_service.power.form_item_url_message')}}" class="am-radius" />
                                </div>
                                <div class="am-form-group row">
                                    <label>{{:MyLang('common_service.power.form_item_icon')}}{{if is_array(MyLang('common_service.power.form_item_icon_tips_list'))}}<a href="javascript:;" class="am-icon-question-circle am-margin-left-xs" data-am-popover="{content: '{{:implode('<br />', MyLang('common_service.power.form_item_icon_tips_list'))}}', trigger: 'hover focus', theme: 'sm'}"></a>{{/if}}</label>
                                    <input type="text" placeholder="{{:MyLang('common_service.power.form_item_icon_message')}}" name="icon" maxlength="60" data-validation-message="{{:MyLang('common_service.power.form_item_icon_message')}}" class="am-radius" />
                                </div>
                                {{:ModuleInclude('lib/sort', ['is_row'=>1])}}
                                {{:ModuleInclude('lib/is_show', ['is_row'=>1])}}

                                <div class="am-form-popup-submit">
                                    <input type="hidden" name="pid" >
                                    <input type="hidden" name="id" />
                                    <button type="button" class="am-btn am-btn-primary-plain am-radius am-btn-xs btn-loading-example am-margin-right-lg" data-am-modal-close>
                                        <span>{{:MyLang('cancel_title')}}</span>
                                    </button>
                                    <button type="submit" class="am-btn am-btn-primary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText:'{{:MyLang('save_title')}}'}">
                                        <span>{{:MyLang('save_title')}}</span>
                                    </button>
                                </div>
                            </div>
                        </form>
                        <!-- form end -->
                    </div>
                </div>
            </div>
            <!-- save win end -->
        {{/if}}

        <!-- list start -->
        <div id="tree" class="am-margin-top" data-head='[{"name":"ID","field":"id"},{"name":"权限名称","field":"name","is_arrow":"1","value_style":{"style":"color:#999","value_style_key":"is_show","value_style_key_status":"0"}},{"name":"图标","field":"icon","type":"icon"},{"name":"是否显示","field":"is_show","type":"status"},{"name":"操作","type":"operate"}]' data-node-url="{{:MyUrl('admin/power/getnodeson')}}" data-del-url="{{if AdminIsPower('power', 'delete')}}{{:MyUrl('admin/power/delete')}}{{/if}}" data-popup-tag="#data-save-win" data-status-url="{{if AdminIsPower('power', 'statusupdate')}}{{:MyUrl('admin/power/statusupdate')}}{{/if}}" data-rank="3">
            {{:ModuleInclude('public/loading')}}
        </div>
        <!-- list end -->
	</div>
</div>
<!-- right content end  -->

<!-- footer start -->
{{:ModuleInclude('public/footer')}}
<script type="text/javascript">
	// 初始化
	Tree(0, $('#tree').data('node-url'), 0, 1);

	// 回调处理
	function TreeFormSaveBack(e)
	{
		TreeFormSaveBackHandle(e);
	}
</script>