|
@@ -1120,10 +1120,11 @@ export default class Dag extends React.Component<any, any> {
|
|
|
|
|
|
// 初始化节点数据
|
|
|
function initNodeData(graph: Graph, newNode: Node<Node.Properties>) {
|
|
|
+ const baseNumber: number = nodeNumber(graph);
|
|
|
// 节点id
|
|
|
newNode.data.id = newNode.id;
|
|
|
newNode.data.nodeId = nanoid();
|
|
|
- newNode.data.nodeName = `node_${graph.getNodes().length + 1}`;
|
|
|
+ newNode.data.nodeName = `node_${baseNumber + 1}`;
|
|
|
switch (newNode.data.type) {
|
|
|
case 'datasource':
|
|
|
newNode.data.inputSource = undefined;
|
|
@@ -1151,3 +1152,14 @@ function initNodeData(graph: Graph, newNode: Node<Node.Properties>) {
|
|
|
function nanoid() {
|
|
|
return 'YL' + Date.now();
|
|
|
}
|
|
|
+
|
|
|
+// 节点名基数
|
|
|
+function nodeNumber(graph: Graph) {
|
|
|
+ let nodeNumber = 0;
|
|
|
+ graph.getNodes().map(node => {
|
|
|
+ const nodeName = node.data.nodeName.split('_');
|
|
|
+ nodeNumber =
|
|
|
+ parseInt(nodeName[1]) > nodeNumber ? parseInt(nodeName[1]) : nodeNumber;
|
|
|
+ });
|
|
|
+ return nodeNumber;
|
|
|
+}
|