<#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-user-edit" class="form-horizontal">
    <@f.hidden id="id" name="id" value="${user.id?default('')}"/>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号：</label>
                <div class="col-sm-8">
                    <@f.input name="username" value="${user.username?default('')}" readonly=true/>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>归属公司：</label>
                <div class="col-sm-8">
                        <@f.treeselect id="compId" name="compId" value="${user.compId?default('')}"
                        labelValue="${user.compName?default('')}" boxTitle="选择归属公司" url="sys/comp/treeData" expandLevel=true placeholder="请选择归属公司"/>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>用户姓名：</label>
                <div class="col-sm-8">
                    <input name="name" id="name" value="${user.name?default("")}"  placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>归属部门：</label>
                <div class="col-sm-8">
                    <@f.treeselect  name="deptId" boxTitle="请选择归属部门" url="sys/dept/selectZtree" value="${user.deptId?default('')}"
                    labelValue="${user.deptName?default('')}" correlationId="compId" isSelectParent=true  placeholder="请选择归属部门"/>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>手机号码：</label>
                <div class="col-sm-8">
                    <@f.input name="mobile" value="${user.mobile?default('')}" placeholder="请输入手机号码" required=true/>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>所属角色：</label>
                <div class="col-sm-8">
                    <@f.select name="roleIdList" multiple = true value="${selectRoles}"  items=roles itemLabel="roleName" itemValue="id" required=true/>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <@f.input name="email" value="${user.email?default('')}" placeholder="请输入邮箱" class="form-control email"  maxlength="50" />
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">用户状态：</label>
                <div class="col-sm-8">
                    <@f.switch name="status" value="${user.status?default('')}"/>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-4 control-label"><span style="color: red; ">*</span>所在岗位：</label>
                <div class="col-sm-8">
                    <@f.select name="postCodes" multiple = true  value="${selectPosts}" items=posts itemLabel="postName" itemValue="postCode" required=true/>
                </div>
            </div>
        </div>
    </div>
</@f.form>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "sys/user";
    /* 校验表单 */
    $("#form-user-edit").validate({
        onkeyup: false,
        rules:{
            mobile:{
                isMobile: true,
                remote: {
                    url: prefix + "/checkMobileUnique",
                    type: "POST",
                    dataType: "html",           /* 接受数据格式 */
                    data: {
                        "mobile": function() {
                            return opt.common.trim($("#mobile").val());
                        },
                        "id":function() {
                            return opt.common.trim($("#id").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return opt.validate.unique(data);
                    }
                }
            }
        },
        messages: {
            "mobile":{
                remote: $.i18n.prop("sys.msg.mobile.already")
            }
        },
        focusCleanup: true
    });

    /*提交*/
    function submitHandler(index, layero){
        if (opt.validate.form()) {
            opt.operate.saveTab(prefix + "/edit", $('#form-user-edit').serialize());
        }
    }
</script>
</@footer>
</@pageTheme>