<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改组织机构" bodyClass="white-bg" libs=["bootstrapSelect"]/>
<div class="wrapper wrapper-content ibox-content">
<@f.form id="form-dept-edit" class="form-horizontal">
    <@f.hidden id="id" name="id"  value="${dept.id}"/>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span>机构类型：</label>
        <div class="col-sm-8">
            <@f.select name="type" dictType="sys_comp_type" value="${dept.type}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label "><span style="color: red; ">*</span>上级机构：</label>
        <div class="col-sm-8">
            <@f.treeselect id="parentId" name="parentId" boxTitle="请选择上级机构" url="sys/comp/treeData"
            expandLevel=true value="${dept.parentId}" labelValue="${dept.parentName?default('总公司')}" isParentIds=true
            parenIdsValue="${dept.parentIds}"
            placeholder="请选择上级机构" required=true/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span>机构名称：</label>
        <div class="col-sm-8">
            <@f.input name="name" value="${dept.name}" required=true/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span>机构全称：</label>
        <div class="col-sm-8">
            <@f.input name="fullName" value="${dept.fullName}" required=true/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span>显示排序：</label>
        <div class="col-sm-8">
            <@f.input name="orderNum"  value="${dept.orderNum?default(0)}" required=true/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span>状态：</label>
        <div class="col-sm-8">
            <@f.radio name="status" value="${dept.status}" dictType="sys_normal_disable"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">备注：</label>
        <div class="col-sm-8">
            <@f.textarea name="remark" value="${dept.remark?default('')}"/>
        </div>
    </div>
</@f.form>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "sys/dept";

    $("#form-dept-edit").validate({
        onkeyup: false,
        rules:{
            name:{
                remote: {
                    url: prefix + "/checkCompNameUnique",
                    type: "POST",
                    dataType: "html",
                    data: {
                        "deptId": function() {
                            return $("#deptId").val();
                        },
                        "parentId": function() {
                            return $("input[name='parentId']").val();
                        },
                        "name" : function() {
                            return opt.common.trim($("#name").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return opt.validate.unique(data);
                    }
                }
            },
            orderNum:{
                digits:true
            }
        },
        messages: {
            "name": {
                remote: "已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
        }
    }
</script>
</@footer>
</@pageTheme>
