Compare commits

...

3 Commits

@ -5,7 +5,6 @@ import qs from 'qs';
import MergeDialog from '../components/dialog/mergeDialog'; import MergeDialog from '../components/dialog/mergeDialog';
import CopyDialog from '../components/dialog/copyDialog'; import CopyDialog from '../components/dialog/copyDialog';
import inset from '../../public/img/back/inset.png'; import inset from '../../public/img/back/inset.png';
import { getLabel } from '../util/i18n.js';
import { import {
HomeOutlined, HomeOutlined,
@ -22,7 +21,7 @@ const DragTree = () => {
const [expandedKeys, setExpandedKeys] = useState([undefined]); const [expandedKeys, setExpandedKeys] = useState([undefined]);
const childRef = useRef(null); const childRef = useRef(null);
const copyChildRef = useRef(null); const copyChildRef = useRef(null);
const [tip, setTip] = useState(''); const [tip, setTip] = useState('正在加载,请稍候...');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [showCanceled, setShowCanceled] = useState(0); const [showCanceled, setShowCanceled] = useState(0);
const [drawerOpen, setDrawerOpen] = useState(false); const [drawerOpen, setDrawerOpen] = useState(false);
@ -37,7 +36,6 @@ const DragTree = () => {
useEffect(() => { useEffect(() => {
d3.json('/api/bs/hrmorganization/orgchart/i18n').then((res) => { d3.json('/api/bs/hrmorganization/orgchart/i18n').then((res) => {
setLabelData(res.data); setLabelData(res.data);
setTip(`${getLabel(547473, res.data)}`);
}); });
getMoveTree(0); getMoveTree(0);
}, [true]); }, [true]);
@ -77,26 +75,40 @@ const DragTree = () => {
const dropPosition = const dropPosition =
info.dropPosition - Number(dropPos[dropPos.length - 1]); info.dropPosition - Number(dropPos[dropPos.length - 1]);
if (dropPosition == -1) { if (dropPosition == -1 || dropPosition == 1) {
return message.error(`${getLabel(547475, labelData)}`, 2); return message.error('不支持该操作!!!', 2);
} }
let pos =
dropPosition == 0
? `${getLabel(547476, labelData)}`
: `${getLabel(547477, labelData)}`;
let title = `${getLabel(547478, labelData)}${ let pos = dropPosition == 0 ? '内部' : '下方';
info.dragNode.title let title = `确定将【${info.dragNode.title}】移到 【${info.node.title}${pos}`;
} ${getLabel(547479, labelData)} ${info.node.title}${pos}`;
Modal.confirm({ Modal.confirm({
title: `${getLabel(547480, labelData)}`, title: '转移操作(仅转移到内部时工作流提醒生效)',
content: title, content: title,
okText: `${getLabel(547319, labelData)}`, okText: '确认',
cancelText: `${getLabel(547318, labelData)}`, cancelText: '取消',
onOk() { async onOk() {
setLoading(true); setLoading(true);
setTip(`${getLabel(547481, labelData)}`); setTip('正在转移,请稍候...');
if (dropPosition == 0) {
let extend = 'dept';
let tranfeserType = 1;
if (dragKey.slice(0, 1).toLowerCase() === 's') {
extend = 'comp';
tranfeserType = 2;
}
if (dropKey.slice(0, 1).toLowerCase() === 's') {
tranfeserType = 2;
}
await messageRemind(
extend,
'MOVE',
dragKey.slice(1),
false,
dropKey.slice(1),
'',
tranfeserType,
);
}
fetch('/api/bs/hrmorganization/dept/dragDepartment', { fetch('/api/bs/hrmorganization/dept/dragDepartment', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -153,14 +165,14 @@ const DragTree = () => {
} }
} }
setGData(data); setGData(data);
message.success(`${getLabel(547482, labelData)}`, 2); message.success('转移成功', 2);
} else { } else {
message.warning(res.msg, 2); message.warning(res.msg, 2);
} }
setLoading(false); setLoading(false);
}) })
.catch((error) => { .catch((error) => {
message.error(`${getLabel(547483, labelData)}`); message.error('接口异常,请联系管理员');
}); });
}, },
onCancel() {}, onCancel() {},
@ -173,12 +185,14 @@ const DragTree = () => {
*/ */
const onDelete = (nodeData) => { const onDelete = (nodeData) => {
const extend = nodeData.type == '1' ? 'comp' : 'dept'; const extend = nodeData.type == '1' ? 'comp' : 'dept';
let id = nodeData.id.substring(1);
let title = nodeData.title;
fetch(`/api/bs/hrmorganization/${extend}/deleteByIds`, { fetch(`/api/bs/hrmorganization/${extend}/deleteByIds`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ ids: nodeData.id.substring(1) }), body: JSON.stringify({ ids: id }),
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((res) => { .then((res) => {
@ -189,17 +203,81 @@ const DragTree = () => {
arr.splice(index, 1); arr.splice(index, 1);
}); });
setGData(data); setGData(data);
message.success(`${getLabel(547484, labelData)}`, 2); message.success('删除成功', 2);
messageRemind(extend, 'DELETE', title);
} else { } else {
message.warning(res.data.message, 2); message.warning(res.data.message, 2);
} }
} }
}) })
.catch((error) => { .catch((error) => {
message.error(`${getLabel(547483, labelData)}`); message.error('接口异常,请联系管理员');
}); });
}; };
/**
* 工作流提醒
*/
const messageRemind = (
type,
operateType,
fromId,
canceled,
toId = '',
mergeName = '',
tranfeserType = null,
) => {
debugger;
return new Promise((reslove, reject) => {
let params = {
workflowId: 1,
operateType: operateType,
mergeName: mergeName,
type: type,
canceled: canceled,
tranfeserType: tranfeserType,
};
if (type == 'dept') {
params = {
...params,
departmentIdFrom: fromId,
};
if (tranfeserType == 2) {
params = {
...params,
subCompanyIdTo: toId,
};
} else {
params = {
...params,
departmentIdTo: toId,
};
}
} else {
params = {
...params,
subCompanyIdFrom: fromId,
subCompanyIdTo: toId,
};
}
fetch('/api/bs/hrmorganization/remind/quickly/workflow/message', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
})
.then((response) => response.json())
.then((res) => {
reslove();
})
.catch((error) => {
message.error('系统默认工作流提醒失败');
});
});
};
/** /**
* 封存 * 封存
* @param {*} nodeData * @param {*} nodeData
@ -207,14 +285,16 @@ const DragTree = () => {
const onCancel = (nodeData) => { const onCancel = (nodeData) => {
setShowCanceled(0); setShowCanceled(0);
const extend = nodeData.type == '1' ? 'comp' : 'dept'; const extend = nodeData.type == '1' ? 'comp' : 'dept';
let id = nodeData.id.substring(1);
let canceled = nodeData.canceled != '0';
fetch(`/api/bs/hrmorganization/${extend}/updateForbiddenTagById`, { fetch(`/api/bs/hrmorganization/${extend}/updateForbiddenTagById`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
id: nodeData.id.substring(1), id: id,
canceled: nodeData.canceled != '0', canceled: canceled,
}), }),
}) })
.then((response) => response.json()) .then((response) => response.json())
@ -222,7 +302,7 @@ const DragTree = () => {
if (res.code == 200) { if (res.code == 200) {
const data = [...gData]; const data = [...gData];
if (nodeData.canceled != '0') { if (nodeData.canceled != '0') {
message.success(`${getLabel(547485, labelData)}`, 2); message.success('恢复成功', 2);
loop(data, nodeData.key, (item, index, arr) => { loop(data, nodeData.key, (item, index, arr) => {
arr[index].canceled = '0'; arr[index].canceled = '0';
}); });
@ -230,15 +310,16 @@ const DragTree = () => {
loop(data, nodeData.key, (item, index, arr) => { loop(data, nodeData.key, (item, index, arr) => {
arr.splice(index, 1); arr.splice(index, 1);
}); });
message.success(`${getLabel(547486, labelData)}`, 2); message.success('封存成功', 2);
} }
setGData(data); setGData(data);
messageRemind(extend, 'CANCELED', id, canceled);
} else { } else {
message.warning(res.msg, 2); message.warning(res.msg, 2);
} }
}) })
.catch((error) => { .catch((error) => {
message.error(`${getLabel(547483, labelData)}`); message.error('接口异常,请联系管理员');
}); });
}; };
@ -255,10 +336,13 @@ const DragTree = () => {
}; };
const onMergeCreate = (values) => { const onMergeCreate = (values) => {
let fromId = mergeId.substring(1);
let toId = values.department.substring(1);
let mergeName = values.mergeName;
let params = { let params = {
department: values.department.substring(1), department: toId,
mergeName: values.mergeName, mergeName: mergeName,
id: mergeId.substring(1), id: fromId,
}; };
fetch('/api/bs/hrmorganization/dept/mergeDepartment', { fetch('/api/bs/hrmorganization/dept/mergeDepartment', {
method: 'POST', method: 'POST',
@ -271,14 +355,15 @@ const DragTree = () => {
.then((res) => { .then((res) => {
if (res.code == 200) { if (res.code == 200) {
getMoveTree(0, values.department); getMoveTree(0, values.department);
message.success(`${getLabel(547487, labelData)}`, 2); message.success('合并成功', 2);
messageRemind('dept', 'MERGE', fromId, false, toId, mergeName);
} else { } else {
message.warning(res.msg, 2); message.warning(res.msg, 2);
} }
setOpen(false); setOpen(false);
}) })
.catch((error) => { .catch((error) => {
message.error(`${getLabel(547483, labelData)}`); message.error('接口异常,请联系管理员');
}); });
}; };
@ -312,13 +397,13 @@ const DragTree = () => {
if (res.code == 200) { if (res.code == 200) {
setCopyOpen(false); setCopyOpen(false);
getMoveTree(0, values.company); getMoveTree(0, values.company);
message.success(`${getLabel(547488, labelData)}`, 2); message.success('复制成功', 2);
} else { } else {
message.warning(res.msg, 2); message.warning(res.msg, 2);
} }
}) })
.catch((error) => { .catch((error) => {
message.error(`${getLabel(547483, labelData)}`); message.error('接口异常,请联系管理员');
}); });
}; };
@ -344,7 +429,7 @@ const DragTree = () => {
{nodeData.title} {nodeData.title}
{nodeData.canceled == '1' ? ( {nodeData.canceled == '1' ? (
<span style={{ color: 'red', marginLeft: '5px' }}> <span style={{ color: 'red', marginLeft: '5px' }}>
({getLabel(547489, labelData)}) (已封存)
</span> </span>
) : ( ) : (
'' ''
@ -363,28 +448,25 @@ const DragTree = () => {
); );
}} }}
> >
{getLabel(547490, labelData)} 查看
</span> </span>
<Popconfirm {/**<Popconfirm
title={`${getLabel(547491, labelData)}[${nodeData.title}]?`} title={`确认要删除[${nodeData.title}]?`}
onConfirm={() => onDelete(nodeData)} onConfirm={() => onDelete(nodeData)}
okText={getLabel(547319, labelData)} okText="确认"
cancelText={getLabel(547318, labelData)} cancelText="取消"
> >
<span className="drag-button"> <span className="drag-button">删除</span>
{getLabel(547492, labelData)}
</span>
</Popconfirm> </Popconfirm>
**/}
<Popconfirm <Popconfirm
title={`${getLabel(547493, labelData)} [${nodeData.title}]?`} title={`确认要封存或恢复 [${nodeData.title}]?`}
onConfirm={() => onCancel(nodeData)} onConfirm={() => onCancel(nodeData)}
okText={getLabel(547319, labelData)} okText="确认"
cancelText={getLabel(547318, labelData)} cancelText="取消"
> >
<span className="drag-button"> <span className="drag-button">
{nodeData.canceled == '0' {nodeData.canceled == '0' ? '封存' : '恢复'}
? `${getLabel(547494, labelData)}`
: `${getLabel(547495, labelData)}`}
</span> </span>
</Popconfirm> </Popconfirm>
<span <span
@ -392,14 +474,14 @@ const DragTree = () => {
className="drag-button" className="drag-button"
onClick={() => onMerge(nodeData)} onClick={() => onMerge(nodeData)}
> >
{getLabel(547194, labelData)} 合并
</span> </span>
<span <span
style={{ display: attr }} style={{ display: attr }}
className="drag-button" className="drag-button"
onClick={() => onCopy(nodeData)} onClick={() => onCopy(nodeData)}
> >
{getLabel(547196, labelData)} 复制
</span> </span>
</div> </div>
</> </>
@ -413,84 +495,84 @@ const DragTree = () => {
}; };
return ( return (
Object.keys(labelData).length != 0 && ( <div className="drag-wrapper">
<div className="drag-wrapper"> <Spin tip={tip} spinning={loading}>
<Spin tip={tip} spinning={loading}> <div className="drag-layout">
<div className="drag-layout"> <div className="drag-header">
<div className="drag-header"> <img src={inset} />
<img src={inset} /> <div>组织快速调整</div>
<div>{getLabel(547282, labelData)}</div> </div>
</div> <div className="drag-content">
<div className="drag-content"> <ApartmentOutlined
<ApartmentOutlined className="drag-showcanceled"
className="drag-showcanceled" style={{ color: showCanceled == 0 ? '#000' : '#1890ff' }}
style={{ color: showCanceled == 0 ? '#000' : '#1890ff' }} onClick={() => {
onClick={() => { const value = showCanceled == 0 ? 1 : 0;
const value = showCanceled == 0 ? 1 : 0; setTip('正在加载,请稍候...');
setTip(`${getLabel(547473, labelData)}`); setShowCanceled(value);
setShowCanceled(value); getMoveTree(value);
getMoveTree(value); }}
}} />
/> <Tree
<Tree className="draggable-tree"
className="draggable-tree" //defaultExpandedKeys={expandedKeys}
//defaultExpandedKeys={expandedKeys} expandedKeys={expandedKeys}
expandedKeys={expandedKeys} onExpand={onExpand}
onExpand={onExpand} draggable
draggable icon={false}
icon={false} blockNode
blockNode onDragEnter={onDragEnter}
onDragEnter={onDragEnter} onDrop={onDrop}
onDrop={onDrop} treeData={gData}
treeData={gData} titleRender={onTitleRender}
titleRender={onTitleRender} />
/> </div>
</div> <Drawer
<Drawer width="60%"
width="60%" placement="right"
placement="right" closable={false}
closable={false} onClose={() => setDrawerOpen(false)}
onClose={() => setDrawerOpen(false)} open={drawerOpen}
open={drawerOpen} >
> <iframe src={iframe} width="100%" height="100%" />
<iframe src={iframe} width="100%" height="100%" /> </Drawer>
</Drawer>
<div className="drag-footer"> <div className="drag-footer">
<p> <p>
<QuestionCircleOutlined /> <QuestionCircleOutlined />
{getLabel(547283, labelData)} 小提示
</p> </p>
<div className="tips"> <div className="tips">
<div>1.{getLabel(547284, labelData)}</div> <div>1.鼠标拖拽Tree节点到任一分部部门下可快速完成组织转移;</div>
<div>2.{getLabel(547285, labelData)}</div> <div>2.点击查看侧滑打开组织详细信息,可快速编辑;</div>
<div>3.{getLabel(547286, labelData)}</div> <div>
<div>4.{getLabel(547287, labelData)}</div> 3.鼠标悬停树节点 一键开启删除封存合并复制等功能;
</div> </div>
<div>4.顶部小图标点击可显示已封存的组织架构</div>
</div> </div>
</div> </div>
</Spin> </div>
</Spin>
<MergeDialog <MergeDialog
ref={childRef} ref={childRef}
open={open} open={open}
onCreate={onMergeCreate} onCreate={onMergeCreate}
onCancel={() => { onCancel={() => {
setOpen(false); setOpen(false);
}} }}
labelData={labelData} labelData={labelData}
/> />
<CopyDialog <CopyDialog
ref={copyChildRef} ref={copyChildRef}
open={copyopen} open={copyopen}
onCreate={onCopyCreate} onCreate={onCopyCreate}
onCancel={() => { onCancel={() => {
setCopyOpen(false); setCopyOpen(false);
}} }}
labelData={labelData} labelData={labelData}
/> />
</div> </div>
)
); );
}; };
export default DragTree; export default DragTree;

@ -99,7 +99,7 @@ export default function userPage() {
// //
useEffect(() => { useEffect(() => {
document.cookie = document.cookie =
'ecology_JSessionid=aaa5JLqrHUV6R9P1cmTbz; JSESSIONID=aaa5JLqrHUV6R9P1cmTbz; loginuuids=1; languageidweaver=7; Systemlanguid=7; loginidweaver=sysadmin; __randcode__=72a0b641-7599-4301-a47f-61620f350ec5'; 'ecology_JSessionid=aaayMjvxCzkVJaNpQnW7y; JSESSIONID=aaayMjvxCzkVJaNpQnW7y; __randcode__=d1d05beb-637c-4417-bee5-e7ee0061eb7e; Systemlanguid=7; languageidweaver=7; loginidweaver=sysadmin;';
d3.json( d3.json(
'/api/bs/hrmorganization/orgchart/userData?fclass=0&fisvitual=0&root=0&level=3&id=0', '/api/bs/hrmorganization/orgchart/userData?fclass=0&fisvitual=0&root=0&level=3&id=0',
).then((data) => { ).then((data) => {

Loading…
Cancel
Save