<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<%@ include file="header.jsp" %>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/addDialog.css"/>
<script type="text/javascript" src="<%=webpath%>/js/business/enterprise.js"></script>
<style>
    .search2 {
        margin: 30px 45px 10px 45px;
    }

    table.searchTable td {
        width: 19.5%;
        padding-bottom: 15px;
    }

    table.searchTable td:nth-last-child(1) {
        width: 22%;
    }

    table.searchTable td input {
        width: 63%;
        height: 28px;
        line-height: 28px;
        border-radius: 5px;
        border: 1px solid #D2D2D2;
        text-indent: 1em;
        color: #AFAFAF;
    }

    .Wdate {
        padding-left: 0;
    }

    .dialog_title {
        background: url(../images/top_bg2.png) no-repeat;
        background-size: cover;
        background-color: #FFFFFF;
    }

    .dialog_left table td .contactWrap {
        float: left;
        width: 27%;
    }

    .dialog_left table td .contactWrap .contactInput {
        width: 95%;
    }

    .dialog_left input::-webkit-input-placeholder {
        color: #AFAFAF;
    }

    .dialog_left input::-moz-input-placeholder {
        color: #AFAFAF;
    }

    .dialog_left input::-ms-input-placeholder {
        color: #AFAFAF;
    }

    .dialog_left input::-o-input-placeholder {
        color: #AFAFAF;
    }
</style>
<script type="text/javascript">

    function clearFormVal() {
        /* 	$(':input','#enterpriseform').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
         enterpriseid */
        $("#enterpriseform").form("clear");
        //$("#enterpriseform").reset();
    }
    function query() {
        var name = $("#nameinput").val();
        var abbrCode = $("#abbrCodeinput").val();
        var brands = $("#brandsinput").val();
        var areaCode = $("#areaCodeinput").val();

        /* 	if((name==null||name=='')&&(abbrCode==null||abbrCode=='')&&(brands==null||brands=='')&&(areaCode==null||vareaCode=='')){
         alert("查询条件不能为空");
         return;
         } */
        var path = $("#paths").val();
        var url = path + "/enterprise/search_enterprise.do";
        var queryParams = {};
        queryParams['name'] = name;
        queryParams['abbrCode'] = abbrCode;
        queryParams['brands'] = brands;
        queryParams['areaCode'] = areaCode;
        queryEnterpriseList(url, queryParams);
    }
    function submit() {
        var path = $("#paths").val();
        var newPassword = $("#newPassword").val();
        var confirmPassword = $("#confirmPassword").val();
        if (newPassword != confirmPassword) {
            alert("密码和确认密码不匹配");
            return;
        }

        if ($("#roadRepair").is(':checked')) {
            var vin = $("#vin").val();
            var carType = $("#carType").val();
            var sellDate = $("#firstSellDate").val();
            if (vin == null || vin == '') {
                alert('请输入VIN码');
                return;
            }
            if (carType == null || carType == '') {
                alert('请输入车型');
                return;
            }
            if (sellDate == null || sellDate == '') {
                alert('请输入首次销售日期');
                return;
            }
        }
        $.ajax({
            cache: true,
            type: "POST",
            url: path + "/enterprise/put_enterprise.do",
            data: $('#enterpriseform').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                var data = eval("(" + data + ")");
                if (data.flag == 1) {
                    $("#addedit_dialog").hide();
                    query();
                } else {
                    alert(data.msg);
                }
            }
        });

    }
    function showmap() {
        $("#map_frame").show();
        $("#addedit_dialog").hide();

    }

    function cancel() {
        $("#addedit_dialog").hide();
    }

    /*  $(".opera").bind("click",function(){
     $(".order_undo").show();
     getMapUrl();

     });  */
    /* $(document).on('click','.opera',function(){
     $(".order_undo").show();
     getMapUrl();
     }); */


    function clearVal() {
        $("#nameinput").val("");
        $("#abbrCodeinput").val("");
        $("#brandsinput").val("");
        $("#areaCodeinput").val("");
    }

    function openNew() {
        $(".order_undo").show();
        clearFormVal();
        getMapUrl();
    }
    function setAddress(lng, lat, address) {


        //alert(address);
        $("#address").val(address);

        $("#lng").val(lng);

        $("#lat").val(lat);
        /* $(".order_undo").hide();
         $(".order_undo").show();	 */
    }
    $(document).ready(function () {
        var path = $("#paths").val();
        var url = path + "/enterprise/search_enterprise.do";
        queryEnterpriseList(url, "");
    })

    //导出数据
    function expordata() {
        var nameinput = $("#nameinput").val();
        var abbrCodeinput = $("#abbrCodeinput").val();
        var params = {};
        params["name"] = nameinput;
        params["abbrCode"] = abbrCodeinput;
        var checkurl = $("#paths").val() + "/enterprise/exportData.do";
        //刷新列表
        var data = ajaxgetresultpost(checkurl, params);
        if (data.result == 1) {
            $.messager.alert("提示", data.msg);
        } else {
//            var regex =/[\u4E00-\u9FA5]+/;
//            var str = data.webUrl;
//            var tempUserName = decodeURIComponent(decodeURIComponent(str.match(regex)));
//            alert(tempUserName);
//            var ss = {};
//            ss = str.split(regex);
//            var newPath = ss[0] + tempUserName + ss[1];
//            alert(newPath);
            window.open(data.webUrl);
        }

    }
</script>


<input type="hidden" id="paths" value="<%=path%>"/>
<div id="main">
    <div class="search2">
        <table class="searchTable">
            <tbody>

            <tr>
                <!-- <td><b><font><font>经销商名称</font></font></b></td> -->
                <td style="position:relative;">经销商名称: <span id="inputnameWrap">
							<input id="nameinput" name="endSubmitDate" type="text" value=""
                                   class="mc-ipt-text hasDatepicker" style=""/> <span
                        class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                   class="mc-ipt-tip-query"
                                                                   style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>

                <!-- <td><b><font><font>代码编号</font></font></b></td> -->
                <td style="position:relative;">代码编号: <span
                        id="inputabbrCodeWrap"> <input id="abbrCodeinput"
                                                       name="endSubmitDate" type="text" value=""
                                                       class="mc-ipt-text hasDatepicker" style=""/> <span
                        class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                   class="mc-ipt-tip-query"
                                                                   style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>

                <!-- <td><b><font><font>品牌</font></font></b></td> -->
                <td style="position:relative;">
                    <!--        邮箱: <span id="inputbrandsWrap">
                                       <input id="brandsinput" name="endSubmitDate" type="text" value=""
                                              class="mc-ipt-text hasDatepicker" style=""/> <span
                                   class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                              class="mc-ipt-tip-query"
                                                                              style="font-size: 11px; line-height: 20px; height: 20px;">
                                               <font> -->
                </td>
                <%--<td style="position:relative;">--%>
                <%--<!-- 地 址: <span--%>
                <%--id="inputareaCodeWrap"> <input id="areaCodeinput"--%>
                <%--name="endSubmitDate" type="text" value=""--%>
                <%--class="mc-ipt-text hasDatepicker" style=""/> <span--%>
                <%--class="mc-ipt" style="width:215px;"><span id="input33Tip"--%>
                <%--class="mc-ipt-tip-query"--%>
                <%--style="font-size: 11px; line-height: 20px; height: 20px;">--%>
                <%--<font> -->--%>
                <%--</td>--%>
                <!-- <td><b><font><font>地址</font></font></b></td> -->


                <td style="width:50%">
                    <button class="t-button searchBtn " style="margin-right:10px;"
                            type="button" onclick="expordata()">导出报表
                    </button>

                    <button class="t-button searchBtn2" style="margin-right:10px;"
                            type="button" onclick="openNew();">
                        <img style="width:12px;" class="searchIcon"
                             src="../images/add.png">新增
                    </button>

                    <button class="t-button searchBtn" id="CaseInfoList2btnCtClear"
                            style="margin-right: 10px;" type="button" onclick="clearVal();">
                        <img class="searchIcon" src="../images/clear.png">清空
                    </button>

                    <button class="t-button searchBtn" style="margin-right:10px;"
                            id="CaseInfoList2btnCtSearch" type="button" onclick="query();">
                        <img class="searchIcon" src="../images/search.png">搜索
                    </button>
                </td>
                <!-- <td style="width:12.5%"></td> -->
            </tr>
            <tr>

            </tr>
            </tbody>
        </table>
    </div>


    <table id="datatable"></table>
</div>


<div class="order_undo" id="addedit_dialog" style="display: none;">
    <form action="" id="enterpriseform" method="post">
        <input type="hidden" value="" id="enterpriseid" name="id">
        <div class="dialog_default" style="width:1300px;" id="dialogNb">
            <div class="dialog_title">新增/编辑</div>
            <div class="dialog_con">

                <div class="dialog_left" style="padding: 15px 0 40px;">
                    <table>
                        <tbody>
                        <tr>
                            <td colspan=""><span>经销商名称</span>
                                <input autocomplete="off" style="" name="name" type="text" value=""/></td>
                            <td><span>经销商代码</span><input name="abbr_code" type="text"
                                                         value=""/></td>
                            <!-- <td><span>简称</span><input name="registry" type="text"
                                                      value=""/></td> -->
                        </tr>

                        <tr>
                            <td colspan="" style="line-height:32px;">
                                <span>服务资质</span>
                                <input type="checkbox" id="roadRepair" name="service_qualification" value="路修"
                                       style="margin-right:5px;"/> 路修
                                <input type="checkbox" id="trailer" name="service_qualification" value="拖车"
                                       style="margin-left:20px;margin-right:5px;"/> 拖车
                            </td>
                            <td><span>地址</span> <input name="address"
                                                       id="address" type="text" value="" style=""/>
                                <!-- <input type="button" class="addressBtn" value="选择地址" onclick="showmap();"/> -->
                            </td>
                            <!-- <td><span>联系人</span><input name="contact" type="text"
                                value="" /></td> -->

                        </tr>

                        <!-- <tr>

                            <td><span>结算方式</span> <select name="settleType">
                                    <option value="0">月结</option>
                                    <option value="1">现金</option>
                            </select></td>
                        </tr> -->


                        <tr>
                            <td colspan="3"></td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">24小时联系人1</span>
                                <div class="contactWrap"><input class="contactInput" name="contact" placeholder="姓名"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone1" placeholder="电话"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="job1" placeholder="职务"
                                                                type="text" value=""/></div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">24小时联系人2</span>
                                <div class="contactWrap"><input class="contactInput" name="contact2" placeholder="姓名"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone2"
                                                                placeholder="电话" type="text"
                                                                value="" style=""/></div>
                                <div class="contactWrap">
                                    <input class="contactInput" name="job2" placeholder="职务" type="text" value=""/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span class="concat">对账联系人</span>
                                <div class="contactWrap"><input class="contactInput" name="contact3" placeholder="姓名"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone3" placeholder="电话"
                                                                type="text"
                                                                value="" style=""/></div>
                                <div class="contactWrap">
                                    <input class="contactInput" name="job3" placeholder="职务" type="text" value=""/>
                                </div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="2"><span>对账邮箱</span><input name="brands" onblur="loginEmailBlur(this.value)"
                                                                    type="text"
                                                                    value=""/><font
                                    style="color:red;margin-left:5px;font-size:12px;">该邮箱自动绑定服务费用结算通知，如有变动请及时更新！</font>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <span>密码</span>
                                <input id="newPassword" name="newPassword" type="text" placeholder="密码"
                                       value=""/></td>
                            <td>
                                <span>确认密码</span>

                                <input id="confirmPassword" name="confirmPassword" type="text" placeholder="确认密码"
                                       value=""/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>VIN码</span>
                                <input id="vin" name="vin_code" type="text" placeholder="VIN码"
                                       value=""/></td>
                            <td>
                                <span>车型</span>

                                <input id="carType" name="car_type" type="text" placeholder="车型"
                                       value=""/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>首次销售日期</span>
                                <input type="text" id="firstSellDate" placeholder="首次销售日期"
                                       class="Wdate" readonly="readonly"
                                       name="first_sale_date"
                                       onfocus="WdatePicker({errDealMode:2,readOnly:true,startDate:'%y-%M-%d %H:%m:%s',dateFmt:'yyyy/MM/dd'})"
                                       style="cursor:pointer;"/>
                            </td>

                        </tr>
                        </tbody>
                    </table>
                    <div class="confirm_cancel clearfix">
                        <input name="lon" value="" id="lng" type="hidden" value="" style=""/>
                        <input name="lat" id="lat" type="hidden" value="" style=""/>
                        <input name="id"  id="id"  type="hidden" style="" value=""/>
                        <a href="javascript:void(0);" class="btn2"
                           style="margin-right:20px;margin-left:80px;" onclick="submit();">提&nbsp;&nbsp;交</a>
                        <a href="javascript:void(0);" class="btn1 cancel" onclick="cancel()">取&nbsp;&nbsp;消</a>
                    </div>

                </div>


                <div class="dialog_right">
                    <iframe src="<%=path%>/base/amap.do" frameborder="0" scrolling="no"
                            id="map_frame" style="width: 689px;height: 550px"></iframe>
                </div>
            </div>
        </div>
    </form>

</div>


<!-- <div id="consume_dialog" style="padding:10px;display: none;" >
<input type="hidden" value="" id="vinCode">
消费金额 <input type="text" id="consumeCount" style="width:215px;"></br>
维修信息 <input type="text" id="reparieInfo" style="width:215px;"></br>
故障信息 <input type="text" id="hitchInfo" style="width:215px;"></br>
<input type="button" value="提交" onclick="submitconsume();">
</div> -->
<%@ include file="footer.jsp" %>