{
  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;


  },
  created: function() {
    /* if(this.codePath.indexOf("appuser")>=0){
       this.bizCode="appuser";
     }else{
       this.bizCode="allusers";
     }*/
  },
  methods: {
    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") {
        debugger;
        if(model.transfer_status=="PAY_OVER" || model.transfer_status=="MATERIAL_PROVIDE"){
          that.$message.warning("状态不可修改");
          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();
            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"
}
