feature/drag #4

Merged
liang.cheng merged 9 commits from feature/drag into master 2 years ago

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8" />
</project>

@ -0,0 +1,36 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="JSX" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="10" project-jdk-type="JavaSDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/org-chart-frant.iml" filepath="$PROJECT_DIR$/.idea/org-chart-frant.iml" />
</modules>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -0,0 +1,535 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="449daba1-1dd3-4ffd-906d-6ef641fb81de" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/d3-org-chart.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#0#49#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="NodeModulesDirectoryManager">
<handled-path value="$PROJECT_DIR$/node_modules" />
</component>
<component name="NodePackageJsonFileManager">
<packageJsonPaths>
<path value="$PROJECT_DIR$/package.json" />
</packageJsonPaths>
</component>
<component name="ProjectFrameBounds" fullScreen="true">
<option name="y" value="28" />
<option name="width" value="1440" />
<option name="height" value="872" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State />
<State>
<id>ActionScript specificJavaScript</id>
</State>
<State>
<id>Android</id>
</State>
<State>
<id>Ant</id>
</State>
<State>
<id>Batch Applications</id>
</State>
<State>
<id>CFML</id>
</State>
<State>
<id>CSS</id>
</State>
<State>
<id>Class structureJava</id>
</State>
<State>
<id>Code quality toolsCSS</id>
</State>
<State>
<id>Code quality toolsJavaScript</id>
</State>
<State>
<id>Code style issuesJava</id>
</State>
<State>
<id>CoffeeScript</id>
</State>
<State>
<id>CorrectnessLintAndroid</id>
</State>
<State>
<id>Cucumber</id>
</State>
<State>
<id>Error handlingJava</id>
</State>
<State>
<id>Faces Model</id>
</State>
<State>
<id>Flow type checkerJavaScript</id>
</State>
<State>
<id>FreeMarker</id>
</State>
<State>
<id>General</id>
</State>
<State>
<id>GeneralCoffeeScript</id>
</State>
<State>
<id>GeneralJavaScript</id>
</State>
<State>
<id>Google Web Toolkit</id>
</State>
<State>
<id>GrailsGroovy</id>
</State>
<State>
<id>Groovy</id>
</State>
<State>
<id>HTML</id>
</State>
<State>
<id>Hibernate</id>
</State>
<State>
<id>IconsUsabilityLintAndroid</id>
</State>
<State>
<id>ImportsJava</id>
</State>
<State>
<id>Inheritance issuesJava</id>
</State>
<State>
<id>Internationalization</id>
</State>
<State>
<id>InternationalizationJava</id>
</State>
<State>
<id>InternationalizationLintAndroid</id>
</State>
<State>
<id>Invalid elementsCSS</id>
</State>
<State>
<id>J2ME issuesJava</id>
</State>
<State>
<id>JSON and JSON5</id>
</State>
<State>
<id>JSP</id>
</State>
<State>
<id>Java</id>
</State>
<State>
<id>Java 8Java language level migration aidsJava</id>
</State>
<State>
<id>Java interop issuesKotlin</id>
</State>
<State>
<id>Java language level migration aidsJava</id>
</State>
<State>
<id>JavaFX</id>
</State>
<State>
<id>JavaScript</id>
</State>
<State>
<id>JavadocJava</id>
</State>
<State>
<id>Kotlin</id>
</State>
<State>
<id>LintAndroid</id>
</State>
<State>
<id>LintLintAndroid</id>
</State>
<State>
<id>Manifest</id>
</State>
<State>
<id>Markdown</id>
</State>
<State>
<id>MessagesCorrectnessLintAndroid</id>
</State>
<State>
<id>Node.jsJavaScript</id>
</State>
<State>
<id>OSGi</id>
</State>
<State>
<id>OtherGroovy</id>
</State>
<State>
<id>Pages Navigation Model</id>
</State>
<State>
<id>Plugin DevKit</id>
</State>
<State>
<id>PortabilityJava</id>
</State>
<State>
<id>Potentially confusing code constructsGroovy</id>
</State>
<State>
<id>Probable bugsJava</id>
</State>
<State>
<id>Properties Files</id>
</State>
<State>
<id>Properties FilesJava</id>
</State>
<State>
<id>RELAX NG</id>
</State>
<State>
<id>RESTful Web Service</id>
</State>
<State>
<id>Resource managementJava</id>
</State>
<State>
<id>SQL</id>
</State>
<State>
<id>Sass/SCSS</id>
</State>
<State>
<id>SecurityLintAndroid</id>
</State>
<State>
<id>SetupSpring CoreSpring</id>
</State>
<State>
<id>Spring</id>
</State>
<State>
<id>Spring BootSpring</id>
</State>
<State>
<id>Spring CoreSpring</id>
</State>
<State>
<id>Struts</id>
</State>
<State>
<id>Struts 1Struts</id>
</State>
<State>
<id>Struts 2Struts</id>
</State>
<State>
<id>Style issuesKotlin</id>
</State>
<State>
<id>TestNGJava</id>
</State>
<State>
<id>Threading issuesJava</id>
</State>
<State>
<id>TypeScript</id>
</State>
<State>
<id>UI Form</id>
</State>
<State>
<id>UsabilityLintAndroid</id>
</State>
<State>
<id>Validity issuesGroovy</id>
</State>
<State>
<id>Velocity</id>
</State>
<State>
<id>Verbose or redundant code constructsJava</id>
</State>
<State>
<id>VisibilityJava</id>
</State>
<State>
<id>Vue</id>
</State>
<State>
<id>Web Services</id>
</State>
<State>
<id>XML</id>
</State>
<State>
<id>XMLSpring CoreSpring</id>
</State>
<State>
<id>XPath</id>
</State>
<State>
<id>YAML</id>
</State>
</expanded-state>
</profile-state>
</entry>
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="CatdeaLogs" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="org-chart-frant" type="b2602c69:ProjectViewProjectNode" />
<item name="org-chart-frant" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="org-chart-frant" type="b2602c69:ProjectViewProjectNode" />
<item name="org-chart-frant" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1689842769496" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="preferences.externalDependencies" />
</component>
<component name="RebelAgentSelection">
<selection>jr</selection>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="449daba1-1dd3-4ffd-906d-6ef641fb81de" name="Default Changelist" comment="" />
<created>1689842546961</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1689842546961</updated>
<workItem from="1689842557088" duration="205000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="205000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="28" width="1440" height="872" extended-state="0" />
<layout>
<window_info id="JRebel" side_tool="true" />
<window_info id="Image Layers" />
<window_info id="UI Designer" />
<window_info id="Favorites" side_tool="true" />
<window_info id="Capture Tool" />
<window_info id="Designer" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Messages" />
<window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="JRebel Console" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Palette" />
<window_info anchor="right" id="Capture Analysis" />
<window_info anchor="right" id="aiXcoder" />
<window_info anchor="right" id="Maven Projects" />
<window_info anchor="right" id="Database" />
<window_info anchor="right" id="Palette&#9;" />
<window_info anchor="right" id="Theme Preview" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/d3-org-chart.js">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<element signature="e#0#49#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="ideajad">
<property name="annotate" value="false" />
<property name="annotateFully" value="false" />
<property name="braces" value="false" />
<property name="clear" value="false" />
<property name="confirmNavigationTriggeredDecompile" value="true" />
<property name="dead" value="true" />
<property name="defaultInitializers" value="false" />
<property name="dissassemblerOnly" value="false" />
<property name="fieldsFirst" value="true" />
<property name="fileExtension" value="java" />
<property name="fullyQualifiedNames" value="false" />
<property name="indentation" value="4" />
<property name="intRadix" value="10" />
<property name="lineNumbersAsComments" value="true" />
<property name="longRadix" value="10" />
<property name="maxStringLength" value="64" />
<property name="nocast" value="false" />
<property name="noclass" value="false" />
<property name="nocode" value="false" />
<property name="noconv" value="false" />
<property name="noctor" value="false" />
<property name="nodos" value="false" />
<property name="nofd" value="false" />
<property name="noinner" value="false" />
<property name="nolvt" value="false" />
<property name="nonlb" value="false" />
<property name="outputDirectory" value="" />
<property name="packFields" value="3" />
<property name="packImports" value="7" />
<property name="prefixNumericalClasses" value="_cls" />
<property name="prefixNumericalFields" value="_fld" />
<property name="prefixNumericalLocals" value="_lcl" />
<property name="prefixNumericalMethods" value="_mth" />
<property name="prefixNumericalParameters" value="_prm" />
<property name="prefixUnusedExceptions" value="_ex" />
<property name="readonly" value="false" />
<property name="safe" value="false" />
<property name="sort" value="false" />
<property name="spaceAfterKeyword" value="false" />
<property name="splitStringsAtNewline" value="false" />
<property name="useTabs" value="false" />
</component>
<component name="masterDetails">
<states>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<last-edited>fastdfs-client-java-1.27-RELEASE</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>10</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>

@ -2,7 +2,7 @@
* @Author: Chengliang 1546584672@qq.com
* @Date: 2022-08-04 10:22:55
* @LastEditors: Chengliang 1546584672@qq.com
* @LastEditTime: 2022-12-16 11:24:29
* @LastEditTime: 2023-07-24 09:57:14
* @FilePath: /org-chart-frant/.umirc.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -26,7 +26,8 @@ export default defineConfig({
proxy: {
'/api': {
// 标识需要进行转换的请求的url
target: 'http://127.0.0.1:8686/api', // 服务端域名 / http://localhost:8686
//target: 'http://127.0.0.1:8686/api', // 服务端域名 / http://localhost:8686
target: 'http://221.226.25.34:11080/api',
changeOrigin: true, // 允许域名进行转换
pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉
},

Binary file not shown.

@ -24,6 +24,7 @@
"@types/d3": "^7.4.0",
"d3": "7.4.4",
"d3-org-chart": "2.6.0",
"js-export-excel": "^1.1.4",
"jspdf": "^2.5.1",
"moment": "^2.29.3",
"qs": "^6.11.0",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

@ -0,0 +1,134 @@
import React from 'react';
import { TreeSelect, Modal, message } from 'antd';
export default class OperateDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
treeData: [],
open: false,
confirmLoading: false,
title: '',
operateType: '',
root: '',
type: 1,
};
}
componentDidMount() {}
handleOk = () => {
const { type } = this.state;
if (type === 1) {
this.props.addFolderNode();
} else {
this.props.deleteNode();
}
setTimeout(() => {
this.setState({ open: false });
message.success('操作成功');
}, 200);
// if (description.length == 0) {
// return message.error('');
// }
// this.setState({ confirmLoading: true });
// let api =
// '/api/bs/hrmorganization/orgchart/versionRecord?fclass=' +
// requestData.fclass +
// '&description=' +
// description;
// fetch(api)
// .then((res) => res.json())
// .then((data) => {
// if (data.api_status) {
// this.setState({
// open: false,
// confirmLoading: false,
// description: '',
// });
// message.success(',', 2, 3);
// } else {
// message.error(',', 2, 3);
// }
// });
};
/**
* 根节点树数据
* @param {} parentId
* @returns
*/
getNodeTreeNode = (parentId) => {
this.setState({ confirmLoading: true });
fetch(`/api/bs/hrmorganization/orgchart/getSubCompanyTree`)
.then((res) => res.json())
.then((data) => {
if (data.api_status) {
let arr = [];
arr = [...this.state.treeData, ...data.companyTree];
this.setState({
treeData: arr,
confirmLoading: false,
});
}
});
};
/**
* 根节点树异步加载
* @param {} parentId
* @returns
*/
onRootLoadData = (treeNode) =>
new Promise((resolve) => {
const { id } = treeNode.props;
setTimeout(() => {
let api = `/api/bs/hrmorganization/orgchart/getSubCompanyTree?subcompany=${id}`;
this.getNodeTreeNode(api);
resolve(undefined);
}, 500);
});
showOperate = (id, title, type) => {
this.setState({
open: true,
confirmLoading: true,
title: title,
type: type,
});
this.getNodeTreeNode(id);
};
onRootChange = (value) => {
this.setState({ root: value });
};
render() {
const { treeData, open, confirmLoading, title } = this.state;
return (
<>
<Modal
title={title}
cancelText="取消"
okText="确定"
open={open}
onOk={this.handleOk}
confirmLoading={confirmLoading}
onCancel={() => this.setState({ open: false })}
>
<TreeSelect
treeDataSimpleMode
allowClear
style={{ width: '100%' }}
value={this.state.root}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择要删除的节点"
onChange={this.onRootChange}
loadData={this.onRootLoadData}
treeData={treeData}
/>
</Modal>
</>
);
}
}

@ -0,0 +1,405 @@
import React from 'react';
import {
Drawer,
Space,
Button,
Dropdown,
Menu,
Table,
Spin,
Checkbox,
} from 'antd';
import { OrgChartComponent } from '@/components/orgChart';
import * as d3 from 'd3';
import qs from 'qs';
import { message } from 'antd';
import jsPDF from 'jspdf';
import ExportJsonExcel from 'js-export-excel';
import './index.less';
let addNodeChildFunc = null;
let orgChart = null;
let active = 'top';
export default class DrawerComponents extends React.Component {
constructor(props) {
super(props);
this.state = {
open: false,
data: [],
detailType: 'chart',
params: {},
dataSource: [],
columns: [],
spinning: true,
showJob: true,
};
}
componentDidMount() {}
//
onNodeClick(node) {}
onButtonClick(event, d) {
if (d.children) {
let idsList = [];
d.children.forEach((item) => {
if (item.data.hasChildren && !item._children) {
idsList.push(item.data.id);
}
});
if (idsList.length == 0) {
return;
}
}
}
//
getDepartmentImage(fisvitual) {
return fisvitual == '0'
? `./img/user-card/user-card.png`
: `./img/user-card/user-card-blue.png`;
}
//
getDeatilDatas(params, type = 'chart', showJob = '1') {
this.setState({ spinning: true });
d3.json(
'/api/bs/hrmorganization/orgchart/getDepartmentDetail?' +
qs.stringify({ detauleType: type, ...params, showJob }),
).then((data) => {
//
if (type == 'chart') {
this.setState({ data: data.data, spinning: false });
} else {
this.setState({ dataSource: data.dataSource, columns: data.columns });
}
});
}
// ButtonContent
buttonContentRender = ({ node, state }) => {
return `
<div style="margin-left: 16px; margin-top: 10px;">
<img src="./img/button_content.png" />
</div>
`;
};
//
nodeWidthRender = (d) => {
return 280;
};
nodeHeightRender = (d) => {
return 160;
};
// tool bar start
handleTopLayoutClick = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart &&
orgChart
.setCentered(orgChart.getChartState().root.id)
.layout('top')
.render();
active = 'top';
};
handleLeftLayoutClick = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart &&
orgChart
.layout('left')
.setCentered(orgChart.getChartState().root.id)
.render();
active = 'left';
};
handleZoomIn = (progressBtn) => {
if (progressBtn) {
let top = parseInt(progressBtn.current.style.top) - 10;
if (top >= 0) {
progressBtn.current.style.top = top + 'px';
} else {
return;
}
}
orgChart && orgChart.zoomIn();
};
handleZoomOut = (progressBtn) => {
if (progressBtn) {
let top = parseInt(progressBtn.current.style.top) + 10;
if (top <= 100) {
progressBtn.current.style.top = top + 'px';
} else {
return;
}
}
orgChart && orgChart.zoomOut();
};
downloadPdf = (chart) => {
chart.exportImg({
save: false,
full: true,
onLoad: (base64) => {
var pdf = new jsPDF();
var img = new Image();
img.src = base64;
img.onload = function () {
pdf.addImage(
img,
'JPEG',
5,
5,
595 / 3,
((img.height / img.width) * 595) / 3,
);
pdf.save('chart.pdf');
};
},
});
};
handleExport = (e) => {
let type = e.key == '1' ? 'png' : e.key == '1' ? 'pdf' : 'excel';
if (type == 'png') {
orgChart && orgChart.exportImg({ full: true });
} else if (type == 'pdf') {
orgChart && this.downloadPdf(orgChart);
} else {
let { dataSource } = this.state;
var option = {};
let dataTable = [];
if (dataSource) {
for (let i in dataSource) {
if (dataSource) {
let obj = {
序号: dataSource[i].id,
工号: dataSource[i].workCode,
姓名: dataSource[i].lastName,
性别: dataSource[i].sex,
部门: dataSource[i].departmentId,
分部: dataSource[i].subcompanyid1,
岗位: dataSource[i].jobTitle,
手机号: dataSource[i].mobile,
};
dataTable.push(obj);
}
}
}
option.fileName = '组织信息';
option.datas = [
{
sheetData: dataTable,
sheetName: 'sheet',
sheetFilter: [
'序号',
'工号',
'姓名',
'性别',
'部门',
'分部',
'岗位',
'手机号',
],
sheetHeader: [
'序号',
'工号',
'姓名',
'性别',
'部门',
'分部',
'岗位',
'手机号',
],
},
];
var toExcel = new ExportJsonExcel(option);
toExcel.saveExcel();
}
};
/**
* 节点渲染
*/
nodeContentRender = (d, i, arr, state) => {
if (d.data.ftype == 2) {
return `<div style="position: relative;">
<div style=" height: 152px;background-size: 100% 100%;box-sizing: border-box;padding-top: 30px;position:relative;z-index:2">
<div style='position:absolute;z-index:-1;top:0'>
<img style='width: 295px;height: 163px;' src="${this.getDepartmentImage(
d.data.fisvitual,
)}">
</div>
<div style="display: inline-block; background-size: 100% 100%; width: 35%; height: 90px; text-align:center; vertical-align: top; margin-left: 11px;box-sizing: border;">
<img src='./img/user-card/avatar-outer.png' style='position:absolute;width:90px;height:90px;left:11px'/>
<img src="./img/department.png" style="width: 58px; height: 58px;position:absolute;left:29px; border-radius: 50%; margin-top: 16px;position:absolute;left:29px;z-index:999"/>
</div>
<div style="display: inline-block; margin-left: 6px;width: 55%">
<div class="dept-box" style="font-size: 15px;font-family: Microsoft YaHei-Regular, Microsoft YaHei;font-weight: 900;color: #333333;height: 25px;line-height: 25px;width:110px,white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
${d.data.fname}
</div>
<div style="font-size: 13px;font-family: Microsoft YaHei-Bold, Microsoft YaHei;color: #333333;height: 25px;line-height: 25px;">
负责人:${d.data.fleader}
</div>
<div style="display:flex" >
<div style="height: 25px; line-height: 25px; min-width: 80px;">
在岗: ${d.data.fonjob}
</div>
</div>
</div>
</div>
</div>`;
} else if (d.data.ftype == 3) {
return `<div style="position: relative;">
<div style=" height: 152px;background-size: 100% 100%;box-sizing: border-box;padding-top: 40px;">
<div style='position:absolute;z-index:-1;top:0'>
<img style='width: 295px;height: 163px;' src='./img/user-card/user-card-orange.png'>
</div>
<img src="./img/user-card/jobicon-orange.png" style="margin-left: 20px; vertical-align: top;"/>
<div style="display: inline-block; margin-left: 15px;">
<div style="font-size: 15px;height: 25px;line-height: 25px;font-family: Microsoft YaHei-Bold, Microsoft YaHei;font-weight: bold;color: #333333;">${d.data.fname}</div>
<div style="font-size: 13px;font-family: Microsoft YaHei-Regular, Microsoft YaHei;font-weight: 400;color: #333333;display: flex;height: 25px;line-height: 25px;">
<span>在岗: ${d.data.fonjob} </span>
</div>
</div>
</div>
</div>`;
} else if (d.data.ftype == 4) {
return `<div style="position: relative;" >
<div style="height: 152px;background-size: 100% 100%;box-sizing: border-box;padding-top: 30px;">
<div style='position:absolute;z-index:-1;top:0px'>
<img style='width: 295px;height: 163px;' src='./img/user-card/user-card-green.png'>
</div>
<div style="display: inline-block; background-size: 100% 100%; width: 35%; height: 90px; text-align:center; vertical-align: top; margin-left: 11px;box-sizing: border;">
<img src='./img/user-card/avatar-outer-green.png' style='position:absolute;width:90px;height:90px;left:11px;z-index:-1'/>
<img src="${
d.data.fleaderimg
? d.data.fleaderimg
: './img/default_avator.png'
}" style="width: 58px; height: 58px; border-radius: 50%; margin-top: 16px;margin-left: -6px;z-index:999" />
</div>
<div style="display: inline-block; margin-left: 6px;width: 55%;height:100%">
<div style='display:flex;align-items:center;height: 25px;line-height: 25px;margin-top:15px'>
<div style="font-weight: bold;font-size: 15px;ont-family: Microsoft YaHei-Bold, Microsoft YaHei;color: #333333;">${
d.data.fname
}</div>
</div>
<div style="font-size: 13px;font-family: Microsoft YaHei-Regular, Microsoft YaHei;font-weight: 400;color: #333333;display: flex;height: 25px;line-height: 25px;">
<span>司龄: ${d.data.companyWorkYear} </span>
</div>
</div>
</div>
</div>`;
}
};
showDrawer = (params) => {
const showJob = params.fclass == '0' ? '1' : '0';
this.getDeatilDatas(params, 'chart', showJob);
this.setState({ open: true, params: params });
};
onClose = () => {
this.setState({ open: false, detailType: 'chart', showJob: true });
};
changeDetail = () => {
const { detailType, params } = this.state;
let type = detailType == 'chart' ? 'table' : 'chart';
const showJob = params.fclass == '0' ? '1' : '0';
this.setState({
detailType: type,
});
this.getDeatilDatas(params, type, showJob);
};
render() {
const {
params,
open,
data,
detailType,
dataSource,
columns,
spinning,
showJob,
} = this.state;
let arr = [];
if (detailType == 'chart') {
arr.push({ label: '导出图片', key: '1' });
//arr.push({ label: 'PDF', key: '2' });
} else {
arr.push({ label: '导出表格', key: '3' });
}
const menu = <Menu onClick={this.handleExport.bind(this)} items={arr} />;
return (
<Drawer
title="详细信息"
width={1000}
onClose={this.onClose}
open={open}
bodyStyle={{
paddingBottom: 80,
}}
extra={
<Space>
{detailType == 'chart' && params && params.fclass == '0' && (
<Checkbox
style={{ marginTop: '5px', marginLeft: 100 }}
checked={showJob}
onChange={(e) => {
this.setState({
showJob: e.target.checked,
});
this.getDeatilDatas(
params,
detailType,
e.target.checked ? '1' : '0',
);
}}
>
是否显示岗位
</Checkbox>
)}
<Dropdown overlay={menu}>
<Button type="primary">导出</Button>
</Dropdown>
<img
style={{ width: 36, height: 36, cursor: 'pointer' }}
src="./img/change.png"
onClick={this.changeDetail}
/>
</Space>
}
>
{detailType == 'chart' ? (
data.length > 0 && (
<Spin size="large" spinning={spinning}>
<OrgChartComponent
setChart={(chart) => (orgChart = chart)}
setClick={(click) => (addNodeChildFunc = click)}
onNodeClick={this.onNodeClick}
onButtonClick={this.onButtonClick}
data={data}
buttonContent={this.buttonContentRender}
nodeWidth={this.nodeWidthRender}
nodeHeight={this.nodeHeightRender}
nodeContent={this.nodeContentRender}
/>
</Spin>
)
) : (
<Table dataSource={dataSource} columns={columns} />
)}
</Drawer>
);
}
}

@ -0,0 +1,4 @@
.dept-box:hover {
width: 500px;
text-align: left;
}

@ -0,0 +1,71 @@
/*
* @Author: Chengliang 1546584672@qq.com
* @Date: 2023-06-25 16:33:21
* @LastEditors: Chengliang 1546584672@qq.com
* @LastEditTime: 2023-06-29 14:24:04
* @FilePath: /org-chart-frant/src/components/timeline/index.jsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React from 'react';
import { Timeline } from 'antd';
import styles from './index.less';
export default class TimeLine extends React.Component {
constructor(props) {
super(props);
this.state = {
timelineList: [],
};
}
handleLineClick(data) {
let newList = this.state.timelineList.map((item) => {
item.color = 'grey';
if (item.key == data.key) {
item.color = 'blue';
}
return item;
});
this.setState({
timelineList: newList,
});
this.props.onClick(data);
}
componentDidMount() {
this.searchTimeLines(this.props.url);
}
searchTimeLines(url) {
fetch(url)
.then((res) => res.json())
.then((data) => {
this.setState({
timelineList: data.timelineList,
});
});
}
render() {
return (
<div className={styles.lineWrapper}>
<Timeline>
{this.state.timelineList.map((item) => {
return (
<Timeline.Item
key={item.key}
onClick={this.handleLineClick.bind(this, item)}
className={styles.timeline}
color={item.color}
style={{ color: item.color == 'blue' ? '#1890ff' : 'dimgray' }}
>
<div>{item.title}</div>
<div className={styles.time}>{item.time}</div>
</Timeline.Item>
);
})}
</Timeline>
</div>
);
}
}

@ -0,0 +1,55 @@
.lineWrapper {
width: 208px;
height: calc(~'100% - 200px');
overflow-y: scroll;
position: fixed;
left: 10px;
z-index: 100;
background: #fff;
border-radius: 20px;
padding-top: 20px;
padding-bottom: 20px;
padding-left: 20px;
.timeline {
cursor: pointer;
}
.timeline :hover {
color: #1890ff;
}
.time {
color: dimgray;
}
}
.lineWrapper::-webkit-scrollbar {
/*滚动条整体样式*/
width: 10px;
/*高宽分别对应横竖滚动条的尺寸*/
height: 1px;
}
.lineWrapper::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
background-color: skyblue;
background-image: -webkit-linear-gradient(
45deg,
rgba(255, 255, 255, 0.2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, 0.2) 50%,
rgba(255, 255, 255, 0.2) 75%,
transparent 75%,
transparent
);
}
.lineWrapper::-webkit-scrollbar-track {
/*滚动条里面轨道*/
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
background: #ededed;
border-radius: 10px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

@ -6,6 +6,12 @@ import top from './img/top.png';
import left from './img/left.png';
import topActive from './img/top_active.png';
import leftActive from './img/left_active.png';
import fullscreen from './img/fullscreen.png';
import fit from './img/fit.png';
import compact from './img/compact.png';
import expandAll from './img/expandAll.png';
import deleteNode from './img/folder-remove.png';
import folderAdd from './img/folder-add.png';
export default class ToolBar extends React.Component {
progressBtn = React.createRef();
@ -97,6 +103,48 @@ export default class ToolBar extends React.Component {
this.props.onLeftLayoutClick(this.progressBtn);
}}
/>
{/* <img
className={styles.toolBarItem}
src={folderAdd}
onClick={() => {
this.props.onFolderAddNode(this.progressBtn);
}}
/>
<img
className={styles.toolBarItem}
src={deleteNode}
onClick={() => {
this.props.onDeleteNode(this.progressBtn);
}}
/> */}
<img
className={styles.toolBarItem}
src={fullscreen}
onClick={() => {
this.props.onFullscreen(this.progressBtn);
}}
/>
<img
className={styles.toolBarItem}
src={fit}
onClick={() => {
this.props.onFit(this.progressBtn);
}}
/>
<img
className={styles.toolBarItem}
src={compact}
onClick={() => {
this.props.onCompact(this.progressBtn);
}}
/>
<img
className={styles.toolBarItem}
src={expandAll}
onClick={() => {
this.props.onExpandAll(this.progressBtn);
}}
/>
</div>
);
}

@ -16,13 +16,13 @@
.progressLine {
height: 100px;
width: 0px;
border-left: 2px solid #C9C9C9;
border-left: 2px solid #c9c9c9;
margin-left: 12px;
}
.progressBtn {
width: 16px;
height: 9px;
background-color: #C9C9C9;
background-color: #c9c9c9;
position: absolute;
left: 5px;
top: 0px;
@ -32,7 +32,8 @@
display: block;
margin-top: 20px;
margin-bottom: 20px;
margin-left: 20px;
margin-left: 26px;
cursor: pointer;
width: 20px;
}
}

@ -1,4 +1,5 @@
import React from 'react';
import { QuestionCircleOutlined } from '@ant-design/icons';
import style from './index.less';
import {
DatePicker,
@ -9,8 +10,14 @@ import {
Col,
Dropdown,
Menu,
TreeSelect,
Tooltip,
Modal,
Input,
message,
} from 'antd';
const { Option } = Select;
const { TextArea } = Input;
import moment from 'moment';
import 'moment/locale/zh-cn';
import locale from 'antd/lib/date-picker/locale/zh_CN';
@ -21,26 +28,66 @@ export class TopBar extends React.Component {
super(props);
this.state = {
fclasslist: [],
companylist: [],
rootTreeData: [], //
treeExpandedKeys: [],
requestData: {
date: moment(new Date()).format('YYYY-MM-DD'),
fclass: '0',
root: '0',
level: '3',
root: undefined,
level: '2',
fisvitual: '0',
},
open: false,
confirmLoading: false,
description: '',
};
}
/**
* 表单值改变
* @param {*} payload
*/
handleFormChange(payload) {
let requestData = { ...this.state.requestData, ...payload };
this.setState({ requestData });
}
//
// disabledDate (current) {
// // return current && current >moment().subtract(1, "days");
// return current && current > moment().endOf("day");
// }
onChange = (e) => {
this.setState({ description: e.target.value });
};
/**
* 弹窗确认
*/
handleOk = () => {
const { description, requestData } = this.state;
if (description.length == 0) {
return message.error('请填写描述信息');
}
this.setState({ confirmLoading: true });
// setTimeout(() => {
// this.setState({ open: false, confirmLoading: false, description: '' });
// message.success(',');
// }, 2000);
let api =
'/api/bs/hrmorganization/orgchart/versionRecord?fclass=' +
requestData.fclass +
'&description=' +
description;
fetch(api)
.then((res) => res.json())
.then((data) => {
if (data.api_status) {
this.setState({
open: false,
confirmLoading: false,
description: '',
});
message.success('版本记录成功,请重新刷新页面', 2, 3);
} else {
message.error('版本记录失败,请联系相关人员处理数据', 2, 3);
}
});
};
handleExportMenuClick(e) {
this.props.onExport(e.key == '1' ? 'png' : 'pdf');
@ -50,16 +97,74 @@ export class TopBar extends React.Component {
this.props.onExport('png');
}
/**
* 根节点树数据
* @param {} parentId
* @returns
*/
getNodeTreeNode = (url, merge = true) => {
fetch(url)
.then((res) => res.json())
.then((data) => {
if (data.api_status) {
let arr = [];
if (merge) {
arr = [...this.state.rootTreeData, ...data.companyTree];
} else {
arr = [...data.companyTree];
}
this.setState({
rootTreeData: arr,
});
}
});
};
/**
* 根节点树异步加载
* @param {} parentId
* @returns
*/
onRootLoadData = (treeNode) =>
new Promise((resolve) => {
const { id } = treeNode.props;
setTimeout(() => {
const { fclass } = this.state.requestData;
let api =
'/api/bs/hrmorganization/orgchart/getSubCompanyTree?subcompany=' +
id +
'&fclass=' +
fclass;
this.getNodeTreeNode(api);
resolve(undefined);
}, 500);
});
onRootChange = (value) => {
let requestData = { ...this.state.requestData, root: value };
this.setState({ requestData });
};
onTreeExpand = (expandedKeys) => {
this.setState({
treeExpandedKeys: expandedKeys,
});
};
componentDidMount() {
fetch(this.props.url)
this.getSeatchCondition(this.props.url);
}
getSeatchCondition = (url) => {
fetch(url)
.then((res) => res.json())
.then((data) => {
this.setState({
fclasslist: data.fclasslist,
companylist: data.companylist,
rootTreeData: data.companyTree,
});
});
}
};
menu = (
<Menu
@ -69,92 +174,67 @@ export class TopBar extends React.Component {
label: '导出图片',
key: '1',
},
{
label: '导出PDF',
key: '2',
},
// {
// label: 'PDF',
// key: '2',
// },
]}
/>
);
render() {
const { disabled } = this.props;
const { disabled, type } = this.props;
const { rootTreeData, open, confirmLoading } = this.state;
return (
<div className={style.topbarWrapper}>
<Row>
<Col span={6}>
数据日期
<DatePicker
placeholder="请选择日期"
style={{ width: 130 }}
locale={locale}
allowClear={false}
// disabledDate={this.disabledDate}
defaultValue={moment(new Date())}
value={
this.state.requestData.date && this.state.requestData.date != ''
? moment(this.state.requestData.date)
: ''
}
onChange={(value) =>
this.handleFormChange({
date: value && value != '' ? value.format('YYYY-MM-DD') : '',
})
}
/>
</Col>
<Col span={6}>
维度
<Select
defaultValue="0"
style={{ width: 120 }}
style={{ width: 140 }}
value={this.state.requestData.fclass}
onChange={(value) => this.handleFormChange({ fclass: value })}
onChange={(value) => {
const requestData = {
fclass: value,
root: undefined,
level: '2',
fisvitual: '0',
};
this.handleFormChange(requestData);
this.getNodeTreeNode(
`/api/bs/hrmorganization/orgchart/getSubCompanyTree?fclass=${value}`,
false,
);
this.props.changeFclass(requestData);
}}
>
{this.state.fclasslist.map((item) => (
<Option value={item.id}>{item.companyname}</Option>
<Option key={item.key} value={item.id}>
{item.companyname}
</Option>
))}
</Select>
</Col>
<Col span={6}>
根节点
<Select
showSearch
filterOption={(input, option) =>
(option?.children).includes(input)
}
defaultValue="0"
style={{ width: 120 }}
<TreeSelect
treeDataSimpleMode
allowClear
style={{ width: '75%' }}
value={this.state.requestData.root}
onChange={(value) => this.handleFormChange({ root: value })}
>
{this.state.companylist.map((item) => (
<Option value={item.id}>{item.fname}</Option>
))}
</Select>
</Col>
<Col span={6}>
显示层级
<Select
defaultValue="3"
style={{ width: 120 }}
value={this.state.requestData.level}
onChange={(value) => this.handleFormChange({ level: value })}
>
<Option value="1">一级</Option>
<Option value="2">二级</Option>
<Option value="3">三级</Option>
</Select>
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="请选择根节点"
onChange={this.onRootChange}
loadData={this.onRootLoadData}
treeData={rootTreeData}
/>
</Col>
</Row>
<Row style={{ marginTop: '15px' }}>
<Col span={6}>
<Checkbox
style={{ marginTop: '5px' }}
style={{ marginTop: '5px', marginLeft: 100 }}
checked={this.state.requestData.fisvitual == '1'}
onChange={(e) =>
this.handleFormChange({
fisvitual: e.target.checked ? '1' : '0',
@ -163,18 +243,44 @@ export class TopBar extends React.Component {
>
显示虚拟组织
</Checkbox>
<Tooltip
title="提示:若启用虚拟组织,需要在分部自定义表增加字段(名称 fblx) 字段类型 下拉框(0实体 1虚拟) 部门自定义表同上(字段名称 bmlx)。"
color="#FF7F00"
placement="rightTop"
>
<QuestionCircleOutlined
style={{ color: '#FF7F00', cursor: 'pointer', fontSize: 16 }}
/>
</Tooltip>
</Col>
<Col span={6}>
部门层级
<Select
defaultValue="3"
style={{ width: 140 }}
value={this.state.requestData.level}
onChange={(value) => this.handleFormChange({ level: value })}
>
<Option value="1">全部</Option>
<Option value="2">一级</Option>
<Option value="3">二级</Option>
<Option value="4">三级</Option>
</Select>
</Col>
</Row>
<Row style={{ marginTop: '15px' }}>
<Col span={8}>
<Button
type="primary"
style={{ marginRight: '10px' }}
disabled={disabled}
onClick={() => {
this.props.onSynchronous(this.state.requestData);
this.setState({ open: true });
}}
>
同步数据
版本记录
</Button>
<Button
type="primary"
style={{ marginRight: '10px' }}
@ -185,10 +291,31 @@ export class TopBar extends React.Component {
查询
</Button>
<Dropdown overlay={this.menu}>
<Button>导出</Button>
<Button type="primary">导出</Button>
</Dropdown>
</Col>
</Row>
<Modal
title="版本记录"
cancelText="取消"
okText="确定"
open={open}
onOk={this.handleOk}
confirmLoading={confirmLoading}
onCancel={() => this.setState({ open: false })}
>
<p style={{ color: 'red' }}>
提示:版本记录耗时较长请谨慎操作仅记录当前维度的数据版本
</p>
<p>主题:</p>
<TextArea
showCount
maxLength={10}
style={{ height: 120, resize: 'none' }}
onChange={this.onChange}
placeholder="please enter"
/>
</Modal>
</div>
);
}

@ -480,7 +480,6 @@ export class OrgChart {
//InnerFunctions which will update visuals
const attrs = this.getChartState();
if (!attrs.data || attrs.data.length == 0) {
console.log('ORG CHART - Data is empty');
return this;
}
@ -637,19 +636,9 @@ export class OrgChart {
({ data }) => attrs.nodeId(data) === attrs.parentNodeId(obj),
)[0];
if (nodeFound) {
console.log(
`ORG CHART - ADD - Node with id "${attrs.nodeId(
obj,
)}" already exists in tree`,
);
return this;
}
if (!parentFound) {
console.log(
`ORG CHART - ADD - Parent node with id "${attrs.parentNodeId(
obj,
)}" not found in the tree`,
);
return this;
}
if (obj._centered && !obj._expanded) obj._expanded = true;
@ -670,19 +659,9 @@ export class OrgChart {
({ data }) => attrs.nodeId(data) === attrs.parentNodeId(obj),
)[0];
if (nodeFound) {
console.log(
`ORG CHART - ADD - Node with id "${attrs.nodeId(
obj,
)}" already exists in tree`,
);
return this;
}
if (!parentFound) {
console.log(
`ORG CHART - ADD - Parent node with id "${attrs.parentNodeId(
obj,
)}" not found in the tree`,
);
return this;
}
obj._expanded = true;
@ -701,9 +680,6 @@ export class OrgChart {
({ data }) => attrs.nodeId(data) == nodeId,
)[0];
if (!node) {
console.log(
`ORG CHART - REMOVE - Node with id "${nodeId}" not found in the tree`,
);
return this;
}
@ -1100,7 +1076,8 @@ export class OrgChart {
) {
return;
}
attrs.onNodeClick(attrs.nodeId(data));
//attrs.onNodeClick(attrs.nodeId(data));
attrs.onNodeClick(data);
});
// Add background rectangle for the nodes
@ -1298,7 +1275,6 @@ export class OrgChart {
// } else {
// this.fit();
// }
console.log(44444, centeredNodes);
this.fit({
animate: true,
scale: false,
@ -1622,7 +1598,6 @@ export class OrgChart {
const attrs = this.getChartState();
const { root } = attrs;
let descendants = nodes ? nodes : root.descendants();
console.log(11111111111, nodes, descendants, scale);
const minX = d3.min(
descendants,
(d) => d.x + attrs.layoutBindings[attrs.layout].nodeLeftX(d),
@ -1639,7 +1614,6 @@ export class OrgChart {
descendants,
(d) => d.y + attrs.layoutBindings[attrs.layout].nodeBottomY(d),
);
console.log('333,minY', minX, maxX, minY, maxY);
this.zoomTreeBounds({
params: { animate: animate, scale },
x0: transform == 'export' ? minX - 700 : minX - 50,
@ -1659,11 +1633,6 @@ export class OrgChart {
)[0];
if (!node) {
console.log(
`ORG CHART - ${
expandedFlag ? 'EXPAND' : 'COLLAPSE'
} - Node with id (${id}) not found in the tree`,
);
return this;
}
node.data._expanded = expandedFlag;
@ -1677,9 +1646,6 @@ export class OrgChart {
(d) => attrs.nodeId(d.data) === nodeId,
)[0];
if (!node) {
console.log(
`ORG CHART - CENTER - Node with id (${nodeId}) not found in the tree`,
);
return this;
}
node.data._centered = true;
@ -1693,9 +1659,6 @@ export class OrgChart {
(d) => attrs.nodeId(d.data) === nodeId,
)[0];
if (!node) {
console.log(
`ORG CHART - HIGHLIGHT - Node with id (${nodeId}) not found in the tree`,
);
return this;
}
node.data._highlighted = true;
@ -1710,9 +1673,6 @@ export class OrgChart {
(d) => attrs.nodeId(d.data) === nodeId,
)[0];
if (!node) {
console.log(
`ORG CHART - HIGHLIGHTROOT - Node with id (${nodeId}) not found in the tree`,
);
return this;
}
node.data._upToTheRootHighlighted = true;

@ -1,32 +1,55 @@
import styles from './index.less';
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import { OrgChartComponent } from '@/components/orgChart';
import * as d3 from 'd3';
import { TopBar } from '../components/topBar';
import ToolBar from '../components/toolBar';
import TimeLine from '../components/timeline';
import DrawerComponents from '../components/drawer';
import OperateDialog from '../components/dialog';
import jsPDF from 'jspdf';
import moment from 'moment';
import qs from 'qs';
import { message } from 'antd';
import { message, Spin } from 'antd';
let active = 'top';
let drawerCom = null;
let operateCom = null;
let timeLine = null;
let orgChart = null;
let topbar = null;
export default function companyPage() {
const [data, setData] = useState(null);
let compact = 0;
let expandAll = 0;
const [sliderProgress, setSliderProgress] = useState(50);
let addNodeChildFunc = null;
let orgChart = null;
let topBarSearchRequest = null;
const [hasRight, setHasRight] = useState('');
const [disabled, setDisabled] = useState(false);
const [timelineId, setTimelineId] = useState(0);
const infoRef = useRef();
useEffect(() => {
infoRef.current = timelineId;
}, [timelineId]);
const [spinning, setSpinning] = useState(false);
//
function onNodeClick(nodeId) {
// alert('clicked ' + nodeId);
const onNodeClick = (node) => {
if (node.ftype == '2') {
const params = {
rootId: node.id,
fclass: topbar.state.requestData.fclass,
id: infoRef.current,
};
drawerCom.showDrawer(params);
}
};
//
function onButtonClick(event, d) {
const onButtonClick = (event, d) => {
if (d.children) {
let idsList = [];
d.children.forEach((item) => {
@ -40,9 +63,6 @@ export default function companyPage() {
}
let idsStr = idsList.join(',');
console.log('idsStr', idsStr);
let api = '';
if (topBarSearchRequest) {
let request = { ...topBarSearchRequest, ids: idsStr };
@ -51,44 +71,36 @@ export default function companyPage() {
qs.stringify(request, { addQueryPrefix: true });
} else {
api =
'/api/bs/hrmorganization/orgchart/asyncCompanyData?fclass=0&root=0&date=' +
moment(new Date()).format('YYYY-MM-DD') +
'&ids=' +
'/api/bs/hrmorganization/orgchart/asyncCompanyData?fclass=0&fisvitual=0&id=0&root=0&ids=' +
idsStr;
}
fetch(api)
.then((res) => res.json())
.then((data) => {
if (data.data) {
data.data.forEach((item) => {
window.chart.addNode(item);
// window.chart.addNode(item);
orgChart.addNode(item);
});
}
});
}
}
};
//
function getDepartmentImage() {
let index = Math.floor(Math.random() * 8) + 1;
// return `./img/department/${index}.png`;
return `./img/department/1.png`;
function getDepartmentImage(fisvitual) {
return fisvitual == '0' ? `./img/back/level4.png` : `./img/back/level8.png`;
}
//
function getSubcompanyImage() {
let index = Math.floor(Math.random() * 3) + 1;
// return `./img/subcompany/${index}.png`;
return `./img/subcompany/2.png`;
//
function getSubcompanyImage(fisvitual) {
return fisvitual == '0' ? `./img/back/level1.png` : `./img/back/level5.png`;
}
//
useEffect(() => {
d3.json(
// "/company/data"
'/api/bs/hrmorganization/orgchart/companyData?fclass=0&isvitual=0&root=0&date=' +
moment(new Date()).format('YYYY-MM-DD'),
'/api/bs/hrmorganization/orgchart/companyData?fclass=0&fisvitual=0&root=0&level=2&id=0',
).then((data) => {
setData(data.data);
setHasRight(data?.hasRight);
@ -120,24 +132,16 @@ export default function companyPage() {
if (d.data.ftype == 0) {
return 100;
} else if (d.data.ftype == 1) {
return 160;
return 106;
} else if (d.data.ftype == 2) {
return 56;
return 106;
}
return 120;
};
const nodeContentRender = (d, i, arr, state) => {
//
let companyUrl =
'/spa/organization/static/index.html#/main/organization/group';
//
let subcompanyUrl = `/spa/organization/static/index.html#/main/organization/companyExtend/${d.data.fobjid}`;
//
let departmentUrl = `/spa/organization/static/index.html#/main/organization/departmentExtend/${d.data.fobjid}`;
if (d.data.ftype == 0) {
return `<div onclick="if(${d.data.fisvitual}==1) return;window.open('${companyUrl}', '_blank')" style="text-align:center">
return `<div style="text-align:center">
<div style="display: inline-block; vertical-align: top;">
<img src="./img/company.png" />
</div>
@ -154,39 +158,30 @@ export default function companyPage() {
</div>
</div>`;
} else if (d.data.ftype == 1) {
return `<div onclick="if(${
d.data.fisvitual
}==1) return;window.open('${subcompanyUrl}', '_blank')">
<div style="width: 85px; height: 85px; border: 1px solid #66BAF5; border-radius: 50%;text-align: center; line-height: 85px; margin: 0 auto;display:flex;justify-content:center;align-items:center">
<img src="${getSubcompanyImage()}" />
</div>
<div style="width: 136px; border: 1px solid #66BAF5; margin: 10px auto 0px; border-radius: 23px; text-align: center;
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #333333;
line-height: 18px;
padding: 15px 10px;
">
${d.data.fname}
return `<div style='position:absolute;height:100%'>
<img style='width:144px;height:106px' src="${getSubcompanyImage(
d.data.fisvitual,
)}"/>
</div>
<div style="width: 144px;height: 80px;top: 35px;position: relative;font-weight: 400;font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;color: #333333;text-align: center;">
<div title=${
d.data.fname
} style="width: 110px;margin: 0 auto;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;-o-text-overflow:ellipsis;
line-height: 18px;word-break: break-all;">${d.data.fname}</div>
</div>`;
} else if (d.data.ftype == 2) {
return `
<div style="width: 100%; height: 100%; background-size: 100% 100%;" onclick="if(${
d.data.fisvitual
}==1) return;window.open('${departmentUrl}')">
<div style='position:absolute'>
<img src='./img/company_job_label.png'/></div>
<div style="padding-left: 8px; padding-top: 23px;display:flex;align-items:center">
<img src="${getDepartmentImage()}"/>
<span style="
margin-left: 3px;
font-size: 12px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #333333;
">${d.data.fname}</span>
<div style="width: 100%; height: 100%; background-size: 100% 100%;">
<div style='position:absolute;height:100%'>
<img style='width:144px;height:106px' src="${getDepartmentImage(
d.data.fisvitual,
)}"/>
</div>
<div style="width: 144px;height: 80px;top: 35px;position: relative;font-weight: 400;font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;color: #333333;text-align: center;">
<div style="width: 110px;margin: 0 auto;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
line-height: 18px;word-break: break-all;">${d.data.fname}</div>
</div>
</div>
`;
@ -194,7 +189,6 @@ export default function companyPage() {
return `<div>${d.data.fname}</div>`;
};
// tool bar start
const handleTopLayoutClick = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart &&
@ -215,6 +209,56 @@ export default function companyPage() {
active = 'left';
};
const handleFullscreen = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart && orgChart.fullscreen('body');
};
const handleFit = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart && orgChart.fit();
};
const handleFolderAddNode = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
operateCom &&
operateCom.showOperate(topbar.state.requestData.root, '新增节点', 1);
};
const addFolderNode = (id) => {
orgChart &&
orgChart.addNode({
id: 'd_10091',
fname: '测试增加节点',
parentId: 's_10',
ftype: '2',
});
};
const handleDeleteNode = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
operateCom &&
operateCom.showOperate(topbar.state.requestData.root, '删除节点', 2);
};
const deleteNode = (id) => {
orgChart && orgChart.removeNode('d_10091');
};
const handleCompact = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart &&
orgChart
.compact(!!(compact++ % 2))
.render()
.fit();
};
const handleExpandAll = (progressBtn) => {
progressBtn.current.style.top = 50 + 'px';
orgChart && expandAll++ % 2 ? orgChart.collapseAll() : orgChart.expandAll();
};
const handleZoomIn = (progressBtn) => {
if (progressBtn) {
let top = parseInt(progressBtn.current.style.top) - 10;
@ -243,10 +287,6 @@ export default function companyPage() {
orgChart && orgChart.zoomBehavior(value - 50);
};
// tool bar end
// top bar start
function downloadPdf(chart) {
chart.exportImg({
save: false,
@ -270,6 +310,10 @@ export default function companyPage() {
});
}
/**
* 导出
* @param {*} type
*/
const handleExport = (type) => {
if (type == 'png') {
orgChart && orgChart.exportImg({ full: true });
@ -278,7 +322,32 @@ export default function companyPage() {
}
};
const handleSearch = (requestData) => {
/**
* 时间轴点击
* @param {*} timeline
*/
const timeLineSearch = (timeline) => {
setTimelineId(timeline.id);
const fclass = topbar.state.requestData.fclass;
const resetParams = { root: undefined, level: '2', fisvitual: '0' };
topbar.handleFormChange({ ...resetParams });
topbar.getNodeTreeNode(
`/api/bs/hrmorganization/orgchart/getSubCompanyTree?fclass=${fclass}&id=${timeline.id}`,
false,
);
let requestData = { fclass: fclass, id: timeline.id, ...resetParams };
handleSearch(requestData, false);
};
/**
* 查询
* @param {*} requestData
*/
const handleSearch = (requestData, cache = true) => {
setSpinning(true);
if (cache) {
requestData = { ...requestData, id: infoRef.current };
}
topBarSearchRequest = requestData;
let api =
'/api/bs/hrmorganization/orgchart/companyData' +
@ -294,27 +363,26 @@ export default function companyPage() {
setData(data?.data);
}
}
setTimeout(function () {
setSpinning(false);
}, 200);
});
};
const handleSynchronous = (requestData) => {
setDisabled(true);
let api = '/api/bs/hrmorganization/orgchart/synchronousData';
fetch(api)
.then((res) => res.json())
.then((data) => {
if (data.code == 200) {
message.success('同步成功,请重新查询');
} else {
message.error('数据同步失败');
}
setDisabled(false);
//this.handleSearch(requestData);
});
/**
* 切换维度
* @param {*} requestData
*/
const handleChange = (requestData) => {
setTimelineId(0);
timeLine.searchTimeLines(
`/api/bs/hrmorganization/orgchart/timeLines?fclass=${requestData.fclass}`,
);
requestData = { ...requestData, id: 0 };
handleSearch(requestData, false);
};
useEffect(() => {
console.log('data', data);
if (active == 'left') {
orgChart &&
orgChart
@ -329,9 +397,8 @@ export default function companyPage() {
.render();
}
}, [data]);
// top bar end
if (hasRight === false) {
//return message.error("", 2);
return (
<div style={{ width: '100%', top: '40%', position: 'absolute' }}>
<img
@ -347,28 +414,42 @@ export default function companyPage() {
hasRight && (
<div className={styles.contentWrapper}>
<TopBar
ref={(r) => (topbar = r)}
onExport={(type) => {
handleExport(type);
}}
onSearch={(requestData) => {
handleSearch(requestData);
}}
onSynchronous={(requestData) => {
handleSynchronous(requestData);
changeFclass={(requestData) => {
handleChange(requestData);
}}
disabled={disabled}
type="company"
url="/api/bs/hrmorganization/orgchart/getCondition?type=company"
url="/api/bs/hrmorganization/orgchart/getCondition?fclass=0&type=company"
/>
<ToolBar
onTopLayoutClick={(progressBtn) => handleTopLayoutClick(progressBtn)}
onLeftLayoutClick={(progressBtn) =>
handleLeftLayoutClick(progressBtn)
}
onFullscreen={(progressBtn) => handleFullscreen(progressBtn)}
onFit={(progressBtn) => handleFit(progressBtn)}
onFolderAddNode={(progressBtn) => handleFolderAddNode(progressBtn)}
onDeleteNode={(progressBtn) => handleDeleteNode(progressBtn)}
onCompact={(progressBtn) => handleCompact(progressBtn)}
onExpandAll={(progressBtn) => handleExpandAll(progressBtn)}
onZoomOut={(progressBtn) => handleZoomOut(progressBtn)}
onZoomIn={(progressBtn) => handleZoomIn(progressBtn)}
onZoomBehavior={(value) => handleZoomBehavior(value)}
/>
<TimeLine
ref={(r) => (timeLine = r)}
onClick={(timeline) => {
timeLineSearch(timeline);
}}
url={'/api/bs/hrmorganization/orgchart/timeLines?fclass=0'}
/>
<Spin size="large" spinning={spinning}>
<OrgChartComponent
setChart={(chart) => (orgChart = chart)}
setClick={(click) => (addNodeChildFunc = click)}
@ -380,6 +461,13 @@ export default function companyPage() {
nodeHeight={nodeHeightRender}
nodeContent={nodeContentRender}
/>
</Spin>
<DrawerComponents ref={(r) => (drawerCom = r)} />
<OperateDialog
ref={(r) => (operateCom = r)}
addFolderNode={addFolderNode}
deleteNode={deleteNode}
/>
</div>
)
);

@ -3,9 +3,9 @@
}
.wrapper {
background: #F7F9FD;
background: #f7f9fd;
}
.contentWrapper {
background-color: #F7F9FD;
background-color: #f7f9fd;
}

@ -4,6 +4,7 @@ import { OrgChartComponent } from '@/components/orgChart';
import * as d3 from 'd3';
import { TopBar } from '../components/topBar';
import ToolBar from '../components/toolBar';
import TimeLine from '../components/timeline';
import moment from 'moment';
import qs from 'qs';
import { message } from 'antd';
@ -11,6 +12,8 @@ import jsPDF from 'jspdf';
let active = 'top';
export default function userPage() {
const [data, setData] = useState(null);
let topbar = null;
let timeLine = null;
const [topBarSearchRequest, setTpBarSearchRequest] = useState(null);
const [requestRes, setRequestRes] = useState({
date: moment(new Date()).format('YYYY-MM-DD'),
@ -25,7 +28,7 @@ export default function userPage() {
let progressBtnRef = null;
const [hasRight, setHasRight] = useState('');
const [disabled, setDisabled] = useState(false);
const [id, setId] = useState(0);
//
function onNodeClick(nodeId) {
// alert('clicked ' + nodeId);
@ -54,8 +57,7 @@ export default function userPage() {
qs.stringify(request, { addQueryPrefix: true });
} else {
api =
'/api/bs/hrmorganization/orgchart/asyncUserData?fclass=0&root=0&date=' +
moment(new Date()).format('YYYY-MM-DD') +
'/api/bs/hrmorganization/orgchart/asyncUserData?fclass=0&fisvitual=0&root=0&level=3&id=0' +
'&ids=' +
idsStr;
}
@ -72,13 +74,23 @@ export default function userPage() {
}
}
/**
* 时间轴点击
* @param {*} timeline
*/
const timeLineSearch = (timeline) => {
setId(timeline.id);
let requestData = { ...topbar.state.requestData, id: timeline.id };
handleSearch(requestData, false);
};
//
function getDepartmentImage() {
let index = Math.floor(Math.random() * 8) + 1;
return `./img/department/${index}.png`;
}
//
//
function getSubcompanyImage() {
let index = Math.floor(Math.random() * 3) + 1;
return `./img/subcompany/${index}.png`;
@ -87,11 +99,10 @@ export default function userPage() {
//
useEffect(() => {
document.cookie =
'Webstorm-3d4d3ad4=b8ca5bef-a131-4c2b-81da-6f8595481dc2; ecology_JSessionid=aaad2HRSW843U9BJFcUuy; JSESSIONID=aaad2HRSW843U9BJFcUuy; loginidweaver=1; languageidweaver=7; loginuuids=1; __randcode__=47f1e1cc-51de-48b3-af04-3875b717805f';
'ecology_JSessionid=aaauntrtgZdkuanT5w2Ly; JSESSIONID=aaauntrtgZdkuanT5w2Ly; loginidweaver=1; languageidweaver=7; loginuuids=1; __randcode__=c5235342-7633-4eec-a754-b36eefdf8c9e';
d3.json(
// "/user/data"
'/api/bs/hrmorganization/orgchart/userData?fclass=0&root=0&date=' +
moment(new Date()).format('YYYY-MM-DD'),
'/api/bs/hrmorganization/orgchart/userData?fclass=0&fisvitual=0&root=0&level=3&id=0',
).then((data) => {
setData(data.data);
setHasRight(data?.hasRight);
@ -161,10 +172,6 @@ export default function userPage() {
orgChart && orgChart.zoomOut();
};
// tool bar end
// top bar start
function downloadPdf(chart) {
chart.exportImg({
save: false,
@ -196,7 +203,10 @@ export default function userPage() {
}
};
const handleSearch = (requestData) => {
const handleSearch = (requestData, cache = true) => {
if (cache) {
requestData = { ...requestData, id: id };
}
setTpBarSearchRequest(requestData);
let api =
'/api/bs/hrmorganization/orgchart/userData' +
@ -215,20 +225,15 @@ export default function userPage() {
});
};
const handleSynchronous = (requestData) => {
setDisabled(true);
let api = '/api/bs/hrmorganization/orgchart/synchronousData';
fetch(api)
.then((res) => res.json())
.then((data) => {
if (data.code == 200) {
message.success('同步成功,请重新查询');
} else {
message.error('数据同步失败');
}
setDisabled(false);
//this.handleSearch(requestData);
});
/**
* 切换维度
* @param {*} requestData
*/
const handleChange = (requestData) => {
timeLine.searchTimeLines(
`/api/bs/hrmorganization/orgchart/timeLines?fclass=${requestData.fclass}`,
);
handleSearch(requestData);
};
useEffect(() => {
@ -309,7 +314,7 @@ export default function userPage() {
? d.data.fleaderimg
: d.data.ftype == 0 || d.data.ftype == 1
? './img/company.png'
: './img/default_avator.png'
: './img/department.png'
}" style="width: 58px; height: 58px;position:absolute;left:29px; border-radius: 50%; margin-top: 16px;position:absolute;left:29px;z-index:999"/>
</div>
<div style="display: inline-block; margin-left: 6px;width: 55%" >
@ -506,6 +511,7 @@ export default function userPage() {
hasRight && (
<div className={styles.contentWrapper}>
<TopBar
ref={(r) => (topbar = r)}
onExport={(type) => {
handleExport(type);
}}
@ -513,12 +519,11 @@ export default function userPage() {
setRequestRes(requestData);
handleSearch(requestData);
}}
onSynchronous={(requestData) => {
handleSynchronous(requestData);
changeFclass={(requestData) => {
handleChange(requestData);
}}
disabled={disabled}
type="user"
url="/api/bs/hrmorganization/orgchart/getCondition?type=user"
url="/api/bs/hrmorganization/orgchart/getCondition?fclass=0&type=user"
/>
<ToolBar
onTopLayoutClick={handleTopLayoutClick}
@ -526,6 +531,13 @@ export default function userPage() {
onZoomOut={(progressBtn) => handleZoomOut(progressBtn)}
onZoomIn={(progressBtn) => handleZoomIn(progressBtn)}
/>
<TimeLine
ref={(r) => (timeLine = r)}
onClick={(timeline) => {
timeLineSearch(timeline);
}}
url={'/api/bs/hrmorganization/orgchart/timeLines?fclass=0'}
/>
<OrgChartComponent
setChart={(chart) => (orgChart = chart)}
setClick={(click) => (addNodeChildFunc = click)}

Loading…
Cancel
Save