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