@{
    ViewBag.Title = "新增权限用户";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div id="toolbar" class="row">
                    <div class="col-sm-1 col-md-1">
                    </div>
                </div>
                <table id="newConfigurationTable" class="table table-bordered table-striped table-hover">
                    <tr style="height: 40px">
                        <td style="text-align: right">登录编号：</td>
                        <td>
                            <input type="hidden" id="operation" value="@TempData["Operation"].ToString()">
                            <input type="text" id="txtLoginID" @(@TempData["Operation"].ToString() == "update" ? "readonly='true'" : " ") value="@ViewBag.LoginID">
                        </td>
                    </tr>
                    <tr style="height: 40px">
                        <td style="text-align: right">登录人员：</td>
                        <td>
                            <input type="text" id="txtLoginName" value="@ViewBag.LoginName">
                        </td>
                    </tr>
                    <tr style="height: 40px">
                        <td style="text-align: right">制单人：</td>
                        <td>
                            <select id="ddlSinglePlayer" style="width: 200px">
                                @{
                                if (@ViewBag.ddl != null && @ViewBag.ddl.Rows.Count > 0)
                                {
                                    for (int i = 0; i < @ViewBag.ddl.Rows.Count; i++)
                                    {
                                            <option @(@ViewBag.ddl.Rows[i]["TypeID_"].ToString() == @ViewBag.TypeID_ ? "selected" : "") value="@ViewBag.ddl.Rows[i]["TypeID_"].ToString(),@ViewBag.ddl.Rows[i]["FullName"].ToString()">@ViewBag.ddl.Rows[i]["FullName"].ToString()</option>
                                    }
                                }
                                }
                            </select>
                        </td>
                    </tr>
                    <tr style="height: 40px">
                        <td style="text-align: right">密码：</td>
                        <td>
                            <input type="text" id="txtPassword" value="@ViewBag.PassWord">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">备注：</td>
                        <td>
                            <textarea cols="100" rows="1" name="cmarks" id="txtRemark">@ViewBag.Comment</textarea>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td style="text-align: left; height: 60px">
                            <button id="btnSubmit" class="btn btn-default"><i class="glyphicon glyphicon-ok"></i>提交</button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

    <script type="text/javascript">
    $(document).ready(function () {
        //提交按钮
        $("#btnSubmit").click(function () {
            //var reg = /^[0-9]*$/;//登录编号验证
            var sp = $.trim($("#ddlSinglePlayer").val());//制单人
            var lid = $.trim($("#txtLoginID").val());//登录编号
            var lname = $.trim($("#txtLoginName").val());//登录人员
            var lpwd = $.trim($("#txtPassword").val());//登录密码
            var lremark = $.trim($("#txtRemark").val());//备注
            if (lid.length <= 0) {
                layer.tips('登录编号不可为空！', '#txtLoginID', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (lid.length <= 0) {
                layer.tips('登录编号不合法！', '#txtLoginID', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (lname.length <= 0) {
                layer.tips('登录人员不可为空！', '#txtLoginName', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (sp.length <= 0) {
                layer.tips('请选择制单人！', '#ddlSinglePlayer', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (lpwd.length > 16) {
                layer.tips('密码长度不可超过16位！', '#txtPassword', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (lremark.length > 250) {
                layer.tips('备注超出字数最大允许值！', '#txtRemark', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            $.ajax({
                url: "../WLTManage/NewOrUpdateUser",
                dataType: "text",
                data: {
                    LoginID: $("#txtLoginID").val(),//登录编号
                    LoginName: $("#txtLoginName").val(),//登录人员
                    Emplore: $("#ddlSinglePlayer").val(),//制单人
                    PassWord: $("#txtPassword").val(),//密码
                    Comment: $("#txtRemark").val(),//备注
                    Operation: $("#operation").val()//操作类型
                },
                type: "post",
                success: function (data) {
                    if (data == "新增成功！" || data == "修改成功！") {
                        parent.$('#RightsListTable').bootstrapTable('refresh');
                        parent.layer.msg(data, { time: 2000 })
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        $("#txtLoginID").val("");
                        $("#txtLoginName").val("");
                        $("#txtPassword").val("");
                        $("#txtRemark").val("");
                        // parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(data, { time: 2000 })
                    }
                },
                error: function (data) {
                    layer.msg(data, { icon: 5, time: 2000 });
                    parent.$('#RightsListTable').bootstrapTable("refresh");
                }
            })
        })
    })
    </script>
</body>