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

fix: 删除添加检测

parent f643013b
......@@ -17,7 +17,13 @@ import FlowModal from './workFlowComponents/FlowModal';
import FlowGroupModal from './workFlowComponents/FlowGroupModal';
import Order from './workFlowComponents/Order';
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 { UpdateFlowGroup } from '@/services/workflow/workflow';
const plugins = [ScrollToPlugin];
......@@ -114,7 +120,7 @@ const WorkflowHomePage = () => {
let list = res.data.map((item, index) => {
item.children.forEach(ele => {
flowNameList.push(ele.FlowName);
ele.PreviewImage = getImgUrl(ele.PreviewImage)
ele.PreviewImage = getImgUrl(ele.PreviewImage);
});
item.isOld = true;
item.bgType = (index + 1) % 5;
......@@ -248,36 +254,81 @@ const WorkflowHomePage = () => {
});
};
// 删除流程
const delFlow = (val, e) => {
const delFlow = async (val, e) => {
e.stopPropagation();
confirm({
title: '确定要删除吗?',
icon: <ExclamationCircleOutlined />,
content: '',
okText: '是',
okType: 'danger',
cancelText: '否',
onOk() {
DeleteFlow({ FlowId: val.FlowID })
.then(res => {
if (res.code === 0) {
setModalType('del');
getFlowList();
message.success('删除成功');
} else {
message.error({
content: (
<div style={{ whiteSpace: 'pre-line', textAlign: 'justify' }}>{res.msg}</div>
),
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({
title: '确定要删除吗?',
icon: <ExclamationCircleOutlined />,
content: '',
okText: '是',
okType: 'danger',
cancelText: '否',
onOk() {
DeleteFlow({ FlowId: val.FlowID })
.then(res2 => {
if (res2.code === 0) {
setModalType('del');
getFlowList();
message.success('删除成功');
} else {
message.error({
content: (
<div style={{ whiteSpace: 'pre-line', textAlign: 'justify' }}>{res2.msg}</div>
),
});
}
})
.catch(() => {
message.error('网络异常请稍后再试');
});
}
})
.catch(() => {
message.error('网络异常请稍后再试');
});
},
onCancel() {},
});
},
onCancel() {},
});
}
} else {
message.error(res1.msg);
}
};
const getImgUrl = img => {
// return new Promise((resolve, reject) => {
......@@ -287,7 +338,7 @@ const WorkflowHomePage = () => {
// reader.onload = () => resolve(reader.result);
// });
// });a
return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=熊猫智慧水务平台\\WorkFlowImage&filePath=${img}`
return `/PandaOMS/OMS/FileCenter/DownLoadFiles?module=熊猫智慧水务平台\\WorkFlowImage&filePath=${img}`;
};
// tab栏选项渲染
const tabRender = (val, index) => (
......
......@@ -10,6 +10,8 @@ import {
DeleteFlowNode,
DeleteFlowNodes,
SaveWorkFlowImage,
CheckDoingFlowNodes,
CloseDoingFlowNodes,
} from '@/services/workflow/workflow';
import { compress } from '@/utils/utils';
import { ExclamationCircleOutlined, TrophyOutlined } from '@ant-design/icons';
......@@ -153,14 +155,24 @@ const FlowChart = props => {
delLinks.add(item.data.LineId);
}
});
showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]);
CheckDoingFlowNodes({ activityIds: [...delNodes] }).then(res => {
if (res.code === 0) {
if (res.data > 0) {
showCloseList([...delNodeIds], [...delNodes], [...delLinks], res.data);
} else {
showDeleteConfirm([...delNodeIds], [...delNodes], [...delLinks]);
}
} else {
message.error(res.msg);
}
});
return false;
};
// 监听线,连接线的时候加上text属性
diagram.addDiagramListener('LinkDrawn', e => {
// e.subject.data.text = '';
e.subject.data.lineDetail = JSON.stringify(e.subject.data);
console.log(e, e.subject.data, 'fasdfasdgds');
diagram.model.updateTargetBindings(e.subject.data);
// leaveCallBack(true);
});
......@@ -168,7 +180,6 @@ const FlowChart = props => {
diagram.addDiagramListener('externalobjectsdropped', e => {
afterNodes.current = new Map([]);
const list = JSON.parse(diagram.model.toJson()).nodeDataArray;
console.log(list, 'list');
let newNum;
let newKey;
......@@ -322,6 +333,27 @@ const FlowChart = props => {
return i;
};
}, [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) => {
confirm({
......@@ -329,7 +361,7 @@ const FlowChart = props => {
icon: <ExclamationCircleOutlined />,
content: '',
okText: '是',
okType: 'danger',
okType: 'primary',
cancelText: '否',
onOk() {
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