using System.Threading.Tasks; using wispro.sp.web.Models; using wispro.sp.web.Services; using Microsoft.AspNetCore.Components; using wispro.sp.web.Components; using System.Collections.Generic; using wispro.sp.entity; using System.Text.Json; using AntDesign; using System; using wispro.sp.share; using Microsoft.AspNetCore.Components.Web; using Microsoft.JSInterop; using System.Linq; namespace wispro.sp.web.Pages { public partial class Welcome { private readonly EditableLink[] _links = { new EditableLink {Title = "Operation 1", Href = ""}, new EditableLink {Title = "Operation 2", Href = ""}, new EditableLink {Title = "Operation 3", Href = ""}, new EditableLink {Title = "Operation 4", Href = ""}, new EditableLink {Title = "Operation 5", Href = ""}, new EditableLink {Title = "Operation 6", Href = ""} }; private ActivitiesType[] _activities = { }; private NoticeType[] _projectNotice = { }; private CurrentUser _CurrentUser; private List AppealRecords = new List(); private List WaitingReviewProjects = new List(); [Inject] public IProjectService ProjectService { get; set; } [Inject] public IUserService _userService { get; set; } [Inject] protected AppealTypeService _atService { get; set; } private ModalRef _modalRef; [Inject] ModalService _ModalService { get; set; } [Inject] MessageService _msgService { get; set; } private Models.CurrentUser _user; [Inject] PerformanceItemServices _ItemService { get; set; } [Inject] CalMonthServices CalMonthServices { get; set; } [Inject] IUserService UserService { get; set; } [Inject] IJSRuntime JSRuntime { get; set; } int waitingHandleItems = 0; int allItems = 0; CalMonth HandlingMonth = null; protected AntDesign.Table table; int _total; int _pageIndex = 1; int _pageSize = 10; protected override async System.Threading.Tasks.Task OnInitializedAsync() { //await base.OnInitializedAsync(); _CurrentUser =await _userService.GetUser(); //_user = _CurrentUser; HandlingMonth = await CalMonthServices.GetHandlingMonth(); if (HandlingMonth != null) { //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize()) var data = await _ItemService.Query(HandlingMonth.Id, _CurrentUser.Userid.Value, jxType.doing ,null); waitingHandleItems = data.TotalCount; } var data1 = await _ItemService.GetMyList(_CurrentUser.Userid.Value, jxType.all); allItems = data1.TotalCount; if (_CurrentUser != null) { AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid); _total = AppealRecords.Count; } WaitingReviewProjects = await ProjectService.GetWaitingReviewProjects(); StateHasChanged(); } private int serialNumber(int pageIndex, int pageSize, AppealRecord appealRecord) { int iIndex = 0; foreach (AppealRecord sf in AppealRecords) { iIndex++; if (sf == appealRecord) { break; } } return (pageIndex - 1) * pageSize + iIndex; } private void HandlePageChange(PaginationEventArgs args) { if (_pageIndex != args.Page) { _pageIndex = args.Page; } if (_pageSize != args.PageSize) { _pageSize = args.PageSize; } } async void ShowModel(AppealRecord appealRecord) { var templateOptions = new Models.ReviewerAppealModel(); await templateOptions.Init(_atService, appealRecord.Id); Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions)); var modalConfig = new ModalOptions(); modalConfig.Title = $"{appealRecord.Type.Name}审核" ; modalConfig.Width = 650; //modalConfig.Footer = null; modalConfig.DestroyOnClose = true; modalConfig.MaskClosable = false; _modalRef = await _ModalService .CreateModalAsync(modalConfig, templateOptions); _modalRef.OnOpen = () => { return Task.CompletedTask; }; _modalRef.OnOk = async () => { try { if (templateOptions.AppealRecord.Type.Name == "案件系数复核") { var ifValue = templateOptions.CreateAppealFieldValues.Where(iv => iv.InputField.FieldName == "案件系数").FirstOrDefault(); if (ifValue.Value == "A" || ifValue.Value == "S") { var temCssObj = new CaseCoefficientStatistics() { Totals = templateOptions.cssObject.Totals, SCount = templateOptions.cssObject.SCount, ACount = templateOptions.cssObject.ACount, customer = templateOptions.cssObject.customer }; if (ifValue != null) { switch (ifValue.Value) { case "S": temCssObj.SCount += 1; break; case "A": temCssObj.ACount += 1; break; } } switch (templateOptions.Item.CaseCoefficient) { case "S": temCssObj.SCount -= 1; break; case "A": temCssObj.ACount -= 1; break; } if (temCssObj.isExceedingLimit()) { var shyjObj = templateOptions.inputFieldValues.Where(i => i.InputField.FieldName == "审核意见").FirstOrDefault(); if (shyjObj!= null && shyjObj.Value == "同意") { Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions)); var reviewer = await UserService.GetUser(templateOptions.AppealRecord.ReviewerId.Value); if (reviewer.Name != "钟子敏") { var SuccessConfig1 = new ConfirmOptions() { Content = $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!" }; _ModalService.Error(SuccessConfig1); //await JSRuntime.InvokeAsync("alert", $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!"); return; } } } } } var retData = await _atService.ReviewerAppeal(templateOptions); if (retData.Success) { await _modalRef.CloseAsync(); AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid); StateHasChanged(); var SuccessConfig = new ConfirmOptions() { Content = @"审核成功!" }; //modalConfig.Footer = null; modalConfig.DestroyOnClose = true; _ModalService.Success(SuccessConfig); } else { throw new ApplicationException(retData.ErrorMessage); } } catch (Exception ex) { _ModalService.Error(new ConfirmOptions() { Title = "审核错误", Content = ex.Message, }); } }; _modalRef.OnCancel = () => { return Task.CompletedTask; }; _modalRef.OnClose = () => { return Task.CompletedTask; }; StateHasChanged(); } int serialNumber(ProjectInfo project) { int i = 0; foreach(var p in WaitingReviewProjects) { i++; if(p.CaseNo == project.CaseNo) { break; } } return i; } #region 审核人变更 bool _visible; List _Staffs; AppealRecord _ChangedRecord; async Task ShowChangeReviewer(AppealRecord appealRecord) { _Staffs = await _userService.GetReviewers(appealRecord.ItemId, appealRecord.TypeId); _ChangedRecord = appealRecord; _visible = true; } private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e) { var response = await _atService.ChangeReviewer(_ChangedRecord); if (response.Success) { AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid); StateHasChanged(); _visible = false; } else { await _msgService.Error(response.ErrorMessage); } } private void HandleCancel(MouseEventArgs e) { _visible = false; } #endregion } }