MyCaselist.razor.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using AntDesign;
  2. using AntDesign.ProLayout;
  3. using AntDesign.TableModels;
  4. using Microsoft.AspNetCore.Authorization;
  5. using Microsoft.AspNetCore.Components;
  6. using Microsoft.AspNetCore.Components.Web;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text.Json;
  11. using System.Threading.Tasks;
  12. using wispro.sp.entity;
  13. using wispro.sp.share;
  14. using wispro.sp.web.Services;
  15. namespace wispro.sp.web.Pages.AppCase
  16. {
  17. [Authorize]
  18. public partial class MyCaselist
  19. {
  20. const string strAgentFeedbackMemo = "AgentFeedbackMemo";
  21. const string strDoItemCoefficient = "DoItemCoefficient";
  22. const string strReturnCasseNo = "ReturnCasseNo";
  23. const string strCaseCoefficient = "CaseCoefficient";
  24. const string strWordCount = "WordCount";
  25. public TableFilter<string>[] CaseCoeFilters = new TableFilter<string>[] {
  26. new() { Text = "S", Value = "S" },
  27. new() { Text = "A", Value = "A" },
  28. new() { Text = "B", Value = "B" },
  29. new() { Text = "C", Value = "C" },
  30. new() { Text = "D", Value = "D" }
  31. };
  32. [Inject]
  33. protected AppealTypeService apTypeService { get; set; }
  34. private List<PerformanceItem> _Datas;
  35. private List<StaffStatistics> MyStatistics;
  36. IEnumerable<PerformanceItem> selectedItems= new List<PerformanceItem>();
  37. private CalMonth HandlingCalMonth;
  38. int _pageIndex = 1;
  39. int _pageSize = 10;
  40. int _total;
  41. bool _loading = false;
  42. PerformanceItem EditingItem = null;
  43. bool _visible = false;
  44. bool _isAdd = false;
  45. List<TabPaneItem> tabList = new List<TabPaneItem>() {
  46. new TabPaneItem(){ Key ="myList", Tab ="本月待确认绩效" },
  47. new TabPaneItem(){ Key ="myAll", Tab ="往期已计算绩效"},
  48. };
  49. [Inject] public PerformanceItemServices _ItemService { get; set; }
  50. [Inject] public MessageService _message { get; set; }
  51. [Inject] protected NavigationManager NavigationManager { get; set; }
  52. [Inject] protected IUserService _userService { get; set; }
  53. [Inject] protected CalMonthServices _CalMonthService { get; set; }
  54. private bool isFirstInit = true;
  55. private Table<PerformanceItem> table;
  56. protected async override Task OnInitializedAsync()
  57. {
  58. if (isFirstInit)
  59. {
  60. _loading = true;
  61. await RefreshMyStatistics();
  62. _Datas = new List<PerformanceItem>();// data.Results;
  63. _total = 0;//data.TotalCount;
  64. _loading = false;
  65. }
  66. isFirstInit = false;
  67. await apTypeService.GetItems();
  68. StateHasChanged();
  69. //Console.WriteLine($"OnInitializedAsync:[tota:{_total}\tPageIndex:{_pageIndex}\tPageSize:{_pageSize}]");
  70. }
  71. private async Task RefreshMyStatistics()
  72. {
  73. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  74. if (HandlingCalMonth != null)
  75. {
  76. if (_userService.CurrentUser.Userid != null)
  77. {
  78. MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _userService.CurrentUser.Userid.Value);
  79. }
  80. else
  81. {
  82. NavigationManager.NavigateTo("/LoginPages");
  83. }
  84. }
  85. }
  86. private string GetStatistics(string strType)
  87. {
  88. try
  89. {
  90. if (strType != "ALL")
  91. {
  92. var tem = MyStatistics.Where<StaffStatistics>(s => s.jxType == strType).FirstOrDefault();
  93. if (tem != null)
  94. {
  95. return (tem.totalBasePoint.HasValue ? tem.totalBasePoint.Value.ToString("0.00") : "");
  96. }
  97. else
  98. {
  99. return "";
  100. }
  101. }
  102. else
  103. {
  104. return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
  105. }
  106. }
  107. catch
  108. {
  109. return "";
  110. }
  111. }
  112. private int serialNumber(int pageIndex, int pageSize, int id)
  113. {
  114. int iIndex = 0;
  115. foreach (PerformanceItem sf in _Datas)
  116. {
  117. iIndex++;
  118. if (sf.Id == id)
  119. {
  120. break;
  121. }
  122. }
  123. return (pageIndex - 1) * pageSize + iIndex;
  124. }
  125. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  126. {
  127. Console.WriteLine(JsonSerializer.Serialize(queryModel));
  128. if (_CurrentKey == tabList[0].Key)
  129. {
  130. _loading = true;
  131. var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.doing, queryModel);
  132. _Datas = data.Results;
  133. _total = data.TotalCount;
  134. _loading = false;
  135. StateHasChanged();
  136. }
  137. else
  138. {
  139. _loading = true;
  140. var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.finished, queryModel);
  141. _Datas = data.Results;
  142. _total = data.TotalCount;
  143. _loading = false;
  144. StateHasChanged();
  145. }
  146. }
  147. private void OnsubShensu(PerformanceItem Item)
  148. {
  149. EditingItem = Item;
  150. _visible = true;
  151. //return new EventCallback();
  152. }
  153. bool _ShowJXModal = false;
  154. private void OnJXCal(PerformanceItem Item)
  155. {
  156. EditingItem = Item;
  157. _ShowJXModal = true;
  158. }
  159. #region 申诉窗口事件
  160. private void HandleOk(MouseEventArgs e)
  161. {
  162. Console.WriteLine(e);
  163. _visible = false;
  164. }
  165. private void HandleCancel(MouseEventArgs e)
  166. {
  167. Console.WriteLine(e);
  168. _visible = false;
  169. }
  170. #endregion
  171. #region 绩效计算窗口事件
  172. private async Task HandleOk1(MouseEventArgs e)
  173. {
  174. _ShowJXModal = false;
  175. var respone = await _ItemService.SaveFieldChange(EditingItem.Id, $"{strAgentFeedbackMemo}|{strWordCount}", $"{_calType.AgentMemo}|{_calType.wordCount}");
  176. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  177. MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _userService.CurrentUser.Userid.Value);
  178. EditingItem.AgentFeedbackMemo = _calType.AgentMemo;
  179. StateHasChanged();
  180. }
  181. private void HandleCancel1(MouseEventArgs e)
  182. {
  183. Console.WriteLine(e);
  184. _ShowJXModal = false;
  185. }
  186. #endregion
  187. public shensuType[] AvatarMenuItems { get; set; } = new shensuType[]
  188. {
  189. new() { ChangeField = "核稿人", Name = "核稿人申诉"},
  190. new() { ChangeField = "处理人", Name = "处理人申诉"},
  191. new() { ChangeField = "案件系数", Name = "案件系数申诉"},
  192. new() { ChangeField = "处理事项系数", Name = "处理事项系数申诉"},
  193. new() { Name = "严重超期说明"}
  194. };
  195. private shensuType _SelectedItem;
  196. private void OnSelectedItemChangedHandler(shensuType value)
  197. {
  198. _SelectedItem = value;
  199. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  200. }
  201. CalType _calType = new CalType();
  202. shenshou _shenshou = new shenshou();
  203. List<Staff> Reviewers = new List<Staff>()
  204. {
  205. new Staff(){Id =1,Name ="钟子敏"},
  206. new Staff(){Id =2,Name ="邢丽霞"},
  207. new Staff(){Id =3,Name ="李丽"},
  208. new Staff(){Id =4,Name ="贾凤涛"},
  209. };
  210. #region 特殊绩效字段选择框变更时处理代码
  211. void SelectChanged(Reason value)
  212. {
  213. if (!_loading && EditingItem != null)
  214. {
  215. var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  216. EditingItem = null;
  217. RefreshMyStatistics();
  218. table.ReloadData();
  219. }
  220. }
  221. void ClearSelect(int itemId)
  222. {
  223. Console.WriteLine($"ClearSelcet:{itemId}");
  224. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  225. EditingItem = null;
  226. RefreshMyStatistics();
  227. table.ReloadData();
  228. }
  229. #endregion
  230. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  231. {
  232. Dictionary<string, object> ret = new Dictionary<string, object>();
  233. ret.Add("onclick", ((Action)delegate
  234. {
  235. EditingItem = row.Data;
  236. }));
  237. return ret;
  238. }
  239. void OnFocus(PerformanceItem item)
  240. {
  241. EditingItem = item;
  242. }
  243. string _CurrentKey = "myList";
  244. void OnTabChange(string key)
  245. {
  246. _CurrentKey = key;
  247. table.ReloadData();
  248. StateHasChanged();
  249. }
  250. private ModalRef _modalRef;
  251. [Inject] ModalService _ModalService { get; set; }
  252. [Inject]protected AppealTypeService _atService { get; set; }
  253. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  254. {
  255. var templateOptions = new Models.CreateAppealModel();
  256. Console.WriteLine($"Success:{JsonSerializer.Serialize(appealType)}");
  257. await templateOptions.Init(_atService,Item, appealType);
  258. var modalConfig = new ModalOptions();
  259. modalConfig.Title = appealType.Name;
  260. modalConfig.Footer = null;
  261. modalConfig.OnCancel = async (e) =>
  262. {
  263. Console.WriteLine("OnCancel");
  264. await _modalRef.CloseAsync();
  265. };
  266. modalConfig.AfterClose = () =>
  267. {
  268. Console.WriteLine("AfterClose");
  269. InvokeAsync(StateHasChanged);
  270. return Task.CompletedTask;
  271. };
  272. _modalRef = await _ModalService
  273. .CreateModalAsync<Components.CreateAppeal , Models.CreateAppealModel>
  274. (modalConfig, templateOptions);
  275. _modalRef.OnOpen = () =>
  276. {
  277. Console.WriteLine("ModalRef OnOpen");
  278. return Task.CompletedTask;
  279. };
  280. _modalRef.OnOk = () =>
  281. {
  282. Console.WriteLine("ModalRef OnOk");
  283. return Task.CompletedTask;
  284. };
  285. _modalRef.OnCancel = () =>
  286. {
  287. Console.WriteLine("ModalRef OnCancel");
  288. return Task.CompletedTask;
  289. };
  290. _modalRef.OnClose = () =>
  291. {
  292. Console.WriteLine("ModalRef OnClose");
  293. return Task.CompletedTask;
  294. };
  295. StateHasChanged();
  296. }
  297. }
  298. }