Commit 01aafad0 authored by 邓超's avatar 邓超

fix: 删除添加检测

parent f643013b
...@@ -17,7 +17,13 @@ import FlowModal from './workFlowComponents/FlowModal'; ...@@ -17,7 +17,13 @@ import FlowModal from './workFlowComponents/FlowModal';
import FlowGroupModal from './workFlowComponents/FlowGroupModal'; import FlowGroupModal from './workFlowComponents/FlowGroupModal';
import Order from './workFlowComponents/Order'; import Order from './workFlowComponents/Order';
import styles from './WorkflowHomePage.less'; import styles from './WorkflowHomePage.less';
import { WFGetAllFlow, GetFlowNode, DeleteFlow } from '@/services/workflow/workflow'; import {
WFGetAllFlow,
GetFlowNode,
DeleteFlow,
CheckDoingFlowNodes,
CloseDoingFlowNodes,
} from '@/services/workflow/workflow';
import { DownLoadFiles } from '@/services/common/api'; import { DownLoadFiles } from '@/services/common/api';
import { UpdateFlowGroup } from '@/services/workflow/workflow'; import { UpdateFlowGroup } from '@/services/workflow/workflow';
const plugins = [ScrollToPlugin]; const plugins = [ScrollToPlugin];
...@@ -114,7 +120,7 @@ const WorkflowHomePage = () => { ...@@ -114,7 +120,7 @@ const WorkflowHomePage = () => {
let list = res.data.map((item, index) => { let list = res.data.map((item, index) => {
item.children.forEach(ele => { item.children.forEach(ele => {
flowNameList.push(ele.FlowName); flowNameList.push(ele.FlowName);
ele.PreviewImage = getImgUrl(ele.PreviewImage) ele.PreviewImage = getImgUrl(ele.PreviewImage);
}); });
item.isOld = true; item.isOld = true;
item.bgType = (index + 1) % 5; item.bgType = (index + 1) % 5;
...@@ -248,8 +254,49 @@ const WorkflowHomePage = () => { ...@@ -248,8 +254,49 @@ const WorkflowHomePage = () => {
}); });
}; };
// 删除流程 // 删除流程
const delFlow = (val, e) => { const delFlow = async (val, e) => {
e.stopPropagation(); e.stopPropagation();
let res1 = await CheckDoingFlowNodes({ flowID: val.FlowID });
if (res1.code === 0) {
if (res1.data > 0) {
confirm({
title: '确定要删除当前流程吗?',
icon: <ExclamationCircleOutlined />,
content: <div>当前流程有{res1.data}条在办工单,确定删除会自动归档在办工单。</div>,
okText: '是',
okType: 'danger',
cancelText: '否',
onOk() {
CloseDoingFlowNodes({ flowID: val.FlowID }).then(res2 => {
if (res2.code === 0) {
DeleteFlow({ FlowId: val.FlowID })
.then(res3 => {
if (res3.code === 0) {
setModalType('del');
getFlowList();
message.success('删除成功');
} else {
message.error({
content: (
<div style={{ whiteSpace: 'pre-line', textAlign: 'justify' }}>
{res3.msg}
</div>
),
});
}
})
.catch(() => {
message.error('网络异常请稍后再试');
});
} else {
message.error(res2.msg);
}
});
},
onCancel() {},
});
} else {
confirm({ confirm({
title: '确定要删除吗?', title: '确定要删除吗?',
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
...@@ -259,15 +306,15 @@ const WorkflowHomePage = () => { ...@@ -259,15 +306,15 @@ const WorkflowHomePage = () => {
cancelText: '否', cancelText: '否',
onOk() { onOk() {
DeleteFlow({ FlowId: val.FlowID }) DeleteFlow({ FlowId: val.FlowID })
.then(res => { .then(res2 => {
if (res.code === 0) { if (res2.code === 0) {
setModalType('del'); setModalType('del');
getFlowList(); getFlowList();
message.success('删除成功'); message.success('删除成功');
} else { } else {
message.error({ message.error({
content: ( content: (
<div style={{ whiteSpace: 'pre-line', textAlign: 'justify' }}>{res.msg}</div> <div style={{ whiteSpace: 'pre-line', textAlign: 'justify' }}>{res2.msg}</div>
), ),
}); });
} }
...@@ -278,6 +325,10 @@ const WorkflowHomePage = () => { ...@@ -278,6 +325,10 @@ const WorkflowHomePage = () => {
}, },
onCancel() {}, onCancel() {},
}); });
}
} else {
message.error(res1.msg);
}
}; };
const getImgUrl = img => { const getImgUrl = img => {
// return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
...@@ -287,7 +338,7 @@ const WorkflowHomePage = () => { ...@@ -287,7 +338,7 @@ const WorkflowHomePage = () => {
// reader.onload = () => resolve(reader.result); // reader.onload = () => resolve(reader.result);
// }); // });
// });a // });a
return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=熊猫智慧水务平台\\WorkFlowImage&filePath=${img}` return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=熊猫智慧水务平台\\WorkFlowImage&filePath=${img}`;
}; };
// tab栏选项渲染 // tab栏选项渲染
const tabRender = (val, index) => ( const tabRender = (val, index) => (
......
...@@ -10,6 +10,8 @@ import { ...@@ -10,6 +10,8 @@ import {
DeleteFlowNode, DeleteFlowNode,
DeleteFlowNodes, DeleteFlowNodes,
SaveWorkFlowImage, SaveWorkFlowImage,
CheckDoingFlowNodes,
CloseDoingFlowNodes,
} from '@/services/workflow/workflow'; } from '@/services/workflow/workflow';
import { compress } from '@/utils/utils'; import { compress } from '@/utils/utils';
import { ExclamationCircleOutlined, TrophyOutlined } from '@ant-design/icons'; import { ExclamationCircleOutlined, TrophyOutlined } from '@ant-design/icons';
...@@ -153,14 +155,24 @@ const FlowChart = props => { ...@@ -153,14 +155,24 @@ const FlowChart = props => {
delLinks.add(item.data.LineId); delLinks.add(item.data.LineId);
} }
}); });
CheckDoingFlowNodes({ activityIds: [...delNodes] }).then(res => {
if (res.code === 0) {
if (res.data > 0) {
showCloseList([...delNodeIds], [...delNodes], [...delLinks], res.data);
} else {
showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]); showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]);
}
} else {
message.error(res.msg);
}
});
return false; return false;
}; };
// 监听线,连接线的时候加上text属性 // 监听线,连接线的时候加上text属性
diagram.addDiagramListener('LinkDrawn', e => { diagram.addDiagramListener('LinkDrawn', e => {
// e.subject.data.text = ''; // e.subject.data.text = '';
e.subject.data.lineDetail = JSON.stringify(e.subject.data); e.subject.data.lineDetail = JSON.stringify(e.subject.data);
console.log(e, e.subject.data, 'fasdfasdgds');
diagram.model.updateTargetBindings(e.subject.data); diagram.model.updateTargetBindings(e.subject.data);
// leaveCallBack(true); // leaveCallBack(true);
}); });
...@@ -168,7 +180,6 @@ const FlowChart = props => { ...@@ -168,7 +180,6 @@ const FlowChart = props => {
diagram.addDiagramListener('externalobjectsdropped', e => { diagram.addDiagramListener('externalobjectsdropped', e => {
afterNodes.current = new Map([]); afterNodes.current = new Map([]);
const list = JSON.parse(diagram.model.toJson()).nodeDataArray; const list = JSON.parse(diagram.model.toJson()).nodeDataArray;
console.log(list, 'list');
let newNum; let newNum;
let newKey; let newKey;
...@@ -322,6 +333,27 @@ const FlowChart = props => { ...@@ -322,6 +333,27 @@ const FlowChart = props => {
return i; return i;
}; };
}, [currentFlowData]); }, [currentFlowData]);
const showCloseList = (delNodeIds, delNodes, delLinks, listMsg) => {
confirm({
title: '确定要删除所选节点吗?',
icon: <ExclamationCircleOutlined />,
content: <div>当前节点有{listMsg}条在办工单,确定删除会自动归档在办工单。</div>,
okText: '是',
okType: 'primary',
cancelText: '否',
onOk() {
CloseDoingFlowNodes({ activityIds: [...delNodes] }).then(res => {
if (res.code === 0) {
delNode(delNodeIds, delNodes, delLinks);
} else {
message.error(res.msg);
}
});
},
onCancel() {},
});
};
// 删除提醒 // 删除提醒
const showDeleteConfirm = (delNodeIds, delNodes, delLinks) => { const showDeleteConfirm = (delNodeIds, delNodes, delLinks) => {
confirm({ confirm({
...@@ -329,7 +361,7 @@ const FlowChart = props => { ...@@ -329,7 +361,7 @@ const FlowChart = props => {
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
content: '', content: '',
okText: '是', okText: '是',
okType: 'danger', okType: 'primary',
cancelText: '否', cancelText: '否',
onOk() { onOk() {
delNode(delNodeIds, delNodes, delLinks); delNode(delNodeIds, delNodes, delLinks);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment