{
  template: '${tmpl}',
    data: function() {
      return {
        multipleSelection: [],
        isSingleSelect: false,
        bizCode: 'mytradetransferdiliver',
        showUploadform: false,
        showEditPhoneForm: false,
        f1: "",
        trackVisable:false,
        trackContent:"",
        trackRecords:[
    
        ],
        currentRow:null,
        isbtnRunning:false,
        isPhoneSaveRunning:false,
        editPhoneForm:{
          id:null,
          phone:"",
          row:null
        },
        rules: {
          phone: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { min: 11, max: 11, message: '手机号长度必须为11位', trigger: 'blur' }
          ]
        }
      }
    },
  mounted: function() {
    this.currentRow=null;
    setTimeout(()=>{
      let $q=$("button span:contains('邮寄资料')");
      let $groupMailSend= $q.parent().parent().parent();
      $groupMailSend.hide();

      let $jg=$("button span:contains('递交官方资料')");
      let $groupJG= $jg.parent().parent().parent();
      $groupJG.hide();

      let $upBuyerGZ=$("button span:contains('上传盖章资料(买家)')");
      console.log($upBuyerGZ.text());
      let $groupBuyerGZ= $upBuyerGZ.parent().parent().parent();
      $groupBuyerGZ.hide();

      let $upSellerGZ=$("button span:contains('上传盖章资料(卖家)')");
      let $groupSellerGZ= $upSellerGZ.parent().parent().parent();
      $groupSellerGZ.hide();

      let $upOtherGZ=$("button span:contains('上传盖章资料(其它)')");
      let $groupOtherGZ= $upOtherGZ.parent().parent().parent();
      $groupOtherGZ.hide();

    },1500);
   
  },
  created: function() {
    /* if(this.codePath.indexOf("appuser")>=0){
       this.bizCode="appuser";
     }else{
       this.bizCode="allusers";
     }*/
  },
  methods: {
    onforminit(fm,ctls){
      ctls["logistics"]=false;
      ctls["mail_zip_url"]=false;
      ctls["seller_proxy"]=false;
      ctls["transfer_receive_ack"]=false;

    },
    onselchange(prop,fm,target,ctls){
      let $q=$("button span:contains('邮寄资料')");
      let $groupMailSend= $q.parent().parent().parent();

      let $jg=$("button span:contains('递交官方资料')");
      let $groupJG= $jg.parent().parent().parent();

      let $upBuyerGZ=$("button span:contains('上传盖章资料(买家)')");
      let $groupBuyerGZ= $upBuyerGZ.parent().parent().parent();


      let $upSellerGZ=$("button span:contains('上传盖章资料(卖家)')");
      let $groupSellerGZ= $upSellerGZ.parent().parent().parent();


      let $upOtherGZ=$("button span:contains('上传盖章资料(其它)')");
      let $groupOtherGZ= $upOtherGZ.parent().parent().parent();

       if(fm[prop]=="BUYER_EXPRESS"){
        $groupMailSend.show();
        ctls["logistics"]=true;
        ctls["mail_zip_url"]=true;
        
       }else{
        ctls["logistics"]=false;
        ctls["mail_zip_url"]=false;
        $groupMailSend.hide();
 
       }
       if(fm[prop]=="SUBMIT_TO_SBJ"){
        ctls["seller_proxy"]=true;
        ctls["transfer_receive_ack"]=true;
        $groupJG.show();
        
       }else{
        ctls["seller_proxy"]=false;
        ctls["transfer_receive_ack"]=false;
        $groupJG.hide();
       }
       
       if(fm[prop]=="BUYER_PROVIDE_MATERIAL"){
        $groupBuyerGZ.show();
        $groupSellerGZ.show();
        $groupOtherGZ.show(); 
       }else{
        $groupBuyerGZ.hide();
        $groupSellerGZ.hide();
        $groupOtherGZ.hide();
       }
       console.log(prop,fm[prop]);
    },
    validateformmethod(rule, value, cbk){
      return cbk();
    },
    inputMobile(row){
      this.showEditPhoneForm = true;
      this.editPhoneForm.id = row.id;
      if(row.mobile&&row.mobile.length==11){
        this.editPhoneForm.phone = row.mobile;
      }else{
        this.editPhoneForm.phone = null
      }
      this.editPhoneForm.row = row;
    },
    phoneFormCancelClick(){
      this.showEditPhoneForm = false;
      this.editPhoneForm.id = null;
      this.editPhoneForm.phone = null;
      this.editPhoneForm.row = null;
    },
    phoneFormSaveClick(){
      this.$refs["editPhoneForm"].validate((valid) => {
        if (valid) {
          this.$root.postReq("/web/transfer/tradetransferCtl/updatePhone", {
            id:this.editPhoneForm.id,
            phone:this.editPhoneForm.phone
          }).then((d)=> {
            if (d.status > -1) {
              this.$message({
                type: 'success',
                message: '修改手机号成功!'
              });
              this.editPhoneForm.row.mobile = this.editPhoneForm.phone;
              this.showEditPhoneForm = false;
              this.editPhoneForm.id = null;
              this.editPhoneForm.phone = null;
              this.editPhoneForm.row = null;
            }else{
              this.$message.warning("修改手机号失败");
            }
          })
        } else {
          return false;
        }
      });
    },
    onDlgFormClick(k, model){
      var that=this;
      if (k = "alisubmit") {
        if(model.transfer_status=="PAY_OVER" || model.transfer_status=="MATERIAL_PROVIDE" || model.transfer_status=="MATERIALS_TO_BE_SUBMITTED" || model.transfer_status=="PASS_ALIYUN_VERIFY"){
          that.$message.warning("状态不可修改");
          return;
        }
        if(model.transfer_status=="BUYER_PROVIDE_MATERIAL"){
          this.$confirm('提交盖章资料后,阿里开始审核,资料再无法修改，除非审核不通过，是否继续提交？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$root.postReq("/web/transfer/tradetransferCtl/submit", model).then(function (d) {
              if (d.status > -1) {
                $("[name='grdid']").show();
                $("[name='frmid']").hide();
                that.$message({
                  type: 'success',
                  message: '提交成功!'
                });
              }else{
                $("[name='grdid']").show();
                $("[name='frmid']").hide();
                if(d.msg){
                  that.$message.warning("提交失败:"+d.msg);
                }else{
                  that.$message.warning("提交失败");
                }
              }
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消提交'
            });  
          });
          return
        }
        this.$root.postReq("/web/transfer/tradetransferCtl/submit", model).then(function (d) {
          if (d.status > -1) {
            $("[name='grdid']").show();
            $("[name='frmid']").hide();
            that.$message({
              type: 'success',
              message: '提交成功!'
            });
          }else{
            $("[name='grdid']").show();
            $("[name='frmid']").hide();
            if(d.msg){
              that.$message.warning("提交失败:"+d.msg);
            }else{
              that.$message.warning("提交失败");
            }
          }
        });
   
      
      }
    },
    onColFormater(row, column, cellvalue, index){
      /*这里解析跟进字段，解析为数组，取最后一条*/
      if(column.property=="tracklast"){
        if(row.tracklog && row.tracklog!=""){
          tlogobj= JSON.parse(row.tracklog.split("|")[0]);
          console.log(tlogobj["content"],"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
          return tlogobj["content"];
        }
       
     }
      return cellvalue;
    },
    handleSelectionChange: function(val) {
      this.multipleSelection = val;
      console.log(val);
    },
    fetchData: function() {

    },
    onRowClick(row, key, e){
      if (key == "upfiles") {
        console.log(this.$router);
        this.$router.push({ path: "/tansfersupplymaterail", query: { ali_bizid: row.ali_bizid } });

      }
      if (key == "notar") {
        console.log(this.$router);
        this.$router.push({ path: "/mynotarizationflow", query: { ali_bizid: row.ali_bizid } });
      }
      if(key=="tracks"){
        this.trackContent="";
        this.currentRow=row;
        this.trackVisable=true;
        this.handlerTrackLog(this.currentRow);
        if(this.trackRecords.length==0){
          this.trackRecords.push({"trackDate":"暂无跟进","trackContent":"请联系客户，进行跟进"});
        }
      }
      if(key=="bicall"){
        this.$confirm('确定要发起双呼?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$root.postReq("/web/transfer/tradetransferCtl/aliDoubleCall", {aliBizId:row.ali_bizid}).then( (d) =>{
            if (d.status > -1) {
              this.$message({
                type: 'success',
                message: '呼叫成功'
              });
            }else{
              this.$message.warning(d.msg);
            }
          })
        }).catch(() => {
        });
      }
    },
    handlerTrackLog(row){
      this.trackRecords=[];
      if(row.tracklog && row.tracklog!=""){
        let arrstrs=row.tracklog.split("|");
        arrstrs.forEach((item)=>{
          if(item && item!=""){
            let it=JSON.parse(item);
            if(it){
              let trackItem={"trackDate":`${it.dateStr} ${it.yw}`,"trackContent":`${it.timeStr} ${it.content}`};
              this.trackRecords.push(trackItem);
            }
       
          }
       
        })
      }
    },
    upsuccess(result){
      console.log(result);
    },
    showdetail(){
      alert("track.......details");
    },
    cancelClick(){
      this.trackVisable=false;
    },
    saveClick(){
      this.isbtnRunning=true;
      if(this.trackContent==""){
        return;
      }
      let tid=this.currentRow.id;
      let pushData={"tid":tid,"log":{"content":this.trackContent}};
      var self=this;
      this.$root.postReq("/web/transfer/tradetransferCtl/track", {logdata:pushData}).then(function (d) {
        /*返回整个跟进字段，解析为数组*/
         console.log(d.data,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
         self.currentRow.version=d.data.version;
         self.currentRow.tracklog=d.data.tracklog;
         self.handlerTrackLog(self.currentRow);
         self.trackContent="";
         self.isbtnRunning=false;
        
      })
      
    }
  },
  computed: Vuex.mapState({
    headStyle: function () {
      return { "background-color": "white" };
    }
  }),
    vname: "gsb-tradetransferdiliver"
}
