Browse Source

添加点击流程清单中详情按钮转到流程详情页面
添加流程定义数据添加、及获取数据API

luocaiyang 3 years ago
parent
commit
e218b59f06

+ 77 - 1
wispro.sp.api/Controllers/WorkflowEngineController.cs

@@ -1,17 +1,27 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
+using wispro.sp.entity;
 using wispro.sp.entity.workflowInstance;
+using wispro.sp.share;
 
 namespace wispro.sp.api.Controllers
 {
-    [Route("api/[controller]")]
+    [Route("api/[controller]/[action]")]
     [ApiController]
     public class WorkflowEngineController : ControllerBase
     {
+        spDbContext Context;
+
+        public WorkflowEngineController(spDbContext context)
+        {
+            Context = context;
+        }
+
         public void DoAction(int instanceId,int stepId,int ActionId,List<InputValue> inputValues)
         {
             //1、取实例对象
@@ -24,5 +34,71 @@ namespace wispro.sp.api.Controllers
 
             //5、保存数据
         }
+
+        [HttpPost]
+        public ApiSaveResponse AddNew(NewWorkflowObject workflowObject)
+        {
+            ApiSaveResponse ret = new ApiSaveResponse();
+            ret.Success = true;
+
+            using(var t = Context.Database.BeginTransaction())
+            {
+                try
+                {
+                    if (workflowObject.InitAction != null)
+                    {
+                        Context.Actions.Add(workflowObject.InitAction);
+                        Context.SaveChanges();
+                    }
+                    else
+                    {
+                        throw new ApplicationException("没有设定初始化Action!");
+                    }
+
+                    workflowObject.Workflow.InitActionId  = workflowObject.InitAction.Id;
+                    workflowObject.Workflow.CreateTime = DateTime.Now;
+                    workflowObject.Workflow.CreateUserId = Context.Staffs.FirstOrDefault<Staff>(s => s.Name == User.Identity.Name).Id;
+                    Context.Workflows.Add(workflowObject.Workflow);
+
+                    Context.SaveChanges();
+                    t.Commit();
+                }
+                catch(Exception ex)
+                {
+                    t.Rollback();
+                    ret.Success = false;
+                    ret.ErrorMessage = ex.Message;
+                }
+            }
+
+            return ret;
+        }
+
+        public List<entity.workflowDefine.Workflow> GetAllWorkflows()
+        {
+            return Context.Workflows.Include(d => d.CreateUser).ToList();
+        }
+
+        public entity.workflowDefine.Workflow GetWorkflow(int workflowId)
+        {
+            return Context.Workflows.Include(d=>d.InitAction).Include(d=>d.CreateUser).FirstOrDefault<entity.workflowDefine.Workflow>(w => w.Id == workflowId);
+        }
+
+        public List<entity.workflowDefine.Step> GetSteps(int workflowId)
+        {
+            return Context.Steps.Where<entity.workflowDefine.Step>(w => w.workflowId  == workflowId).ToList();
+        }
+
+        public List<entity.workflowDefine.Action> GetActions(int workflowId)
+        {
+            var workflow = Context.Workflows.FirstOrDefault<entity.workflowDefine.Workflow>(w => w.Id == workflowId);
+            return Context.Actions.Where<entity.workflowDefine.Action>(d => d.step.workflowId == workflowId || d.Id == workflow.InitActionId).ToList();
+        }
+
+        public List<entity.workflowDefine.TrasferCondition> GetTrasfers(int workflowId)
+        {
+            return Context.TrasferConditions.Where(d => d.Step.workflowId == workflowId || d.nextStep.workflowId == workflowId).ToList();
+        }
+
     }
 }

+ 3 - 1
wispro.sp.api/spDbContext.cs

@@ -63,7 +63,7 @@ namespace wispro.sp.api
         public virtual DbSet<Position> Positions { get; set; }
 
         #region 流程定义
-        public virtual DbSet<Workflow> Wrokflows { get; set; }
+        public virtual DbSet<Workflow> Workflows { get; set; }
 
         public virtual DbSet<Step> Steps { get; set; }
 
@@ -728,6 +728,7 @@ namespace wispro.sp.api
                     .WithMany()
                     .HasForeignKey(d => d.nextStepId)
                     .OnDelete(DeleteBehavior.NoAction);
+
             });
 
             modelBuilder.Entity<entity.workflowDefine.Action>(entity => {
@@ -736,6 +737,7 @@ namespace wispro.sp.api
                 entity.HasOne(d => d.step)
                     .WithMany()
                     .HasForeignKey(d => d.StepId);
+                
             });
 
             modelBuilder.Entity<InputValueSetting>(entity => {

+ 17 - 0
wispro.sp.share/NewWorkflowObject.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using wispro.sp.entity.workflowDefine;
+
+namespace wispro.sp.share
+{
+    public class NewWorkflowObject
+    {
+        public Workflow Workflow { get; set; }
+
+        public entity.workflowDefine.Action InitAction { get; set; }
+
+    }
+}

+ 11 - 7
wispro.sp.web/Components/FlowChart.razor

@@ -14,7 +14,11 @@
 
     <text x="@(ChartWidth/2)" y="@(TitleHeight/2)" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="30" font-weight="800">@workflow.Name</text>
 
-    <line x1="@startNode.x" y1="@(startNode.y + startNode.width / 2) " x2="@(InitShape.x)" y2="@(InitShape.y - InitShape.height / 2)" stroke="black" stroke-width="2" marker-end="url(#idArrow)" />
+    @{
+        dynamic startLine = GetStartInitLine();
+        <line x1="@startLine.x1" y1="@startLine.y1 " x2="@startLine.x2" y2="@startLine.y2" stroke="black" stroke-width="2" marker-end="url(#idArrow)" />
+
+    }
 
     @for (int iLevel = 0; iLevel < LevelNodes.Count; iLevel++)
     {
@@ -22,9 +26,9 @@
         {
             if (node.Type == 0)
             {
-                <circle cx="@(node.x)" cy="@node.y" r="@(node.width / 2) " stroke="black" stroke-width="2" fill="white" />
-                <a @onclick="() => ClickNode(node)">
-                    <text x="@(node.x)" y="@node.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="16">
+                <circle cx="@(node.x)" cy="@node.y" r="@(node.width / 2) " stroke="black" stroke-width="2" fill="@(node.FillColor)" />
+                <a @ondblclick="()=>ClickNode(node)">
+                    <text x="@(node.x)" y="@node.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="14">
                         @if (node == startNode)
                         {
                             @("开始")
@@ -49,8 +53,8 @@
 
             if (node.Type == 1)
             {
-                <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" />
-                <a @onclick="() => ClickNode(node)">
+                <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:@(node.FillColor);stroke:black;stroke-width:3;opacity:0.5" />
+                <a @ondblclick="() => ClickNode(node)">
                     <text x="@node.x" y="@node.y" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="@rectFontSize" font-weight="700">
                         @if (node.NodeObject is entity.workflowDefine.Action)
                         {
@@ -81,7 +85,7 @@
 
     @{
         dynamic endLine = GetEndStepLine();
-        <line x1="@endLine.x1" y1="@endLine.y1" x2="@endLine.x2" y2="@endLine.y2" stroke="black" stroke-width="2" marker-end="url(#idArrow)"/>
+        <line x1="@endLine.x1" y1="@endLine.y1" x2="@endLine.x2" y2="@endLine.y2" stroke="black" stroke-width="2" marker-end="url(#idArrow)" />
     }
 
     @*<circle cx="@(endNode.x)" cy="@endNode.y" r="@(endNode.width/2) " stroke="black" stroke-width="2" fill="gray" />

+ 118 - 14
wispro.sp.web/Components/FlowChart.razor.cs

@@ -1,6 +1,7 @@
 using Microsoft.AspNetCore.Components;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Dynamic;
 using System.Linq;
 using System.Threading.Tasks;
@@ -13,23 +14,28 @@ namespace wispro.sp.web.Components
         [Parameter]
         public double TitleHeight { get; set; } = 100;
 
-
         [Parameter]
         public double ChartWidth { get; set; } = 1200;
         [Parameter]
         public double ChartHeight { get; set; } = 900;
         [Parameter]
         public double rectWidth { get; set; } = 150;
-        
+
         [Parameter]
         public double rectHeight { get; set; } = 60;
         [Parameter]
-        public double initRadius { get; set; } = 25;
+        public double initRadius { get; set; } = 20;
         [Parameter]
-        public double EndRadius { get; set; } = 25;
+        public double EndRadius { get; set; } = 20;
         [Parameter]
         public double hSeparation { get; set; } = 40;
 
+        [Parameter]
+        public string StepShapeColor { get; set; } = "green";
+
+        [Parameter]
+        public string EndShapColor { get; set; } = "gray";
+
         int rectFontSize { get; set; } = 18;
 
         [Parameter]
@@ -73,13 +79,15 @@ namespace wispro.sp.web.Components
 
             public List<shapeNode> Parents { get; set; }
 
+            public string FillColor { get; set; } = "white";
+
         }
 
         private List<shapeNode> shapeTrees = null;
 
         private shapeNode FindNode(int stepId, out int Level, List<shapeNode> lstNodes)
         {
-            
+
             Level = 1;
             foreach (var sNode in lstNodes)
             {
@@ -149,13 +157,16 @@ namespace wispro.sp.web.Components
                 height = 2 * initRadius,
                 Level = 0
             };
+
+            
             InitShape = new shapeNode()
             {
                 NodeObject = workflow.InitAction,
                 InCount = 0,
                 OutCount = 0,
                 Type = 1,
-                Level = 1
+                Level = 1,
+                FillColor = StepShapeColor
             };
 
             startNode.Childrens = new List<shapeNode>();
@@ -169,7 +180,8 @@ namespace wispro.sp.web.Components
                 InCount = 0,
                 OutCount = 0,
                 height = 2 * EndRadius,
-                width = 2 * EndRadius
+                width = 2 * EndRadius,
+                FillColor = EndShapColor
             };
 
             shapeTrees.Add(startNode);
@@ -177,7 +189,7 @@ namespace wispro.sp.web.Components
             //shapeTrees.Add(endNode);
 
             #region 将步骤对象生成形状Node并添加到列表中
-            if (Steps == null || Steps.Count == 0 || Steps.FirstOrDefault(s=>s.Id == workflow.EndStepId) == null)
+            if (Steps == null || Steps.Count == 0 || Steps.FirstOrDefault(s => s.Id == workflow.EndStepId) == null)
             {
                 InitShape.Childrens = new List<shapeNode>();
                 InitShape.Childrens.Add(endNode);
@@ -192,7 +204,7 @@ namespace wispro.sp.web.Components
             {
                 foreach (var step in Steps)
                 {
-                    var temNode = new shapeNode() { NodeObject = step, InCount = 0, OutCount = 0, Type = 1 };
+                    var temNode = new shapeNode() { NodeObject = step, InCount = 0, OutCount = 0, Type = 1,FillColor = StepShapeColor };
 
                     if (workflow.EndStepId == step.Id)
                     {
@@ -205,7 +217,7 @@ namespace wispro.sp.web.Components
                     shapeTrees.Add(temNode);
                 }
             }
-            
+
             #endregion
 
             #region 遍历转移条件,生成流程树
@@ -255,7 +267,7 @@ namespace wispro.sp.web.Components
             }
             #endregion
 
-            
+
 
             GetShapeLevelNodes(LevelNodes, shapeTrees);
 
@@ -333,7 +345,7 @@ namespace wispro.sp.web.Components
                 LevelNodes[i] = LevelNodes[i].OrderBy(node =>
                 {
                     // calculate average position based on connected nodes in top layer
-                    if(node.Parents == null)
+                    if (node.Parents == null)
                     {
                         return 0;
                     }
@@ -435,7 +447,7 @@ namespace wispro.sp.web.Components
 
 
         }
-        
+
         public dynamic GetLineParater(entity.workflowDefine.TrasferCondition trasferCondition)
         {
             int level = 0;
@@ -453,12 +465,77 @@ namespace wispro.sp.web.Components
             ret.x2 = endNode.x;
             ret.y2 = endNode.y - endNode.height / 2;
 
+            double x3 = 0.0;
+            double y3 = 0.0;
+            GetArrorEndPoint(ret, out x3, out y3);
+
+            Console.WriteLine($"x1:{ret.x1};y1:{ret.y1}\r\nx2:{ret.x2};y2:{ret.y2}\r\nx3:{x3};y3:{y3}\r\n");
+            ret.x2 = x3;
+            ret.y2 = y3;
+
             return ret;
         }
 
+        public void GetArrorEndPoint(dynamic ret, out double x3, out double y3)
+        {
+            if (ret.x1 == ret.x2)
+            {
+                x3 = ret.x1;
+                if (ret.y2 > ret.y1)
+                {
+                    y3 = ret.y2 - 8;
+                }
+                else
+                {
+                    y3 = ret.y2 + 8;
+                }
+            }
+            else
+            {
+                if (ret.y1 == ret.y2)
+                {
+                    y3 = ret.y1;
+
+                    if (ret.x1 < ret.x2)
+                    {
+                        x3 = ret.x2 - 8;
+                    }
+                    else
+                    {
+                        x3 = ret.x2 + 8;
+                    }
+                }
+                else
+                {
+                    double k = (ret.y1 - ret.y2) / (ret.x1 - ret.x2);
+                    double b = ret.y2 - k * ret.x2;
+                    Console.WriteLine($"k={k};b={b}");
+
+                    double a = k * k + 1;
+                    double B = 2 * k * (b - ret.y2) - 2 * ret.x2;
+                    double c = (b - ret.y2) * (b - ret.y2) + ret.x2 * ret.x2 - 100;
+
+
+                    double x3_1 = (Math.Sqrt(B * B - 4 * a * c) - B) / (2 * a);
+                    double x3_2 = ((Math.Sqrt(B * B - 4 * a * c) + B) / (2 * a)) * -1;
+
+                    if (ret.x1 < ret.x2)
+                    {
+                        x3 = (x3_1 < x3_2) ? x3_1 : x3_2;
+                    }
+                    else
+                    {
+                        x3 = (x3_1 < x3_2) ? x3_2 : x3_1;
+                    }
+
+                    y3 = k * x3 + b;
+                }
+            }
+        }
+
         public dynamic GetEndStepLine()
         {
-            var startNode =endNode.Parents[0];
+            var startNode = endNode.Parents[0];
             dynamic ret = new ExpandoObject();
             ret.x1 = startNode.x;
             ret.y1 = startNode.y + startNode.height / 2;
@@ -466,7 +543,34 @@ namespace wispro.sp.web.Components
             ret.x2 = endNode.x;
             ret.y2 = endNode.y - endNode.height / 2;
 
+            double x3 = 0.0;
+            double y3 = 0.0;
+            GetArrorEndPoint(ret, out x3, out y3);
+
+            ret.x2 = x3;
+            ret.y2 = y3;
+
+            return ret;
+        }
+
+        public dynamic GetStartInitLine()
+        {
+            dynamic ret = new ExpandoObject();
+            ret.x1 = this.startNode.x;
+            ret.y1 = this.startNode.y + startNode.height / 2;
+
+            ret.x2 = InitShape.x;
+            ret.y2 = InitShape.y - InitShape.height / 2;
+
+            double x3 = 0.0;
+            double y3 = 0.0;
+            GetArrorEndPoint(ret, out x3, out y3);
+
+            ret.x2 = x3;
+            ret.y2 = y3;
+
             return ret;
+            
         }
 
         protected  override  void OnInitialized()

+ 1 - 1
wispro.sp.web/Components/InputValueSetting.razor

@@ -1,4 +1,4 @@
-<Card Title="栏位设定" Style="width:100%;">
+<Card Title="输入栏位设定" Style="width:100%;">
     <Extra>
         <Button Type="@ButtonType.Primary" OnClick="() => AddNew(null)">添加</Button>
     </Extra>

+ 12 - 56
wispro.sp.web/Layouts/BasicLayout.razor

@@ -57,44 +57,7 @@
             Path="/MyCaselist",
 
         },
-        //new MenuDataItem
-        //{
-        //    Name = "我的专案",
-        //    Key = "staffManager",
-        //    Icon = "setting",
-        //    Children= new MenuDataItem[]
-        //    {
-        //        //new MenuDataItem
-        //        //{
-        //        //    Path ="/Project/ReadMessage",
-        //        //    Name ="专案点数分配系统通知",
-        //        //    Key= "project_readMsg",
-        //        //    Icon = ""
-        //        //},
-        //        new MenuDataItem
-        //        {
-        //            Path ="/Project/AssignPoint",
-        //            Name ="分配专案点数",
-        //            Key= "project_assignpoint",
-        //            Icon = ""
-        //        },
-        //        //new MenuDataItem
-        //        //{
-        //        //    Path ="/Project/ReadAssignPointMsg",
-        //        //    Name ="专案点数分配通知阅读",
-        //        //    Key= "ReadAssignPointMsg",
-        //        //    Icon = ""
-        //        //},
-        //        //new MenuDataItem
-        //        //{
-        //        //    Path ="/Project/ConfirmProjectPoint",
-        //        //    Name ="代理人确认",
-        //        //    Key= "project_point_confirm",
-        //        //    Icon = ""
-        //        //}
-
-        //    }
-        //},
+        
         new MenuDataItem
         {
             Name = "基本资料管理",
@@ -123,21 +86,6 @@
                     Key= "sg",
                     Icon = ""
                 },
-                //new MenuDataItem
-                //{
-                //    Path ="/VerifyCeofficient",
-                //    Name ="核稿系数设定",
-                //    Key="vc",
-                //    Icon = ""
-                //}
-                //,
-                //new MenuDataItem
-                //{
-                //    Path ="/VerifyCeofficient",
-                //    Name ="案件难度系数设定",
-                //    Key="vc",
-                //    Icon = ""
-                //},
                 new MenuDataItem
                 {
                     Path ="/CustomerList",
@@ -147,11 +95,19 @@
                 }
 
             }
+        },
+        new MenuDataItem
+        {
+            Path ="/Workflow/Manage",
+            Name ="流程管理",
+            Key= "wfManage",
+            Icon = "apartment"
         }
+
     };
 
-    public LinkItem[] Links { get; set; } =
-    {
+        public LinkItem[] Links { get; set; } =
+        {
         new LinkItem
         {
             Key = "威世博官网",
@@ -181,4 +137,4 @@
             BlankTarget = true,
         }
     };
-}
+    }

+ 13 - 21
wispro.sp.web/Pages/Workflow/WorkflowDefine.razor

@@ -40,9 +40,7 @@
                     <AntDesign.Column Title="生效日期" @bind-Field="@context.EffectivrDate" Format="yyyy-MM-dd" Sortable Filterable />
                     <AntDesign.Column Title="失效日期" @bind-Field="@context.ExpirationDate" Format="yyyy-MM-dd" Sortable Filterable />
                     <AntDesign.Column Title="绑定对象" TData="string">
-
                         @workflowService.GetBindObjectName(context.ContentObjectType)
-
                     </AntDesign.Column>
                     <AntDesign.Column Title="说明" @bind-Field="@context.Memo" Filterable />
                     <AntDesign.Column Title="创建人" TData="string">
@@ -55,9 +53,6 @@
                     </AntDesign.Column>
                     <ActionColumn>
                         <Space>
-                            <SpaceItem><Button OnClick="()=>InitFieldSetting(context)">初始化栏位</Button></SpaceItem>
-                        </Space>
-                        <Space>
                             <SpaceItem><Button OnClick="()=>Detail(context.Id)">详情</Button></SpaceItem>
                         </Space>
                         <Space>
@@ -77,11 +72,6 @@
             </AntDesign.Table>
         }
         
-        <Divider />
-        <div style="height:400px;width:100%;overflow:auto;background:#FFFFFF;">
-            <wispro.sp.web.Components.FlowChart workflow="@EditingObj" />
-        </div>
-
 </ChildContent>
 </PageContainer>
 
@@ -95,20 +85,14 @@
             border-radius: 100%;
         }
 </style>
-    <Modal Title="初始化栏位"
-       Visible="@_initModalVisible"
-       OnOk="@InitOk"
-       OnCancel="@InitCancel"
-        OkText="@("确认")"
-        CancelText="@("取消")"
-       Width="900" MaskClosable="false">
-        <wispro.sp.web.Components.InputValueSetting DataSource="@InitInputValues"/>
-    </Modal>
-
+    
     <Modal Title="修改"
            Visible="@_visible"
            OnOk="@HandleOk"
-           OnCancel="@HandleCancel">
+           OnCancel="@HandleCancel"
+           OkText="@("保存")"
+           CancelText="@("取消")"
+           Width="1000" MaskClosable="false">
 
         <Form Model="EditingObj" LabelColSpan="6"
               WrapperColSpan="16">
@@ -140,6 +124,14 @@
                 <TextArea @bind-Value="@context.Memo" MinRows="4" />
             </FormItem>
 
+            <Divider />
+            <FormItem Label="初始化操作名称">
+                <Input @bind-Value="@InitAction.Name" />
+            </FormItem>
+            <FormItem Label="初始化界面">
+                <Input @bind-Value="@InitAction.InputForm" />
+            </FormItem>
+            <wispro.sp.web.Components.InputValueSetting DataSource="@InitAction.inputValuesSettings" />
         </Form>
 
     </Modal>

+ 40 - 44
wispro.sp.web/Pages/Workflow/WorkflowDefine.razor.cs

@@ -23,7 +23,8 @@ namespace wispro.sp.web.Pages.Workflow
         bool isAdd = false;
 
         entity.workflowDefine.Workflow EditingObj = null;
-        List<entity.workflowDefine.InputValueSetting> InitInputValues;
+        entity.workflowDefine.Action InitAction = null;
+        
 
         bool _visible = false;
         bool _initModalVisible = false;
@@ -38,40 +39,44 @@ namespace wispro.sp.web.Pages.Workflow
 
         [Inject] protected MessageService _msgService { get; set; }
 
+        [Inject] protected NavigationManager navigation { get; set; }
+
         protected override async System.Threading.Tasks.Task OnInitializedAsync()
         {
             await base.OnInitializedAsync();
+            workflows = await workflowService.getAllWorkflows();
         }
 
         private void AddNew()
         {
             isAdd = true;
             EditingObj = new entity.workflowDefine.Workflow();
+            InitAction = new entity.workflowDefine.Action();
+            InitAction.inputValuesSettings  = new List<entity.workflowDefine.InputValueSetting>();
             _visible = true;
         }
 
-        async void HandleOk()
+        async Task HandleOk()
         {
             if (EditingObj.Id ==0)
             {
-                int maxId = 0;
-                foreach(var wf in workflows)
+                
+                EditingObj.CreateTime = DateTime.Now;
+
+                var retResponse = await workflowService.AddWorkflow(EditingObj,InitAction);
+
+                if (retResponse.Success)
                 {
-                    if(wf.Id > maxId)
-                    {
-                        maxId = wf.Id;
-                    }
-                }
 
-                EditingObj.Id = maxId + 1;
-                EditingObj.CreateTime = DateTime.Now;
-                EditingObj.CreateUser = new entity.Staff() { Name = (await UserService.GetUser()).Name };
-                workflows.Add(EditingObj);
-                _total = workflows.Count;
+                    workflows = await workflowService.getAllWorkflows();
+                    _visible = false;
+                    StateHasChanged();
+                }
+                else
+                {
+                   await _msgService.Error(retResponse.ErrorMessage);
+                }
             }
-
-            _visible = false;
-            StateHasChanged();
         }
     
 
@@ -115,36 +120,27 @@ namespace wispro.sp.web.Pages.Workflow
 
         void Detail(int Id)
         {
-
+            navigation.NavigateTo($"/Workflow/Detail/{Id}");
         }
 
-        IDictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>> dicFieldSettings
-            = new Dictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>>();
-        void InitFieldSetting(entity.workflowDefine.Workflow workflow)
-        {
-            if (dicFieldSettings.ContainsKey(workflow))
-            {
-                InitInputValues = dicFieldSettings[workflow];
-            }
-            else
-            {
-                InitInputValues = new List<entity.workflowDefine.InputValueSetting>();
-                dicFieldSettings.Add(workflow,InitInputValues);
-            }
+        //IDictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>> dicFieldSettings
+        //    = new Dictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>>();
+        //void InitFieldSetting(entity.workflowDefine.Workflow workflow)
+        //{
+        //    if (dicFieldSettings.ContainsKey(workflow))
+        //    {
+        //        InitInputValues = dicFieldSettings[workflow];
+        //    }
+        //    else
+        //    {
+        //        InitInputValues = new List<entity.workflowDefine.InputValueSetting>();
+        //        dicFieldSettings.Add(workflow,InitInputValues);
+        //    }
+
+        //    _initModalVisible = true;
+        //}
 
-            _initModalVisible = true;
-        }
-
-        async void InitOk()
-        {
-            _initModalVisible  = false;
-        }
-
-
-        void InitCancel()
-        {
-            _initModalVisible = false;
-        }
+        
 
 
        

+ 8 - 1
wispro.sp.web/Pages/Workflow/WorkflowDetail.razor

@@ -1,4 +1,4 @@
-@page "/Workflow/Detail"
+@page "/Workflow/Detail/{WorkflowId}"
 
 <PageContainer>
     <Breadcrumb>
@@ -15,6 +15,12 @@
         <Button Type="primary" Icon="plus" OnClick="AddNewStep" Style="float:right">添加新步骤</Button>
     </Content>
     <ChildContent>
+        @if (workflow == null)
+        {
+            <Spin/>
+        }
+        else
+        {
         <div style="height:800px;width:100%;overflow:auto;background:#FFFFFF;">
             <wispro.sp.web.Components.FlowChart @ref="chart" 
                             workflow="@workflow" Actions="@Actions" 
@@ -23,5 +29,6 @@
                             OnClickStep="OnClickStep"
                             OnClickTransfer="OnClickTransfer"/>
         </div>
+        }
     </ChildContent>
 </PageContainer>

+ 59 - 43
wispro.sp.web/Pages/Workflow/WorkflowDetail.razor.cs

@@ -4,6 +4,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
+using wispro.sp.web.Services;
 
 namespace wispro.sp.web.Pages.Workflow
 {
@@ -16,37 +17,52 @@ namespace wispro.sp.web.Pages.Workflow
         List<entity.workflowDefine.Action> Actions;
         List<entity.workflowDefine.TrasferCondition> Transfers;
 
+        [Parameter]
+        public string WorkflowId { get; set; }
         
         [Inject] protected MessageService _msgService { get; set; }
 
-        protected override void OnInitialized()
+        [Inject] protected WorkflowService _wfService { get; set; }
+
+        async Task InitData()
         {
-            base.OnInitialized();
+            int Id = int.Parse(WorkflowId.ToString());
+            workflow = await _wfService.GetWorkflow(Id);
+            Steps = await _wfService.GetSteps(Id);
+            Actions = await _wfService.GetActions(Id);
+            Transfers = await _wfService.GetTransfers(Id);
+        }
+        
+        protected async override Task OnInitializedAsync()
+        {
+            await base.OnInitializedAsync();
 
             #region Demo流程数据
-            workflow = new entity.workflowDefine.Workflow();
-            workflow.Name = "专案绩效流程";
-            workflow.Id = 1;
-            workflow.EndStepId = -1;
-
-            workflow.InitAction = new entity.workflowDefine.Action();
-            workflow.InitAction.Name = "填写请假条";
-
-            Steps = new List<entity.workflowDefine.Step>();
-            var step1 = new entity.workflowDefine.Step();
-            step1.Name = "部门主管申核";
-            step1.Id = 1;
-            Steps.Add(step1);
-
-            var step2 = new entity.workflowDefine.Step();
-            step2.Name = "老板申核";
-            step2.Id = 2;
-            Steps.Add(step2);
-
-            var step3 = new entity.workflowDefine.Step();
-            step3.Name = "申核结果通知";
-            step3.Id = 3;
-            Steps.Add(step3);
+            await InitData();
+
+            //在此处添加获取流程数据栏位
+
+
+            //workflow = new entity.workflowDefine.Workflow();
+            //workflow.Name = "请假流程";
+            //workflow.InitAction = new entity.workflowDefine.Action();
+            //workflow.InitAction.Name = "填写请假条";
+
+            //Steps = new List<entity.workflowDefine.Step>();
+            //var step1 = new entity.workflowDefine.Step();
+            //step1.Name = "部门主管申核";
+            //step1.Id = 1;
+            //Steps.Add(step1);
+
+            //var step2 = new entity.workflowDefine.Step();
+            //step2.Name = "总经理申核";
+            //step2.Id = 2;
+            //Steps.Add(step2);
+
+            //var step3 = new entity.workflowDefine.Step();
+            //step3.Name = "申核结果通知";
+            //step3.Id = 3;
+            //Steps.Add(step3);
 
             //var step4 = new entity.workflowDefine.Step();
             //step4.Name = "新步骤";
@@ -59,28 +75,28 @@ namespace wispro.sp.web.Pages.Workflow
             //Steps.Add(step5);
 
 
-            workflow.EndStepId = 3;
+            //workflow.EndStepId = 3;
 
-            Transfers = new List<entity.workflowDefine.TrasferCondition>();
-            var t = new entity.workflowDefine.TrasferCondition();
-            t.StepId = null;
-            t.nextStepId = 1;
-            Transfers.Add(t);
+            //Transfers = new List<entity.workflowDefine.TrasferCondition>();
+            //var t = new entity.workflowDefine.TrasferCondition();
+            //t.StepId = null;
+            //t.nextStepId = 1;
+            //Transfers.Add(t);
 
-            var t1 = new entity.workflowDefine.TrasferCondition();
-            t1.StepId = 1;
-            t1.nextStepId = 2;
-            Transfers.Add(t1);
+            //var t1 = new entity.workflowDefine.TrasferCondition();
+            //t1.StepId = 1;
+            //t1.nextStepId = 2;
+            //Transfers.Add(t1);
 
-            var t2 = new entity.workflowDefine.TrasferCondition();
-            t2.StepId = 1;
-            t2.nextStepId = 3;
-            Transfers.Add(t2);
+            //var t2 = new entity.workflowDefine.TrasferCondition();
+            //t2.StepId = 1;
+            //t2.nextStepId = 3;
+            //Transfers.Add(t2);
 
-            var t3 = new entity.workflowDefine.TrasferCondition();
-            t3.StepId = 2;
-            t3.nextStepId = 3;
-            Transfers.Add(t3);
+            //var t3 = new entity.workflowDefine.TrasferCondition();
+            //t3.StepId = 2;
+            //t3.nextStepId = 3;
+            //Transfers.Add(t3);
             #endregion
         }
 

+ 56 - 0
wispro.sp.web/Services/WorkflowService.cs

@@ -3,11 +3,19 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using wispro.sp.entity.workflowDefine;
+using wispro.sp.share;
 
 namespace wispro.sp.web.Services
 {
     public class WorkflowService
     {
+        private readonly IHttpService _httpClient;
+
+        public WorkflowService(IHttpService http)
+        {
+            _httpClient = http;
+        }
+
         private List<BindObjectType> bindObjectTypes = new List<BindObjectType>()
         {
             new BindObjectType(){ Name ="绩效记录",ObjectTypeFullName = typeof(wispro.sp.entity.PerformanceItem).FullName},
@@ -32,5 +40,53 @@ namespace wispro.sp.web.Services
                 return "";
             }
         }
+
+        List<entity.workflowDefine.Workflow> Workflows = new List<Workflow>();
+        Dictionary<int, List<entity.workflowDefine.InputValueSetting>> InitInputValues = new Dictionary<int, List<InputValueSetting>>();
+        public async Task<ApiSaveResponse> AddWorkflow(entity.workflowDefine.Workflow wf,entity.workflowDefine.Action InitAction)
+        {
+            share.NewWorkflowObject newWorkflow = new share.NewWorkflowObject();
+            newWorkflow.Workflow = wf;
+            newWorkflow.InitAction = InitAction;
+
+            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(newWorkflow));
+
+            var ret = await _httpClient.Post<ApiSaveResponse>("WorkflowEngine/AddNew", newWorkflow);
+
+            return ret;
+            
+        }
+
+        public async Task<List<Workflow>> getAllWorkflows()
+        {
+            var retList = await _httpClient.Get<List<Workflow>>($"WorkflowEngine/GetAllWorkflows");
+            return retList;
+        }
+
+        public async  Task<Workflow> GetWorkflow(int Id)
+        {
+            Workflow ret = await _httpClient.Get<Workflow>($"WorkflowEngine/GetWorkflow?workflowId={Id}");
+
+            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(ret));
+            return ret;
+        }
+
+        public async  Task<List<entity.workflowDefine.Step>> GetSteps(int Id)
+        {
+            var ret = await _httpClient.Get<List<entity.workflowDefine.Step>>($"WorkflowEngine/GetSteps?workflowId={Id}");
+            return ret;
+        }
+        
+        public async Task<List<entity.workflowDefine.Action>> GetActions(int workflowId)
+        {
+            var ret = await _httpClient.Get<List<entity.workflowDefine.Action>>($"WorkflowEngine/GetActions?workflowId={workflowId}");
+            return ret;
+        }
+
+        public async Task<List<entity.workflowDefine.TrasferCondition>> GetTransfers(int workflowId)
+        {
+            var ret = await _httpClient.Get<List<entity.workflowDefine.TrasferCondition>>($"WorkflowEngine/GetTrasfers?workflowId={workflowId}");
+            return ret;
+        }
     }
 }

+ 7 - 4
wospro.sp.entity/workflowDefine/Action.cs

@@ -31,16 +31,19 @@ namespace wispro.sp.entity.workflowDefine
         /// <summary>
         /// 所属步骤Id
         /// </summary>
-        public int StepId { get; set; }
+        public int? StepId { get; set; }
 
-        public Step step { get; set; }
+        public virtual Step step { get; set; }
 
         /// <summary>
         /// 完成操作时调用的对象类型
         /// </summary>
         public String OnActionObjectType { get; set; }
 
-
-
+        ///// <summary>
+        ///// 自动执行
+        ///// </summary>
+        //public bool Auto { get; set; }
+        
     }
 }

+ 3 - 2
wospro.sp.entity/workflowDefine/trasferCondition.cs

@@ -16,7 +16,7 @@ namespace wispro.sp.entity.workflowDefine
         /// <summary>
         /// 所属步骤
         /// </summary>
-        public Step Step { get; set; }
+        public virtual Step Step { get; set; }
 
         /// <summary>
         /// 所属步骤Id
@@ -32,11 +32,12 @@ namespace wispro.sp.entity.workflowDefine
         /// <summary>
         /// 下一步骤
         /// </summary>
-        public Step nextStep { get; set; }
+        public virtual Step nextStep { get; set; }
 
         /// <summary>
         /// 下一步骤Id
         /// </summary>
         public int nextStepId { get; set; }
+        
     }
 }