using AntDesign; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using wispro.sp.entity; using wispro.sp.web.Services; namespace wispro.sp.web.Pages.Project { public partial class MyProject { List ProjectInfos; int _pageIndex = 1; int _pageSize = 10; int _total = 0; bool _loading = false; private ModalRef _modalRef; [Inject] protected IProjectService _itemService { get; set; } [Inject] public MessageService MsgSvr { get; set; } [Inject] NavigationManager _NavigationManager { get; set; } [Inject] ModalService _ModalService { get; set; } [Inject] MessageService _msgService { get; set; } private string getStatus(int state) { switch (state) { case 0: return "未提交"; break; case 1: return "待审核"; break; case 2: return "已审核"; break; default: return ""; } } protected async override Task OnInitializedAsync() { ProjectInfos = await _itemService.GetMyProjects(); _total = ProjectInfos.Count; await base.OnInitializedAsync(); } public int serialNumber(int pageIndex, int pageSize, ProjectContentRecord pr) { int iIndex = ProjectInfos.IndexOf(pr); return iIndex + 1; } public async Task SetFinished(string CaseNo) { var result = await _itemService.SetProjectFinish(CaseNo); if (!result) { await MsgSvr.Error($"设定专案[{CaseNo}]为已完成时出错,请稍后再试!"); } } private void HandlePageChange(PaginationEventArgs args) { if (_pageIndex != args.Page) { _pageIndex = args.Page; } if (_pageSize != args.PageSize) { _pageSize = args.PageSize; } } public void AddNew() { _NavigationManager.NavigateTo("/Project/WorkContent"); } public void Edit(ProjectContentRecord projectContent) { _NavigationManager.NavigateTo($"/Project/WorkContent/{projectContent.Id}"); } async void Submit(ProjectContentRecord projectContent) { var modalConfig = new ModalOptions(); modalConfig.Title = $"{projectContent.Project.CaseNo}工作内容提交审核"; modalConfig.Width = 850; //modalConfig.Footer = null; modalConfig.DestroyOnClose = true; modalConfig.MaskClosable = false; modalConfig.OkText = "提交"; modalConfig.CancelText = "取消"; _modalRef = await _ModalService .CreateModalAsync(modalConfig, projectContent); _modalRef.OnOpen = () => { return Task.CompletedTask; }; _modalRef.OnOk = async () => { try { if (projectContent.Project.ReviewerId.HasValue) { await _itemService.SubmitToReview(projectContent.Id, projectContent.Project.ReviewerId.Value); var SuccessConfig = new ConfirmOptions() { Content = @"提交成功!" }; modalConfig.DestroyOnClose = true; _ModalService.Success(SuccessConfig); ProjectInfos = await _itemService.GetMyProjects(); } else { _ModalService.Info(new ConfirmOptions() { Content = "请选择审核人员!", }); } } catch (Exception ex) { _ModalService.Error(new ConfirmOptions() { Title = "错误", Content = ex.Message, }); } }; _modalRef.OnCancel = () => { return Task.CompletedTask; }; _modalRef.OnClose = () => { return Task.CompletedTask; }; StateHasChanged(); } } }