|
@@ -12,21 +12,22 @@ import or from "@/assets/wf_icon_or.gif";
|
|
|
import { Graph, Node } from "@antv/x6";
|
|
|
|
|
|
const items = [
|
|
|
- { key: NodeType.START, icon: start, text: "开始" },
|
|
|
- { key: NodeType.PROCESS, icon: handle, text: "处理" },
|
|
|
- { key: NodeType.AUTO_PROCESS, icon: autohandle, text: "自动处理" },
|
|
|
- { key: NodeType.DECISION, icon: or, text: "判断" },
|
|
|
- { key: NodeType.AND, icon: and, text: "与" },
|
|
|
- { key: NodeType.LINK, icon: judge, text: "连接" },
|
|
|
- { key: NodeType.END, icon: end, text: "结束" },
|
|
|
+ { key: NodeType.START, name: "start-node", icon: start, text: "开始" },
|
|
|
+ { key: NodeType.PROCESS, name: "process-node", icon: handle, text: "处理" },
|
|
|
+ { key: NodeType.AUTO_PROCESS, name: "auto-process-node", icon: autohandle, text: "自动处理" },
|
|
|
+ { key: NodeType.DECISION, name: "decision-node", icon: or, text: "判断" },
|
|
|
+ { key: NodeType.AND, name: "and-node", icon: and, text: "与" },
|
|
|
+ { key: NodeType.LINK, name: "link-node", icon: judge, text: "连接" },
|
|
|
+ { key: NodeType.END, name: "end-node", icon: end, text: "结束" },
|
|
|
];
|
|
|
|
|
|
export default function NodeMenu(props: {
|
|
|
graph?: Graph;
|
|
|
onChange?: (n?: Node) => void;
|
|
|
position?: { x: number; y: number };
|
|
|
+ hideNodes?: string[];
|
|
|
}) {
|
|
|
- const { graph } = props;
|
|
|
+ const { graph, hideNodes } = props;
|
|
|
// 添加节点
|
|
|
const handleAddNode = (type: NodeType) => {
|
|
|
const node = nodes.find((item) => item.type === type);
|
|
@@ -73,18 +74,22 @@ export default function NodeMenu(props: {
|
|
|
|
|
|
return (
|
|
|
<div className="w-280px flex flex-wrap gap-[8px 12px]">
|
|
|
- {items.map((item) => {
|
|
|
- return (
|
|
|
- <div
|
|
|
- className="w-[38%] border-box h-40px px-12px rounded-8px flex items-center cursor-pointer hover:bg-#eff0f8"
|
|
|
- key={item.key}
|
|
|
- onClick={(e) => {handleAddNode(item.key)}}
|
|
|
- >
|
|
|
- <img src={item.icon} className="w-24px" />
|
|
|
- <span>{item.text}</span>
|
|
|
- </div>
|
|
|
- );
|
|
|
- })}
|
|
|
+ {items
|
|
|
+ .filter((item) => !hideNodes?.includes(item.name))
|
|
|
+ .map((item) => {
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className="w-[38%] border-box h-40px px-12px rounded-8px flex items-center cursor-pointer hover:bg-#eff0f8"
|
|
|
+ key={item.key}
|
|
|
+ onClick={(e) => {
|
|
|
+ handleAddNode(item.key);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <img src={item.icon} className="w-24px" />
|
|
|
+ <span>{item.text}</span>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ })}
|
|
|
</div>
|
|
|
);
|
|
|
}
|