{
  template:'${tmpl}',
  data:function(){
     
      return {
        d:{},
        action:"",
        form:{},
        id:"",
        code:"",
        ncl_one_code:"",
        tmList:[],
        tmdetail:{},
        bizCode:"",
      }
  },
  computed: Vuex.mapState({
    count:state=>state.count,
    headStyle:function(){
      return {"background-color":"white"};
    }
  }),
  created:function(){
    
  },
  mounted:function(){
    var that=this;
    if(this.codePath.split("/").indexOf("ptmtransactiondetailpmg")>=0){
      this.bizCode="ptmtransactiondetailpmg";
    }else{
      this.bizCode="ptmtransactiondetail";
    }
    console.log("aaaaaaaaaa:"+this.bizCode);
    var id = this.$router.history.current.query.id;
    var code = this.$router.history.current.query.code;
    var ncl_one_code = this.$router.history.current.query.ncl_one_code;
    if(ncl_one_code){
      this.ncl_one_code=ncl_one_code;
    }
    if(this.bizCode=="ptmtransactiondetailpmg"){
      if(id){
        this.id=id;
        this.getDetailById();
        this.tmRegistSearch();
      }else{
        this.$message.warning("id参数错误");
        this.$root.pushx({
          title:"商标交易库",
          name:"/tmtransactionpmg"
        });
        return;
      }
    }else{
      if(code){
        this.code=code;
        this.getDetailByCode();
        this.tmRegistSearch();
      }else{
        this.$message.warning("code参数错误");
        this.$root.pushx({
          title:"商标交易库",
          name:"/mytmtransaction"
        });
        return;
      }
    }
    this.$root.postReq("/web/uploadCtl/getOssConfig","").then(function(d){
        that.d["key"]="key";
        that.d["Bucket"]=d.Bucket;
        that.d["OSSAccessKeyId"]=d.OSSAccessKeyId;
        that.d["Signature"]=d.Signature;
        that.d["policy"]=d.policy;
        that.d["success_action_status"]=d.success_action_status;
        that.action=d.url;
    });
  },
  methods:{
    getDetailById(){
      if(this.id){
        var o= {id:this.id};
        this.$root.getReq("web/trademarktransactionCtl/getDetailById",o).then(d=>{
          console.log(d);
          if(d && d.code==1){
            this.form=d.data;
          }else{
            this.$message.warning(d.msg);
          }
        }).catch(e=>{
          this.$message.warning("操作失败");
        })
      }
    },
    getDetailByCode(){
      if(this.code){
        var o= {code:this.code};
        if(this.ncl_one_code){
          o["ncl_one_code"] =this.ncl_one_code;
        }
        this.$root.getReq("web/trademarktransactionCtl/getDetailByCode",o).then(d=>{
          console.log(d);
          if(d && d.code==1){
            this.form=d.data;
          }else{
            this.$message.warning(d.msg);
          }
        }).catch(e=>{
          this.$message.warning("操作失败");
        })
      }
    },
    tmRegistSearch(){
      if(this.code){
        var o= {registNum:this.code};
        if(this.ncl_one_code){
          o={sbzch:this.code,gjfl:this.ncl_one_code};
          this.$root.getReq("web/trademarktransactionCtl/tmRegistGjflSearch",o).then(d=>{
            console.log(d);
            if(d && d.status==0 && d.data && d.data.rows && d.data.rows.length>0){
              var list = d.data.rows;
              this.tmList=list;
              this.tmdetail=list[0];
            }
          }).catch(e=>{
            this.$message.warning("操作失败");
          })
        }else{
          this.$root.getReq("web/trademarktransactionCtl/tmRegistSearch",o).then(d=>{
            console.log(d);
            if(d && d.status==0 && d.data && d.data.rows && d.data.rows.length>0){
              var list = d.data.rows;
              this.tmList=list;
              this.tmdetail=list[0];
            }
          }).catch(e=>{
            this.$message.warning("操作失败");
          })
        }
        
      }
    },
    updatePlatformPrice(){
      var price = this.form.business_quoted_price || 0;
      var platform_quoted_price = Number(price)*1.2+1000;
      platform_quoted_price = platform_quoted_price.toFixed(2);
      this.form.platform_quoted_price=platform_quoted_price;
    },
    setKey(name,flag){
      var myDate = new Date();
      var key = "zc_"+flag+Math.round(Math.random()*10000)+myDate.getTime()+myDate.getFullYear()+myDate.getMonth()+myDate.getDate()+".jpg";
      this.$refs[flag].d.key = key;
    },
    error(err){
      this.$message.warning(`上传失败，请重新上传`);
      console.log(err);
    },
    uploadsuccess(obj){
      console.log(obj);
      this.form.pic_url=obj.result;
    },
    submitUpdate(){
      this.$root.showMask();
      this.$root.postReq("web/trademarktransactionCtl/updateTm",this.form).then(d=>{
        console.log(d);
        if(d && d.code==1){
          this.$message.success("修改成功");
          this.getDetailByCode();
        }else{
          this.$message.warning(d.msg);
        }
        this.$root.hideMask();
      }).catch(e=>{
        this.$message.warning("操作失败");
        this.$root.hideMask();
      })
    }
  },

  vname:"gsb-ptmtransactiondetail"
}
