index.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react';
  2. import CircleServe from './mapServe';
  3. import { Badge } from 'antd';
  4. import { useXFlowApp, XFlowNodeCommands } from '@antv/xflow';
  5. export { CircleServe };
  6. export default function CustomRect(props) {
  7. const { size = { width: 90, height: 90 }, data } = props;
  8. const { width, height } = size;
  9. const { label, stroke, fill, fontFill, fontSize } = data;
  10. const app = useXFlowApp();
  11. const handleClick = () => {
  12. // console.log(data);
  13. app.executeCommand(XFlowNodeCommands.SELECT_NODE.id, {
  14. nodeId: data.id,
  15. });
  16. // console.log('XFlowNodeCommands.SELECT_NODE.id', data);
  17. // message.success(`${XFlowNodeCommands.SELECT_NODE.label}: 命令执行成功`);
  18. };
  19. return (
  20. <Badge count={data.versions} offset={[-10, 10]}>
  21. <div
  22. className="container"
  23. onClick={handleClick}
  24. style={{
  25. width,
  26. height,
  27. border: `2px solid ${stroke || '#FEDDAE'}`,
  28. backgroundColor: fill || '#FEF7E7',
  29. color: fontFill,
  30. fontSize,
  31. borderRadius: '50%',
  32. display: 'flex',
  33. justifyContent: 'center',
  34. alignItems: 'center',
  35. padding: "0px 8px",
  36. lineHeight: 1.2
  37. }}
  38. >
  39. <span style={{ textAlign: 'center', lineHeight: '20px' }}>{label}</span>
  40. </div>
  41. </Badge>
  42. );
  43. }