@{
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<style type="text/css">
    table tr td:first-child {
        text-align: right;
        width: 30%;
    }
</style>
<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>公司名称：</td>
                    <td>
                        <input type="text" id="userfullname" value="@ViewBag.userfullname" style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td>联系人：</td>
                    <td>
                        <input type="text" id="person" value="@ViewBag.person" style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td>联系电话：</td>
                    <td>
                        <input type="text" id="persontel" value="@ViewBag.persontel" style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td>行业：</td>
                    <td>
                        <input type="text" id="hangye" value="@ViewBag.hy" style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td>地区：</td>
                    <td>
                        <select  name="regtype" id="province" style="width:160px;float:left;">
                            @{
                                if (!string.IsNullOrEmpty(@ViewBag.shen))
                                {
        <option value="@ViewBag.shen">@ViewBag.shen</option>
                                }
                                else
                                {
                                 <option>—请选择—</option>
                                }
                                }
                           
                        </select>
                        <select  name="regtype" id="city" style="width:160px;float:left;">
                            @{
                                if (!string.IsNullOrEmpty(@ViewBag.shi))
                                {
        <option value="@ViewBag.shi">@ViewBag.shi</option>
                                }
                                else
                                {
        <option>—请选择—</option>
                                }
                            }
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>域名：</td>
                    <td>
                        <input type="text" id="PCUrl" value="@ViewBag.PCUrl" style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td>端口号：</td>
                    <td>
                        <input type="text" id="PCPort" value="@ViewBag.PCPort"  style="width: 400px">
                    </td>
                </tr>
                @{
                    if (ViewBag.password == "mediasoft")
                    {
                        <tr>
                            <td>推送地址：</td>
                            <td>
                                <input type="text" id="WXSerUrl" value="@ViewBag.WXSerUrl" style="width: 400px">
                            </td>
                        </tr>
                    }
                }
                <tr>
                    <td>备注：</td>
                    <td>
                        <input type="text" id="comment" value="@ViewBag.comment"  style="width: 400px">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <button id="btnSave" class="btn btn-default">保存</button>&nbsp;&nbsp;&nbsp;
                        <button id="btnClose" class="btn btn-default">取消</button>
                        <input id="comparyid" value="@ViewBag.comparyid" type="hidden" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<script>
    $(function () {

        var urlis = '@ViewBag.isurl';
        if (urlis == "true") {
            $("#WXSerUrl").show();
        } else {
            $("#WXSerUrl").hide();
        }

        $.ajax({
            url: "../DealerEdition/GetProvincelist",
            type: "post",
            datatype: "Json",
            async: false,
            success: function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["PID"]).text(item["ProvinceName"]).appendTo($("#province"));
                })
            }
        });
        $("#province").change(function () {
            GetCity();
        });
    })
    function GetCity() {
        $("#city").empty();
        $.ajax({
            url: "../DealerEdition/GetCitylist",
            data: {
                pid: $("#province").val()
            },
            type: "post",
            datatype: "Json",
            async: false,
            success: function (data) {
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#city"));
                })
            }
        });
    }

    $("#btnSave").click(function () {
        $.ajax({
            url: "../WeChatAssistant/SaveCompanyinformation",
            dataType: "text",
            data: {
                comparyid: $("#comparyid").val(),
                userfullname: $("#userfullname").val(),
                person: $("#person").val(),
                persontel: $("#persontel").val(),
                hangye: $("#hangye").val(),
                province: $("#province").val(),
                city: $("#city").val(),
                PCUrl: $("#PCUrl").val(),
                PCPort: $("#PCPort").val(),
                WXSerUrl: $("#WXSerUrl").val(),
                comment: $("#comment").val()
            },
            type: "post",
            success: function (data) {
                if (data == "true") {
                    parent.layer.msg(data, { icon2: 1, time: 2000 });
                    parent.$('#businessTable').bootstrapTable("refresh");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                } else {
                    parent.layer.msg(data, { icon2: 1, time: 2000 });
                }
            },
            error: function (data) {
                layer.msg(data, { icon2: 1, time: 2000 });
            }
        })
    })
    $("#btnClose").click(function () {
        parent.$('#businessTable').bootstrapTable("refresh");
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    })

</script>
