{
  template:'${tmpl}',
  data:function(){
      return {
        sourcecode:"",
        applicant_cn:"",
        tm_company_type:"",
        business:{},
        bclist:[],
      }
  },
  computed: Vuex.mapState({
    count:state=>state.count,
    headStyle:function(){
      return {"background-color":"white"};
    }
  }),
  created:function(){

  },
  mounted:function(){
    var that=this;
    console.log("11111111111111111111111");
    console.log(this.$router.history.current.query);
    var sourcecode=this.$router.history.current.query.sourcecode || "";
    var applicant_cn= this.$router.history.current.query.applicant_cn || "";
    var tm_company_type = this.$router.history.current.query.tm_company_type || "";
    if(sourcecode){
      this.sourcecode=sourcecode;
      this.getBusinessDetail();
    }else if(applicant_cn && tm_company_type){
      console.log(applicant_cn);
      this.applicant_cn=applicant_cn;
      this.tm_company_type=tm_company_type;
      this.getBusinessDetail();
      
    }else{
      this.$message.warning("sourcecode参数错误！");
      this.$root.pushx({
        title:"平台线索池",
        name:"/businesscompany"
      });
      return;
    }
  },
  methods:{
    formatTime(data){
      if(data){
        var d = new Date(data);
        var datetime=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
        return datetime;
      }else{
        return "";
      }
      
    },
    getBusinessDetail(){
      var that = this;
      this.$root.postReq("/web/businesscompanyCtl/getBusinessDetail",{sourceCode:this.sourcecode,applicant_cn:this.applicant_cn,tm_company_type:this.tm_company_type}).then(d=>{
        console.log(d);
        if(d && d.code==1){
          for(var i=0;i<d.data.biList.length;i++){
            if(d.data.biList[i].regist_notice_day){
              d.data.biList[i].regist_notice_day = that.formatTime(d.data.biList[i].regist_notice_day);
            }
            d.data.biList[i].tm_end_day = that.formatTime(d.data.biList[i].tm_end_day);
          }
          that.business=d.data;
          var bc = d.data.bc;
          if(bc && bc.mobile_list){
            console.log(bc.mobile_list);
            var mobile = bc.mobile_list;
            mobile=JSON.parse(mobile);
            bc.mobile_list=mobile.join(",");
          }
          if(bc && bc.company_mail){
            console.log(bc.company_mail);
            var mail = bc.company_mail;
            mail=JSON.parse(mail);
            bc.company_mail=mail.join(",");
          }
          if(bc){
            if(bc.tm_end_day_min){
              bc.tm_end_day_min = that.formatTime(bc.tm_end_day_min);
            }
            if(bc.tm_end_day_max){
              bc.tm_end_day_max = that.formatTime(bc.tm_end_day_max);
            }
            if(bc.tm_end_day_max && bc.tm_end_day_min){
              bc.tm_end_day_min = bc.tm_end_day_min+"至"+bc.tm_end_day_max;
            }
            if(bc.claim_time){
              bc.claim_time = that.formatTime(bc.claim_time);
            }
            if(bc.recovery_time){
              bc.recovery_time = that.formatTime(bc.recovery_time);
            }
          }
          that.bclist=[bc];
        }else{
          that.$message.warning(d.msg);
        }
      }).catch(e=>{
        console.log(e);
        that.$message.warning("操作失败");
      });
    },
    uodateStatus(status){
      if(status){
        var that = this;
        this.$root.postReq("/web/businesscompanyCtl/updateBusinessStatus",{sourceCode:this.sourcecode,status:status}).then(d=>{
          console.log(d);
          if(d && d.code==1){
            that.getBusinessDetail();
            that.$message.success("操作成功");
          }else{
            that.$message.warning(d.msg);
          }
        }).catch(e=>{
          console.log(e);
          that.$message.warning("操作失败");
        });
      }
    }
    
  },

  vname:"gsb-businessdetail"
}
