using AntDesign; using AntDesign.ProLayout; using AntDesign.TableModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; using System.Threading.Tasks; using wispro.sp.entity; using wispro.sp.share; using wispro.sp.web.Services; namespace wispro.sp.web.Pages.AppCase { [Authorize] public partial class MyCaselist { const string strAgentFeedbackMemo = "AgentFeedbackMemo"; const string strDoItemCoefficient = "DoItemCoefficient"; const string strReturnCasseNo = "ReturnCasseNo"; const string strCaseCoefficient = "CaseCoefficient"; const string strWordCount = "WordCount"; public TableFilter[] CaseCoeFilters = new TableFilter[] { new() { Text = "S", Value = "S" }, new() { Text = "A", Value = "A" }, new() { Text = "B", Value = "B" }, new() { Text = "C", Value = "C" }, new() { Text = "D", Value = "D" } }; [Inject] protected AppealTypeService apTypeService { get; set; } private List _Datas; private List MyStatistics; IEnumerable selectedItems= new List(); private CalMonth HandlingCalMonth; int _pageIndex = 1; int _pageSize = 10; int _total; bool _loading = false; PerformanceItem EditingItem = null; bool _visible = false; bool _isAdd = false; List tabList = new List() { new TabPaneItem(){ Key ="myList", Tab ="本月待确认绩效" }, new TabPaneItem(){ Key ="myAll", Tab ="往期已计算绩效"}, }; [Inject] public PerformanceItemServices _ItemService { get; set; } [Inject] public MessageService _message { get; set; } [Inject] protected NavigationManager NavigationManager { get; set; } [Inject] protected IUserService _userService { get; set; } [Inject] protected CalMonthServices _CalMonthService { get; set; } private bool isFirstInit = true; private Table table; protected async override Task OnInitializedAsync() { if (isFirstInit) { _loading = true; await RefreshMyStatistics(); _Datas = new List();// data.Results; _total = 0;//data.TotalCount; _loading = false; } isFirstInit = false; await apTypeService.GetItems(); StateHasChanged(); //Console.WriteLine($"OnInitializedAsync:[tota:{_total}\tPageIndex:{_pageIndex}\tPageSize:{_pageSize}]"); } private async Task RefreshMyStatistics() { var HandlingCalMonth = await _CalMonthService.GetHandlingMonth(); if (HandlingCalMonth != null) { if (_userService.CurrentUser.Userid != null) { MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _userService.CurrentUser.Userid.Value); } else { NavigationManager.NavigateTo("/LoginPages"); } } } private string GetStatistics(string strType) { try { if (strType != "ALL") { var tem = MyStatistics.Where(s => s.jxType == strType).FirstOrDefault(); if (tem != null) { return (tem.totalBasePoint.HasValue ? tem.totalBasePoint.Value.ToString("0.00") : ""); } else { return ""; } } else { return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00"); } } catch { return ""; } } private int serialNumber(int pageIndex, int pageSize, int id) { int iIndex = 0; foreach (PerformanceItem sf in _Datas) { iIndex++; if (sf.Id == id) { break; } } return (pageIndex - 1) * pageSize + iIndex; } private async Task HandleTableChange(QueryModel queryModel) { Console.WriteLine(JsonSerializer.Serialize(queryModel)); if (_CurrentKey == tabList[0].Key) { _loading = true; var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.doing, queryModel); _Datas = data.Results; _total = data.TotalCount; _loading = false; StateHasChanged(); } else { _loading = true; var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.finished, queryModel); _Datas = data.Results; _total = data.TotalCount; _loading = false; StateHasChanged(); } } private void OnsubShensu(PerformanceItem Item) { EditingItem = Item; _visible = true; //return new EventCallback(); } bool _ShowJXModal = false; private void OnJXCal(PerformanceItem Item) { EditingItem = Item; _ShowJXModal = true; } #region 申诉窗口事件 private void HandleOk(MouseEventArgs e) { Console.WriteLine(e); _visible = false; } private void HandleCancel(MouseEventArgs e) { Console.WriteLine(e); _visible = false; } #endregion #region 绩效计算窗口事件 private async Task HandleOk1(MouseEventArgs e) { _ShowJXModal = false; var respone = await _ItemService.SaveFieldChange(EditingItem.Id, $"{strAgentFeedbackMemo}|{strWordCount}", $"{_calType.AgentMemo}|{_calType.wordCount}"); var HandlingCalMonth = await _CalMonthService.GetHandlingMonth(); MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _userService.CurrentUser.Userid.Value); EditingItem.AgentFeedbackMemo = _calType.AgentMemo; StateHasChanged(); } private void HandleCancel1(MouseEventArgs e) { Console.WriteLine(e); _ShowJXModal = false; } #endregion public shensuType[] AvatarMenuItems { get; set; } = new shensuType[] { new() { ChangeField = "核稿人", Name = "核稿人申诉"}, new() { ChangeField = "处理人", Name = "处理人申诉"}, new() { ChangeField = "案件系数", Name = "案件系数申诉"}, new() { ChangeField = "处理事项系数", Name = "处理事项系数申诉"}, new() { Name = "严重超期说明"} }; private shensuType _SelectedItem; private void OnSelectedItemChangedHandler(shensuType value) { _SelectedItem = value; //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id); } CalType _calType = new CalType(); shenshou _shenshou = new shenshou(); List Reviewers = new List() { new Staff(){Id =1,Name ="钟子敏"}, new Staff(){Id =2,Name ="邢丽霞"}, new Staff(){Id =3,Name ="李丽"}, new Staff(){Id =4,Name ="贾凤涛"}, }; #region 特殊绩效字段选择框变更时处理代码 void SelectChanged(Reason value) { if (!_loading && EditingItem != null) { var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo); EditingItem = null; RefreshMyStatistics(); table.ReloadData(); } } void ClearSelect(int itemId) { Console.WriteLine($"ClearSelcet:{itemId}"); var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,""); EditingItem = null; RefreshMyStatistics(); table.ReloadData(); } #endregion Dictionary OnRow(RowData row) { Dictionary ret = new Dictionary(); ret.Add("onclick", ((Action)delegate { EditingItem = row.Data; })); return ret; } void OnFocus(PerformanceItem item) { EditingItem = item; } string _CurrentKey = "myList"; void OnTabChange(string key) { _CurrentKey = key; table.ReloadData(); StateHasChanged(); } private ModalRef _modalRef; [Inject] ModalService _ModalService { get; set; } [Inject]protected AppealTypeService _atService { get; set; } async Task ShowModel(PerformanceItem Item,AppealType appealType) { var templateOptions = new Models.CreateAppealModel(); Console.WriteLine($"Success:{JsonSerializer.Serialize(appealType)}"); await templateOptions.Init(_atService,Item, appealType); var modalConfig = new ModalOptions(); modalConfig.Title = appealType.Name; modalConfig.Footer = null; modalConfig.OnCancel = async (e) => { Console.WriteLine("OnCancel"); await _modalRef.CloseAsync(); }; modalConfig.AfterClose = () => { Console.WriteLine("AfterClose"); InvokeAsync(StateHasChanged); return Task.CompletedTask; }; _modalRef = await _ModalService .CreateModalAsync (modalConfig, templateOptions); _modalRef.OnOpen = () => { Console.WriteLine("ModalRef OnOpen"); return Task.CompletedTask; }; _modalRef.OnOk = () => { Console.WriteLine("ModalRef OnOk"); return Task.CompletedTask; }; _modalRef.OnCancel = () => { Console.WriteLine("ModalRef OnCancel"); return Task.CompletedTask; }; _modalRef.OnClose = () => { Console.WriteLine("ModalRef OnClose"); return Task.CompletedTask; }; StateHasChanged(); } } }