瀏覽代碼

添加流程图保存为图片功能
修正流程详情界面

luocaiyang 3 年之前
父節點
當前提交
c98bb4f1ff

+ 1 - 1
wispro.sp.api/Controllers/SceduleController.cs

@@ -22,7 +22,7 @@ namespace wispro.sp.api.Controllers
                 .Build();
 
 
-            QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
+            _ = QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
         }
     }
 }

+ 250 - 68
wispro.sp.api/Controllers/WorkflowEngineController.cs

@@ -1,13 +1,18 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.EntityFrameworkCore;
 using System;
 using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using wispro.sp.entity;
 using wispro.sp.entity.workflowInstance;
 using wispro.sp.share;
+using wispro.sp.share.Utility;
 
 namespace wispro.sp.api.Controllers
 {
@@ -47,15 +52,33 @@ namespace wispro.sp.api.Controllers
                 {
                     if (workflowObject.InitAction != null)
                     {
-                        Context.Actions.Add(workflowObject.InitAction);
+                        Context.Actions.Add(workflowObject.InitAction.Action);
                         Context.SaveChanges();
+
+                        foreach(var iv in workflowObject.InitAction.InputValueSettingObjects)
+                        {
+                            iv.InputValueSetting.actionId = workflowObject.InitAction.Action.Id;
+                            Context.InputValueSettings.Add(iv.InputValueSetting);
+                            Context.SaveChanges();
+
+                            if(iv.Children != null)
+                            {
+                                foreach(var childIV in iv.Children)
+                                {
+                                    childIV.actionId = workflowObject.InitAction.Action.Id;
+                                    childIV.ParentSettingId = iv.InputValueSetting.Id;
+                                    Context.InputValueSettings.Add(childIV);
+                                }
+                                Context.SaveChanges();
+                            }
+                        }
                     }
                     else
                     {
                         throw new ApplicationException("没有设定初始化Action!");
                     }
 
-                    workflowObject.Workflow.InitActionId  = workflowObject.InitAction.Id;
+                    workflowObject.Workflow.InitActionId  = workflowObject.InitAction.Action.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);
@@ -189,61 +212,47 @@ namespace wispro.sp.api.Controllers
                         Context.Steps.Add(step);
                         Context.SaveChanges();
 
-                        if (stepObj.actions != null)
+                        if(stepObj.NewActions != null)
                         {
-                            foreach (var ac in stepObj.actions)
+                            foreach(var ac in stepObj.NewActions)
                             {
-                                var temAc = Context.Actions.FirstOrDefault(a => a.Id == ac.Id);
-
-                                if (temAc == null)
-                                {
-                                    ac.StepId = step.Id;
-                                    Context.Actions.Add(ac);
-                                    Context.SaveChanges();
-                                }
-                                else
-                                {
-                                    temAc.Name = ac.Name;
-                                    temAc.InputForm = ac.InputForm;
-                                    temAc.OnActionObjectType = ac.OnActionObjectType;
-                                    temAc.StepId = ac.StepId;
-                                    Context.SaveChanges();
-                                }
+                                ac.Action.StepId = step.Id;
+                                Context.Actions.Add(ac.Action);
+                                Context.SaveChanges();
 
-                                if (ac.inputValuesSettings != null)
+                                if(ac.NewInputValueSettingObjects!= null)
                                 {
-                                    foreach (var iv in ac.inputValuesSettings)
+                                    foreach(var iv in ac.NewInputValueSettingObjects)
                                     {
-                                        var temIV = Context.InputValueSettings.FirstOrDefault(p => p.Id == iv.Id);
-                                        if (temIV == null)
-                                        {
-                                            iv.actionId = temAc.Id;
-                                            Context.InputValueSettings.Add(iv);
-                                            Context.SaveChanges();
-                                        }
-                                        else
+                                        iv.InputValueSetting.actionId = ac.Action.Id;
+                                        Context.InputValueSettings.Add(iv.InputValueSetting);
+
+                                        Context.SaveChanges();
+
+                                        if(iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
                                         {
-                                            temIV.actionId = temAc.Id;
-                                            temIV.bindField = iv.bindField;
-                                            temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
-                                            temIV.DisplayName = iv.DisplayName;
-                                            temIV.Options = iv.Options;
-                                            temIV.ParentSettingId = iv.ParentSettingId;
-                                            temIV.valueType = iv.valueType;
-                                            Context.SaveChanges();
+                                            if(iv.Children != null)
+                                            {
+                                                foreach(var cIV in iv.Children)
+                                                {
+                                                    cIV.ParentSettingId = iv.InputValueSetting.Id;
+                                                    Context.InputValueSettings.Add(cIV);
+                                                }
+
+                                                Context.SaveChanges();
+                                            }
                                         }
                                     }
                                 }
                             }
                         }
-                        
                     }
                     else
                     {
                         var temStep = Context.Steps.FirstOrDefault(a => a.Id == step.Id);
                         if (temStep != null)
                         {
-                            if(temStep.workflowId != step.workflowId)
+                            if (temStep.workflowId != step.workflowId)
                             {
                                 throw new ApplicationException("修改步骤时,不能修改步骤所属流程!");
                             }
@@ -251,53 +260,112 @@ namespace wispro.sp.api.Controllers
                             temStep.Name = step.Name;
                             temStep.stepType = step.stepType;
                             temStep.defaultResponseSetting = step.defaultResponseSetting;
+                            
+                            Context.SaveChanges();
 
-                            foreach (var ac in stepObj.actions)
+                            if (stepObj.NewActions != null)
                             {
-                                var temAc = Context.Actions.FirstOrDefault(a => a.Id == ac.Id);
-
-                                if (temAc == null)
+                                foreach (var ac in stepObj.NewActions)
                                 {
-                                    ac.StepId = step.Id;
-                                    Context.Actions.Add(ac);
+                                    ac.Action.StepId = temStep.Id;
+                                    Context.Actions.Add(ac.Action);
                                     Context.SaveChanges();
-                                }
-                                else
-                                {
-                                    temAc.Name = ac.Name;
-                                    temAc.InputForm = ac.InputForm;
-                                    temAc.OnActionObjectType = ac.OnActionObjectType;
-                                    temAc.StepId = ac.StepId;
+
+                                    if (ac.NewInputValueSettingObjects != null)
+                                    {
+                                        foreach (var iv in ac.NewInputValueSettingObjects)
+                                        {
+                                            iv.InputValueSetting.actionId = ac.Action.Id;
+                                            Context.InputValueSettings.Add(iv.InputValueSetting);
+                                            Context.SaveChanges();
+
+                                            if (iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
+                                            {
+                                                if (iv.Children != null)
+                                                {
+                                                    foreach (var cIV in iv.Children)
+                                                    {
+                                                        cIV.ParentSettingId = iv.InputValueSetting.Id;
+                                                        Context.InputValueSettings.Add(cIV);
+                                                    }
+
+                                                    Context.SaveChanges();
+                                                }
+                                            }
+                                        }
+                                    }
+
                                     Context.SaveChanges();
                                 }
+                            }
 
-                                if (ac.inputValuesSettings != null)
+                            if(stepObj.ModifyActions != null)
+                            {
+                                foreach(var ac in stepObj.ModifyActions)
                                 {
-                                    foreach (var iv in ac.inputValuesSettings)
+
+                                    var temAction = Context.Actions.FirstOrDefault(a=>a.Id == ac.Action.Id);
+
+                                    if(temAction != null)
                                     {
-                                        var temIV = Context.InputValueSettings.FirstOrDefault(p => p.Id == iv.Id);
-                                        if (temIV == null)
+                                        temAction.Name = ac.Action.Name;
+                                        temAction.InputForm = ac.Action.InputForm;
+                                        //temAction.inputValuesSettings = ac.Action.inputValuesSettings;
+                                        temAction.OnActionObjectType = ac.Action.OnActionObjectType;
+                                        Context.SaveChanges();
+
+                                        if(ac.NewInputValueSettingObjects != null)
                                         {
-                                            iv.actionId = temAc.Id;
-                                            Context.InputValueSettings.Add(iv);
+                                            foreach (var iv in ac.NewInputValueSettingObjects)
+                                            {
+                                                iv.InputValueSetting.actionId = ac.Action.Id;
+                                                Context.InputValueSettings.Add(iv.InputValueSetting);
+
+                                                Context.SaveChanges();
+
+                                                if (iv.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
+                                                {
+                                                    if (iv.Children != null)
+                                                    {
+                                                        foreach (var cIV in iv.Children)
+                                                        {
+                                                            cIV.ParentSettingId = iv.InputValueSetting.Id;
+                                                            Context.InputValueSettings.Add(cIV);
+                                                        }
+
+                                                        Context.SaveChanges();
+                                                    }
+                                                }
+                                            }
                                             Context.SaveChanges();
                                         }
-                                        else
+
+                                        if(ac.UpdateInputValueSettingObjects != null)
                                         {
-                                            temIV.actionId = temAc.Id;
-                                            temIV.bindField = iv.bindField;
-                                            temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
-                                            temIV.DisplayName = iv.DisplayName;
-                                            temIV.Options = iv.Options;
-                                            temIV.ParentSettingId = iv.ParentSettingId;
-                                            temIV.valueType = iv.valueType;
+                                            foreach (var iv in ac.UpdateInputValueSettingObjects)
+                                            {
+                                                var temIvObj = Context.InputValueSettings.FirstOrDefault(s=>s.Id == iv.InputValueSetting.Id);
+
+                                                if(temIvObj != null)
+                                                {
+                                                    temIvObj.actionId = iv.InputValueSetting.actionId;
+                                                    temIvObj.bindField = iv.InputValueSetting.bindField;
+                                                    temIvObj.bindFieldSavetoObjectCondition = iv.InputValueSetting.bindFieldSavetoObjectCondition;
+                                                    temIvObj.DisplayName = iv.InputValueSetting.DisplayName;
+                                                    temIvObj.Options = iv.InputValueSetting.Options;
+
+                                                    Context.SaveChanges();
+                                                }
+                                                
+                                            }
                                             Context.SaveChanges();
                                         }
                                     }
+                                    
                                 }
                             }
 
-                            
+
                         }
                         else
                         {
@@ -355,6 +423,7 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
+        
         public ApiSaveResponse DeleteTransfer(int Id)
         {
             ApiSaveResponse ret = new ApiSaveResponse();
@@ -379,6 +448,30 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
+        public ApiSaveResponse DeleteInputValueSetting(int Id)
+        {
+            ApiSaveResponse ret = new ApiSaveResponse();
+            ret.Success = true;
+
+            using (var t = Context.Database.BeginTransaction())
+            {
+                try
+                {
+                    Context.InputValueSettings.Remove(new entity.workflowDefine.InputValueSetting() { Id = Id });
+                    Context.SaveChanges();
+                    t.Commit();
+                }
+                catch (Exception ex)
+                {
+                    t.Rollback();
+                    ret.Success = false;
+                    ret.ErrorMessage = ex.Message;
+                }
+            }
+
+            return ret;
+        }
+
         public ApiSaveResponse DeleteStep(int Id)
         {
             ApiSaveResponse ret = new ApiSaveResponse();
@@ -450,10 +543,25 @@ namespace wispro.sp.api.Controllers
             {
                 try
                 {
+                    var temInputValueSettings = action.inputValuesSettings;
+                    action.inputValuesSettings = null;
 
                     if (action.Id == 0)
                     {
                         Context.Actions.Add(action);
+                        Context.SaveChanges();
+
+                        if (temInputValueSettings != null)
+                        {
+                            foreach (var iv in temInputValueSettings)
+                            {
+                                iv.actionId = action.Id;
+
+                                Context.InputValueSettings.Add(iv);
+                            }
+
+                            Context.SaveChanges();
+                        }
                     }
                     else
                     {
@@ -465,6 +573,34 @@ namespace wispro.sp.api.Controllers
                             temAtion.StepId = action.StepId;
                             temAtion.inputValuesSettings = action.inputValuesSettings;
                             temAtion.OnActionObjectType = action.OnActionObjectType;
+
+                            if(temInputValueSettings != null)
+                            {
+                                foreach (var iv in temInputValueSettings)
+                                {
+                                    var temIV = Context.InputValueSettings.FirstOrDefault(p=>p.Id == iv.Id);
+
+                                    if(temIV != null)
+                                    {
+                                        temIV.actionId = iv.actionId;
+                                        temIV.bindField = iv.bindField;
+                                        temIV.bindFieldSavetoObjectCondition = iv.bindFieldSavetoObjectCondition;
+                                        temIV.DisplayName = iv.DisplayName;
+                                        temIV.Options = iv.Options;
+                                        temIV.ParentSettingId = iv.ParentSettingId;
+                                    }
+                                    else
+                                    {
+                                        iv.actionId = action.Id;
+                                        Context.InputValueSettings.Add(iv);
+                                    }
+                                    
+
+                                    
+                                }
+
+                                Context.SaveChanges();
+                            }
                         }
                         else
                         {
@@ -564,5 +700,51 @@ namespace wispro.sp.api.Controllers
             return retList;
         }
 
+        [HttpGet, DisableRequestSizeLimit]
+        public async Task<IActionResult> ExportToImage(int workflowId)
+        {
+            var workflow = GetWorkflow(workflowId);
+            var Steps = GetSteps(workflowId);
+            var Actions = GetActions(workflowId);
+            var Transfers = GetTrasfers(workflowId);
+
+            FlowChartUtility flowChart = new FlowChartUtility();
+            flowChart.workflow = workflow;
+            flowChart.Steps = Steps;
+            flowChart.Transfers = Transfers;
+
+            string strSvg = flowChart.GetSvgString();
+
+            System.Xml.XmlDocument xmdoc = new System.Xml.XmlDocument();
+            xmdoc.LoadXml(strSvg);
+            Svg.SvgDocument svg = Svg.SvgDocument.Open(xmdoc);
+            Bitmap bitmap = svg.Draw();
+            MemoryStream mStream = new MemoryStream();
+            bitmap.Save(mStream, ImageFormat.Jpeg);
+            
+            var filename = $"{workflow.Name}.jpg";
+            mStream.Position = 0;
+            return File(mStream, GetContentType(filename), filename);
+
+            
+        }
+
+        private string GetContentType(string path)
+        {
+            var provider = new FileExtensionContentTypeProvider();
+            string contentType;
+
+            if (!provider.TryGetContentType(path, out contentType))
+            {
+                contentType = "application/octet-stream";
+            }
+
+            return contentType;
+        }
+
+        public entity.workflowDefine.InputValueSetting  getInputValueSteeingById(int Id)
+        {
+            return Context.InputValueSettings.FirstOrDefault(s=>s.Id == Id);
+        }
     }
 }

+ 2 - 2
wispro.sp.api/Program.cs

@@ -50,7 +50,7 @@ namespace wispro.sp.api
                 .Build();
 
 
-            QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
+            _ = QuartzUtil.Add(typeof(ImportReportJob), jobKey, trigger);
             #endregion
 
             #region ÿÌì¸üм¨Ð§Êý¾Ý
@@ -61,7 +61,7 @@ namespace wispro.sp.api
                 .Build();
 
 
-            QuartzUtil.Add(typeof(UpdateJXDataFromIPEasyJob), jobKey1, trigger1);
+            _ = QuartzUtil.Add(typeof(UpdateJXDataFromIPEasyJob), jobKey1, trigger1);
             #endregion
 
 

+ 1 - 0
wispro.sp.api/wispro.sp.api.csproj

@@ -17,6 +17,7 @@
     <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
     <PackageReference Include="Quartz" Version="3.3.3" />
+    <PackageReference Include="Svg" Version="3.3.0" />
   </ItemGroup>
 
   <ItemGroup>

+ 19 - 0
wispro.sp.share/ActionObject.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.share
+{
+    public class ActionObject
+    {
+        public entity.workflowDefine.Action Action { get; set; }
+
+        public List<InputValueSettingObject> InputValueSettingObjects { get; set; }
+
+        public List<InputValueSettingObject> UpdateInputValueSettingObjects { get; set; }
+
+        public List<InputValueSettingObject> NewInputValueSettingObjects { get; set; }
+    }
+}

+ 15 - 0
wispro.sp.share/InputValueSettingObject.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace wispro.sp.share
+{
+    public class InputValueSettingObject
+    {
+        public entity.workflowDefine.InputValueSetting InputValueSetting { get; set; }
+
+        public List<entity.workflowDefine.InputValueSetting> Children{ get; set; }
+    }
+}

+ 5 - 1
wispro.sp.share/NewStepObject.cs

@@ -12,6 +12,10 @@ namespace wispro.sp.share
 
         public bool isLastStep { get; set; }
 
-        public List<entity.workflowDefine.Action> actions { get; set; }
+        public List<ActionObject> actions { get; set; }
+
+        public List<ActionObject> ModifyActions { get; set; }
+
+        public List<ActionObject> NewActions { get; set; }
     }
 }

+ 1 - 1
wispro.sp.share/NewWorkflowObject.cs

@@ -11,7 +11,7 @@ namespace wispro.sp.share
     {
         public Workflow Workflow { get; set; }
 
-        public entity.workflowDefine.Action InitAction { get; set; }
+        public ActionObject InitAction { get; set; }
 
     }
 }

+ 19 - 10
wispro.sp.share/Utility/FlowChartUtility.cs

@@ -244,6 +244,7 @@ namespace wispro.sp.share.Utility
                 endNode.Parents.Add(InitShape);
                 endNode.InCount += 1;
                 endNode.Level = InitShape.Level + 1;
+                shapeTrees.Remove(endNode);
                 //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(endNode));
 
             }
@@ -664,13 +665,13 @@ namespace wispro.sp.share.Utility
         public string GetSvgString()
         {
             initShapeTree();
-            string strReturn = $"<svg width =\"{ChartWidth}\" height = \"{ChartHeight}\" id = \"FlowChartContainer\" xmlns=\"http://www.w3.org/2000/svg\"  version=\"1.1\">";
+            string strReturn = $"<svg width =\"{ChartWidth}\" height = \"{ChartHeight}\" id = \"FlowChartContainer\" xmlns=\"http://www.w3.org/2000/svg\"  version=\"1.2\">";
             strReturn = strReturn +
                 "<defs>\r\n" +
                     "\t<marker id =\"idArrow\" viewBox=\"0 0 20 20\" refX = \"0\" refY = \"10\" markerUnits = \"strokeWidth\" markerWidth = \"5\" markerHeight = \"10\" orient=\"auto\">\r\n" +
                         "\t\t<path d =\"M 0 0 L 20 10 L 0 20 z\" fill=\"black\" stroke = \"black\" />\r\n" +
-                    "</marker>" +
-                "</defs>";
+                    "</marker>\r\n" +
+                "</defs>\r\n";
 
             if (shapeTrees != null)
             {
@@ -736,17 +737,25 @@ namespace wispro.sp.share.Utility
                     }
                 }
 
-                foreach (var t in Transfers)
+                if (Transfers.Count > 0)
                 {
-                    dynamic ret = GetLineParater(t);
+                    foreach (var t in Transfers)
+                    {
+                        dynamic ret = GetLineParater(t);
 
-                    strReturn += $"<line x1 =\"{ret.x1}\" y1=\"{ret.y1}\" x2=\"{ret.x2}\" y2=\"{ret.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
-                    strReturn += $"<circle cx =\"{((ret.x1 + ret.x2) / 2)}\" cy=\"{((ret.y1 + ret.y2) / 2)}\" r=\"7\" stroke=\"black\" stroke-width=\"1.5\" fill=\"white\"/>\r\n";
-                    strReturn += $"<a ondblclick =\"() => DoubleClickTrasfer(t)\" onclick=\"()=>ClickTrasfer(t)\">\r\n";
-                    strReturn += $"<text x =\"{((ret.x1 + ret.x2) / 2)}\" y=\"{((ret.y1 + ret.y2) / 2)}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"12\">c</text>\r\n";
-                    strReturn += "</a>";
+                        strReturn += $"<line x1 =\"{ret.x1}\" y1=\"{ret.y1}\" x2=\"{ret.x2}\" y2=\"{ret.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
+                        strReturn += $"<circle cx =\"{((ret.x1 + ret.x2) / 2)}\" cy=\"{((ret.y1 + ret.y2) / 2)}\" r=\"7\" stroke=\"black\" stroke-width=\"1.5\" fill=\"white\"/>\r\n";
+                        strReturn += $"<a ondblclick =\"() => DoubleClickTrasfer(t)\" onclick=\"()=>ClickTrasfer(t)\">\r\n";
+                        strReturn += $"<text x =\"{((ret.x1 + ret.x2) / 2)}\" y=\"{((ret.y1 + ret.y2) / 2)}\" fill=\"black\" alignment-baseline=\"middle\" text-anchor=\"middle\" font-size=\"12\">c</text>\r\n";
+                        strReturn += "</a>\r\n";
+                    }
                 }
+                else
+                {
+                    dynamic ret = GetEndStepLine();
+                    strReturn += $"<line x1 =\"{ret.x1}\" y1=\"{ret.y1}\" x2=\"{ret.x2}\" y2=\"{ret.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
 
+                }
                 //dynamic endLine = GetEndStepLine();
                 //strReturn += $"<line x1 =\"{endLine.x1}\" y1=\"{endLine.y1}\" x2=\"{endLine.x2}\" y2=\"{endLine.y2}\" stroke=\"black\" stroke-width=\"2\" marker-end=\"url(#idArrow)\"/>\r\n";
             }

+ 26 - 3
wispro.sp.web/Components/FlowChart.razor

@@ -78,21 +78,44 @@
         }
     }
 
+    
     @foreach (var t in Transfers)
     {
         dynamic ret = flowChartUtility.GetLineParater(t);
         <line x1="@ret.x1" y1="@ret.y1" x2="@ret.x2" y2="@ret.y2" stroke="black" stroke-width="2" marker-end="url(#idArrow)" />
 
         <circle cx="@((ret.x1 + ret.x2) / 2)" cy="@((ret.y1 + ret.y2) / 2)" r="7" stroke="black" stroke-width="1.5" fill="white" />
-        <a @ondblclick="() => DoubleClickTrasfer(t)" @onclick ="()=>ClickTrasfer(t)">
+        <a @ondblclick="() => DoubleClickTrasfer(t)" @onclick="()=>ClickTrasfer(t)">
             <text x="@((ret.x1 + ret.x2) / 2)" y="@((ret.y1 + ret.y2) / 2)" fill="black" alignment-baseline="middle" text-anchor="middle" font-size="12">c</text>
         </a>
 
+        if (SelectedObject != null && (SelectedObject is entity.workflowDefine.TrasferCondition))
+        {
+            if (SelectedObject.Id == t.Id)
+            {
+                var cX = (ret.x1 + ret.x2) / 2;
+                var cY = (ret.y1 + ret.y2) / 2;
+                var x1 = (cX + ret.x1) / 2;
+                var y1 = (cY + ret.y1) / 2;
+                var x2 = (cX + ret.x2) / 2;
+                var y2 = (cY + ret.y2) / 2;
+                <circle cx="@x1" cy="@y1" r="2" stroke="black" stroke-width="1" fill="white" />
+                <circle cx="@x2" cy="@y2" r="2" stroke="black" stroke-width="1" fill="white" />
+            }
+        }
+
     }
 
+    @if (Transfers.Count ==0)
+    {
+        dynamic endLine = flowChartUtility.GetEndStepLine();
+        <line x1="@endLine.x1" y1="@endLine.y1" x2="@endLine.x2" y2="@endLine.y2" stroke="black" stroke-width="2" marker-end="url(#idArrow)" />
+
+    }
+
+
+
 
-   
-    
 </svg>
     }
     else

+ 54 - 56
wispro.sp.web/Components/InputValueSetting.razor

@@ -3,10 +3,9 @@
         <Button Type="@ButtonType.Primary" OnClick="() => AddNew(null)">添加</Button>
     </Extra>
     <Body>
-        <AntDesign.Table @ref="table"
-                         TItem="wispro.sp.entity.workflowDefine.InputValueSetting"
-                         DataSource="@GetChildItem(null)"
-                         Total="@GetChildItem(null).Count()"
+        <AntDesign.Table 
+                         TItem="share.InputValueSettingObject"
+                         DataSource="@EditAction.InputValueSettingObjects"
                          Bordered=@true
                          Size=@TableSize.Middle
                          HidePagination
@@ -14,21 +13,21 @@
             <RowTemplate>
 
                 <AntDesign.Column Title="栏位名称" TData="string">
-                    @if (context == EditObj)
+                    @if (context.InputValueSetting == EditObj)
                     {
-                        <Input @bind-Value="context.DisplayName" />
+                        <Input @bind-Value="context.InputValueSetting.DisplayName" />
 
                     }
                     else
                     {
-                        @context.DisplayName
+                        @context.InputValueSetting.DisplayName
                     }
                 </AntDesign.Column>
                 <AntDesign.Column Title="栏位类型" TData="string">
-                    @if (context == EditObj)
+                    @if (context.InputValueSetting == EditObj)
                     {
                         <Select DataSource="@FieldTypes"
-                                @bind-Value="@context.valueType"
+                                @bind-Value="@context.InputValueSetting.valueType"
                                 LabelName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>.Description)"
                                 ValueName="@nameof(wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>.Value)"
                                 Placeholder="请选项一项"
@@ -40,75 +39,74 @@
                     }
                     else
                     {
-                        <span>@wispro.sp.entity.EnumHelper.GetDescription(context.valueType)</span>
+                        <span>@wispro.sp.entity.EnumHelper.GetDescription(context.InputValueSetting.valueType)</span>
                     }
                 </AntDesign.Column>
                 <AntDesign.Column Title="可选值" TData="string">
-                    @if (context == EditObj)
+                    @if (context.InputValueSetting == EditObj)
                     {
-                        <Input @bind-Value="context.Options" />
+                        <Input @bind-Value="context.InputValueSetting.Options" />
                     }
                     else
                     {
-                        @context.Options
+                        @context.InputValueSetting.Options
                     }
                 </AntDesign.Column>
-                <AntDesign.Column Title="绑定栏位" @bind-Field="@context.bindField">
-                    @if (context == EditObj)
+                <AntDesign.Column Title="绑定栏位" TData="string">
+                    @if (context.InputValueSetting == EditObj)
                     {
-                        <Input @bind-Value="context.bindField" />
+                        <Input @bind-Value="context.InputValueSetting.bindField" />
                     }
                     else
                     {
-                        @context.bindField
+                        @context.InputValueSetting.bindField
                     }
                 </AntDesign.Column>
                 <ActionColumn Style="float:right">
-                    @if (context == EditObj)
-                    {
-                        <Space>
-                            <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => Save(context)">保存</Button></SpaceItem>
-                        </Space>
-                        <Space>
-                            <Popconfirm Title="确定要忽略当前修改?"
-                                        OnConfirm="() => OnCancel(context)"
-                                        OkText="Yes"
-                                        CancelText="No">
-                                <a>取消</a>
-                            </Popconfirm>
-                        </Space>
-                    }
-                    else
-                    {
-                        <Space>
-                            <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => Edit(context)">编辑</Button></SpaceItem>
-                        </Space>
-                        <Space>
-                            <Popconfirm Title="确定要删除当前栏位?"
-                                        OnConfirm="() => Delete(context)"
-                                        OkText="Yes"
-                                        CancelText="No">
-                                <a>删除</a>
-                            </Popconfirm>
-                        </Space>
+            @if (context.InputValueSetting == EditObj)
+            {
+                <Space>
+                    <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => Save(context.InputValueSetting)">保存</Button></SpaceItem>
+                </Space>
+                <Space>
+                    <Popconfirm Title="确定要忽略当前修改?"
+                                OnConfirm="() => OnCancel(context.InputValueSetting)"
+                                OkText="Yes"
+                                CancelText="No">
+                        <a>取消</a>
+                    </Popconfirm>
+                </Space>
+            }
+            else
+            {
+                <Space>
+                    <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => Edit(context.InputValueSetting)">编辑</Button></SpaceItem>
+                </Space>
+                <Space>
+                    <Popconfirm Title="确定要删除当前栏位?"
+                                OnConfirm="() => Delete(context)"
+                                OkText="Yes"
+                                CancelText="No">
+                        <a>删除</a>
+                    </Popconfirm>
+                </Space>
 
-                        if (context.valueType == entity.workflowDefine.EnumFieldType.List)
-                        {
-                            <Space>
-                                <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => AddNew(context)">添加子栏位</Button></SpaceItem>
-                            </Space>
-                        }
-                    }
-                </ActionColumn>
+                if (context.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
+                {
+                    <Space>
+                        <SpaceItem><Button Type="@ButtonType.Text" OnClick="() => AddNew(context.InputValueSetting)">添加子栏位</Button></SpaceItem>
+                    </Space>
+                }
+            }
+        </ActionColumn>
             </RowTemplate>
             
             <ExpandTemplate  Context="rowData" >
-                @if (rowData.Data.valueType == entity.workflowDefine.EnumFieldType.List)
+                @if (rowData.Data.InputValueSetting.valueType == entity.workflowDefine.EnumFieldType.List)
                 {
-                <AntDesign.Table @ref="table"
+                <AntDesign.Table 
                                  TItem="wispro.sp.entity.workflowDefine.InputValueSetting"
                                  DataSource="@GetChildItem(rowData.Data)"
-                                 Total="@GetChildItem(null).Count()"
                                  Bordered=@true
                                  Size=@TableSize.Middle
                                  HidePagination>
@@ -152,7 +150,7 @@
                             @context.Options
                         }
                     </AntDesign.Column>
-                    <AntDesign.Column Title="绑定栏位" @bind-Field="@context.bindField">
+                    <AntDesign.Column Title="绑定栏位" TData="string">
                         @if (context == EditObj)
                         {
                             <Input @bind-Value="context.bindField" />

+ 260 - 8
wispro.sp.web/Components/InputValueSetting.razor.cs

@@ -13,21 +13,28 @@ namespace wispro.sp.web.Components
         List<wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.EnumFieldType>> FieldTypes
             = entity.EnumHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.EnumFieldType>();
 
-        ITable table;
+        
         entity.workflowDefine.InputValueSetting EditObj;
 
         [Parameter]
-        public List<entity.workflowDefine.InputValueSetting> DataSource { get; set; }
+        public share.ActionObject EditAction { get; set; }
+
 
         IDictionary<string, (bool edit, entity.workflowDefine.InputValueSetting data)> editCache = new Dictionary<string, (bool edit, entity.workflowDefine.InputValueSetting data)>();
 
-        private List<entity.workflowDefine.InputValueSetting> GetChildItem(entity.workflowDefine.InputValueSetting setting)
+        private List<entity.workflowDefine.InputValueSetting > GetChildItem(share.InputValueSettingObject setting)
         {
-            return DataSource.Where<entity.workflowDefine.InputValueSetting>(p => p.ParentSetting == setting).ToList();
+            if(setting.Children == null)
+            {
+                setting.Children = new List<entity.workflowDefine.InputValueSetting>();
+            }
+            return setting.Children;
+            //return DataSource.Where<entity.workflowDefine.InputValueSetting>(p => p.ParentSetting == setting).ToList();
         }
 
         void AddNew(entity.workflowDefine.InputValueSetting setting)
         {
+            Console.WriteLine("AddNew");
             var newObj = new entity.workflowDefine.InputValueSetting()
             {
                 valueType = entity.workflowDefine.EnumFieldType.Text,
@@ -37,14 +44,202 @@ namespace wispro.sp.web.Components
             };
             EditObj = newObj;
 
-            DataSource.Add(newObj);
+            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(EditObj));
+
+            if (setting != null)
+            {
+                foreach(var ss in EditAction.InputValueSettingObjects)
+                {
+                    if(ss.InputValueSetting == setting)
+                    {
+                        if(ss.Children == null)
+                        {
+                            ss.Children = new List<entity.workflowDefine.InputValueSetting>();
+                            ss.Children.Add(newObj);
+                            break;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                share.InputValueSettingObject newSettingobj = new share.InputValueSettingObject();
+                newSettingobj.InputValueSetting = EditObj;
+
+                EditAction.InputValueSettingObjects.Add(newSettingobj);
+
+                if (EditAction.NewInputValueSettingObjects == null)
+                {
+                    EditAction.NewInputValueSettingObjects = new List<share.InputValueSettingObject>();
+                }
+                EditAction.NewInputValueSettingObjects.Add(newSettingobj);
+            }
         }
 
         void Delete(entity.workflowDefine.InputValueSetting setting)
         {
+            Console.WriteLine($"begin Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
+
+            Console.WriteLine($"Delete Setting:{ System.Text.Json.JsonSerializer.Serialize(setting)}");
+
+            foreach (var temObj in EditAction.InputValueSettingObjects)
+            {
+                if (temObj.InputValueSetting.DisplayName  == setting.DisplayName )
+                {
+                    EditAction.InputValueSettingObjects.Remove(temObj);
+                }
+
+                bool isFound = false;
+                if (temObj.Children != null)
+                {
+                    foreach (var iv in temObj.Children)
+                    {
+                        if (iv.DisplayName  == setting.DisplayName)
+                        {
+                            temObj.Children.Remove(iv);
+                            isFound = true;
+                            break;
+                        }
+                    }
+                }
+
+                if (isFound)
+                {
+                    break;
+                }
+            }
+
+            if (EditAction.NewInputValueSettingObjects != null)
+            {
+                foreach (var temObj in EditAction.NewInputValueSettingObjects)
+                {
+                    if (temObj.InputValueSetting.DisplayName == setting.DisplayName)
+                    {
+                        EditAction.NewInputValueSettingObjects.Remove(temObj);
+                    }
+
+                    bool isFound = false;
+                    if (temObj.Children != null)
+                    {
+                        foreach (var iv in temObj.Children)
+                        {
+                            if (iv.DisplayName == setting.DisplayName)
+                            {
+                                temObj.Children.Remove(iv);
+                                isFound = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (isFound)
+                    {
+                        break;
+                    }
+                }
+            }
+
+            if (EditAction.UpdateInputValueSettingObjects != null)
+            {
+                foreach (var temObj in EditAction.UpdateInputValueSettingObjects)
+                {
+                    if (temObj.InputValueSetting.DisplayName == setting.DisplayName)
+                    {
+                        EditAction.UpdateInputValueSettingObjects.Remove(temObj);
+                    }
+
+                    bool isFound = false;
+                    if (temObj.Children != null)
+                    {
+                        foreach (var iv in temObj.Children)
+                        {
+                            if (iv.DisplayName == setting.DisplayName)
+                            {
+                                temObj.Children.Remove(iv);
+                                isFound = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (isFound)
+                    {
+                        break;
+                    }
+                }
+            }
+
+            Console.WriteLine($"End Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
+        }
+        async void Delete(share.InputValueSettingObject setting)
+        {
+
+            Console.WriteLine($"Begin Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
+
+            Console.WriteLine($"Delete Setting:{ System.Text.Json.JsonSerializer.Serialize(setting)}");
             //此处添加删除代码
+            if (EditAction.InputValueSettingObjects.Contains(setting))
+            {
+                EditAction.InputValueSettingObjects.Remove(setting);
+            }
+            else
+            {
+                foreach (var temObj in EditAction.InputValueSettingObjects)
+                {
+                    if (temObj.Children != null && temObj.Children.Contains ( setting.InputValueSetting))
+                    {
+                        temObj.Children.Remove(setting.InputValueSetting);
+                        break;
+                    }
+                }
+            }
+
+            if (EditAction.NewInputValueSettingObjects != null)
+            {
+                if (EditAction.NewInputValueSettingObjects.Contains(setting))
+                {
+                    EditAction.NewInputValueSettingObjects.Remove(setting);
+                }
+                else
+                {
+                    foreach (var temObj in EditAction.NewInputValueSettingObjects)
+                    {
+                        if (temObj.Children != null && temObj.Children.Contains(setting.InputValueSetting))
+                        {
+                            temObj.Children.Remove(setting.InputValueSetting);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            if (EditAction.UpdateInputValueSettingObjects != null)
+            {
+                if (EditAction.UpdateInputValueSettingObjects.Contains(setting))
+                {
+                    EditAction.UpdateInputValueSettingObjects.Remove(setting);
+                }
+                else
+                {
+                    foreach (var temObj in EditAction.UpdateInputValueSettingObjects)
+                    {
+                        if (temObj.Children != null && temObj.Children.Contains(setting.InputValueSetting))
+                        {
+                            temObj.Children.Remove(setting.InputValueSetting);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            if (setting.InputValueSetting.Id > 0)
+            {
+                //添加从数据库中删除代码;
+                await wfService.DeleteInputValueSetting(setting.InputValueSetting.Id);
+            }
+
+            Console.WriteLine($"End Delete:{ System.Text.Json.JsonSerializer.Serialize(EditAction)}");
 
-            DataSource.Remove(setting);
             StateHasChanged();
         }
 
@@ -55,16 +250,73 @@ namespace wispro.sp.web.Components
 
         void Save(entity.workflowDefine.InputValueSetting setting)
         {
-            //此处添加保存代码
+            
+            if (setting.Id > 0)
+            {
+                var temObj = EditAction.InputValueSettingObjects.FirstOrDefault(p => p.InputValueSetting.Id == setting.Id);
+
+                if (temObj != null)
+                {
+                    if (EditAction.UpdateInputValueSettingObjects == null)
+                    {
+                        EditAction.UpdateInputValueSettingObjects = new List<share.InputValueSettingObject>();
+                        
+                    }
+
+                    if (!EditAction.UpdateInputValueSettingObjects.Contains(temObj))
+                    {
+                        EditAction.UpdateInputValueSettingObjects.Add(temObj);
+                    }
+                }
+            }
 
             EditObj = null;
             StateHasChanged();
         }
 
-        void OnCancel(entity.workflowDefine.InputValueSetting setting)
+        async Task OnCancel(entity.workflowDefine.InputValueSetting setting)
         {
+            if(setting.Id == 0)
+            {
+                foreach(var temobj in EditAction.InputValueSettingObjects)
+                {
+                    if(temobj.InputValueSetting == setting)
+                    {
+                        EditAction.InputValueSettingObjects.Remove(temobj);
+                        break;
+                    }
+                }
+
+                foreach (var temobj in EditAction.NewInputValueSettingObjects )
+                {
+                    if (temobj.InputValueSetting == setting)
+                    {
+                        EditAction.NewInputValueSettingObjects.Remove(temobj);
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                foreach (var temobj in EditAction.UpdateInputValueSettingObjects)
+                {
+                    if (temobj.InputValueSetting == setting)
+                    {
+                        EditAction.UpdateInputValueSettingObjects.Remove(temobj);
+                        break;
+                    }
+                }
+
+                setting = await  wfService.getInputValueSteeingById(setting.Id);
+
+            }
 
             EditObj = null;
         }
+
+        [Inject]
+        Services.WorkflowService  wfService { get; set; }
     }
+
+    
 }

+ 11 - 3
wispro.sp.web/Components/ResponseManCondition.razor.cs

@@ -53,8 +53,8 @@ namespace wispro.sp.web.Components
                     var parentNode = FindNode(dept.parentId.Value.ToString(),retList);
                     var currentNode = FindNode(dept.Id.ToString(), retList);
 
-                    Console.WriteLine($"Find:{dept.parentId},return:{System.Text.Json.JsonSerializer.Serialize(parentNode)}");
-                    Console.WriteLine($"Find:{dept.Id},return:{System.Text.Json.JsonSerializer.Serialize(currentNode)}");
+                    //Console.WriteLine($"Find:{dept.parentId},return:{System.Text.Json.JsonSerializer.Serialize(parentNode)}");
+                    //Console.WriteLine($"Find:{dept.Id},return:{System.Text.Json.JsonSerializer.Serialize(currentNode)}");
 
                     if (parentNode != null)
                     {
@@ -84,7 +84,7 @@ namespace wispro.sp.web.Components
                 
                 if (node.Value == deptId)
                 {
-                    Console.WriteLine($"Founded:{System.Text.Json.JsonSerializer.Serialize(node)}");
+                    //Console.WriteLine($"Founded:{System.Text.Json.JsonSerializer.Serialize(node)}");
                     return node;
                 }
                 else
@@ -127,7 +127,15 @@ namespace wispro.sp.web.Components
             uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.UserDepartment });
             uctItems.Add(new UserConditionTpyeItem() { Type = UserConditionType.UserDepartmentPosition });
 
+            if (UserField != null)
+            {
+                if (!string.IsNullOrEmpty(UserField.Positon))
+                {
+                    SelectPositionsId = int.Parse(UserField.Positon);
+                }
 
+                
+            }
             await base.OnInitializedAsync();
         }
 

+ 1 - 1
wispro.sp.web/Pages/Organization/Department.razor.cs

@@ -188,7 +188,7 @@ namespace wispro.sp.web.Pages.Organization
             {
                 selectPosition = new Position();
             }
-            Console.WriteLine($"Edit:{JsonSerializer.Serialize(selectPosition)}");
+            //Console.WriteLine($"Edit:{JsonSerializer.Serialize(selectPosition)}");
             PositionId = selectPosition.Id;
             _isAdd = false;
             _newUserModal  = true;

+ 3 - 3
wispro.sp.web/Pages/Workflow/WorkflowDefine.razor

@@ -126,12 +126,12 @@
 
             <Divider />
             <FormItem Label="初始化操作名称">
-                <Input @bind-Value="@InitAction.Name" />
+                <Input @bind-Value="@InitAction.Action.Name" />
             </FormItem>
             <FormItem Label="初始化界面">
-                <Input @bind-Value="@InitAction.InputForm" />
+                <Input @bind-Value="@InitAction.Action.InputForm" />
             </FormItem>
-            <wispro.sp.web.Components.InputValueSetting DataSource="@InitAction.inputValuesSettings" />
+            <wispro.sp.web.Components.InputValueSetting EditAction="InitAction" />
         </Form>
 
     </Modal>

+ 7 - 4
wispro.sp.web/Pages/Workflow/WorkflowDefine.razor.cs

@@ -23,7 +23,7 @@ namespace wispro.sp.web.Pages.Workflow
         bool isAdd = false;
 
         entity.workflowDefine.Workflow EditingObj = null;
-        entity.workflowDefine.Action InitAction = null;
+        share.ActionObject InitAction = null;
         
 
         bool _visible = false;
@@ -51,8 +51,11 @@ namespace wispro.sp.web.Pages.Workflow
         {
             isAdd = true;
             EditingObj = new entity.workflowDefine.Workflow();
-            InitAction = new entity.workflowDefine.Action();
-            InitAction.inputValuesSettings  = new List<entity.workflowDefine.InputValueSetting>();
+            InitAction = new share.ActionObject();
+            InitAction.Action = new entity.workflowDefine.Action();
+            InitAction.InputValueSettingObjects = new List<share.InputValueSettingObject>();
+
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(InitAction));
             _visible = true;
         }
 
@@ -107,7 +110,7 @@ namespace wispro.sp.web.Pages.Workflow
             ["onclick"] = ((Action)delegate
             {
                 SelectedWorkflow = row.Data;
-                Console.WriteLine($"row {row.Data.Name} was clicked");
+                //Console.WriteLine($"row {row.Data.Name} was clicked");
             })
         };
 

+ 54 - 51
wispro.sp.web/Pages/Workflow/WorkflowDetail.razor

@@ -1,10 +1,11 @@
 @page "/Workflow/Detail/{WorkflowId:int}"
 
+
 <PageContainer>
     <Breadcrumb>
         <Breadcrumb>
             <BreadcrumbItem>
-                <a href="/Home"><Icon Type="home"></Icon></a>
+                <a href="/Home"><Icon Type="home"></Icon></a> 
             </BreadcrumbItem>
             <BreadcrumbItem>
                 <Icon Type="apartment" Theme="outline" /><span>流程管理</span>
@@ -12,34 +13,20 @@
         </Breadcrumb>
     </Breadcrumb>
     <Content>
-        <Space>
-            <SpaceItem>
-                <Button Type="primary" Icon="new" OnClick="AddNewStep">添加步骤</Button>
-            </SpaceItem>
-
-            <SpaceItem>
-                <Button Type="primary" Icon="new" OnClick="AddNewTransfer">添加步骤转移条件</Button>
-            </SpaceItem>
-            
-            <SpaceItem Style="float:right">
-                <Space>
-                    <SpaceItem>
-                        <Button Type="primary" Icon="refresh" OnClick="OnRefresh">刷新</Button>
-                    </SpaceItem>
-                    <SpaceItem>
-                        <Popconfirm Title="您确认删除选中的对象?"
-                                    OnConfirm="DeleteObject"
-                                    OkText="Yes"
-                                    CancelText="No">
-                            <a>删除</a>
-                        </Popconfirm>
-                        @*<Button Danger Icon="delete" OnClick="DeleteObject" disabled="@(chart.SelectedObject != null)">删除</Button>*@
-                    </SpaceItem>
-                </Space>
-                
-            </SpaceItem>
-        </Space>
-        
+        <Menu Mode=MenuMode.Horizontal>
+            <MenuItem OnClick="AddNewStep"><Icon Type="file-add" Theme="twotone" />添加步骤</MenuItem>
+            <MenuItem OnClick="AddNewTransfer"><Icon Type="line" Theme="outline" />添加步骤转移条件</MenuItem>
+            <MenuItem OnClick="OnRefresh"><Icon Type="layout" Theme="twotone" />自动布局</MenuItem>
+            <MenuItem>
+                <Popconfirm Title="您确认删除选中的对象?"
+                            OnConfirm="DeleteObject"
+                            OkText="Yes"
+                            CancelText="No">
+                    <a><Icon Type="delete" Theme="outline"/>删除</a>
+                </Popconfirm>
+            </MenuItem>
+
+        </Menu>
     </Content>
     <ChildContent>
         @if (workflow == null)
@@ -48,15 +35,19 @@
         }
         else
         {
-            <div style="height:800px;width:100%;overflow:auto;background:#FFFFFF;">
-                <wispro.sp.web.Components.FlowChart @ref="chart"
-                                                    workflow="@workflow" Actions="@Actions"
-                                                    Transfers="@Transfers" Steps="@Steps"
-                                                    OnClickAction="OnClickAction"
-                                                    OnClickStep="OnClickStep"
-                                                    OnClickTransfer="OnClickTransfer" 
-                                                    OnDoubleClickStep="OnDblClickStep"/>
-            </div>
+    <div style="height:800px;width:100%;overflow:auto;background:#FFFFFF;" id="div-Container">
+        <Affix TargetSelector="#div-Container" OffsetTop="10" Style="float:right">
+            <a href="@DownloadUrl"><Icon Type="download" Theme="outline" /></a>
+        </Affix>
+        <wispro.sp.web.Components.FlowChart @ref="chart"
+                                            workflow="@workflow" Actions="@Actions"
+                                            Transfers="@Transfers" Steps="@Steps"
+                                            OnClickAction="OnClickAction"
+                                            OnClickStep="OnClickStep"
+                                            OnClickTransfer="OnClickTransfer"
+                                            OnDoubleClickStep="OnDblClickStep"
+                                            hSeparation="80"/>
+    </div>
         }
     </ChildContent>
 </PageContainer>
@@ -80,16 +71,27 @@
         </FormItem>
 
         <div><Button Type="primary" Icon="plus" OnClick="AddNewAction" Style="float:right">添加操作</Button></div>
-        <AntDesign.Table TItem="wispro.sp.entity.workflowDefine.Action"                         
-                         DataSource="@EditStep.actions"
+       
+        <AntDesign.Table DataSource="@context.actions"
                          Bordered=@true
                          Size=@TableSize.Middle
                          HidePagination
                          Context="ss">
             <ChildContent>
                 
-                <AntDesign.Column Title="名称" @bind-Field="@ss.Name" Sortable Filterable />
-                <AntDesign.Column Title="操作界面" @bind-Field="@ss.InputForm" Format="yyyy-MM-dd" Sortable Filterable />
+                <AntDesign.Column Title="名称" TData="string">
+                    @if (ss.Action != null)
+                    {
+                        <span>@ss.Action.Name</span>
+                    }
+                    
+                </AntDesign.Column> 
+                <AntDesign.Column Title="操作界面" TData="string">
+                    @if(ss.Action != null)
+                    {
+                        <span>@ss.Action.InputForm</span>
+                    }
+                </AntDesign.Column>
                 <AntDesign.Column Title="所属步骤" TData="string">
 
                     @if (context.Step.Name != null)
@@ -100,10 +102,10 @@
                 </AntDesign.Column>
                 <ActionColumn>
                     <Space>
-                        <SpaceItem><Button OnClick="()=>BeginEditAction(ss.Id)">修改</Button></SpaceItem>
+                        <SpaceItem><Button OnClick="()=>BeginEditAction(ss.Action.Id)">修改</Button></SpaceItem>
                     </Space>
                     <Space>
-                        <SpaceItem><Button Danger OnClick="()=>DeleteAction(ss.Id)">删除</Button></SpaceItem>
+                        <SpaceItem><Button Danger OnClick="()=>DeleteAction(ss.Action.Id)">删除</Button></SpaceItem>
                     </Space>
                 </ActionColumn>
             </ChildContent>
@@ -123,10 +125,10 @@
 
     <Form Model="EditAction" LabelColSpan="6"
           WrapperColSpan="16">
-        <FormItem Label="所属步骤">
+        @*<FormItem Label="所属步骤">
             <Select DataSource="@Steps"
-                DefaultValue="@EditAction.StepId"
-                @bind-Value="@EditAction.StepId"
+                DefaultValue="@EditAction.Action.StepId"
+                @bind-Value="@EditAction.Action.StepId"
                 LabelName="@nameof(wispro.sp.entity.workflowDefine.Step.Name)"
                 ValueName="@nameof(wispro.sp.entity.workflowDefine.Step.Id)"
                 Style="width: 200px"
@@ -135,14 +137,15 @@
                 EnableSearch="true"
                 AllowClear>
         </Select>
-        </FormItem>
+        </FormItem>*@
         <FormItem Label="操作名称">
-            <Input @bind-Value="@EditAction.Name" />
+            <Input @bind-Value="@EditAction.Action.Name" />
         </FormItem>
         <FormItem Label="初始化界面">
-            <Input @bind-Value="@EditAction.InputForm" />
+            <Input @bind-Value="@EditAction.Action.InputForm" />
         </FormItem>
-        <wispro.sp.web.Components.InputValueSetting DataSource="@EditAction.inputValuesSettings" />
+        
+        <wispro.sp.web.Components.InputValueSetting EditAction="@EditAction" />
     </Form>
 
 </Modal>

+ 74 - 22
wispro.sp.web/Pages/Workflow/WorkflowDetail.razor.cs

@@ -1,5 +1,6 @@
 using AntDesign;
 using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Configuration;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -29,13 +30,21 @@ namespace wispro.sp.web.Pages.Workflow
 
         [Inject] protected WorkflowService _wfService { get; set; }
 
+        [Inject] protected IConfiguration _configuration { get; set; }
+
+        string DownloadUrl;
         async Task InitData()
         {
+
             //int Id = int.Parse(WorkflowId.ToString());
             workflow = await _wfService.GetWorkflow(WorkflowId);
             Steps = await _wfService.GetSteps(WorkflowId);
             Actions = await _wfService.GetActions(WorkflowId);
             Transfers = await _wfService.GetTransfers(WorkflowId);
+
+            DownloadUrl = $"{_configuration.GetValue<string>("APIUrl")}WorkflowEngine/ExportToImage?workflowId={workflow.Id}";
+
+
         }
         
         protected async override Task OnInitializedAsync()
@@ -68,7 +77,7 @@ namespace wispro.sp.web.Pages.Workflow
             }
 
             EditStep.actions = GetActions(step.Id);
-            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(EditStep));
+            
             StepModalShow = true;
 
         }
@@ -85,7 +94,7 @@ namespace wispro.sp.web.Pages.Workflow
 
         share.NewStepObject EditStep;
          
-        entity.workflowDefine.Action EditAction;
+        share.ActionObject EditAction;
         entity.workflowDefine.TrasferCondition EditTransfer;
 
         bool StepModalShow = false;
@@ -96,35 +105,45 @@ namespace wispro.sp.web.Pages.Workflow
         {
             EditStep = new share.NewStepObject();
             EditStep.Step = new entity.workflowDefine.Step() { Name = "新步骤", stepType = 2, workflowId = workflow.Id };
+            EditStep.actions = new List<share.ActionObject>();
             EditStep.isLastStep = false;
             userField = new UserField();
-            newActions = new List<entity.workflowDefine.Action>();
+            
 
             StepModalShow = true;
         }
 
         void AddNewAction()
         {
-            EditAction = new entity.workflowDefine.Action();
-            EditAction.Name = "新操作";
-            EditAction.inputValuesSettings = new List<entity.workflowDefine.InputValueSetting>();
+            EditAction = new share.ActionObject();
+            EditAction.Action = new entity.workflowDefine.Action();
+            EditAction.Action.Name = "新操作";
+            EditAction.InputValueSettingObjects = new List<share.InputValueSettingObject>();
 
+            if (EditStep.NewActions == null)
+            {
+                EditStep.NewActions = new List<share.ActionObject>();
+            }
+
+            EditStep.NewActions.Add(EditAction);
+            
             ActionModalShow = true;
         }
 
         async Task BeginEditAction(int Id)
         {
-            EditAction = Actions.FirstOrDefault(a=>a.Id == Id);
+            EditAction = EditStep.actions.FirstOrDefault(a => a.Action.Id == Id);
 
-            if(EditAction != null)
+            Console.WriteLine($"BeginEditAction-Begin:{System.Text.Json.JsonSerializer.Serialize(EditAction)}");
+            if (EditAction != null)
             {
-                if(EditAction.inputValuesSettings == null)
+                if ( EditAction.Action.Id >0)
                 {
-                    EditAction.inputValuesSettings = await _wfService.getInputValueSteeing(EditAction.Id);
+                    EditAction.InputValueSettingObjects = await _wfService.getInputValueSteeing(EditAction.Action.Id);
                 }
                 ActionModalShow = true;
             }
-
+            Console.WriteLine($"BeginEditAction-End:{System.Text.Json.JsonSerializer.Serialize(EditAction)}");
         }
 
         async void DeleteAction(int Id)
@@ -148,14 +167,24 @@ namespace wispro.sp.web.Pages.Workflow
             TransferModalShow = true;
         }
 
-        List<entity.workflowDefine.Action> GetActions(int stepId)
+        List<share.ActionObject> GetActions(int stepId)
         {
-            return Actions.Where<entity.workflowDefine.Action>(a=>a.StepId == stepId).ToList();
+            var actionList = Actions.Where<entity.workflowDefine.Action>(a=>a.StepId == stepId).ToList();
+            List<share.ActionObject> retList = new List<share.ActionObject>();
+
+            foreach(var ac in actionList)
+            {
+                share.ActionObject acobj = new share.ActionObject();
+                acobj.Action = ac;
+                retList.Add(acobj);
+            }
+
+            return retList;
         }
 
         async Task EditStepOK()
         {
-            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(userField));
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(userField));
             EditStep.Step.defaultResponseSetting = System.Text.Json.JsonSerializer.Serialize(userField);
             
             var ret = await _wfService.SaveStep(EditStep);
@@ -177,7 +206,7 @@ namespace wispro.sp.web.Pages.Workflow
             StepModalShow = false;
         }
 
-        List<entity.workflowDefine.Action> newActions;
+        List<share.ActionObject> newActions;
         async Task EditActionOK()
         {
             if (EditStep != null)
@@ -185,14 +214,30 @@ namespace wispro.sp.web.Pages.Workflow
                 if (!EditStep.actions.Contains(EditAction))
                 {
                     EditStep.actions.Add(EditAction);
+
+                    if (EditStep.NewActions == null)
+                    {
+                        EditStep.NewActions = new List<share.ActionObject>();
+                    }
+
+                    if (!EditStep.NewActions.Contains(EditAction))
+                    {
+                        EditStep.NewActions.Add(EditAction);
+                    }
                 }
-            }
-            else
-            {
-                if(newActions == null)
+                else
+                {
+                    if (EditStep.ModifyActions == null)
+                    {
+                        EditStep.ModifyActions = new List<share.ActionObject>();
+                    }
+                }
+
+                if (!EditStep.ModifyActions.Contains(EditAction))
                 {
-                    newActions.Add(EditAction);
+                    EditStep.ModifyActions.Add(EditAction);
                 }
+                
             }
 
             ActionModalShow = false;
@@ -206,7 +251,7 @@ namespace wispro.sp.web.Pages.Workflow
         async Task EditTransferOK()
         {
             
-            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(EditTransfer));
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(EditTransfer));
 
             if(EditTransfer.StepId!= null && EditTransfer.StepId.Value == 0)
             {
@@ -237,26 +282,33 @@ namespace wispro.sp.web.Pages.Workflow
         void OnRefresh()
         {
             chart.Refresh();
+
+            StateHasChanged();
         }
 
         [Inject] ModalService _modalService { get; set; }
         async Task DeleteObject()
         {
-            if(chart.SelectedObject != null)
+            string strMsg = "";
+            if (chart.SelectedObject != null)
             {
                 if(chart.SelectedObject is entity.workflowDefine.TrasferCondition)
                 {
                     TrasferCondition transfer = chart.SelectedObject as TrasferCondition;
                     await _wfService.DeleteTransfer(transfer);
+                    strMsg = (transfer.StepId == null) ? "开始" : transfer.Step.Name;
+                    strMsg = $"已删除{strMsg}的转移条件!";
                 }
 
                 if(chart.SelectedObject is entity.workflowDefine.Step)
                 {
                     await _wfService.DeleteStep((entity.workflowDefine.Step)chart.SelectedObject);
+                    strMsg = $"已删除步骤[{((entity.workflowDefine.Step)chart.SelectedObject).Name}]";
                 }
             }
 
             await InitData();
+            await _msgService.Info(strMsg);
             chart.Refresh();
         }
     }

+ 3 - 1
wispro.sp.web/Properties/launchSettings.json

@@ -24,7 +24,9 @@
     },
     "wispro.sp.web": {
       "commandName": "Project",
-      "launchBrowser": true
+      "launchBrowser": true,
+      "nativeDebugging": false,
+      "jsWebView2Debugging": true
     }
   }
 }

+ 1 - 1
wispro.sp.web/Services/PerformanceItemServices.cs

@@ -121,7 +121,7 @@ namespace wispro.sp.web.Services
                 }
             }
             var data = await _httpClient.Post<ListApiResponse<PerformanceItem>>($"PerformanceItem/QueryFilter",query);
-            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(queryModel));
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(queryModel));
             return data;
         }
 

+ 43 - 10
wispro.sp.web/Services/WorkflowService.cs

@@ -44,13 +44,13 @@ namespace wispro.sp.web.Services
 
         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)
+        public async Task<ApiSaveResponse> AddWorkflow(entity.workflowDefine.Workflow wf,share.ActionObject InitAction)
         {
             share.NewWorkflowObject newWorkflow = new share.NewWorkflowObject();
             newWorkflow.Workflow = wf;
             newWorkflow.InitAction = InitAction;
 
-            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(newWorkflow));
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(newWorkflow));
 
             var ret = await _httpClient.Post<ApiSaveResponse>("WorkflowEngine/AddNew", newWorkflow);
 
@@ -68,7 +68,7 @@ namespace wispro.sp.web.Services
         {
             Workflow ret = await _httpClient.Get<Workflow>($"WorkflowEngine/GetWorkflow?workflowId={Id}");
 
-            Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(ret));
+            //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(ret));
             return ret;
         }
 
@@ -120,22 +120,55 @@ namespace wispro.sp.web.Services
             return ret;
         }
 
-        public async Task<List<InputValueSetting>> getInputValueSteeing(int actionId)
+        public async Task<List<share.InputValueSettingObject>> getInputValueSteeing(int actionId)
         {
             var ret = await _httpClient.Get<List<InputValueSetting>>($"WorkflowEngine/getInputValueSteein?actionId={actionId}");
+
+            var retList = new List<share.InputValueSettingObject>();
+            if(ret != null)
+            {
+                foreach(var iv in ret)
+                {
+                    if (iv.ParentSettingId == null)
+                    {
+                        InputValueSettingObject ivObj = new InputValueSettingObject();
+                        ivObj.InputValueSetting = iv;
+                        if(iv.valueType == EnumFieldType.List)
+                        {
+                            ivObj.Children = ret.Where<entity.workflowDefine.InputValueSetting>(s => s.ParentSettingId == iv.ParentSettingId).ToList();
+                        }
+
+                        retList.Add(ivObj);
+                    }
+                }
+            }
+
+            //Console.WriteLine($"Services-GetInputValueSettings:{System.Text.Json.JsonSerializer.Serialize(retList)}");
+            return retList;
+        }
+
+        public async Task<ApiSaveResponse> DeleteInputValueSetting(int Id)
+        {
+            var ret = await _httpClient.Get<ApiSaveResponse>($"WorkflowEngine/DeleteInputValueSetting?Id={Id}");
             return ret;
         }
 
-        public async Task DeleteStep(Step selectedObject)
+        public async Task<ApiSaveResponse> DeleteStep(Step selectedObject)
         {
-            var ret = await _httpClient.Get<bool>($"WorkflowEngine/DeleteStep?Id={selectedObject.Id}");
-            //return ret;
+            var ret = await _httpClient.Get<ApiSaveResponse>($"WorkflowEngine/DeleteStep?Id={selectedObject.Id}");
+            return ret;
         }
 
-        public async Task DeleteTransfer(TrasferCondition transfer)
+        public async Task<ApiSaveResponse> DeleteTransfer(TrasferCondition transfer)
         {
-            var ret = await _httpClient.Get<bool>($"WorkflowEngine/DeleteTransfer?Id={transfer.Id}");
-            //return ret;
+            var ret = await _httpClient.Get<ApiSaveResponse>($"WorkflowEngine/DeleteTransfer?Id={transfer.Id}");
+            return ret;
+        }
+
+        public async Task<InputValueSetting> getInputValueSteeingById(int id)
+        {
+            var ret = await _httpClient.Get<InputValueSetting>($"WorkflowEngine/getInputValueSteeingById?Id={id}");
+            return ret;
         }
     }
 }

+ 16 - 6
wispro.sp.winClient/Form1.cs

@@ -7,7 +7,9 @@ using System.Configuration;
 using System.Data;
 using System.Diagnostics;
 using System.Drawing;
+using System.Drawing.Imaging;
 using System.Dynamic;
+using System.IO;
 using System.Linq;
 using System.Net.Http;
 using System.Net.Http.Json;
@@ -185,7 +187,7 @@ namespace wispro.sp.winClient
 
             #region Demo流程数据
             HttpClient http = new HttpClient();
-            int wfId = 5;
+            int wfId = 6;
             var workflow = await GetWorkflow(wfId, http);
             var Steps = await GetSteps(wfId, http);
             var Actions = await GetActions(wfId, http);
@@ -198,11 +200,19 @@ namespace wispro.sp.winClient
 
             string strSvg = flowChart.GetSvgString();
 
-            var file = System.IO.File.CreateText("c:\\temp\\tem.svg");
-            file.WriteLine(strSvg);
-            file.Close();
-
-
+            //var file = System.IO.File.CreateText("c:\\temp\\tem.svg");
+            //file.WriteLine(strSvg);
+            //file.Close();
+
+            System.Xml.XmlDocument xmdoc = new System.Xml.XmlDocument();
+            xmdoc.LoadXml(strSvg);
+            Svg.SvgDocument svg = Svg.SvgDocument.Open(xmdoc);
+            Bitmap bitmap = svg.Draw();
+            bitmap.Save("c:\\temp\\test.jpg",ImageFormat.Jpeg);
+            MemoryStream mStream = new MemoryStream();
+            bitmap.Save(mStream, ImageFormat.Jpeg);
+            byte[] bitMaps = new byte[mStream.Length];
+            mStream.Read(bitMaps, 0, (int)mStream.Length);
 
 
 

+ 1 - 0
wispro.sp.winClient/wispro.sp.winClient.csproj

@@ -39,6 +39,7 @@
     </PackageReference>
     <PackageReference Include="NPOI" Version="2.5.4" />
     <PackageReference Include="PinYinConverterCore" Version="1.0.2" />
+    <PackageReference Include="Svg" Version="3.3.0" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
wospro.sp.entity/workflowDefine/workflow.cs

@@ -59,7 +59,7 @@ namespace wispro.sp.entity.workflowDefine
         /// <summary>
         /// 生效日期
         /// </summary>
-        public DateTime EffectivrDate { get; set; }
+        public DateTime EffectivrDate { get; set; } = DateTime.Now;
 
         /// <summary>
         /// 失效日期