From d6b7856d569b3043bbf3781b3ad00a23fa826d93 Mon Sep 17 00:00:00 2001
From: Chengliang <1546584672@qq.com>
Date: Tue, 28 Mar 2023 13:43:23 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=9A=E4=BF=A1=E7=A7=91=E6=8A=80=E7=BB=84?=
=?UTF-8?q?=E7=BB=87=E5=9B=BE=E8=A7=86=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
pc4mobx/organization/apis/orgchart.js | 8 +
.../organization/components/orgchart/index.js | 145 ++++++++++++++++++
pc4mobx/organization/index.js | 5 +-
pc4mobx/organization/stores/index.js | 6 +-
pc4mobx/organization/stores/orgchart.js | 114 ++++++++++++++
6 files changed, 275 insertions(+), 5 deletions(-)
create mode 100644 pc4mobx/organization/apis/orgchart.js
create mode 100644 pc4mobx/organization/components/orgchart/index.js
create mode 100644 pc4mobx/organization/stores/orgchart.js
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()}
+ >
+
+
+
+
+
+ )
+ }
+}
diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js
index de71a75..50e3afc 100644
--- a/pc4mobx/organization/index.js
+++ b/pc4mobx/organization/index.js
@@ -34,7 +34,8 @@ import ResourceBasicInfo from "./components/resource/ResourceBasicInfo";
import ResourceCard from "./components/resource/ResourceCard";
import ManagerDetach from "./components/detach/ManagerDetach";
import ColumnSetting from "./components/columnSetting";
-import PersonnelResume from "./components/resource/PersonnelResume"
+import PersonnelResume from "./components/resource/PersonnelResume";
+import OrgChart from "./components/orgchart/index";
import stores from "./stores";
import "./style/index";
@@ -102,7 +103,7 @@ const Routes = (
-
+
);
diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js
index 0fe47d4..1d64b75 100644
--- a/pc4mobx/organization/stores/index.js
+++ b/pc4mobx/organization/stores/index.js
@@ -28,7 +28,8 @@ import {ImportDialogStore} from "./importDialog";
import {ResourceCardStore} from "./resourceCard";
import {ManagerDetachStore} from "./managerDetach";
import {ColumnSetting} from './columnSetting';
-import {PersonnelResumeStore} from './personnelResume'
+import {PersonnelResumeStore} from './personnelResume';
+import { OrgChartStore } from "./orgchart";
module.exports = {
@@ -62,5 +63,6 @@ module.exports = {
resourceCard:new ResourceCardStore(),
managerDetach: new ManagerDetachStore(),
columnSetting: new ColumnSetting(),
- personnelResume:new PersonnelResumeStore()
+ personnelResume:new PersonnelResumeStore(),
+ orgchart:new OrgChartStore()
};
diff --git a/pc4mobx/organization/stores/orgchart.js b/pc4mobx/organization/stores/orgchart.js
new file mode 100644
index 0000000..2c7c341
--- /dev/null
+++ b/pc4mobx/organization/stores/orgchart.js
@@ -0,0 +1,114 @@
+import {
+ observable,
+ action
+} from 'mobx';
+import { WeaTools } from 'ecCom';
+import * as mobx from 'mobx';
+import * as API from '../apis/orgchart';
+import {
+ Modal,
+ message,
+} from 'antd'
+import {
+ i18n
+} from '../public/i18n';
+import moment from "moment";
+const toJS = mobx.toJS;
+
+
+export class OrgChartStore {
+
+ @observable spinning = false;
+ @observable hasRight = '';
+ @observable date = moment(new Date()).format('YYYY-MM-DD');
+
+ iframe;
+ /********************* action list *********************/
+ initData = (refresh = false) => {
+ this.iframe = null;
+ //this.hasRight = true;
+ this.callInitData();
+ }
+
+
+ callInitData = () => {
+ if(this.spinning)
+ return;
+ this.spinning = true;
+ this.getChartData();
+ }
+
+ setIframe = (iframe) => {
+ if(iframe == null || this.iframe != null)
+ return;
+ this.iframe = iframe;
+ this.callInitData();
+ }
+
+ changeDate = (value) => {
+ this.date = value;
+ this.getChartData();
+ }
+
+ onInitOrgChart = (status) => {
+ this.spinning = false;
+ switch (status) {
+ case 0:
+ message.error(i18n.message.dataNone());
+ break;
+ case -1:
+ message.error(i18n.message.dataConstructError());
+ break
+ }
+ }
+
+ showSpin = (val) => {
+ this.spinning = (val === '0');
+ }
+
+ @action getChartData = (reset = false) => {
+ this.spinning = true;
+ const params = {};
+
+ Object.assign(params, {
+ arg0: 1,
+ arg3: true,
+ arg11: ';;B',
+ date: this.date
+ });
+ API.getOrgChartData(params).then(data => {
+ if (data.status === '1') {
+ const msgData = {
+ act: 'orgChart', // 自定义的消息类型、行为,用于switch条件判断等。。
+ orgData: data.data,
+ params: {
+ sorgid: 1,
+ isShow: params.arg11,
+ showNum: 'false',
+ shownum: 25
+ },
+ client: {
+ browser: WeaTools.ua.browser,
+ browserVersion: {
+ browser: WeaTools.ua.browser,
+ version: parseInt(WeaTools.ua.version)
+ },
+ version: parseInt(WeaTools.ua.version),
+ os: WeaTools.ua.os
+ }
+ };
+ const sendMsg = setInterval(() => {
+ if ($('#orgChartFrame')[0] != null) {
+ clearInterval(sendMsg);
+ $('#orgChartFrame')[0].contentWindow.postMessage(msgData, '*');
+ }
+ }, 500);
+ // this.iframe && this.iframe.contentWindow.postMessage(msgData, '*');
+ } else {
+ this.spinning = false;
+ }
+ }, error => {
+ this.spinning = false;
+ })
+ }
+}