import React from "react"; import { Node } from "@antv/x6"; import { Tooltip } from "antd"; import linkConfig from "@/config/linkConfig"; import { CorrelationType } from "@/enum"; export default function FlowExtra({ node }: { node: Node }) { const { attrs } = node.getData(); const enterpriseCode = sessionStorage.getItem("enterpriseCode"); const token = localStorage.getItem("token_" + enterpriseCode); function objectToUrlParams(obj: Record) { const params = new URLSearchParams(); for (const [key, value] of Object.entries(obj)) { params.append(key, value); } return params.toString(); } const linkTypeMap = { [CorrelationType.scene]: { name: "场景", url: linkConfig.scene, param: `#/${attrs?.linkValue?.value}` }, [CorrelationType.flow]: { name: "流程", url: linkConfig.flow, param: `#/${attrs?.linkValue?.value}` }, [CorrelationType.page]: { name: "页面", url: linkConfig.page, param: objectToUrlParams({ token, pageId: attrs?.linkValue?.value }) }, [CorrelationType.table]: { name: "数据表", url: linkConfig.table, param: objectToUrlParams({ id: attrs?.linkValue?.value, isSvg: true, type: 16 }) }, [CorrelationType.view]: { name: "视图", url: linkConfig.view, param: objectToUrlParams({ id: attrs?.linkValue?.value, isSvg: true, type: 16 }) }, }; const handleOpenLink = () => { const url = linkTypeMap[attrs.linkType as CorrelationType]?.url; const param = linkTypeMap[attrs.linkType as CorrelationType]?.param; if (!url) return; window.open(url + '?' + param, "_blank"); } return (
{attrs?.linkValue?.value && ( )}
); }