using AntDesign; using AntDesign.TableModels; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using wispro.sp.web.Services; namespace wispro.sp.web.Pages.Workflow { public partial class WorkflowDefine { private List workflows = new List(); ITable table; int _pageIndex = 1; int _pageSize = 10; int _total = 0; bool _loading = false; bool isAdd = false; entity.workflowDefine.Workflow EditingObj = null; share.ActionObject InitAction = null; bool _visible = false; bool _initModalVisible = false; List> FieldTypes = entity.EnumHelper.getEnumDescriptionDic(); entity.workflowDefine.FieldType fieldType = entity.workflowDefine.FieldType.ActionInputValue; [Inject] protected IUserService UserService { get; set; } [Inject] protected WorkflowService workflowService { get; set; } [Inject] protected MessageService _msgService { get; set; } [Inject] protected NavigationManager navigation { get; set; } [Inject] protected IAuthService _authService { get; set; } [Inject] protected IJSRuntime JSRuntime { get; set; } protected override async System.Threading.Tasks.Task OnInitializedAsync() { await _authService.CanVisitResource(); await base.OnInitializedAsync(); workflows = await workflowService.getAllWorkflows(); } private void AddNew() { isAdd = true; EditingObj = new entity.workflowDefine.Workflow(); InitAction = new share.ActionObject(); InitAction.Action = new entity.workflowDefine.Action(); InitAction.InputValueSettingObjects = new List(); //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(InitAction)); _visible = true; } async Task HandleOk() { if (EditingObj.Id ==0) { EditingObj.CreateTime = DateTime.Now; var retResponse = await workflowService.AddWorkflow(EditingObj,InitAction); if (retResponse.Success) { workflows = await workflowService.getAllWorkflows(); _visible = false; //StateHasChanged(); } else { await _msgService.Error(retResponse.ErrorMessage); } } } void HandleCancel() { _visible = false; } public int serialNumber(int pageIndex, int pageSize, int Id) { int iIndex = 0; foreach (wispro.sp.entity.workflowDefine.Workflow sf in workflows) { iIndex++; if (sf.Id == Id) { break; } } return iIndex; } wispro.sp.entity.workflowDefine.Workflow SelectedWorkflow; Dictionary OnRow(RowData row) => new() { ["id"] = row.Data.Id, ["onclick"] = ((Action)delegate { SelectedWorkflow = row.Data; //Console.WriteLine($"row {row.Data.Name} was clicked"); }) }; async Task Delete(entity.workflowDefine.Workflow workflow) { var ret = await workflowService.Delete(workflow.Id); if (ret.Success) { workflows.Remove(workflow); } else { await _msgService.Error(ret.ErrorMessage); } } void Detail(int Id) { navigation.NavigateTo($"/Workflow/Detail/{Id}"); } //IDictionary> dicFieldSettings // = new Dictionary>(); //void InitFieldSetting(entity.workflowDefine.Workflow workflow) //{ // if (dicFieldSettings.ContainsKey(workflow)) // { // InitInputValues = dicFieldSettings[workflow]; // } // else // { // InitInputValues = new List(); // dicFieldSettings.Add(workflow,InitInputValues); // } // _initModalVisible = true; //} } }