FlowChart.razor 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 
  2. @if (shapeTrees != null)
  3. {
  4. <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="@ChartWidth" height="@ChartHeight">
  5. <text x="@(ChartWidth/2)" y="@(TitleHeight/2)" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="30" font-weight="800">@workflow.Name</text>
  6. <line x1="@startNode.x" y1="@(startNode.y + startNode.width / 2) " x2="@(InitShape.x)" y2="@(InitShape.y - InitShape.height / 2)" stroke="black" stroke-width="2" />
  7. @for (int iLevel = 0; iLevel < LevelNodes.Count; iLevel++)
  8. {
  9. @foreach (var node in LevelNodes[iLevel])
  10. {
  11. if (node.Type == 0)
  12. {
  13. <circle cx="@(node.x)" cy="@node.y" r="@(node.width / 2) " stroke="black" stroke-width="2" fill="white" />
  14. <a @onclick="() => ClickNode(node)">
  15. <text x="@(node.x)" y="@node.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="16">
  16. @if (node == startNode)
  17. {
  18. @("开始")
  19. }
  20. else
  21. {
  22. if (node == endNode)
  23. {
  24. @("结束")
  25. }
  26. else
  27. {
  28. if (node.NodeObject is entity.workflowDefine.Step)
  29. {
  30. @(((entity.workflowDefine.Step)node.NodeObject).Name)
  31. }
  32. }
  33. }
  34. </text>
  35. </a>
  36. }
  37. if (node.Type == 1)
  38. {
  39. <rect x="@(node.x - node.width / 2)" y="@(node.y - node.height / 2)" rx="10" ry="10" width="@node.width" height="@node.height" style="fill:green;stroke:black;stroke-width:3;opacity:0.5" />
  40. <a @onclick="() => ClickNode(node)">
  41. <text x="@node.x" y="@node.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="@rectFontSize" font-weight="700">
  42. @if (node == InitShape)
  43. {
  44. @((workflow.InitAction == null || string.IsNullOrEmpty(workflow.InitAction.Name)) ? $"启动{workflow.Name}" : workflow.InitAction.Name)
  45. }
  46. else
  47. {
  48. @(((entity.workflowDefine.Step)node.NodeObject).Name)
  49. }
  50. </text>
  51. </a>
  52. }
  53. }
  54. }
  55. @foreach (var t in Transfers)
  56. {
  57. dynamic ret = GetLineParater(t);
  58. <line x1="@ret.x1" y1="@ret.y1" x2="@ret.x2" y2="@ret.y2" stroke="black" stroke-width="2" />
  59. <circle cx="@((ret.x1 + ret.x2) / 2)" cy="@((ret.y1 + ret.y2) / 2)" r="5" stroke="black" stroke-width="1" fill="white" />
  60. <a @onclick="() => ClickTrasfer(t)">
  61. <text x="@((ret.x1 + ret.x2) / 2)" y="@((ret.y1 + ret.y2) / 2)" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="5">c</text>
  62. </a>
  63. }
  64. @{
  65. dynamic endLine = GetEndStepLine();
  66. <line x1="@endLine.x1" y1="@endLine.y1" x2="@endLine.x2" y2="@endLine.y2" stroke="black" stroke-width="2" />
  67. }
  68. @*<circle cx="@(endNode.x)" cy="@endNode.y" r="@(endNode.width/2) " stroke="black" stroke-width="2" fill="gray" />
  69. <a>
  70. <text x="@(endNode.x)" y="@endNode.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="5">结束</text>
  71. </a>*@
  72. </svg>
  73. }
  74. else
  75. {
  76. <Spin />
  77. }