MyCaselist.razor.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. if (_CurrentKey == tabList[0].Key)
  128. {
  129. _loading = true;
  130. var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.doing, queryModel);
  131. _Datas = data.Results;
  132. _total = data.TotalCount;
  133. _loading = false;
  134. StateHasChanged();
  135. }
  136. else
  137. {
  138. _loading = true;
  139. var data = await _ItemService.Query(_userService.CurrentUser.Userid.Value, jxType.finished, queryModel);
  140. _Datas = data.Results;
  141. _total = data.TotalCount;
  142. _loading = false;
  143. StateHasChanged();
  144. }
  145. }
  146. private void OnsubShensu(PerformanceItem Item)
  147. {
  148. EditingItem = Item;
  149. _visible = true;
  150. //return new EventCallback();
  151. }
  152. bool _ShowJXModal = false;
  153. private void OnJXCal(PerformanceItem Item)
  154. {
  155. EditingItem = Item;
  156. _ShowJXModal = true;
  157. }
  158. private shensuType _SelectedItem;
  159. private void OnSelectedItemChangedHandler(shensuType value)
  160. {
  161. _SelectedItem = value;
  162. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  163. }
  164. #region 特殊绩效字段选择框变更时处理代码
  165. void SelectChanged(Reason value)
  166. {
  167. if (!_loading && EditingItem != null)
  168. {
  169. var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  170. EditingItem = null;
  171. _ = RefreshMyStatistics();
  172. table.ReloadData();
  173. }
  174. }
  175. void ClearSelect(int itemId)
  176. {
  177. //Console.WriteLine($"ClearSelcet:{itemId}");
  178. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  179. EditingItem = null;
  180. _ = RefreshMyStatistics();
  181. table.ReloadData();
  182. }
  183. #endregion
  184. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  185. {
  186. Dictionary<string, object> ret = new Dictionary<string, object>();
  187. ret.Add("onclick", ((Action)delegate
  188. {
  189. EditingItem = row.Data;
  190. }));
  191. return ret;
  192. }
  193. void OnFocus(PerformanceItem item)
  194. {
  195. EditingItem = item;
  196. }
  197. string _CurrentKey = "myList";
  198. void OnTabChange(string key)
  199. {
  200. _CurrentKey = key;
  201. table.ReloadData();
  202. StateHasChanged();
  203. }
  204. private ModalRef _modalRef;
  205. [Inject] ModalService _ModalService { get; set; }
  206. [Inject]protected AppealTypeService _atService { get; set; }
  207. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  208. {
  209. var templateOptions = new Models.CreateAppealModel();
  210. await templateOptions.Init(_atService,Item, appealType);
  211. Console.WriteLine(JsonSerializer.Serialize(templateOptions));
  212. var modalConfig = new ModalOptions();
  213. modalConfig.Title = appealType.Name;
  214. modalConfig.Width = 650;
  215. //modalConfig.Footer = null;
  216. modalConfig.DestroyOnClose = true;
  217. _modalRef = await _ModalService
  218. .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
  219. _modalRef.OnOpen = () =>
  220. {
  221. Console.WriteLine("ModalRef OnOpen");
  222. return Task.CompletedTask;
  223. };
  224. _modalRef.OnOk = async () =>
  225. {
  226. Console.WriteLine(JsonSerializer.Serialize(templateOptions));
  227. try
  228. {
  229. await _atService.CreateAppeal(templateOptions);
  230. await _modalRef.CloseAsync();
  231. }
  232. catch (Exception ex)
  233. {
  234. //_ErrorMessage = ex.Message;
  235. }
  236. //return Task.CompletedTask;
  237. };
  238. _modalRef.OnCancel = () =>
  239. {
  240. Console.WriteLine("ModalRef OnCancel");
  241. return Task.CompletedTask;
  242. };
  243. _modalRef.OnClose = () =>
  244. {
  245. Console.WriteLine("ModalRef OnClose");
  246. return Task.CompletedTask;
  247. };
  248. StateHasChanged();
  249. }
  250. }
  251. }