|
@@ -7,8 +7,8 @@ import { selectTopic } from "@/utils/mindmapHander";
|
|
|
import { uuid } from "@repo/utils";
|
|
|
import { getTheme } from "@/utils/mindmap/theme";
|
|
|
import { traverseNode } from "@/utils/mindmapHander";
|
|
|
-import { EditMindMapElement, AddMindMapElement } from "@/api/systemDesigner";
|
|
|
-import { debounce, isEqual } from "lodash-es";
|
|
|
+import { EditMindMapElement, AddMindMapElement, BatchDeleteMindMapElement } from "@/api/systemDesigner";
|
|
|
+import { cloneDeep, debounce, isEqual } from "lodash-es";
|
|
|
|
|
|
enum positionType {
|
|
|
left = "left",
|
|
@@ -218,7 +218,10 @@ export const bindMindMapEvents = (
|
|
|
graph
|
|
|
);
|
|
|
}
|
|
|
- if (current?.width !== previous?.width || current?.height !== previous?.height) {
|
|
|
+ if (
|
|
|
+ current?.width !== previous?.width ||
|
|
|
+ current?.height !== previous?.height
|
|
|
+ ) {
|
|
|
setMindProjectInfo &&
|
|
|
updateTopic(
|
|
|
args.cell.id,
|
|
@@ -595,8 +598,10 @@ const handleSwitchPosition = (
|
|
|
position?: { x: number; y: number },
|
|
|
graph?: Graph
|
|
|
) => {
|
|
|
- // @ts-ignore
|
|
|
- const mindmapProjectInfo: MindMapProjectInfo = graph.extendAttr.getMindProjectInfo();
|
|
|
+ const mindmapProjectInfo: MindMapProjectInfo = cloneDeep(
|
|
|
+ // @ts-ignore
|
|
|
+ graph?.extendAttr.getMindProjectInfo()
|
|
|
+ );
|
|
|
if (!mindmapProjectInfo) return;
|
|
|
|
|
|
// 找到要拖拽的节点并删除
|
|
@@ -605,14 +610,20 @@ const handleSwitchPosition = (
|
|
|
if (topic.id === sourceId) {
|
|
|
source = topic;
|
|
|
}
|
|
|
- mindmapProjectInfo.topics = mindmapProjectInfo.topics.filter(
|
|
|
- (item) => item.id !== sourceId
|
|
|
- );
|
|
|
});
|
|
|
+ // 顶节点时删除节点
|
|
|
+ if (source) {
|
|
|
+ BatchDeleteMindMapElement({ ids: [sourceId ]});
|
|
|
+ }
|
|
|
+ // 删除自由节点
|
|
|
+ mindmapProjectInfo.topics = mindmapProjectInfo.topics.filter(
|
|
|
+ (item) => item.id !== sourceId
|
|
|
+ );
|
|
|
const topics = source
|
|
|
? mindmapProjectInfo.topics
|
|
|
: traverseNode(mindmapProjectInfo.topics, (topic) => {
|
|
|
const findItem = topic?.children?.find((item) => item.id === sourceId);
|
|
|
+ // 找到要移动的节点
|
|
|
if (findItem) {
|
|
|
source = findItem;
|
|
|
topic.children = topic.children?.filter(
|