{
  template: '${tmpl}',
  data: function () {
    return {
      multipleSelection: [],
      isSingleSelect: false,
      dialogVisible: false,
      epartner_id: "",
      epartnerLoading: false,
      epartnerList:[],
      contractId: 0,
      
    }
  },
  mounted: function () {},
  created: function () {},
  methods: {
    btnvisbleMethod(row, btn){
      if(btn.key=="assign"){
        return row.epartner_id ? false : true;
      }
      return true;
    },
    onColFormater(row, column, cellvalue, index) {
      var self = this;     
      if (column.property == "created_at") {
        return self.formateTime(cellvalue);
      }

      console.log(column.property);

      if (column.property == "epartner.nickName") {
        return cellvalue || "无";
      }

      if(typeof(cellvalue) == 'number') {
        return cellvalue || 0;
      }
      return cellvalue || "---";
    },
    onDlgFormClick(k, model){
    },
    handleSelectionChange: function (val) {
      this.multipleSelection = val;
      console.log(val);
    },
    fetchData: function () {

    },
    toolBarClick(k, t) {
      if(k == "mynew") {
        this.$root.pushx({
          title : "新建合同",
          name : "/ecompanycontractedit",
        });
      }
    },    
    onRowClick(row, key, e) {
      var self = this;
      if(key == 'cancel') {
        window.history.back(-1);
      }
      console.log($(e.target).text());

      if(key == 'assign') {
        console.log(key, row.id, "----------------------------------");
        this.dialogVisible = true;
        this.epartner_id = "";
        this.contractId = row.id;
        /* this.$router.push({path:"/ecommissionlist",query:{epartnerId: row.id}}); */
      }

      if(key == 'info') {
        this.$root.pushx({
          title : "查看合同",
          name : "/ecompanycontractinfo",
          params: {contrId: row.id}
        });
      }
    },
    formateTime(inputTime) {
      if(!inputTime) {
        return "";
      }
      var date = new Date(inputTime);
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? ('0' + m) : m;
      var d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      var h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      var minute = date.getMinutes();
      minute = minute < 10 ? ('0' + minute) : minute;
      return y + '-' + m + '-' + d + ' ' + h + ':' + minute;
    },
    getEPartners(query) {
      var self = this;
      self.epartnerLoading = true;
      self.$root.postReq("/web/epartnerCtl/suggest", {
          name: query
      }).then(function (d) {
          self.epartnerLoading = false;
          self.epartnerList = d.data || [];
      });
      setTimeout(() => {
          self.epartnerLoading = false; 
      }, 5000);
    },

    assignContract() {
      var self = this;
      if(!self.epartner_id) {
        self.$message({
          type: 'warning',
          message:"请先选择合伙人",
        });
        return;
      }
      self.$root.postReq("/web/ecompanycontractCtl/assignContract", {
        contractId: self.contractId,
        epartner_id: self.epartner_id,
      }).then(function (d) {
        if (d.status == 0) {
          self.$message.success(`分配成功`);
          self.dialogVisible = false;
          self.$refs.ecompanycontractallGrid.fetchData();
        } else {
          self.$message.warning(d.msg || `分配失败`);
        }
      });
    }

  },
  computed: Vuex.mapState({
    count: state => state.count,
    headStyle: function () {
      return {
        "background-color": "white"
      };
    }
  }),
  vname: "gsb-ecompanycontractall"
}