var tmpl=`
/**说明：添加了获取焦点时显示历史客户的功能 目前应用于agencytmreg页面 */
 <div>
     <el-select style="width:100%" size="small" :value="value" @change="onchange"  v-model="sels" clearable
     @focus="focus" @blur="blur" @clear="clear"
       :placeholder="placeHolder"
       :default-first-option="isFirstDefault"
       :filterable="isFilter"
       :multiple="isMulti"
       :remote="autoComplete"
       :reserve-keyword="autoComplete"
       :remote-method="remoteMethod"
       :disabled="isDisabled"
       :allow-create="allowcreatedata"
       :loading="loading">
        <template>
          <el-option
            v-for="(item,index) in dataSouce"
            :key="index"
            :label="item.entName"
            :value="item.creditCode"
          ></el-option>
        </template>
     </el-select>
 </div>
`
module.exports=
`{
   template:'${tmpl}',
   model:{
    prop: 'value',
    event: 'change'
   },
   props:["frombrowser","showhistory","refwhere2","parentcode","parentfield","level","levelfield","value","refMethod","dicKey","refModel","placeHolder","autoComplete","isGrouped","isFirstDefault","isFilter","isMulti","labelField","valueField", "isDisabled","allowcreate"],
   data:function(){
     return {
       fetchtype:"bigdata",
       dataSouce:[],
       loading:false,
       sels:this.value?this.value:[],
       allowcreatedata:this.allowcreate?true:false,
       refwhere:this.refwhere2?this.refwhere2:{},
       showhistory:this.showhistory,
       frombrowser:this.frombrowser?this.frombrowser:false,
     };
   },
   mounted:function(){

   },
   watch:{
     value:function(v){
        this.sels=v;
     },
   },
   created:function(){
     
   },
   computed:{

   },
   methods:{
     focus(){
       this.fetchHistoryData();
     },
     blur(){
       this.$emit("input",this.sels);
     },
     clear(){
       this.$emit("input",this.sels);
     },
     fetchHistoryData(){
       console.log("this.frombrowser");
       console.log(this.frombrowser);
       if(this.frombrowser){
         var personList=[];
         var historypersondata = localStorage.getItem("historypersonlist");
         console.log(historypersondata);
         if(historypersondata){
            historypersondata=JSON.parse(historypersondata);
            personList = historypersondata.data;
            this.dataSouce=personList;
            this.loading=false;
         }
       }else{
         this.$root.getReq("/web/customerinfoCtl/getMyCustomerPersonInfo",{likeName:this.sels}).then(d=>{
            if(d && d.code==1 && d.data){
              this.dataSouce=d.data;
              this.loading=false;
            }
          })
       }
       
     },
     remoteMethod(query) {
       this.value = query;
       this.sels = query;
       if(this.sels){
         this.fetchHistoryData();
       }
       this.$emit("input",query);
      },
     fetchData:function(slike){
       
     },
     onchange:function(curval){
       if(this.dataSouce && this.dataSouce.length>0){
           for(var i=0;i<this.dataSouce.length;i++){
             var data = this.dataSouce[i];
             if(data.creditCode==curval){
               this.$emit("historychange",data);
               return;
             }
           }
         }
        
     },
   },
   vname:"gsb-selectperson"
}`
