diff --git a/README.md b/README.md index f2246d4..71eba63 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 聚才林人员组织前端代码 -####分支介绍 +#### 分支介绍 亚信科技 #### 介绍 diff --git a/pc4mobx/organization/apis/orgchart.js b/pc4mobx/organization/apis/orgchart.js new file mode 100644 index 0000000..201a1e1 --- /dev/null +++ b/pc4mobx/organization/apis/orgchart.js @@ -0,0 +1,8 @@ +import { WeaTools } from 'ecCom' + + +export const getOrgChartData = (params) => { + return WeaTools.callApi(`/api/hrm/orgchart/getOrgChartData`, 'POST', params); +} + + diff --git a/pc4mobx/organization/components/orgchart/index.js b/pc4mobx/organization/components/orgchart/index.js new file mode 100644 index 0000000..dd132f1 --- /dev/null +++ b/pc4mobx/organization/components/orgchart/index.js @@ -0,0 +1,145 @@ +import React from 'react' +import * as mobx from 'mobx' +import { + inject, + observer +} from 'mobx-react' +import { + WeaTop, WeaTab, WeaFormItem, WeaRightMenu, WeaLeftRightLayout, WeaDatePicker +} from 'ecCom' +import { + Spin,Button +} from 'antd' +import { + i18n +} from '../../public/i18n'; +const toJS = mobx.toJS; +import '../../style/common.less'; +import domtoimage from 'dom-to-image'; +import { saveAs } from 'file-saver'; + +@inject('orgchart') +@observer +export default class OrgChart extends React.Component { + constructor(props) { + super(props); + } + + componentDidMount() { + this.init(); + console.log("22",document.getElementById("box_org_tree")); + window.addEventListener('message', this.messageHandle, false); + } + + componentWillUnmount() { + window.removeEventListener('message', this.messageHandle, false); + } + + componentWillReceiveProps(nextProps) { + if (this.props.location.key !== nextProps.location.key) { + this.init(true); + } + } + + messageHandle = (e) => { + const { + orgchart: store + } = this.props; + if (e.data.act == 'initOrgChart') { + store.onInitOrgChart(e.data.status); + } else if (e.data.act == 'callChild') { + store.showSpin(e.data.status); + } + } + + //导出架构图 + exportImage = () => { + const node = document.getElementById("box_org_tree"); + domtoimage.toBlob(node).then((blob) => { + // 调用file-save方法 直接保存图片 + saveAs(blob, '组织架构.png') + }) +} + + /** + * 添加多级路径 + * + * @param {*} url + */ + addContentPath = (url) => { + const ecologyContentPath = window.ecologyContentPath || ''; + if (url && ecologyContentPath) { + //避免重复添加ecologyContentPath + //避免传入的参数不是链接 + if (url.startsWith('/') && !url.startsWith(ecologyContentPath)) { + url = ecologyContentPath + url; + } + } + return url; + }; + + init(refresh = false) { + const { + orgchart: store + } = this.props; + //checkAuthorized('orgchart', null, () => initData(refresh)); + store.initData(refresh); + } + + getChildrenCom = () => { + const { + orgchart + } = this.props; + const { + date + } = orgchart; + + let btns = []; + btns.push( +
+
日期选择:
+ orgchart.changeDate(value)} + endValue={new Date()} + /> + +
+ ) + return btns; + } + + + + render() { + + const { + orgchart: store + } = this.props; + const { + setIframe, + spinning + } = store; + + return ( + +
+ + } + iconBgcolor='#217346' + loading={true} + buttons={this.getChildrenCom()} + > +
+