@{
    ViewBag.Title = "用户信息";
    Layout = "~/Views/Shared/_LayoutContent.cshtml";
}
@section scripts{
    <script type="text/javascript">
        var id = request("id") === "" ? -1 : request("id");
        $(function () { 
            $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
            $("#btnClose").on("click", function () {
                parent.$("#btnSearch").trigger("click");
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            });
            $("#btnSave").on("click", function () {
                $(this).blur();
                var json = { id: id, account: "", realname: "", psw: "", sex: "", phone: "", dept: "", status: "" };
                for (var item in json) {
                    if (item == "id") {
                        continue;
                    }
                    else if (item == "sex" || item == "status") {
                        json[item] = $("[name='{0}']:checked".format(item)).val();
                    }
                    else if (item == "psw") {
                        if ($("#psw1").val().length == 0) {
                            parent.layer.alert("请输入密码！"); return false;
                        } else if ($("#psw2").val().length == 0) {
                            parent.layer.alert("请输入确认密码！"); return false;
                        } else if ($("#psw1").val() != $("#psw2").val() != "") {
                            parent.layer.alert("两次密码输入不一致，请重新输入！"); return false;
                        }
                        else {
                            json[item] = $("#psw1").val();
                        }
                    }
                    else {
                        json[item] = $("#" + item).val();
                    }
                }
                if ($.trim(json.account).length == 0) {
                    parent.layer.alert("用户名不可为空！"); return false;
                }
                if ($.trim(json.realname).length == 0) {
                    parent.layer.alert("用户姓名不可为空！"); return false;
                }
                doAjax("post", "../Users/EditAdmin", json, false, function (msg) {
                    parent.layer.alert(msg.message, function (index) {
                        parent.layer.close(index);
                        if (msg.result) {
                            $("#btnClose").trigger("click");
                        }
                    });
                });
            });
        });
    </script>
}
<div class="wrapper wrapper-content animated zoomIn">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>@ViewBag.Title</h5>
                </div>
                <div class="ibox-content ">
                    <div class="form-horizontal m-t">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">帐户:</label>
                            <div class="col-sm-4">
                                <input id="account" type="text" minlength="2" class="form-control">
                            </div>
                            <label class="col-sm-2 control-label">姓名:</label>
                            <div class="col-sm-4">
                                <input id="realname" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">密码:</label>
                            <div class="col-sm-4">
                                <input id="psw1" type="password" class="form-control" name="url">
                            </div>
                            <label class="col-sm-2 control-label">确认密码:</label>
                            <div class="col-sm-4">
                                <input id="psw2" type="password" class="form-control" name="url">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">部门:</label>
                            <div class="col-sm-4">
                                <input id="dept" class="form-control" />
                            </div>
                            <label class="col-sm-2 control-label">电话:</label>
                            <div class="col-sm-4">
                                <input id="phone" type="text" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">性别:</label>
                            <div class="col-sm-4">
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="男" name="sex" checked> 男
                                    </label>
                                </div>
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="女" name="sex"> 女
                                    </label>
                                </div>
                            </div> 
                            <label class="col-sm-2 control-label">状态:</label>
                            <div class="col-sm-4">
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="1" name="status" checked> 启用
                                    </label>
                                </div>
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="0" name="status"> 禁用
                                    </label>
                                </div>
                            </div>
                            <div class="radio i-checks inline">
                                        <input type="checkbox" value="1" name="status" checked> 启用
                                        <input type="checkbox" value="0" name="status"> 禁用
                                </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-5">
                                <button id="btnSave" class="btn btn-default" type="button">提交</button>
                                <button id="btnClose" class="btn btn-info" type="button">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
