<style>
    .page_VisitPlan ._mc_addbox{padding:20px 0}
    .page_VisitPlan ._mc_edit{overflow: auto;display: none;position:absolute;bottom:0;left: 0;border-top:3px solid #38425d; background-color:#fff;padding: 15px 33px;width: 100%;min-width: 1146px;padding-right: 10px} 
    .page_VisitPlan .edHeight{display: block;height: 350px;}
    .page_VisitPlan ._addr{color: #666666}
    .page_VisitPlan ._edHeight{height:340px;}
    .page_VisitPlan ._scrollbar::-webkit-scrollbar{width: 4px;height: 8px;}
    .page_VisitPlan ._scrollbar::-webkit-scrollbar-thumb{border-radius: 4px;-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);background: #c9c9c9;}
    .page_VisitPlan ._scrollbar::-webkit-scrollbar-track{-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);border-radius: 4px;background: #EDEDED;}
    .page_VisitPlan ._tit{padding-left: 10px;border-left: 3px solid #E95252; font-size: 14px;color: #000000;height: 14px; line-height: 14px;}
    .page_VisitPlan ._mc_edit ._info_box ul._form li{float: left;}
    .page_VisitPlan ._check_list{padding-left: 120px;margin-bottom: 20px;}
    .page_VisitPlan ._check_box .el-form-item{margin-bottom: 0}
    .page_VisitPlan textarea{resize: none;width: 646px;height: 100px}
    .page_VisitPlan .TPDateContentX{margin-top: 20px; width: 407px;}
    .page_VisitPlan .TPDateContentX .month ul {margin: 0;padding: 0;display: flex;background-color: #E6E6E6;color: #666666;border-top-left-radius:10px;border-top-right-radius:10px;}
    .page_VisitPlan .TPDateContentX .year-month {flex-direction: column;align-items: center;justify-content: space-around;}
    .page_VisitPlan .TPDateContentX .year-month > input {width: 100px;float: left;}
    .page_VisitPlan .TPDateContentX .arrow {    padding: 10px;    font-style: normal;    cursor: pointer;  }
    .page_VisitPlan .TPDateContentX .monthminus {    position: absolute;    left: 15px;    top: 15px;  }
    .page_VisitPlan .TPDateContentX .monthadd {    position: absolute;    right: 21px;    top: 16px;  }
    .page_VisitPlan .TPDateContentX .currentInput{    width: 120px;    height: 30px;    border-radius: 17px;    outline: none;    border: none;    margin-top: 20px;    border: 1px solid #dcdfe6;  }
    .page_VisitPlan .TPDateContentX .month ul li { margin-left: 30px;   font-size: 12px;    position: relative;       letter-spacing: 3px;  }
    .page_VisitPlan .TPDateContentX .month ul li > input {  background: #fff;      text-align: center;    margin: 20px 10px 20px;  }
    .page_VisitPlan .TPDateContentX .weekdays {    margin: 0;    padding: 10px 0;    background-color: #F9F9F9;    display: flex;    flex-wrap: wrap;    color: #999999;    justify-content: space-around;  }
    .page_VisitPlan .TPDateContentX .weekdays li {    display: inline-block;    width: 13.6%;    text-align: center; font-size: 12px; }
    .page_VisitPlan .TPDateContentX .days {    width: 407px;    padding: 0;    margin: 0;  border-radius: 0 0 10px 10px;  display: flex;    flex-wrap: wrap;    justify-content: space-around;  background-color: #FFFFFF}
    .page_VisitPlan .TPDateContentX .days li {    list-style-type: none;    display: inline-block;    width: 14.2%;    text-align: center;    position: relative;    padding-bottom: 15px;    padding-top: 10px;    font-size: 1rem;    color: #000;  }
    /* 日期选择样式 */
    .page_VisitPlan ._mc_list{overflow: auto}
    .page_VisitPlan ._mc_list .days li span{    display: inline-block;    width: 30px;    height: 30px;    border: 1px solid #fff;    border-radius: 17px;    line-height: 30px;       }
    .page_VisitPlan ._mc_list .checked{cursor: pointer;}
    .page_VisitPlan ._mc_list .checked span{    border-color: #E95252 !important;    color: #E95252}
    .page_VisitPlan ._mc_list .other-month{  display: inline-block;width:30px;height: 30px;line-height: 30px;color: gainsboro;}
    .page_VisitPlan ._mc_list .checkStateT span{background-color: #E95252;color: white}
    .page_VisitPlan ._mgt20{margin-top: 20px;}
    .page_VisitPlan ._today {margin-left: 30px;width: 650px;font-size: 14px;}
    .page_VisitPlan ._future{width: 1085px;font-size: 14px; height: 438px; overflow-y: auto; background: #fff; border-radius: 10px;}
    .page_VisitPlan ._today ._today_list{padding: 20px;border: 1px solid #F1F2F5;border-radius: 10px;color: #666666;height: 438px;background-color: #FFFFFF}
    .page_VisitPlan ._future ._today_list{width: 1085px;padding: 20px;color: #666666;background-color: #FFFFFF}
    .page_VisitPlan ._today_list .img-rili{color: #999999}
    .page_VisitPlan ._today_list .icon-ditu{float: right;color: #E95252}
    .page_VisitPlan ._today_list>div>ul{padding-left: 10px;padding-top: 15px;height: 350px; overflow-y: auto}
    .page_VisitPlan ._future  ._today_list>div>ul{padding-left: 10px;padding-top: 15px; overflow-y: inherit; height: auto;}
    .page_VisitPlan ._today_list>div>ul>li{position: relative;border-left: 1px solid #F5F5F5;padding-left: 15px;}
    .page_VisitPlan ._today_list>div>ul>li span._dot{font-size: 10px;width: 16px;height: 16px;border-radius: 50%;background-color: #257BF1;border: 2px solid #B7D3FA;display: inline-block;text-align: center;color: white;line-height: 11px;position: absolute;left: -8px}
    .page_VisitPlan ._today_list>div>ul>li span._dot span{transform: scale(0.7);display: inline-block;}
    .page_VisitPlan ._time{color: #333333;width: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap; position: relative; padding: 5px 0;}
    .page_VisitPlan ._time>span.fr{display: none; position: absolute; right: 0; top: 0; z-index: 10; background: #fff; }
    .page_VisitPlan ._time>span i{cursor: pointer; color: #666;}
    .page_VisitPlan ._today_list>div>ul>li:hover ._time span{display: inline-block;}
    .page_VisitPlan ._info{color: #666666;font-size: 12px; padding: 10px 15px; background: #f5f5f5;}
    .page_VisitPlan ._today_hipi{text-align: center}
    .page_VisitPlan ._today_hipi .icon-kong{font-size: 68px;color: #CCCCCC;padding-top: 150px;display: inline-block}
    .page_VisitPlan ._today_hipi p{color: #B3B3B3;}
    .page_VisitPlan ._future ._today_hipi{background-color: white;margin-top: 20px;padding-bottom: 190px;border: 1px solid #f1f2f5}
    .page_VisitPlan .icon-ditu{cursor: pointer;}
    ._add_nav li{float: left;padding: 18px 10px;margin-right: 10px;cursor: pointer;font-size: 14px;color: #666666}
    ._add_nav li._active{color: #E95252}
    ._add_nav li>div{margin: 10px auto 0; width: 26px; height: 3px; background: #E95252;}
    ._label_wd150 .el-form-item__label{width: 150px !important;}
    ._h34{height: 34px !important}
    ._h34 .el-select__tags{margin-top: 3px}
    
    .page_VisitPlan .avatar-uploader .el-upload {
	    border: 1px dashed #d9d9d9;
	    border-radius: 6px;
	    cursor: pointer;
	    position: relative;
	    overflow: hidden;
	  }
	.page_VisitPlan  .avatar-uploader .el-upload:hover {
	    border-color: #409EFF;
	  }
	.page_VisitPlan  .avatar-uploader-icon {
	    font-size: 28px;
	    color: #8c939d;
	    width: 148px;
	    height: 148px;
	    line-height: 148px;
	    text-align: center;
	  }
	.page_VisitPlan  .avatar {
	    width: 148px;
	    height: 148px;
	    display: block;
	  }    
	.page_VisitPlan .prevPlanMsg{
		display: flex;
		width: 100%; height: 82px; border: 1px dashed #ccc; margin-bottom: 15px;
	}
	.page_VisitPlan .prevPlanMsg>div.split{height:70px; border-left: 1px dashed #ccc; margin-top:6px;}
	.page_VisitPlan .prevPlanMsg>div.title{padding: 0 20px; text-align: center; min-width: 200px;}
	.page_VisitPlan .prevPlanMsg>div.details{padding: 0 20px;}
	.page_VisitPlan .prevPlanMsg>div.details span{margin-right: 30px;}
</style>
<template>
    <div class="page_VisitPlan">
        <div class="_mc_addbox">
            <button class="hollowFixedBtn" @click="addShow=true,isDisabled=false,isOldPerson=false,isUpdate=false,initMsg()">新增拜访</button>
        </div>
        <div class="_mc_list clearfix _scrollbar" :class="addShow==true?'_edHeight':''">
            <div class="fl">
                <p class="_tit">{{$t('salesModule.VisitPlan')}} </p>
                <div class="TPDateContentX " id="DayAll">
                    <div class="month">
                        <ul>
                            <li>
                                <i class="arrow monthminus" @click="currentYear-=1,getDateString(),getCalendar(dateString)">❮</i>
                                <input type="text" disabled v-model="currentYear" class="currentInput" @input="getDateString(),getCalendar(dateString)"/>{{$t('pub.year')}}
                                <i class="arrow monthadd" @click="currentYear+=1,getDateString(),getCalendar(dateString)">❯</i>
                            </li>
                            <li>
                                <i class="arrow monthminus" @click="pickPre(currentYear,currentMonth)">❮</i>
                                <input type="text" disabled v-model="currentMonth" class="currentInput" @input="getDateString(),getCalendar(dateString)" />{{$t('pub.month')}}
                                <i class="arrow monthadd" @click="pickNext(currentYear,currentMonth)">❯</i>
                            </li>
                        </ul>
                    </div>
                    <!-- 星期 -->
                    <ul class="weekdays">
                        <li>{{$t('hotel.hotel_Monday')}}</li>
                        <li>{{$t('hotel.hotel_Tuesday')}}</li>
                        <li>{{$t('hotel.hotel_Wednesday')}}</li>
                        <li>{{$t('hotel.hotel_Thursday')}}</li>
                        <li>{{$t('hotel.hotel_Friday')}}</li>
                        <li>{{$t('hotel.hotel_Saturday')}}</li>
                        <li>{{$t('hotel.hotel_Sunday')}}</li>
                    </ul>
                    <!-- 日期 -->
                    <ul class="days">
                        <li class="liList" :class="{'checked':dayobject.checkState==$calendarUtils.checkState.checked,'checkStateT':dayobject.checkStateT==true}" v-for="(dayobject,index) in days" :key="dayobject.subCode">
                            <!-- <span v-if="dayobject.day.getMonth()+1 != currentMonth" class="other-month">{{ dayobject.day.getDate()}}</span> -->
                            <span v-if="dayobject.day.getMonth()+1 == currentMonth" class="ckStyle" @click="dayobject.checkState==true?clickedDay(dayobject):''"> 
                                {{dayobject.day.getDate()}}
                            </span>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="fl _today">
                <div class="_today_list" style="margin-top: 33px;">
                    <div>
                        <p><i class="iconfont icon-img-rili"></i>&nbsp;&nbsp;{{$t('salesModule.Today')}}({{toDay}}&nbsp;&nbsp;{{toDayWeek}})<i class="iconfont icon-ditu" @click="goUrl('VisitPlanMap',toDay)"></i></p>
                        <ul class="clearfix _scrollbar" v-if="TodayVisitList.length>0">
                            <li v-for="(item,index) in TodayVisitList">
                                <span class="_dot"><span>{{index+1}}</span></span>
                                <p class="_time">{{item.time}}&nbsp;&nbsp;
                                    <el-tooltip class="item" effect="dark" :content="item.customerName" placement="top-start" popper-class="max-w250">
                                        <span>{{item.customerName}}</span>
                                    </el-tooltip>
                                </p>
                                <p class="_info">{{item.remark}}</p>
                            </li>
                        </ul>
                        <div class="_today_hipi" v-else>
                            <i class="iconfont icon-kong"></i>
                            <p>{{$t('salesModule.noVisitPlan')}}</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="clearfix"></div>
            <p class="_tit mt30">{{$t('salesModule.RecentVisitPlan')}} </p>
            <div class="_today" style="margin-left: 0!important;" v-show="thisDayShow">
                <div class="_mgt20 _today_list" style="width: 1085px!important;">
                    <div>
                        <p><i class="iconfont icon-img-rili"></i>&nbsp;&nbsp;{{StartDate}}&nbsp;&nbsp;{{thisDayWeek}} <i class="iconfont icon-ditu" @click="goUrl('VisitPlanMap',StartDate)"></i></p>
                        <ul class="clearfix _scrollbar" v-if="ThisDayList.length>0">
                            <li v-for="(item,index) in ThisDayList">
                                <span class="_dot"><span>{{index+1}}</span></span>
                                <p class="_time">{{item.time}}&nbsp;&nbsp;
                                    <el-tooltip class="item" effect="dark" :content="item.customerName" placement="top-start" popper-class="max-w250">
                                        <span>{{item.customerName}}</span>
                                    </el-tooltip>
                                    <span class="fr"  v-if='StartDate>toDay'>
                                        	 <i class="iconfont icon-img_delete_small" @click="deleteItem(item,item.timestr)"></i>&nbsp;
                                        	 <i class="iconfont icon-img_bianji_small" @click='getDetail(item,item.timestr)'></i>
                                     </span>
                                </p>
                                <p class="_info">{{item.remark}}
                                </p>
                            </li>
                        </ul>
                        <div class="_today_hipi" v-else>
                            <i class="iconfont icon-kong"></i>
                            <p>{{$t('salesModule.noVisitPlan')}}</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="_future mt20" v-show="futureShow">
                <div class="clearfix">
                    <div class="_today_list fl" v-if="RecentVisitListByDate.length" v-for="(item,index) in RecentVisitListByDate" v-show="index<2">
                        <div>
                            <p><i class="iconfont icon-img-rili"></i>&nbsp;&nbsp;{{item.timestr}}&nbsp;&nbsp;{{item.timestrWeek}} <i class="iconfont icon-ditu" @click="goUrl('VisitPlanMap',item.timestr)"></i></p>
                            <ul class="clearfix _scrollbar" >
                                <li v-for="(son,sIndex) in item.customerVisit">
                                    <span class="_dot"><span>{{sIndex+1}}</span></span>
                                    <p class="_time">{{son.time}}&nbsp;&nbsp;
                                        <el-tooltip class="item" effect="dark" :content="son.customerName" placement="top-start" popper-class="max-w250">
                                            <span> {{son.customerName}}</span>
                                        </el-tooltip>
                                        <span class="fr">
                                        	 <i class="iconfont icon-img_delete_small" @click="deleteItem(son,item.timestr)"></i>&nbsp;
                                             <i class="iconfont icon-img_bianji_small" @click='getDetail(son,item.timestr)'></i>
                                        </span>
                                    </p>
                                    <p class="_info">{{son.remark}}</p>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="_today_hipi" v-if="RecentVisitListByDate.length==0">
                        <i class="iconfont icon-kong"></i>
                        <p>{{$t('salesModule.RecentNoPlan')}}</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="_mc_edit _scrollbar" :class="addShow==true?'edHeight':''">
            <p class="_tit">
            	{{$t('salesModule.addVisit')}}
            	<span class="fr" v-show='leftActive==true'>
            		<button class="hollowFixedBtn" type="button" @click="cancelEdit(),resetForm('addMsgNew')">{{$t('pub.cancelBtn')}}</button>
                    <button type="button" class="normalBtn" @click="submitForm('addMsgNew')">{{$t('pub.saveBtn')}}</button>
            	</span>
            	<span class="fr" v-show='leftActive==false'>
                    <button class="hollowFixedBtn" type="button" @click="cancelEdit(),resetForm('addMsgOldS')">{{$t('pub.cancelBtn')}}</button>
                    <button type="button" class="normalBtn" @click="submitForm('addMsgOldS')">{{$t('pub.saveBtn')}}</button>
            	</span>
            </p>
            <ul class="_add_nav clearfix">
                <li v-if='!isUpdate' :class="leftActive==true?'_active':''" @click="leftActive=true,resetForm('addMsgNew'),resetForm('addMsgOldS')">
                 	   {{$t('salesModule.VisitingCustomers')}}
                 	 <div v-show="leftActive"></div>
                </li>
                <li v-if='isUpdate' :class="{_active:leftActive==true}">
                 	   {{$t('salesModule.VisitingCustomers')}}
                 	 <div v-show="leftActive"></div>   
                </li>
                <li v-if='!isUpdate' :class="leftActive==false?'_active':''" @click="leftActive=false,prevVisitObj={},resetForm('addMsgNew'),resetForm('addMsgOldS')">
                  	  {{$t('salesModule.NewCustomer')}}
                  	 <div v-show="!leftActive"></div>   
                </li>
                <li v-if='isUpdate' :class="{_active:leftActive==false}" >
                 	   {{$t('salesModule.VisitOldCustomer')}}
                 	 <div v-show="!leftActive"></div>      
                </li>
            </ul>
            <div class="prevPlanMsg" v-show="leftActive==true&&prevVisitObj.customerName">
            	<div class="title">
            		<p class="fz14 fbold color000 mt15">{{prevVisitObj.customerName}}</p>
            		<p class="fz12 color666 mt5">{{$t('salesModule.beforeVisitPlan')}}</p>
            	</div>
            	<div class="split"></div>
            	<div class="details">
            		<p class="fz12 mt10">
            			<span>
            				<i class="iconfont icon-img-rili color666"></i>
            				{{prevVisitObj.expectVisitDateTimeStr}}
            			</span>
            			<span>
            				<i class="color666">{{$t('fnc.lcleixing')}}：</i>
            				{{prevVisitObj.salesProcess}}
            			</span>
            			<span>
            				<i class="color666">{{$t('salesModule.goutong')}}：</i>
            				{{prevVisitObj.visitRecord}}
            			</span>
            		</p>
            		<p style="background: #f5f5f5; font-size: 12px; color: #666;padding: 5px 20px; max-height: 45px; overflow-y: auto;" class="ownScrollbarStyle">
            			{{prevVisitObj.remark}}
            		</p>
            	</div>
            </div>
            <el-form class="_info_box clearfix" :model="addMsgNew" :rules="rules" ref="addMsgNew" label-width="120px" v-show="leftActive==true">
                <ul class="_form clearfix">
                    <li>
                        <el-form-item :label="$t('pub.Customer')" prop="customerInfoId">
                            <el-select v-model="addMsgNew.customerInfoId" class="w135" @change='getPrevVisitDetails'>
                                <el-option 
                                    :placeholder="$t('pub.pleaseSel')"
                                    v-for="item in AppCoustomer" 
                                    :key="item.customerId" 
                                    :label="item.customerName" 
                                    :value="item.customerId">
                                </el-option>
                            </el-select> 
                        </el-form-item> 
                    </li>
                    <li>
                        <el-form-item :label="$t('salesModule.VisitDate')" prop="newVisitDay">
                            <el-date-picker class="w135"
                                v-model="addMsgNew.newVisitDay"
                                type="date"
                                value-format="yyyy-MM-dd"
                                :picker-options="pickerOptions0"
                                :placeholder="$t('admin.admin_choDate')">
                            </el-date-picker>
                        </el-form-item> 
                    </li>
                    <li>
                        <el-form-item :label="$t('salesModule.VisitTime')" prop="newVisitTime">
                            <el-time-picker class="w135"
                                v-model="addMsgNew.newVisitTime"
                                :picker-options="{
                                    selectableRange: '00:00:00 - 23:59:59'
                                }"
                                value-format="HH:mm:ss"
                                :placeholder="$t('pub.ChoiceTime')">
                            </el-time-picker>
                        </el-form-item>
                    </li>
                    <li>
                        <el-form-item :label="$t('salesModule.belongProcess')" prop="SalesProcess">
                            <el-select v-model="addMsgNew.SalesProcess" class="w135">
                            	<el-option 
                                    :placeholder="$t('pub.pleaseSel')"
                                    v-for="item in sslc" 
                                    :key="item.ID" 
                                    :label="item.Name" 
                                    :value="item.ID">
                                </el-option>
                            </el-select> 
                        </el-form-item> 
                    </li>
                </ul>
                <el-form-item :label="$t('salesModule.VisitDetail')">
                    <el-input v-model="addMsgNew.remark" type="textarea" maxlength="500" size=mini class="w400" :placeholder="$t('pub.pleaseImport')"></el-input>
                </el-form-item>
            </el-form>
            <el-form class="_info_box clearfix" :model="addMsgOldS" :rules="rules" ref="addMsgOldS" label-width="120px" v-show="leftActive==false">
                <div>
                    <el-form-item :label="$t('salesModule.IsSignCustomer')" class="_label_wd150">
                        <el-switch @change="initMsg()"
                            v-model="addMsgOld.isPreFilled"
                            :disabled='isDisabled'
                            active-color="#4BCA81"
                            inactive-color="#ff4949">
                        </el-switch>
                    </el-form-item> 
                </div>
                <el-row :gutter="20" v-if="addMsgOld.isPreFilled==true">
					<el-col :span="6">
						<el-form-item :label="$t('restaurant.res_ContactNumber')" prop="contactNumber">
                            <el-input  :disabled="isOldPerson" @input='searchHistory(addMsgOldS.contactNumber)' v-model="addMsgOldS.contactNumber"  :placeholder="$t('pub.pleaseImport')"></el-input>
                        </el-form-item>  
					</el-col>	
					<el-col :span="6">
						  <el-form-item :label="$t('fnc.khmingcheng')" prop="customerName">
                            <el-input :disabled="isOldPerson" v-model="addMsgOldS.customerName"  maxlength="20" :placeholder="$t('pub.pleaseImport')"></el-input>
                        </el-form-item> 
					</el-col>	
					<el-col :span="6">
						 <el-form-item :label="$t('hotel.suplier_contact')" prop="contact">
                            <el-input :disabled="isOldPerson" v-model="addMsgOldS.contact"  maxlength="20" :placeholder="$t('pub.pleaseImport')"></el-input>
                        </el-form-item> 
					</el-col>	
					<el-col :span="6">
					</el-col>	
                </el-row>
				<el-row :gutter="20" v-if="addMsgOld.isPreFilled==true">
					<el-col :span="12">
						<el-form-item  :label="$t('pub.area')">
							<el-select  filterable v-model='addMsgOldS.Province' @change='getCity'>
								<el-option v-for='item in provinceList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>
							<el-select filterable  v-model='addMsgOldS.City'  @change='getRegion'>
								<el-option v-for='item in cityList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>
							<el-select filterable  v-model='addMsgOldS.District'>
								<el-option v-for='item in regionList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>							
						</el-form-item>				
            		</el-col>
            		<el-col :span="6">
            			 <el-form-item :label="$t('hotel.hotel_detailinfo')" prop="address">
                            <el-input v-model="addMsgOldS.address" :placeholder="$t('salesModule.HouseNumber')" maxlength="50" ></el-input>
                        </el-form-item> 
            		</el-col>
            		<el-col :span="6">
            			<el-form-item :label="$t('salesModule.belongProcess')" prop="SalesProcess">
                            <el-select v-model="addMsgOldS.SalesProcess" >
                            	<el-option 
                                    :placeholder="$t('pub.pleaseSel')"
                                    v-for="item in sslc" 
                                    :key="item.ID" 
                                    :label="item.Name" 
                                    :value="item.ID">
                                </el-option>
                            </el-select> 
                        </el-form-item> 
            		</el-col>
				</el-row> 
				<el-row :gutter="20" v-if="addMsgOld.isPreFilled==true">
					<el-col :span="6">
  						<el-form-item  :label="$t('salesModule.Belongbrand')" prop="brandIds">
			                <el-select filterable  class='multiple_input' multiple   v-model='addMsgOldS.brandIds' :placeholder="$t('pub.pleaseSel')">
								<el-option v-for='item in CustomerBrandList' 
									:label='item.name'
									:value='item.id'
									:key='item.id'>
								</el-option>
							  </el-select>
		                </el-form-item>							
					</el-col>            		
					<el-col :span="6">
                        <el-form-item :label="$t('visaT.post')" prop="Duty">
                            <el-select filterable    v-model='addMsgOldS.Duty' :placeholder="$t('pub.pleaseSel')">
								<el-option v-for='item in zw' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							  </el-select>
                        </el-form-item> 						
					</el-col>
					<el-col :span="6">
						 <el-form-item :label="$t('salesModule.premises')" prop="Premises">
                            <el-select filterable    v-model='addMsgOldS.Premises' :placeholder="$t('pub.pleaseSel')">
								<el-option v-for='item in jycs' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							  </el-select>
                        </el-form-item> 
					</el-col>
					<el-col :span="6">
            			<el-form-item  :label="$t('salesModule.CustomerSource')" prop="CustomerSourceType">
			                <el-select filterable  v-model='addMsgOldS.CustomerSourceType' :placeholder="$t('pub.pleaseSel')">
								<el-option v-for='item in khly' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							  </el-select>
		                </el-form-item>	
            		</el-col>	
				</el-row>	
				<el-row :gutter="20" v-if="addMsgOld.isPreFilled==true">
					<el-col :span="6">
						<el-form-item :label="$t('salesModule.BusinessPhoto')">
							<el-upload class="avatar-uploader" 
								action="" 
								:http-request="uploadImg" 
								 accept="image/jpeg,image/gif,image/png,image/bmp"			
								:show-file-list="false"
								>
							  <img v-if="BusinessCardPhotos" :src="BusinessCardPhotos" class="avatar">
							  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
							</el-upload>							
						</el-form-item> 
					</el-col>	
					<el-col :span="6">
						<el-form-item :label="$t('salesModule.doorPhoto')">
							<el-upload class="avatar-uploader" 
								action="" 
								:http-request="uploadImg1" 
								 accept="image/jpeg,image/gif,image/png,image/bmp"			
								:show-file-list="false"
								>
							  <img v-if="HousePhotos" :src="HousePhotos" class="avatar">
							  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
							</el-upload>
						</el-form-item> 
					</el-col>	
					<el-col :span="6">
						<el-form-item :label="$t('salesModule.businessPhoto')">
							<el-upload class="avatar-uploader" 
								action="" 
								:http-request="uploadImg2" 
								 accept="image/jpeg,image/gif,image/png,image/bmp"			
								:show-file-list="false"
								>
							  <img v-if="Images" :src="Images" class="avatar">
							  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
							</el-upload>							
						</el-form-item> 
					</el-col>	
					 <el-col :span="6">
					    	 <el-form-item :label="$t('salesModule.CustomerInfo')" prop="remark" v-show='addMsgOldS.CustomerSourceType==6'>
					    	 	 <el-input class='w200' v-model="addMsgOldS.CustomerSource" maxlength="20"></el-input>
					    	 </el-form-item> 
					    </el-col>
					</el-row>	
					<el-row :gutter="20">
						<el-col :span="12">
							 <el-form-item :label="$t('pub.remarkInfo')">
	                            <el-input v-model="addMsgOldS.remark" type="textarea" maxlength="500" size=mini class="" :placeholder="$t('pub.pleaseImport')"></el-input>
	                        </el-form-item>
						</el-col>
						<el-col :span="12">
							 <el-form-item :label="$t('salesModule.kaifaDetail')">
	                            <el-input v-model="addMsgOld.customerVisit.remark" type="textarea" maxlength="500" size=mini class="" :placeholder="$t('pub.pleaseImport')"></el-input>
	                        </el-form-item>
						</el-col>
					</el-row>	
                <!--<ul class="_form clearfix">
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="联系电话：" prop="contactNumber">
                            <el-input v-model="addMsgOldS.contactNumber" class="w135" placeholder="请输入"></el-input>
                        </el-form-item>  
                    </li>                	
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="客户名称：" prop="customerName">
                            <el-input v-model="addMsgOldS.customerName" class="w135" maxlength="20" placeholder="请输入"></el-input>
                        </el-form-item>  
                    </li>
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="联系人：" prop="contact">
                            <el-input v-model="addMsgOldS.contact" class="w135" maxlength="20" placeholder="请输入"></el-input>
                        </el-form-item>  
                    </li>
                    <li v-if="addMsgOld.isPreFilled==true">
						<el-form-item  label="地区：">
							<el-select  v-model='addMsgOldS.Province' @change='getCity'>
								<el-option v-for='item in provinceList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>
							<el-select  v-model='addMsgOldS.City'  @change='getRegion'>
								<el-option v-for='item in cityList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>
							<el-select  v-model='addMsgOldS.District'>
								<el-option v-for='item in regionList' 
									:label='item.Name'
									:value='item.ID'
									:key='item.ID'>
								</el-option>
							</el-select>							
						</el-form-item>			                    	
                    </li>
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="客户地址：" prop="address">
                            <el-input v-model="addMsgOldS.address" class="w290" maxlength="50" placeholder="请输入"></el-input>
                        </el-form-item>  
                    </li>
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="所属品牌："  prop="brandIds" class="_h34">
                            <el-select filterable
                                v-model="addMsgOldS.brandIds"
                                multiple
                                collapse-tags
                                class='multiple_input'
                                placeholder="请选择">
                                <el-option
                                    v-for="item in CustomerBrandList"
                                    :key="item.id"
                                    :label="item.name"
                                    :value="item.id">
                                    </el-option>
                            </el-select>
                        </el-form-item>  
                    </li>
                    <li v-if="addMsgOld.isPreFilled==true">
                        <el-form-item label="备注信息：">
                            <el-input v-model="addMsgOldS.remark" type="textarea" maxlength="500" size=mini class="" placeholder="请输入......"></el-input>
                        </el-form-item>
                    </li>
                    <li>
                        <el-form-item label="开发说明：">
                            <el-input v-model="addMsgOld.customerVisit.remark" type="textarea" maxlength="500" size=mini class="" placeholder="请输入......"></el-input>
                        </el-form-item>
                    </li>
                </ul>-->
                <div style="display:flex">
                    <el-form-item :label="$t('salesModule.bookDate')">
                        <el-date-picker class="w200"
                            v-model="addMsgOld.customerVisit.expectVisitDateTime"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            :picker-options="pickerOptions0"
                            :placeholder="$t('admin.admin_choDate')">
                        </el-date-picker>
                    </el-form-item> 
                    <!--<el-form-item label="预计耗时：">
                        <el-input v-model="addMsgOld.customerVisit.expectHour" class="w150">
                        	<template slot="append">小时</template>
                        </el-input>
                    </el-form-item>-->
                </div>
            </el-form>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
        		isOldPerson:false,
	        	BusinessCardPhotos:'',
	        	HousePhotos:'',
	        	Images:'',	
			    provinceList:[],
			    cityList:[],
			    regionList:[],		
			    jycs:[],   //经营场所
			    zw:[],     //职务
			    khly:[],   //客户来源		
			    sslc:[],   //所属流程
        	isUpdate:false,
        	isDisabled:false,
            msg:{
                pageIndex:1,
                pageSize:15
            },
            addMsgNew:{
                customerInfoId:'',
                remark:'',
                expectVisitDateTime:'',
                newVisitDay:'',
                newVisitTime:'',
                CustomerId:'0',
    			VisitID:'0',
    			CustomerAccountId:'0',
    			
            },
            addMsgOldS:{
                customerName:'',
                contact:'',
                contactNumber:'',
                address:'',
                brandIds:[],
                CustomerId:'0',
                CustomerAccountId:'0',
                remark:'',
                Duty:'',
                Premises:'',
                BusinessCardPhotos:[],
                HousePhotos:[],
                Images:[],
                CustomerSourceType:'',
                CustomerSource:'0',
                Country:'2',
                Province:'',
                City:'',
                District:'',
                SalesProcess:''
            },            
            addMsgOld:{   //新客户
                isPreFilled:false,
                customerInfo:{
                    customerName:'',
                    contact:'',
                    contactNumber:'',
                    address:'',
                    remark:'',
                    brandIds:[],
                },
                customerVisit:{
                    remark:'',
                    expectVisitDateTime:'',
                    expectHour:0,
                    VisitId:'0'
                }
            },
            rules:{
                customerInfoId:[{required: true, message:this.$t('rule.qxzkhmingcheng'), trigger: "change"}],
                newVisitDay:[{required: true, message:this.$t('rule.ChoiceVDate'), trigger: "change"}],
                newVisitTime:[{required: true, message:this.$t('rule.ChoiceVTime'), trigger: "change"}],
                SalesProcess:[{required: true, message:this.$t('rule.ChoiceLC'), trigger: "change"}],
                customerName:[{required: true, message:this.$t('rule.EnterCusName'), trigger: "blur"}],
                contact:[{required: true, message:this.$t('rule.EnterContratPerson'), trigger: "blur"}],
                contactNumber:[{required: true, message:this.$t('rule.EnterPNum'), trigger: "blur"}],
                address:[{required: true, message:this.$t('rule.EnterCusAds'), trigger: "blur"}],
                brandIds:[{required: true, message:this.$t('rule.ChoiceBrand'), trigger: "change"}],
                Duty:[{required: true, message:this.$t('rule.ChoiceJob'), trigger: "change"}],
                remark:[{required: false, message:this.$t('rule.ChoiceJob'), trigger: "change"}],
                Premises:[{required: true, message:this.$t('rule.ChoiceJYCS'), trigger: "change"}],
                CustomerSourceType:[{required: true, message:this.$t('rule.ChoiceCusFrom'), trigger: "change"}],                  
            },
            pickerOptions0: {
                disabledDate(time) {
                    let timeSpace = time.getTime() < Date.now() - 8.64e7;
                    return timeSpace;
                }
            }, 
            toDay:new Date().Format('yyyy-MM-dd'),
            toDayWeek:'',
            thisDayWeek:'',
            dataList:[],
            CustomerBrandList:[],
            checkedCities:[],
            days: [],
            TodayVisitList:[],
            RecentVisitListByDate:[],
            AppCoustomer:[],
            ThisDayList:[],
            checkAll:false,
            addShow:false,
            noData:false,
            loading:true,
            isIndeterminate:true,
            leftActive:true,
            futureShow:true,
            thisDayShow:false,
            currentDay: 1,
            currentMonth: 1,
            currentYear: 1970,
            total: 0,
            currentPage: 1,
            calendarList:[],
            StartDate:'',
            prevVisitObj:{}
        }
    },methods:{
    	getPrevVisitDetails(){
    		if(this.addMsgNew.customerInfoId!='')
    		{
	    		this.apipost('app_get_my_GetVisitPlanLastList',{customerId:this.addMsgNew.customerInfoId,empId:this.getLocalStorage().EmployeeId},res=>{
	    			if(res.data.resultCode==1){
	    				this.prevVisitObj=res.data.data
	    			}else{
	    				this.$message.error(res.data.message)
	    			}
	    			
	    		},err=>{})	
    		}else{
    			this.prevVisitObj={}
    		}
    		
    	},
    	getSslc(){
    		this.apipost('app_customer_GetSalesProcessEnum',{},res=>{
    			this.sslc=res.data.data
    		},err=>{})
    	},
		searchHistory(val){
    		if(val.length==11){
	    		this.apipost('app_customer_GetCustomerByContactNumber',{ContactNumber:val},res=>{
	    			if(res.data.resultCode==1){
	    				if(x.customerId>0)
	    				{
	    					this.isOldPerson=true
							let x=x
							this.addMsgOldS=x
							this.addMsgOldS.Province=x.province
							this.getCity1()
							this.addMsgOldS.City=x.city
							this.getRegion1()
							this.addMsgOldS.District=x.district
							this.addMsgOldS.Duty=x.duty
							this.addMsgOldS.Premises=x.premises
							this.addMsgOldS.CustomerSourceType=x.customerSourceType
							let dictid=[]
							res.data.data.brandList.forEach(x=>{
								dictid.push(x.dictId)
							})
							this.addMsgOldS.brandIds=dictid
							
							if(x.businessCardPhotos&&x.businessCardPhotos.length>0)
						 	{
						 		this.BusinessCardPhotos=x.businessCardPhotos[0]
						 	}
						 	if(x.images&&x.images.length>0)
						 	{
						 		this.Images=x.images[0]
						 	}
						 	if(x.housePhotos&&x.housePhotos.length>0)
						 	{
						 		this.HousePhotos=x.housePhotos[0]				
						 	}
					 	}
					}else{
						this.$message.error(res.data.message)
					}
	    		},err=>{})
    		}else{}
    	},    	    	
 		uploadImg(file) {
	      //上传
	      let newArr = [];
	      newArr.push(file.file);
	      let path = "/Upload/Temporary/";
	      this.UploadSelfFileT(path, newArr, x => {
	      	this.BusinessCardPhotos= this.domainManager().ViittoFileUrl + x.data.FilePath
	      });
	    },
	    uploadImg1(file) {
	      //上传
	      let newArr = [];
	      newArr.push(file.file);
	      let path = "/Upload/Temporary/";
	      this.UploadSelfFileT(path, newArr, x => {
	        this.HousePhotos= this.domainManager().ViittoFileUrl + x.data.FilePath
	      });
	    },
	    uploadImg2(file) {
	      //上传
	      let newArr = [];
	      newArr.push(file.file);
	      let path = "/Upload/Temporary/";
	      this.UploadSelfFileT(path, newArr, x => {
	         this.Images= this.domainManager().ViittoFileUrl + x.data.FilePath
	      });
	    },    	
    	getJycs(){
			this.apipost('app_today_visit_GetCustomerPremisesEnum',{},res=>{
				if(res.data.resultCode==1){
					this.jycs=res.data.data
				}
			},err=>{})    		
    	},
    	getZw(){
    		this.apipost('app_today_visit_GetCustomerDutyEnum',{},res=>{
				if(res.data.resultCode==1){
					this.zw=res.data.data
				}
			},err=>{}) 
    	},
    	getKhly(){
    		this.apipost('app_customer_GetCustomerSourceEnum',{},res=>{
				if(res.data.resultCode==1){
					this.khly=res.data.data
				}
			},err=>{})     		
    	}, 
		getProvince(){
			this.apipost('app_customer_GetChildList',{Id:2,"level":1},res=>{
				if(res.data.resultCode==1){
					this.provinceList=res.data.data
				}
			},err=>{})
		},     	
		getCity(){
			this.apipost('app_customer_GetChildList',{Id:this.addMsgOldS.Province,"level":2},res=>{
				if(res.data.resultCode==1){
					this.cityList=res.data.data
					this.regionList=[]
					this.addMsgOldS.City=''
					this.addMsgOldS.District=''
				}
			},err=>{})
		},
		getRegion(){
			this.apipost('app_customer_GetChildList',{Id:this.addMsgOldS.City,"level":3},res=>{
				if(res.data.resultCode==1){
					this.regionList=res.data.data
					this.addMsgOldS.District=''
				}
			},err=>{})
		},
		getCity1(){
			this.apipost('app_customer_GetChildList',{Id:this.addMsgOldS.Province,"level":2},res=>{
				if(res.data.resultCode==1){
					this.cityList=res.data.data
				}
			},err=>{})
		},
		getRegion1(){
			this.apipost('app_customer_GetChildList',{Id:this.addMsgOldS.City,"level":3},res=>{
				if(res.data.resultCode==1){
					this.regionList=res.data.data
				}
			},err=>{})
		},	    	
    	getDetail(obj,date){

    		this.isDisabled=true
    		this.isUpdate=true
    		this.apipost('app_today_visit_GetVisitEntity',{visitId:obj.visitId},res=>{
    			if(res.data.resultCode == 1) {

    				this.addShow=true
    				if(res.data.data.createFromType==1){   //老客户

    					this.leftActive=true
    				    this.addMsgNew.customerInfoId=res.data.data.customerInfoId
    					this.addMsgNew.remark=res.data.data.remark
    					this.addMsgNew.newVisitDay=res.data.data.expectVisitDateTime.substring(0,10)
    					this.addMsgNew.newVisitTime=res.data.data.expectVisitDateTime.substring(11,19)
    					this.addMsgNew.CustomerId=res.data.data.customerInfoId
    					this.addMsgNew.VisitID=res.data.data.visitId
    					this.addMsgNew.CustomerAccountId=res.data.data.customerInfo.customerAccountId
    					this.addMsgNew.SalesProcess=res.data.data.salesProcess

    				}else{   
                        //新客户
    					this.leftActive=false
    					this.addMsgOldS.CustomerId=res.data.data.customerInfoId
    					this.addMsgOldS.CustomerAccountId=res.data.data.customerInfo.customerAccountId
    					this.addMsgOld.customerVisit.VisitId=res.data.data.visitId 

    					this.addMsgOld.customerVisit.expectVisitDateTime=res.data.data.expectVisitDateTime
    					this.addMsgOld.customerVisit.expectHour=res.data.data.expectHour
    					
    					if(res.data.data.customerInfo.customerId>0){   //有预约资料
    						let x = res.data.data.customerInfo
    						this.addMsgOld.isPreFilled=true
    						this.addMsgOldS.customerName=x.customerName
    						this.addMsgOldS.Province=x.province
							this.getCity1()
							this.addMsgOldS.City=x.city
							this.getRegion1()
							this.addMsgOldS.District=x.district
							this.addMsgOldS.address=x.address.split(',')[1]
    						this.addMsgOldS.contact=x.contact
    						this.addMsgOldS.contactNumber=x.contactNumber
    						this.addMsgOldS.remark=res.data.data.remark
    						this.addMsgOld.customerVisit.remark=x.remark
    						this.addMsgOldS.brandIds=[]
    						res.data.data.brandList.forEach(x=>{
    							this.addMsgOldS.brandIds.push(x.dictId)
    						})
	    					this.addMsgOldS.Duty=x.duty
	    					this.addMsgOldS.Premises=x.premises
							this.addMsgOldS.CustomerSourceType=x.customerSourceType
							if(x.businessCardPhotos&&x.businessCardPhotos.length>0)
						 	{
						 		this.BusinessCardPhotos=x.businessCardPhotos[0]
						 	}
						 	if(x.images&&x.images.length>0)
						 	{
						 		this.Images=x.images[0]
						 	}
						 	if(x.housePhotos&&x.housePhotos.length>0)
						 	{
						 		this.HousePhotos=x.housePhotos[0]				
						 	}
    						
    					}else{                                       //无预约资料
    						this.addMsgOld.customerVisit.remark=res.data.data.remark   
    						this.addMsgOld.isPreFilled=false
    					}
    				}
    			}else{
    				this.$message.error(res.data.message)
    			}
    		},err=>{})
    	},
    	deleteItem(obj,date){
    		this.$confirm(this.$t('tips.shifoushanchu'), this.$t('tips.tips'), {
					confirmButtonText: this.$t('pub.sureBtn'),
					cancelButtonText: this.$t('pub.cancelBtn'),
					type: 'warning'
				}).then(() => {
					this.apipost('app_today_visit_RemoveCustomerVisit', {
						visitId:obj.visitId
					}, res => {
						if(res.data.resultCode == 1) {
							this.$message.success(res.data.message);
							this.getGetRecentVisitListByDate()
							this.getThisDay(this.StartDate)
						} else {
							this.$message.error(res.data.message)
						}
					}, err => {})
				}).catch(() => {
                        this.$message.info(this.$t('tips.cancleDelete'));
				});
    	},
        goUrl(path,time) {
            this.$router.push({ name: path,query:{"time":time} }) 
        },
        getAppCoustomer(){   // 获取客户列表      
            this.apipost('app_get_my_select_coustomer',{},res=>{
                if(res.data.resultCode==1){
                    this.AppCoustomer = res.data.data;
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        isNull(object){ 
            if(object == null || typeof object == "undefined"){ 
                return true; 
            } 
            return false; 
        },
        getWeek(dateString){
            var date;
            if(this.isNull(dateString)){
                date = new Date();
            }else{
                var dateArray = dateString.split("-");
                date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
            }
            //var weeks = new Array("日", "一", "二", "三", "四", "五", "六");
            //return "星期" + weeks[date.getDay()];
            return "周" + "日一二三四五六".charAt(date.getDay());
        },
        getGetRecentVisitListByDate(){  // 获取近期拜访
            this.apipost('app_post_GetRecentVisitListByDate',{visitDate:this.toDay},res=>{
                if(res.data.resultCode==1){
                    this.RecentVisitListByDate = res.data.data;
                    this.RecentVisitListByDate.forEach(x=>{
                        x.timestrWeek = x.timestr.substring(11,x.timestr.length)
                        x.timestr = x.timestr.substring(0,11).replace('年','-').replace('月','-').replace('日','')
                    })
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        getThisDay(date){ // 获取点击天拜访计划
        	if(date!=''){
	            this.apipost('app_get_my_visit_plan_list',{visitDate:date},res=>{
	                if(res.data.resultCode==1){
	                    this.ThisDayList = res.data.data;
	                }else{
	                    this.$message.error(res.data.message)
	                }
	            },err=>{})
            }
        },
        getCustomerBrandList(){ // 获取品牌
            this.apipost('app_get_customer_brand',this.msg,res=>{
                if(res.data.resultCode==1){
                    this.CustomerBrandList = res.data.data;
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        submitForm(addMsg) {//提交创建、修改表单
            this.$refs[addMsg].validate((valid) => {
                if (valid) {
                    if(addMsg=="addMsgNew"){
                        this.saveVisaNew()
                    }else{
                        this.saveNewVisit()
                    }
                } else {
                    return false;
                }
            });
         },
        saveVisaNew(){  // 保存
            this.addMsgNew.expectVisitDateTime = this.addMsgNew.newVisitDay+" "+this.addMsgNew.newVisitTime
            let msg = []
            msg[0] = this.addMsgNew
            this.apipost('app_add_visit',msg,res=>{
                if(res.data.resultCode==1){
                    this.$message.success(res.data.message)
                    this.addShow=false
                    this.getCalendar()
                    this.getTodayVisitList()
                    this.getThisDay(this.StartDate)
                    this.toDayWeek = this.getWeek(new Date().Format("yyyy-MM-dd"))
                    this.getGetRecentVisitListByDate()
                    this.initMsg()
                    this.futureShow=true
                    this.thisDayShow=false
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        saveNewVisit(){  // 保存 新客户   
			if(this.addMsgOldS.District=='')
        	{
        		this.addMsgOldS.District=0
        	}
            this.addMsgOldS.customerInfo = this.addMsg
             if(this.BusinessCardPhotos)
	            {   this.addMsgOldS.BusinessCardPhotos=[]
	            	this.addMsgOldS.BusinessCardPhotos.push(this.BusinessCardPhotos)
	            }
	            if(this.HousePhotos)
	            {   this.addMsgOldS.HousePhotos=[]
	            	this.addMsgOldS.HousePhotos.push(this.HousePhotos)
	            }
	            if(this.Images)
	            {   this.addMsgOldS.Images=[]
	            	this.addMsgOldS.Images.push(this.Images)
	            }
				let sheng=''
				let shi=''
				let qu=''
				if(this.addMsgOldS.District=='')
				{
					this.addMsgOldS.District=0
				}
				if(this.addMsgOldS.City=='')
				{
					this.addMsgOldS.City=0
				}
				this.provinceList.forEach(item=>{
					if(this.addMsgOldS.Province==item.ID)
					{
						sheng=item.Name
					}
				})
				this.cityList.forEach(item=>{
					if(this.addMsgOldS.City==item.ID)
					{
						shi=item.Name
					}
				})
				this.regionList.forEach(item=>{
					if(this.addMsgOldS.District==item.ID)
					{
						qu=item.Name
					}
				})
				let AreaName=sheng+shi+qu	   
			    this.addMsgOldS.address=AreaName+','+this.addMsgOldS.address
			    this.addMsgOld.customerInfo = this.addMsgOldS
       
            this.apipost('app_add_new_visit_customer',this.addMsgOld,res=>{
                if(res.data.resultCode==1){
                    this.$message.success(res.data.message)
                    this.addShow=false
                    this.getCalendar()
                    this.getTodayVisitList()
                    this.getThisDay(this.StartDate)
                    this.toDayWeek = this.getWeek(new Date().Format("yyyy-MM-dd"))
                    this.getGetRecentVisitListByDate()
                    this.initMsg()
                    this.futureShow=true
                    this.thisDayShow=false
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        cancelEdit(){  // 取消新增
            this.addShow=false
            this.initMsg()
            this.prevVisitObj={}
        },
        initMsg(){
            this.addMsgNew = {
                customerInfoId:'',
                remark:'',
                expectVisitDateTime:'',
                newVisitDay:'',
                newVisitTime:'',
                CustomerId:'0',
    			VisitID:'0',
    			CustomerAccountId:'0',
    			SalesProcess:''
            }
            this.addMsgOldS = {
   				customerName:'',
                contact:'',
                contactNumber:'',
                address:'',
                brandIds:[],
                CustomerId:'0',
                CustomerAccountId:'0',
                remark:'',
                Duty:'',
                Premises:'',
                BusinessCardPhotos:[],
                HousePhotos:[],
                Images:[],
                CustomerSourceType:'',
                CustomerSource:'',
                Country:'2',
                Province:'',
                City:'',
                District:'',
            }
            this.customerVisit={
                remark:'',
                expectVisitDateTime:'',
                expectHour:0,
                VisitId:'0'
            }
    		this.BusinessCardPhotos='',
    		this.HousePhotos='',
    		this.Images='',            
            this.addMsgOld.customerVisit.expectHour=0
            this.addMsgOld.customerVisit.expectVisitDateTime=''
            this.addMsgOld.customerVisit.remark=''
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        handleCurrentChange(val) {
            this.msg.pageIndex = val;
        },
        
        getDateString: function() {//年月点击切换
            this.dateString = this.$calendarUtils.formatDate(
                this.currentYear,
                this.currentMonth,
                1
            );
        },
        initCalendar: function(cur) {  //初始化日历
            var newDays = this.$calendarUtils.createCalendar(cur);
            this.currentDay = newDays.CurrentDay;
            this.currentYear = newDays.CurrentYear;
            this.currentMonth = newDays.CurrentMonth;
            this.days.length = 0;
            var dateArray = newDays.DayArray;
            for (var i = 0; i < dateArray.length; i++) {
                var d = dateArray[i].day;
                var dayobject = {};
                dayobject.day = d;
                var myDate = this.$calendarUtils.formatDate(
                    d.getFullYear(),
                    d.getMonth() + 1,
                    d.getDate()
                );
                dayobject.checkState = this.$calendarUtils.checkState.noChecked;
                dayobject.checkStateT = false
                if (d.getMonth() + 1 == this.currentMonth) {
                    let newDate = new Date(d).Format('yyyy-MM-dd')
                    this.calendarList.forEach((x,index)=>{
                        if(x.haveVisit==true&&x.date==newDate){
                            dayobject.checkState = this.$calendarUtils.checkState.checked;
                        }
                    })
                }
                this.days.push(dayobject);
            }
        },
        clickedDay(item) {  //点击选取日历日期
            if (this.days != "" && this.days.length > 0) {
                this.days.forEach(dayItem => {
                    if (dayItem.day == item.day) {
                        dayItem.checkStateT=true
                        this.StartDate = this.$calendarUtils.formatDate2(item.day);
                        this.getThisDay(this.StartDate)
                        this.futureShow=false
                        this.thisDayShow=true
                        this.thisDayWeek = this.getWeek(this.StartDate)
                    } else {
                        dayItem.checkStateT=false
                    }
                });
            }
        },
        getTodayVisitList(){ //获取今日拜访计划
            this.apipost('app_get_my_visit_plan_list',{visitDate:this.toDay},res=>{
                if(res.data.resultCode==1){
                    this.TodayVisitList = res.data.data;
                }else{

                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        getCalendar(date){ // 获取日历计划
            let  msg = {
                date:''
            }
            if(date){
                msg.date=date
            }else{
                msg.date=new Date().Format("yyyy-MM-dd")
            }
            this.apipost('app_get_my_visit_calendar',msg,res=>{
                if(res.data.resultCode==1){
                    this.calendarList = res.data.data;
                    if(date){
                        this.initCalendar(date)
                    }else{
                        this.initCalendar()
                    }
                }else{
                    this.$message.error(res.data.message)
                }
            },err=>{})
        },
        pickPre: function(year, month) { //点击左箭头切换年月
            var d = new Date(this.$calendarUtils.formatDate(year, month, 1));
            d.setDate(0);
            this.getCalendar(
                this.$calendarUtils.formatDate(d.getFullYear(), d.getMonth() + 1, 1)
            );
        },
       
        pickNext: function(year, month) {   //点击右箭头切换年月
            var d = new Date(this.$calendarUtils.formatDate(year, month, 1));
            d.setDate(35);
            this.getCalendar(
                this.$calendarUtils.formatDate(d.getFullYear(), d.getMonth() + 1, 1)
            );
        },
        handleCheckAllChange(val) { //全选
            if(val){
                this.addMsg.brandIds=[]
                this.CustomerBrandList.forEach(x=>{
                    this.addMsg.brandIds.push(x.id)
                })
            }else{
                this.addMsg.brandIds=[]
            }
            this.isIndeterminate = false;
        },
        handleCheckedCitiesChange(value) {  //单选
            let checkedCount = value.length;
            this.checkAll = checkedCount === this.CustomerBrandList.length;
            this.isIndeterminate = checkedCount > 0 && checkedCount < this.CustomerBrandList.length;
        }
    },mounted(){
    	let userInfo=this.getLocalStorage();

        this.getCustomerBrandList()

        this.getCalendar()
        this.getTodayVisitList()
        this.toDayWeek = this.getWeek(new Date().Format("yyyy-MM-dd"))
        this.getGetRecentVisitListByDate()
        this.getAppCoustomer()
        this.getProvince()
        this.getJycs()   
        this.getZw()
        this.getKhly()   
        this.getSslc()
    }
}
</script>
