|
|
|
@ -17,7 +17,8 @@ const DragTree = () => {
|
|
|
|
|
const [gData, setGData] = useState([]);
|
|
|
|
|
const [expandedKeys, setExpandedKeys] = useState([undefined]);
|
|
|
|
|
const childRef = useRef(null);
|
|
|
|
|
const [tip, setTip] = useState('正在加载...');
|
|
|
|
|
const copyChildRef = useRef(null);
|
|
|
|
|
const [tip, setTip] = useState('正在加载,请稍候...');
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
const [showCanceled, setShowCanceled] = useState(0);
|
|
|
|
|
|
|
|
|
@ -30,10 +31,10 @@ const DragTree = () => {
|
|
|
|
|
getMoveTree(0);
|
|
|
|
|
}, [true]);
|
|
|
|
|
|
|
|
|
|
const getMoveTree = (showCanceled) => {
|
|
|
|
|
const getMoveTree = (showCanceled, expandedKeys = '') => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
d3.json(
|
|
|
|
|
`/api/bs/hrmorganization/orgchart/getMovingTree?showCanceled=${showCanceled}`,
|
|
|
|
|
`/api/bs/hrmorganization/orgchart/getMovingTree?showCanceled=${showCanceled}&expandedKeys=${expandedKeys}`,
|
|
|
|
|
).then((data) => {
|
|
|
|
|
setGData(data.movingTree);
|
|
|
|
|
setExpandedKeys(data.expandedKeys);
|
|
|
|
@ -122,6 +123,7 @@ const DragTree = () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setGData(data);
|
|
|
|
|
message.success('转移成功', 2);
|
|
|
|
|
} else {
|
|
|
|
|
message.warning(res.msg, 2);
|
|
|
|
|
}
|
|
|
|
@ -145,7 +147,7 @@ const DragTree = () => {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({ ids: nodeData.id }),
|
|
|
|
|
body: JSON.stringify({ ids: nodeData.id.substring(1) }),
|
|
|
|
|
})
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
@ -179,7 +181,7 @@ const DragTree = () => {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
id: nodeData.id,
|
|
|
|
|
id: nodeData.id.substring(1),
|
|
|
|
|
canceled: nodeData.canceled != '0',
|
|
|
|
|
}),
|
|
|
|
|
})
|
|
|
|
@ -229,6 +231,7 @@ const DragTree = () => {
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
getMoveTree(0, values.department);
|
|
|
|
|
message.success('合并成功', 2);
|
|
|
|
|
} else {
|
|
|
|
|
message.warning(res.msg, 2);
|
|
|
|
@ -245,6 +248,9 @@ const DragTree = () => {
|
|
|
|
|
* @param {*} nodeData
|
|
|
|
|
*/
|
|
|
|
|
const onCopy = (nodeData) => {
|
|
|
|
|
if (copyChildRef.current) {
|
|
|
|
|
copyChildRef.current.getTreeData();
|
|
|
|
|
}
|
|
|
|
|
setCopyOpen(true);
|
|
|
|
|
setCopyId(nodeData.id);
|
|
|
|
|
};
|
|
|
|
@ -255,12 +261,13 @@ const DragTree = () => {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({ ...values, ids: copyId }),
|
|
|
|
|
body: JSON.stringify({ ...values, ids: copyId.substring(1) }),
|
|
|
|
|
})
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
setCopyOpen(false);
|
|
|
|
|
getMoveTree(0, values.company);
|
|
|
|
|
message.success('复制成功', 2);
|
|
|
|
|
} else {
|
|
|
|
|
message.warning(res.msg, 2);
|
|
|
|
@ -282,7 +289,6 @@ const DragTree = () => {
|
|
|
|
|
<>
|
|
|
|
|
{nodeData.type == 0 ? (
|
|
|
|
|
<span>
|
|
|
|
|
{' '}
|
|
|
|
|
<ClusterOutlined />
|
|
|
|
|
<span style={{ marginLeft: '5px' }}>{nodeData.title}</span>
|
|
|
|
|
</span>
|
|
|
|
@ -290,14 +296,25 @@ const DragTree = () => {
|
|
|
|
|
<>
|
|
|
|
|
<span>
|
|
|
|
|
{icon}
|
|
|
|
|
<span style={{ marginLeft: '5px' }}>{nodeData.title}</span>
|
|
|
|
|
<span style={{ marginLeft: '5px' }}>
|
|
|
|
|
{nodeData.title}
|
|
|
|
|
{nodeData.canceled == '1' ? (
|
|
|
|
|
<span style={{ color: 'red', marginLeft: '5px' }}>
|
|
|
|
|
(已封存)
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
''
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
<div id="drag-button-ops">
|
|
|
|
|
<span
|
|
|
|
|
className="drag-button"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
window.open(
|
|
|
|
|
`/spa/organization/static/index.html#/main/organization/${extend}/${nodeData.id}`,
|
|
|
|
|
`/spa/organization/static/index.html#/main/organization/${extend}/${nodeData.id.substring(
|
|
|
|
|
1,
|
|
|
|
|
)}`,
|
|
|
|
|
'_blank',
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -343,12 +360,17 @@ const DragTree = () => {
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onExpand = (info) => {
|
|
|
|
|
setExpandedKeys(info);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<ApartmentOutlined
|
|
|
|
|
style={{ color: showCanceled == 0 ? '#1890ff' : '#eb2f96' }}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const value = showCanceled == 0 ? 1 : 0;
|
|
|
|
|
setTip('正在加载,请稍候...');
|
|
|
|
|
setShowCanceled(value);
|
|
|
|
|
getMoveTree(value);
|
|
|
|
|
}}
|
|
|
|
@ -356,7 +378,9 @@ const DragTree = () => {
|
|
|
|
|
<Spin tip={tip} spinning={loading}>
|
|
|
|
|
<Tree
|
|
|
|
|
className="draggable-tree"
|
|
|
|
|
defaultExpandedKeys={expandedKeys}
|
|
|
|
|
//defaultExpandedKeys={expandedKeys}
|
|
|
|
|
expandedKeys={expandedKeys}
|
|
|
|
|
onExpand={onExpand}
|
|
|
|
|
draggable
|
|
|
|
|
icon={false}
|
|
|
|
|
blockNode
|
|
|
|
@ -373,11 +397,14 @@ const DragTree = () => {
|
|
|
|
|
setOpen(false);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
{/* <CopyDialog open={copyopen}
|
|
|
|
|
onCreate={onCopyCreate}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
setCopyOpen(false);
|
|
|
|
|
}}/> */}
|
|
|
|
|
<CopyDialog
|
|
|
|
|
ref={copyChildRef}
|
|
|
|
|
open={copyopen}
|
|
|
|
|
onCreate={onCopyCreate}
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
setCopyOpen(false);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Spin>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|