@{
    ViewBag.Title = "V_NewOrUpdateBtypeLode";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <table class="table table-bordered table-striped table-hover">
                    @*<tr>
                        <td style="text-align: right">时 间：</td>
                        <td style="text-align:left">
                            <input type="text" onFocus="WdatePicker({isShowClear:false,readOnly:true})" id="txtDate" value="@ViewBag.Date" />
                            
                        </td>
                    </tr>*@
                    <tr>
                        <td style="text-align: right">业务员：</td>
                        <td style="text-align: left">
                            <input type="hidden" id="operation" value="@TempData["Operation"]">
                            <input type="hidden" id="num" value="@ViewBag.num">
                            <select id="ddlSalesman" style="width: 200px">
                                @{
                                if (@ViewBag.ulist != null && @ViewBag.ulist.Rows.Count > 0)
                                {
                                    for (int i = 0; i < @ViewBag.ulist.Rows.Count; i++)
                                    {
                                            <option @(@ViewBag.ulist.Rows[i]["TypeID_"].ToString() == @ViewBag.etypeid ? "selected" : "") value=@ViewBag.ulist.Rows[i]["TypeID_"].ToString()>@ViewBag.ulist.Rows[i]["FullName"].ToString()</option>
                                    }
                                }
                                }
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">线路名称：</td>
                        <td style="text-align: left">
                            <input type="text" id="txtBtlName" value="@ViewBag.fullname">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">线路备注：</td>
                        <td style="text-align: left">
                            <textarea cols="100" rows="5" name="cmarks" id="txtRemark">@ViewBag.Comment</textarea>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right"></td>
                        <td style="text-align: left">
                            <button id="btnSave" class="btn btn-default"><i class="glyphicon glyphicon-saved"></i> 提 交</button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function () {
        //提交按钮
        $("#btnSave").click(function () {
            //var date = $.trim($("#txtDate").val());//时间
            var bln = $.trim($("#txtBtlName").val());//线路名称
            var slm = $.trim($("#ddlSalesman").val());//业务员
            var remark = $.trim($("#txtRemark").val());//备注
            var operation = $.trim($("#operation").val());//操作类型
            var num = $.trim($("#num").val());//num
            //if (date.length <= 0) {
            //    layer.tips('请选择时间！', '#txtDate', {
            //        shift: 0,
            //        tips: [1, '#c00']
            //    }); return;
            //}
            if (bln.length <= 0) {
                layer.tips('线路名称不能为空！', '#txtBtlName', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (slm.length <= 0) {
                layer.tips('请选择业务员！', '#ddlSalesman', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            if (remark.length > 250) {
                layer.tips('备注超出字数最大允许值！', '#txtRemark', {
                    shift: 0,
                    tips: [1, '#c00']
                }); return;
            }
            $.ajax({
                url: "../Shop/NewOrUpdateOperation",
                dataType: "text",
                data: {
                    //date: date,//时间
                    lodename: bln,//线路名称
                    salesman: slm,//业务员
                    remark: remark,//备注
                    operation: operation,//操作类型
                    num: num,//num
                    oldname: '@ViewBag.fullname'
                },
                type: "post",
                success: function (data) {
                    if (data == "保存成功！") {
                        parent.$('#BtypeLodeTable').bootstrapTable('refresh');
                        parent.layer.msg(data, { time: 2000 });
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        parent.layer.msg(data, { time: 2000 });
                    }
                },
                error: function (data) {
                    layer.msg(data, { icon: 5, time: 2000 });
                    parent.$('#BtypeLodeTable').bootstrapTable("refresh");
                }
            })
        })
    })
    </script>
</body>