/**
 * Created by MyPC on 2019/12/17.
 */

//构建地区HTML
function buildArea(data){
    //data-toggle="dropdown"
    var html='<div class="cldform-contarl-box cldform-contarl-textareabox" >' +
        '<span class="cldform-contarl-dropdown">'+setUndefined(data.local)+'<i class="far fa-map-marker-alt mt-1"></i></span></div>' +
        '<div class="dropdown-menu" style="width:300px"> ' +
        '<ul class="nav nav-tabs nav-tabs-clean justify-content-center" role="tablist"> ' +
        '<li class="nav-item"><a class="nav-link text-center active" data-toggle="tab" href="#tab-province" role="tab" aria-selected="true">省份</a></li> ' +
        '<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-city" role="tab" aria-selected="false">市区</a></li> ' +
        '<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-area" role="tab" aria-selected="false">县区</a></li> ' +
        '</ul>';

    html+='<div class="tab-content p-3"> <div class="tab-pane city-item fade active show" id="tab-province" role="tabpanel" aria-labelledby="tab-province">';

    html+='<button type="button" class="btn btn-xs btn-outline-default">黑龙江省</button>';

    html+='</div>';


    html+='<div class="tab-pane city-item fade" id="tab-city" role="tabpanel" aria-labelledby="tab-city">';
    html+='<button type="button" class="btn btn-xs btn-outline-default">广州市</button>';
    html+='</div>';

    html+='<div class="tab-pane city-item fade" id="tab-area" role="tabpanel" aria-labelledby="tab-area">';

    html+='<button type="button" class="btn btn-xs btn-primary">香洲区</button>';

    html+='</div> </div> </div>';

    return html;
}

//构建客户HTML
function buildClient(data){
    var html='';
    html+='<div class="form-header mt-3">';
    html+='<div class="d-flex justify-content-between"><span class="text-muted">CLD客户</span>' +
        '<span class="text-muted">'+setUndefined(data.staff.username)+' 创建于 '+setUndefined(data.createTime)+'</span></div>';
    html+='<legend>'+setUndefined(data.clientname)+'</legend> ' +
        '</div>';

    html+='<div class="cldform clearfix">' +
        '<div class="cldform-line"></div> <div class="cldform-item"> ' +
        '<div class="cldform-label">姓名</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        ' <span>'+setUndefined(data.clientname)+'</span></div> </div> </div>';

    //地区
    var areaHtml=buildArea(data);
    html+='<div class="cldform-line"></div> <div class="cldform-item cldform-item-wauto"> <div class="cldform-label">客户地区</div>';
    html+='<div class="cldform-control">';

    html+=areaHtml;

    html+='</div> </div>';

    if(isExistence(data.companyname)){
        /*
         '<a href="javascript:void(0);" data-original-title="移除单位" class="btn btn-outline-danger btn-xs btn-icon mr-1" data-toggle="modal" data-target="#remover-com"><i class="far fa-unlink" data-toggle="tooltip" data-placement="left" ></i></a>' +
         '<a href="javascript:void(0);" data-original-title="更换单位" class="btn btn-outline-primary btn-xs btn-icon" data-toggle="modal" data-target="#link-com"><i class="far fa-retweet" data-toggle="tooltip" data-placement="left" ></i></a>' +
        * */

        //单位
        html+='<div class="cldform-line"></div> <div class="cldform-item">';
        html+='<div class="cldform-label">单位名称</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox"><div class="card p-2 text-primary" href="#"><div class="d-flex justify-content-between">' +
            '<span>'+setUndefined(data.companyname)+'</span><span>' +

            '</span></div></div></div> </div> </div>';
    }else{
        html+='<div class="cldform-line"></div> <div class="cldform-item"> <div class="cldform-label">单位名称</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox"><span>' +
            '<a href="#link-com" data-toggle="modal" data-target="#link-com"><i class="far fa-link"></i> 关联单位</a></span></div> </div> </div>';
    }





    html+='<div class="cldform-line"></div> ' +
        '<div class="cldform-item cldform-item-half pr-3"> ' +
        '<div class="cldform-label">性别</div> ' +
        '<div class="cldform-control"> ' +
        '<div class="cldform-contarl-box cldform-contarl-textareabox" data-toggle="dropdown">' +
        '<span class="cldform-contarl-dropdown">'+setUndefined(data.gender)+'</span></div> </div> </div>';

    html+='<div class="cldform-item cldform-item-half pl-3">' +
        '<div class="cldform-label">昵称</div> ' +
        '<div class="cldform-control"> ' +
        '<div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.nicename)+'</span></div> </div> </div>' +
        '' +
        '<div class="cldform-line"></div>' +
        '<div class="cldform-item cldform-item-half pr-3"> ' +
        '<div class="cldform-label">手机</div> ' +
        '<div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.telephone)+'</span></div> </div> </div> ' +

        '<div class="cldform-item cldform-item-half pl-3"> ' +
        '<div class="cldform-label">QQ</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.qq)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item cldform-item-half pr-3"> ' +
        '<div class="cldform-label">电话</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.phone)+'</span></div> </div> </div> <div class="cldform-item cldform-item-half pl-3"> ' +

        '<div class="cldform-label">邮箱</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.email)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item cldform-item-half pr-3"> ' +
        '<div class="cldform-label">传真</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.fax)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item cldform-item-half pr-3"> ' +
        '<div class="cldform-label">部门/职称</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox text-muted">' +
        '<span>'+setUndefined(data.position)+'</span></div> </div> </div> <div class="cldform-item cldform-item-half pl-3"> ' +

        '<div class="cldform-label">办公室</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.office)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item">' +
        '<div class="cldform-label">客户地址</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox">' +
        '<span>'+setUndefined(data.address)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item"> ' +
        '<div class="cldform-label">客户乘车</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox text-muted">' +
        '<span>'+setUndefined(data.ride)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item"> ' +
        '<div class="cldform-label">客户地标</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox text-muted">' +
        '<span>'+setUndefined(data.landmarks)+'</span></div></div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item">' +
        '<div class="cldform-label">客户住宿</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox text-muted">' +
        '<span>'+setUndefined(data.stay)+'</span></div> </div> </div> ' +
        '' +
        '<div class="cldform-line"></div> <div class="cldform-item"> ' +
        '<div class="cldform-label">备注</div> <div class="cldform-control"> <div class="cldform-contarl-box cldform-contarl-textareabox text-muted">' +
        '<span>'+setUndefined(data.mark)+'&nbsp;</span></div> </div> </div>';

    html+='<div class="cldform-line"></div> <div class="cldform-item text-center">' +
        '<a data="'+setUndefined(data.cid)+'" href="javascript:void(0)" class="btn btn-sm btn-outline-danger" data-toggle="modal" data-target="#unlinkcld"><i class="far fa-unlink"></i> 移除CLD客户</a> ' +
        '</div>';

    html+='';

    html+='</div>' +
        '<script type="text/javascript">autoFlashHeight();</script> <script type="text/javascript">$(".slimScroll1").slimScroll({position: \'right\', height:\'auto\' , railVisible: true}); </script> <script type="text/javascript">        $(".slimScrol2").slimScroll({            position: \'right\',            height:\'auto\' ,            railVisible: true        });</script>    <script type="text/javascript">        $(".slimScrol3").slimScroll({            position: \'right\',            height:\'auto\' ,            railVisible: true});</script> <script type="text/javascript"> $(".slimScrol4").slimScroll({position: \'right\', height:\'auto\' , railVisible: true});</script>' +
    '';

    return html;
}

