WorkflowDefine.razor.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using wispro.sp.web.Services;
  9. namespace wispro.sp.web.Pages.Workflow
  10. {
  11. public partial class WorkflowDefine
  12. {
  13. private List<wispro.sp.entity.workflowDefine.Workflow> workflows = new List<wispro.sp.entity.workflowDefine.Workflow>();
  14. ITable table;
  15. double ChartWidth = 1000;
  16. double rectWidth = 120;
  17. double rectHeight = 60;
  18. int rectFontSize = 26;
  19. int _pageIndex = 1;
  20. int _pageSize = 10;
  21. int _total = 0;
  22. bool _loading = false;
  23. bool isAdd = false;
  24. entity.workflowDefine.Workflow EditingObj = null;
  25. List<entity.workflowDefine.InputValueSetting> InitInputValues;
  26. bool _visible = false;
  27. bool _initModalVisible = false;
  28. List<wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>> FieldTypes
  29. = entity.EnumHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.FieldType>();
  30. entity.workflowDefine.FieldType fieldType = entity.workflowDefine.FieldType.ActionInputValue;
  31. [Inject] protected IUserService UserService { get; set; }
  32. [Inject] protected WorkflowService workflowService { get; set; }
  33. [Inject] protected MessageService _msgService { get; set; }
  34. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  35. {
  36. await base.OnInitializedAsync();
  37. }
  38. private void AddNew()
  39. {
  40. isAdd = true;
  41. EditingObj = new entity.workflowDefine.Workflow();
  42. _visible = true;
  43. }
  44. async void HandleOk()
  45. {
  46. if (EditingObj.Id ==0)
  47. {
  48. int maxId = 0;
  49. foreach(var wf in workflows)
  50. {
  51. if(wf.Id > maxId)
  52. {
  53. maxId = wf.Id;
  54. }
  55. }
  56. EditingObj.Id = maxId + 1;
  57. EditingObj.CreateTime = DateTime.Now;
  58. EditingObj.CreateUser = new entity.Staff() { Name = (await UserService.GetUser()).Name };
  59. workflows.Add(EditingObj);
  60. _total = workflows.Count;
  61. }
  62. _visible = false;
  63. StateHasChanged();
  64. }
  65. void HandleCancel()
  66. {
  67. _visible = false;
  68. }
  69. public int serialNumber(int pageIndex, int pageSize, int Id)
  70. {
  71. int iIndex = 0;
  72. foreach (wispro.sp.entity.workflowDefine.Workflow sf in workflows)
  73. {
  74. iIndex++;
  75. if (sf.Id == Id)
  76. {
  77. break;
  78. }
  79. }
  80. return (pageIndex - 1) * pageSize + iIndex;
  81. }
  82. wispro.sp.entity.workflowDefine.Workflow SelectedWorkflow;
  83. Dictionary<string, object> OnRow(RowData<wispro.sp.entity.workflowDefine.Workflow> row) => new()
  84. {
  85. ["id"] = row.Data.Id,
  86. ["onclick"] = ((Action)delegate
  87. {
  88. SelectedWorkflow = row.Data;
  89. Console.WriteLine($"row {row.Data.Name} was clicked");
  90. })
  91. };
  92. void Delete(entity.workflowDefine.Workflow workflow)
  93. {
  94. workflows.Remove(workflow);
  95. _total = workflows.Count;
  96. }
  97. void Detail(int Id)
  98. {
  99. }
  100. IDictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>> dicFieldSettings
  101. = new Dictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>>();
  102. void InitFieldSetting(entity.workflowDefine.Workflow workflow)
  103. {
  104. if (dicFieldSettings.ContainsKey(workflow))
  105. {
  106. InitInputValues = dicFieldSettings[workflow];
  107. }
  108. else
  109. {
  110. InitInputValues = new List<entity.workflowDefine.InputValueSetting>();
  111. dicFieldSettings.Add(workflow,InitInputValues);
  112. }
  113. _initModalVisible = true;
  114. }
  115. async void InitOk()
  116. {
  117. _initModalVisible = false;
  118. }
  119. void InitCancel()
  120. {
  121. _initModalVisible = false;
  122. }
  123. void ClickStep(bool isEnd)
  124. {
  125. var msg = "您点击了开始步骤!";
  126. if (isEnd)
  127. {
  128. msg = "您点击了结束步骤!";
  129. }
  130. _msgService.Info(msg);
  131. }
  132. void ChangeRectSize()
  133. {
  134. Random rd = new Random();
  135. var s = 0.5 + rd.NextDouble();
  136. rectWidth = s * rectWidth;
  137. rectHeight = s * rectHeight;
  138. rectFontSize =(int)(s * rectFontSize);
  139. StateHasChanged();
  140. }
  141. }
  142. }