import React, { Component } from 'react';
import {
  WeaOrgTree,
  WeaLocaleProvider,
} from "ecCom";

const {getLabel} = WeaLocaleProvider;

export default class OrganzationTree extends Component {
  
  treeNodeClick = (nodeObj) => {
    if(nodeObj && nodeObj.node && nodeObj.node.props) {
      // type: 0公司   1分部   2部门
      let {id="", type="0"} = nodeObj.node.props;
      if(this.props.refreshData && typeof(this.props.refreshData) === "function") {
        this.props.refreshData(id, type);
      }
    }
  }

  render() {
    return (
      <WeaOrgTree ecId={`${this && this.props && this.props.ecId || ''}_WeaOrgTree@8uaoth`}
        needSearch
        // isLoadAllSub={true}
        topPrefix={'hrmSearch'}
        params={{showCanceled: "", rightStr: this.props.rightStr}}
        inputLeftDom={`<div style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap;"><b>${getLabel(25332, '组织结构')}</b></div>`}
        treeNodeClick={this.treeNodeClick}
        selectedKeys={this.props.selectedKeys || []}
        {...this.props}
      />
    )
  }
}
