mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-02 15:50:51 +08:00
审批序列化
This commit is contained in:
@@ -23,7 +23,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
if (DiagramViewModel != null)
|
||||
{
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel, false);
|
||||
}
|
||||
_service.DrawModeViewModel.LineDrawMode = DrawMode.ConnectingLineSmooth;
|
||||
}
|
||||
@@ -46,22 +46,22 @@ namespace AIStudio.Wpf.Flowchart
|
||||
DesignerItemViewModelBase start = new StartFlowNode() { Left = 100, Top = 0, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
|
||||
DiagramViewModel.Add(start);
|
||||
|
||||
DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List<string> { "操作员1", "操作员2" }, ActType = "or" };
|
||||
DesignerItemViewModelBase middle1 = new MiddleFlowNode() { Left = 100, Top = 100, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "主管审批", UserIds= new List<string> { "操作员1", "操作员2" }, ActType = "or", SimulateApprove = true };
|
||||
DiagramViewModel.Add(middle1);
|
||||
|
||||
DesignerItemViewModelBase decide = new DecideFlowNode() { Left = 100, Top = 200, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "5" };
|
||||
DiagramViewModel.Add(decide);
|
||||
|
||||
DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List<string> { "操作员1", "操作员2" }, ActType = "and", DoubleApprove = true };
|
||||
DesignerItemViewModelBase middle2 = new MiddleFlowNode() { Left = 200, Top = 300, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "分管领导", UserIds = new List<string> { "操作员1", "操作员2" }, ActType = "and", SimulateApprove = true };
|
||||
DiagramViewModel.Add(middle2);
|
||||
|
||||
DesignerItemViewModelBase cobegin = new COBeginFlowNode() { Left = 100, Top = 400, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
|
||||
DiagramViewModel.Add(cobegin);
|
||||
|
||||
DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List<string> { "Admin" }, ActType = "or", DoubleApprove = true };
|
||||
DesignerItemViewModelBase middle3 = new MiddleFlowNode() { Left = 100, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "财务审批", UserIds = new List<string> { "Admin" }, ActType = "or", SimulateApprove = true };
|
||||
DiagramViewModel.Add(middle3);
|
||||
|
||||
DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List<string> { "操作员", "管理员" }, ActType = "or", DoubleApprove = true };
|
||||
DesignerItemViewModelBase middle4 = new MiddleFlowNode() { Left = 200, Top = 500, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString(), Text = "人力审批", RoleIds = new List<string> { "操作员", "管理员" }, ActType = "or", SimulateApprove = true };
|
||||
DiagramViewModel.Add(middle4);
|
||||
|
||||
DesignerItemViewModelBase coend = new COEndFlowNode() { Left = 100, Top = 600, ItemWidth = 80, ItemHeight = 40, StatusColor = Colors.Yellow.ToString() };
|
||||
@@ -102,7 +102,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
ConnectionViewModel connector10 = new ConnectionViewModel(coend.BottomConnector, end.TopConnector, _service.DrawModeViewModel.LineDrawMode, _service.DrawModeViewModel.LineRouterMode);
|
||||
DiagramViewModel.Add(connector10);
|
||||
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel);
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectionViewModel>().ToList(), DiagramViewModel, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -291,11 +291,12 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
if (e.PropertyName == "IsSelected")
|
||||
{
|
||||
_service.SelectedItemViewModel = CopyHelper.Mapper(DiagramViewModel?.SelectedItem);
|
||||
return;
|
||||
}
|
||||
|
||||
var property = sender.GetType().GetProperty(e.PropertyName);
|
||||
var attr = property.GetCustomAttributes(typeof(BrowsableAttribute), true);
|
||||
if (attr != null && attr.Length != 0 && (attr[0] as BrowsableAttribute).Browsable == false)
|
||||
if (attr != null && attr.OfType<BrowsableAttribute>().FirstOrDefault()?.Browsable != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,20 +15,18 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
public LogicalGateDesignerItemBase(LogicalGateItemViewModelBase item) : base(item)
|
||||
{
|
||||
this.Connectors = new List<LogicalConnectorInfoItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors.OfType<LogicalConnectorInfo>())
|
||||
{
|
||||
LogicalConnectorInfoItem connector = new LogicalConnectorInfoItem(fullyCreatedConnectorInfo);
|
||||
this.Connectors.Add(connector);
|
||||
}
|
||||
this.OrderNumber = item.OrderNumber;
|
||||
this.LogicalType = item.LogicalType;
|
||||
this.Value = item.Value;
|
||||
this.IsEnabled = item.IsEnabled;
|
||||
LogicalConnectors = new List<LogicalConnectorInfoItem>(item.Connectors.OfType<LogicalConnectorInfo>().Select(p => new LogicalConnectorInfoItem(p)));
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<LogicalConnectorInfoItem> Connectors { get; set; }
|
||||
public List<LogicalConnectorInfoItem> LogicalConnectors
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public int OrderNumber { get; set; }
|
||||
|
||||
@@ -62,10 +62,13 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.Icon = designer.Icon;
|
||||
this.CornerRadius = designer.CornerRadius;
|
||||
this.BorderThickness = designer.BorderThickness;
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designer.Connectors != null)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
foreach (var connector in designer.Connectors)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,19 +165,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Input.Clear();
|
||||
Output.Clear();
|
||||
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designer.LogicalConnectors != null)
|
||||
{
|
||||
LogicalConnectorInfo fullyCreatedConnectorInfo = new LogicalConnectorInfo(this.Root, this, connector);
|
||||
foreach (var connector in designer.LogicalConnectors)
|
||||
{
|
||||
LogicalConnectorInfo fullyCreatedConnectorInfo = new LogicalConnectorInfo(this.Root, this, connector);
|
||||
|
||||
if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Left)
|
||||
{
|
||||
Input.Add(Input.Count, fullyCreatedConnectorInfo);
|
||||
if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Left)
|
||||
{
|
||||
Input.Add(Input.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
else if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Right)
|
||||
{
|
||||
Output.Add(Output.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
else if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Right)
|
||||
{
|
||||
Output.Add(Output.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
/// <param name="json"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static void InitData(List<FlowNode> oASteps, List<ConnectionViewModel> connectors, IDiagramViewModel viewModel)
|
||||
public static void InitData(List<FlowNode> oASteps, List<ConnectionViewModel> connectors, IDiagramViewModel viewModel, bool initNew)
|
||||
{
|
||||
foreach (var edge in connectors)
|
||||
{
|
||||
@@ -136,7 +136,10 @@ namespace AIStudio.Wpf.Flowchart
|
||||
|
||||
FlowNodes.Add(viewModel, nodes);
|
||||
|
||||
Approve(oAStartStep, 100);
|
||||
if (initNew)
|
||||
{
|
||||
Approve(oAStartStep, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Serialization;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart.Models
|
||||
{
|
||||
@@ -24,28 +26,67 @@ namespace AIStudio.Wpf.Flowchart.Models
|
||||
UserIds = middleFlow.UserIds;
|
||||
RoleIds = middleFlow.RoleIds;
|
||||
ActType = middleFlow.ActType;
|
||||
SimulateApprove = middleFlow.SimulateApprove;
|
||||
}
|
||||
Color = item.StatusColor;
|
||||
Kind = item.Kind;
|
||||
StateImage = item.StateImage;
|
||||
Status = item.Status;
|
||||
Remark = item.Remark;
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<string> UserIds { get; set; }
|
||||
public List<string> UserIds
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<string> RoleIds { get; set; }
|
||||
public List<string> RoleIds
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string ActType { get; set; }
|
||||
public string ActType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Color { get; set; }
|
||||
public bool SimulateApprove
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public NodeKinds Kind { get; set; }
|
||||
public int Status
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string StateImage { get; set; }
|
||||
public string Remark
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Color
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public NodeKinds Kind
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string StateImage
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,12 +65,15 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||
this.StatusColor = designer.Color;
|
||||
this.Kind = designer.Kind;
|
||||
this.StateImage = designer.StateImage;
|
||||
this.Status = designer.Status;
|
||||
this.Remark = designer.Remark;
|
||||
|
||||
if (this is MiddleFlowNode middle)
|
||||
{
|
||||
middle.UserIds = designer.UserIds;
|
||||
middle.RoleIds = designer.RoleIds;
|
||||
middle.ActType = designer.ActType;
|
||||
middle.SimulateApprove = designer.SimulateApprove;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,12 +110,15 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||
[Browsable(false)]
|
||||
public string StateImage { get; set; }
|
||||
|
||||
#region 没有存起来,仅仅测试使用,实际这些代码应该都在服务端
|
||||
#region 模拟使用
|
||||
private int _status;
|
||||
|
||||
|
||||
public int Status
|
||||
{
|
||||
get { return _status; }
|
||||
get
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _status, value);
|
||||
@@ -122,13 +128,18 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||
private string _remark;
|
||||
public string Remark
|
||||
{
|
||||
get { return _remark; }
|
||||
get
|
||||
{
|
||||
return _remark;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _remark, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 没有存起来,仅仅测试使用,实际这些代码应该都在服务端
|
||||
public List<string> PreStepId { get; set; }
|
||||
public string NextStepId { get; set; }
|
||||
public Dictionary<string, string> SelectNextStep { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
@@ -74,16 +74,18 @@ namespace AIStudio.Wpf.Flowchart.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoubleApprove
|
||||
#region 模拟使用
|
||||
public bool SimulateApprove
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void ExecuteEditCommand(object param)
|
||||
{
|
||||
if (IsReadOnly == true) return;
|
||||
|
||||
if (DoubleApprove)
|
||||
if (SimulateApprove)
|
||||
{
|
||||
if (Status == 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user