WorkflowDefine.razor.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components;
  4. using Microsoft.JSInterop;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using wispro.sp.web.Services;
  10. namespace wispro.sp.web.Pages.Workflow
  11. {
  12. public partial class WorkflowDefine
  13. {
  14. private List<wispro.sp.entity.workflowDefine.Workflow> workflows = new List<wispro.sp.entity.workflowDefine.Workflow>();
  15. ITable table;
  16. int _pageIndex = 1;
  17. int _pageSize = 10;
  18. int _total = 0;
  19. bool _loading = false;
  20. bool isAdd = false;
  21. entity.workflowDefine.Workflow EditingObj = null;
  22. share.ActionObject InitAction = null;
  23. bool _visible = false;
  24. bool _initModalVisible = false;
  25. List<wispro.sp.entity.EnumnDescription<wispro.sp.entity.workflowDefine.FieldType>> FieldTypes
  26. = entity.EnumHelper.getEnumDescriptionDic<wispro.sp.entity.workflowDefine.FieldType>();
  27. entity.workflowDefine.FieldType fieldType = entity.workflowDefine.FieldType.ActionInputValue;
  28. [Inject] protected IUserService UserService { get; set; }
  29. [Inject] protected WorkflowService workflowService { get; set; }
  30. [Inject] protected MessageService _msgService { get; set; }
  31. [Inject] protected NavigationManager navigation { get; set; }
  32. [Inject] protected IAuthService _authService { get; set; }
  33. [Inject] protected IJSRuntime JSRuntime { get; set; }
  34. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  35. {
  36. await _authService.CanVisitResource();
  37. await base.OnInitializedAsync();
  38. workflows = await workflowService.getAllWorkflows();
  39. }
  40. private void AddNew()
  41. {
  42. isAdd = true;
  43. EditingObj = new entity.workflowDefine.Workflow();
  44. InitAction = new share.ActionObject();
  45. InitAction.Action = new entity.workflowDefine.Action();
  46. InitAction.InputValueSettingObjects = new List<share.InputValueSettingObject>();
  47. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(InitAction));
  48. _visible = true;
  49. }
  50. async Task HandleOk()
  51. {
  52. if (EditingObj.Id ==0)
  53. {
  54. EditingObj.CreateTime = DateTime.Now;
  55. var retResponse = await workflowService.AddWorkflow(EditingObj,InitAction);
  56. if (retResponse.Success)
  57. {
  58. workflows = await workflowService.getAllWorkflows();
  59. _visible = false;
  60. //StateHasChanged();
  61. }
  62. else
  63. {
  64. await _msgService.Error(retResponse.ErrorMessage);
  65. }
  66. }
  67. }
  68. void HandleCancel()
  69. {
  70. _visible = false;
  71. }
  72. public int serialNumber(int pageIndex, int pageSize, int Id)
  73. {
  74. int iIndex = 0;
  75. foreach (wispro.sp.entity.workflowDefine.Workflow sf in workflows)
  76. {
  77. iIndex++;
  78. if (sf.Id == Id)
  79. {
  80. break;
  81. }
  82. }
  83. return iIndex;
  84. }
  85. wispro.sp.entity.workflowDefine.Workflow SelectedWorkflow;
  86. Dictionary<string, object> OnRow(RowData<wispro.sp.entity.workflowDefine.Workflow> row) => new()
  87. {
  88. ["id"] = row.Data.Id,
  89. ["onclick"] = ((Action)delegate
  90. {
  91. SelectedWorkflow = row.Data;
  92. //Console.WriteLine($"row {row.Data.Name} was clicked");
  93. })
  94. };
  95. async Task Delete(entity.workflowDefine.Workflow workflow)
  96. {
  97. var ret = await workflowService.Delete(workflow.Id);
  98. if (ret.Success)
  99. {
  100. workflows.Remove(workflow);
  101. }
  102. else
  103. {
  104. await _msgService.Error(ret.ErrorMessage);
  105. }
  106. }
  107. void Detail(int Id)
  108. {
  109. navigation.NavigateTo($"/Workflow/Detail/{Id}");
  110. }
  111. //IDictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>> dicFieldSettings
  112. // = new Dictionary<entity.workflowDefine.Workflow, List<entity.workflowDefine.InputValueSetting>>();
  113. //void InitFieldSetting(entity.workflowDefine.Workflow workflow)
  114. //{
  115. // if (dicFieldSettings.ContainsKey(workflow))
  116. // {
  117. // InitInputValues = dicFieldSettings[workflow];
  118. // }
  119. // else
  120. // {
  121. // InitInputValues = new List<entity.workflowDefine.InputValueSetting>();
  122. // dicFieldSettings.Add(workflow,InitInputValues);
  123. // }
  124. // _initModalVisible = true;
  125. //}
  126. }
  127. }