|
@@ -1,5 +1,5 @@
|
|
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
-import { EventArgs, Graph, Shape, Point } from "@antv/x6";
|
|
|
+import { EventArgs, Graph, Shape } from "@antv/x6";
|
|
|
import { Transform } from "@antv/x6-plugin-transform";
|
|
|
import { Scroller } from "@antv/x6-plugin-scroller";
|
|
|
import { Snapline } from "@antv/x6-plugin-snapline";
|
|
@@ -7,10 +7,10 @@ import { Keyboard } from "@antv/x6-plugin-keyboard";
|
|
|
import { Export } from "@antv/x6-plugin-export";
|
|
|
import { Selection } from "@antv/x6-plugin-selection";
|
|
|
import { SaveDataModel } from "@/api";
|
|
|
-import { useRequest } from "umi";
|
|
|
-import { useFullscreen } from "ahooks";
|
|
|
+import { useFullscreen, useSessionStorageState } from "ahooks";
|
|
|
import { throttle } from "lodash-es";
|
|
|
-import { createTable } from "@/utils";
|
|
|
+import { createTable, uuid } from "@/utils";
|
|
|
+import dayjs from "dayjs";
|
|
|
|
|
|
import type {
|
|
|
ColumnItem,
|
|
@@ -20,17 +20,24 @@ import type {
|
|
|
TableItemType,
|
|
|
TopicAreaInfo,
|
|
|
} from "@/type";
|
|
|
-import { createColumn, uuid } from "@/utils";
|
|
|
-import { DataType, RelationLineType, RelationType, TableType } from "@/enum";
|
|
|
+import { RelationLineType } from "@/enum";
|
|
|
import { render } from "./renderer";
|
|
|
-import { useSessionStorageState } from "ahooks";
|
|
|
-import { useSearchParams } from "umi";
|
|
|
|
|
|
import "@/components/TableNode";
|
|
|
import "@/components/TopicNode";
|
|
|
import "@/components/NoticeNode";
|
|
|
import { message } from "antd";
|
|
|
|
|
|
+const DEFAULT_SETTING = {
|
|
|
+ showMenu: true,
|
|
|
+ showSidebar: true,
|
|
|
+ showColumnDetail: true,
|
|
|
+ showGrid: true,
|
|
|
+ showRelation: true,
|
|
|
+ autoUpdate: false,
|
|
|
+ tableWidth: 220,
|
|
|
+};
|
|
|
+
|
|
|
export default function erModel() {
|
|
|
const graphRef = useRef<Graph>();
|
|
|
const [graph, setGraph] = useState<Graph>();
|
|
@@ -41,6 +48,7 @@ export default function erModel() {
|
|
|
defaultValue: false,
|
|
|
listenStorageChange: true
|
|
|
});
|
|
|
+ const [saveTime, setSaveTime] = useState<string>();
|
|
|
const [project, setProjectInfo] = useState<ProjectInfo>({
|
|
|
id: "1",
|
|
|
name: "新建模型",
|
|
@@ -56,15 +64,10 @@ export default function erModel() {
|
|
|
remarkInfos: [],
|
|
|
todos: [],
|
|
|
setting: {
|
|
|
- showMenu: true,
|
|
|
- showSidebar: true,
|
|
|
- showColumnDetail: true,
|
|
|
- showGrid: true,
|
|
|
- showRelation: true,
|
|
|
- autoUpdate: false,
|
|
|
- tableWidth: 220,
|
|
|
+ ...DEFAULT_SETTING
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
const [_tabActiveKey, setTabActiveKey] =
|
|
|
useSessionStorageState("tabs-active-key");
|
|
|
const [_relationActive, setRelationActive] =
|
|
@@ -119,6 +122,8 @@ export default function erModel() {
|
|
|
// 提交服务器
|
|
|
if(!isInit) {
|
|
|
SaveDataModel(project);
|
|
|
+ // 格式化当前时间
|
|
|
+ setSaveTime(dayjs().format('YYYY-MM-DD HH:mm:ss'));
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -251,10 +256,9 @@ export default function erModel() {
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- instance.on("node:change:position", throttle((args) => {
|
|
|
- console.log(args);
|
|
|
+ instance.on("node:moved", throttle((args) => {
|
|
|
+ console.log('moved', args);
|
|
|
const data = args.node.data;
|
|
|
- const current = args.current;
|
|
|
if(data.isTable) {
|
|
|
updateTable({
|
|
|
...data,
|
|
@@ -262,8 +266,8 @@ export default function erModel() {
|
|
|
...data.table,
|
|
|
style: {
|
|
|
...data.table.style,
|
|
|
- x: current.x,
|
|
|
- y: current.y,
|
|
|
+ x: args.x,
|
|
|
+ y: args.y,
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -273,8 +277,8 @@ export default function erModel() {
|
|
|
...data,
|
|
|
style: {
|
|
|
...data.style,
|
|
|
- x: current.x,
|
|
|
- y: current.y,
|
|
|
+ x: args.x,
|
|
|
+ y: args.y,
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -283,8 +287,8 @@ export default function erModel() {
|
|
|
...data,
|
|
|
style: {
|
|
|
...data.style,
|
|
|
- x: current.x,
|
|
|
- y: current.y,
|
|
|
+ x: args.x,
|
|
|
+ y: args.y,
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -347,8 +351,7 @@ export default function erModel() {
|
|
|
const x = area?.center.x || 300;
|
|
|
const y = area?.center.y || 300;
|
|
|
// 数据表类型动态路由传参
|
|
|
- const [searchParams] = useSearchParams();
|
|
|
- const newTable = createTable(searchParams.get('type') as unknown as TableType || 3, parentId);
|
|
|
+ const newTable = createTable(project.type || 3, parentId);
|
|
|
newTable.table.style.x = x;
|
|
|
newTable.table.style.y = y;
|
|
|
|
|
@@ -364,6 +367,7 @@ export default function erModel() {
|
|
|
...project,
|
|
|
tables: list
|
|
|
})
|
|
|
+ setTabActiveKey("1");
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -429,6 +433,7 @@ export default function erModel() {
|
|
|
...project,
|
|
|
topicAreas: [...project.topicAreas, newTopicArea],
|
|
|
});
|
|
|
+ setTabActiveKey("3");
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -481,6 +486,7 @@ export default function erModel() {
|
|
|
...project,
|
|
|
remarkInfos: [...project.remarkInfos, newRemark],
|
|
|
});
|
|
|
+ setTabActiveKey("4");
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -590,6 +596,7 @@ export default function erModel() {
|
|
|
return state;
|
|
|
}
|
|
|
});
|
|
|
+ setTabActiveKey("2");
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -847,6 +854,7 @@ export default function erModel() {
|
|
|
enterPlayMode,
|
|
|
playModeEnable,
|
|
|
setPlayModeEnable,
|
|
|
- exitPlayMode
|
|
|
+ exitPlayMode,
|
|
|
+ saveTime
|
|
|
};
|
|
|
}
|