<!DOCTYPE html>
<html lang="zh">
<head>
    <@meta/>
	<title>资源-编辑</title>
    <#include "admin/common/include_hplus.ftl">
    <#include "admin/common/include_form.ftl">
    <#include "admin/common/include_ztree.ftl">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h3>${module.name}</h3><a href="javascript:history.back(-1);" class="btn btn-link">| 返回列表</a>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" action="<@contextPath/>/sys/module/saveEntity" method="post">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上级：</label>
                            <div class="col-sm-8">
                                <div class="ztree-content input-ztree-1">
                                    <div class="input-group">
                                        <input type="hidden" name="parentId" value="${parent.oid}">
                                        <input type="text" class="form-control input-sm" autocomplete="off" name="parentName" value="${parent.name}">
                                        <div class="input-group-btn">
                                            <button class="btn btn-white btn-sm" type="button" aria-expanded="true"><span class="caret"></span></button>
                                        </div>
                                    </div>
                                    <div class="menuContent" style="display:none; position: absolute;z-index: 999;">
                                        <ul class="ztree" style="margin-top:0; "></ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>名称：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" required="" aria-required="true" name="name" value="${entity.name }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span class="text-danger">*</span>代码：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" required="" aria-required="true" class="error" name="mark" value="${entity.mark }" placeholder="保存后无法修改" <#if entity.oid??>readonly</#if>>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">英文名称：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" name="englishName" value="${entity.englishName }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">访问地址：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" name="visiturl" value="${entity.visiturl }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">参数：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" name="params" value="${entity.params }" placeholder="格式: {&quot;key&quot;:&quot;value&quot;}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">类型：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" value="1" name="mtype" checked="">资源（菜单）</label>
                                    <label><input type="radio" value="2" name="mtype" <#if entity.mtype == '2'>checked</#if>>按钮</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" id="mtype_btn" <#if entity.mtype == '2'>hidden</#if>>
                            <label class="col-sm-2 control-label">权限按钮：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="checkbox" value="Query" name="mtypeBtn">查看</label>
                                    <label><input type="checkbox" value="Add" name="mtypeBtn">添加</label>
                                    <label><input type="checkbox" value="Edit" name="mtypeBtn">修改</label>
                                    <label><input type="checkbox" value="Del" name="mtypeBtn">删除</label>
                                    <label><input type="checkbox" value="Audit" name="mtypeBtn">审核</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态：</label>
                            <div class="col-sm-8">
                                <div class="radio i-checks">
                                    <label><input type="radio" value="1" name="state" checked="">启用</label>
                                    <label><input type="radio" value="2" name="state" <#if entity.state == '2'>checked</#if>>禁用</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图标：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" name="iconcls" value="${entity.iconcls }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" digits="true" name="morder" value="${entity.morder }">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">备注：</label>
                            <div class="col-sm-8">
                                <input class="form-control input-sm" type="text" name="remark" value="${entity.remark }">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
						<input type="hidden" name="oid" value="${entity.oid }">
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function(){

        $('.input-ztree-1').zTreeInit({
            url: Config.ROOT + '/sys/module/treeList'
        });

        $.form.render(function () {
            history.go(-1);
        });

        //类型单选改变事件,要放在$.form.render()之后
        $('input').on('ifChecked', function(event){
            if($(this).attr('name') == 'mtype'){
                var type = $(this).val();
                if(type == 1){
                    $('#mtype_btn').show();
                }else{
                    $('#mtype_btn').hide();
                }
            }
        });

    });
</script>
</body>
</html>
