|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
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';
|
|
|
|
@ -15,24 +15,34 @@ let active = 'top';
|
|
|
|
|
let drawerCom = null;
|
|
|
|
|
let timeLine = null;
|
|
|
|
|
let orgChart = null;
|
|
|
|
|
let topbar = null;
|
|
|
|
|
|
|
|
|
|
export default function companyPage() {
|
|
|
|
|
let topbar = null;
|
|
|
|
|
const [data, setData] = useState(null);
|
|
|
|
|
const [sliderProgress, setSliderProgress] = useState(50);
|
|
|
|
|
let addNodeChildFunc = null;
|
|
|
|
|
|
|
|
|
|
let topBarSearchRequest = null;
|
|
|
|
|
const [hasRight, setHasRight] = useState('');
|
|
|
|
|
const [id, setId] = useState(0);
|
|
|
|
|
const [timelineId, setTimelineId] = useState(0);
|
|
|
|
|
const infoRef = useRef();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
infoRef.current = timelineId;
|
|
|
|
|
}, [timelineId]);
|
|
|
|
|
const [spinning, setSpinning] = useState(false);
|
|
|
|
|
|
|
|
|
|
// 点击节点
|
|
|
|
|
function onNodeClick(node) {
|
|
|
|
|
const onNodeClick = (node) => {
|
|
|
|
|
if (node.ftype == '2') {
|
|
|
|
|
drawerCom.showDrawer(node.id);
|
|
|
|
|
const params = {
|
|
|
|
|
rootId: node.id,
|
|
|
|
|
fclass: topbar.state.requestData.fclass,
|
|
|
|
|
id: infoRef.current,
|
|
|
|
|
};
|
|
|
|
|
drawerCom.showDrawer(params);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 扩展按钮点击
|
|
|
|
|
const onButtonClick = (event, d) => {
|
|
|
|
@ -86,7 +96,7 @@ export default function companyPage() {
|
|
|
|
|
// 获取数据
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
d3.json(
|
|
|
|
|
'/api/bs/hrmorganization/orgchart/companyData?fclass=0&fisvitual=0&root=0&level=3&id=0',
|
|
|
|
|
'/api/bs/hrmorganization/orgchart/companyData?fclass=0&fisvitual=0&root=0&level=2&id=0',
|
|
|
|
|
).then((data) => {
|
|
|
|
|
setData(data.data);
|
|
|
|
|
setHasRight(data?.hasRight);
|
|
|
|
@ -263,8 +273,15 @@ export default function companyPage() {
|
|
|
|
|
* @param {*} timeline
|
|
|
|
|
*/
|
|
|
|
|
const timeLineSearch = (timeline) => {
|
|
|
|
|
setId(timeline.id);
|
|
|
|
|
let requestData = { ...topbar.state.requestData, id: timeline.id };
|
|
|
|
|
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);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -275,7 +292,7 @@ export default function companyPage() {
|
|
|
|
|
const handleSearch = (requestData, cache = true) => {
|
|
|
|
|
setSpinning(true);
|
|
|
|
|
if (cache) {
|
|
|
|
|
requestData = { ...requestData, id: id };
|
|
|
|
|
requestData = { ...requestData, id: infoRef.current };
|
|
|
|
|
}
|
|
|
|
|
topBarSearchRequest = requestData;
|
|
|
|
|
let api =
|
|
|
|
@ -301,10 +318,12 @@ export default function companyPage() {
|
|
|
|
|
* @param {*} requestData
|
|
|
|
|
*/
|
|
|
|
|
const handleChange = (requestData) => {
|
|
|
|
|
setTimelineId(0);
|
|
|
|
|
timeLine.searchTimeLines(
|
|
|
|
|
`/api/bs/hrmorganization/orgchart/timeLines?fclass=${requestData.fclass}`,
|
|
|
|
|
);
|
|
|
|
|
handleSearch(requestData);
|
|
|
|
|
requestData = { ...requestData, id: 0 };
|
|
|
|
|
handleSearch(requestData, false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|