@{
    ViewBag.Title = "修改经纬度";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<body>
    <div class="wrapper wrapper-content animated fadeInDown">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <table id="newConfigurationTable" class="table table-bordered table-striped table-hover">
                    <tr style="height: 40px">
                        <td style="text-align: right">经纬度：</td>
                        <td>
                            <input type="text" id="txtLongitude" class="form-control" value="">
                        </td>
                    </tr>
                    @*<tr>
                        <td style="text-align: right">纬度：</td>
                        <td>
                            <input type="text" id="txtLatitude" value="">
                        </td>
                    </tr>*@
                    <tr>
                        <td></td>
                        <td style="text-align: left; height: 60px">
                            <button id="btnSubmit" class="btn btn-default" onclick="SaveTags()"><i class="glyphicon glyphicon-ok"></i>保存</button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">

    //保存经纬度
        function SaveTags() {
            var longLat = $("#txtLongitude").val().replace(/，/ig, ",").trim();
            if ($.trim(longLat).length <= 0) {
                layer.tips('经纬度不能为空！', '#txtLongitude', { shift: 0, tips: [1, '#c00'] }); return;
            }
            //if ($.trim($("#txtLongitude").val()).length <= 0) {
            //    layer.tips('经度不能为空！', '#txtLongitude', {
            //        shift: 0,
            //        tips: [1, '#c00']
            //    }); return;
            //}
            //if ($.trim($("#txtLatitude").val()).length <= 0) {
            //    layer.tips('纬度不能为空！', '#txtLatitude', {
            //        shift: 0,
            //        tips: [1, '#c00']
            //    }); return;
            //}
            var reg = /^\d{1,3}\.\d{1,12}\,\d{1,3}\.\d{1,12}$/
            if (!reg.test(longLat)) {
                layer.msg("经纬度格式不正确", { time: 2000 });
                return;
            }
            var lat = longLat.substring(0, longLat.lastIndexOf(","));
            var long = longLat.substring(longLat.lastIndexOf(",") + 1, longLat.length);
            $.ajax({
                url: "../WLTManage/SaveLatLong",
                data: {
                    Lat: lat,
                    Long: long,
                    typeid: parent.$("#rowIndex").val()
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    if (data == "保存成功！") {
                        parent.$('#CustomersTable').bootstrapTable('refresh');
                        parent.layer.msg(data, { time: 2000 })
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(data, { time: 2000 });
                    }
                }
            })

        }

        $(function () {
            var longLat = "";
            if (parent.$("#hidLong").val() != "null" && parent.$("#hidLat").val() != "null") {
                //$("#txtLongitude").val(parent.$("#hidLong").val());
                longLat = parent.$("#hidLat").val() + "," + parent.$("#hidLong").val();
            }
            $("#txtLongitude").val(longLat);
            //if (parent.$("#hidLat").val() != "null")
            //    $("#txtLatitude").val(parent.$("#hidLat").val());
            //else
            //    $("#txtLatitude").val('');

        });
    </script>
</body>
