MyCaselist.razor.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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.Models;
  15. using wispro.sp.web.Services;
  16. namespace wispro.sp.web.Pages.AppCase
  17. {
  18. [Authorize]
  19. public partial class MyCaselist
  20. {
  21. const string strAgentFeedbackMemo = "AgentFeedbackMemo";
  22. const string strDoItemCoefficient = "DoItemCoefficient";
  23. const string strReturnCasseNo = "ReturnCasseNo";
  24. const string strCaseCoefficient = "CaseCoefficient";
  25. const string strWordCount = "WordCount";
  26. public TableFilter<string>[] CaseCoeFilters = new TableFilter<string>[] {
  27. new() { Text = "S", Value = "S" },
  28. new() { Text = "A", Value = "A" },
  29. new() { Text = "B", Value = "B" },
  30. new() { Text = "C", Value = "C" },
  31. new() { Text = "D", Value = "D" }
  32. };
  33. [Inject]
  34. protected AppealTypeService apTypeService { get; set; }
  35. private List<PerformanceItem> _Datas;
  36. private List<StaffStatistics> MyStatistics;
  37. IEnumerable<PerformanceItem> selectedItems= new List<PerformanceItem>();
  38. private CalMonth HandlingCalMonth;
  39. int _pageIndex = 1;
  40. int _pageSize = 10;
  41. int _total;
  42. bool _loading = false;
  43. PerformanceItem EditingItem = null;
  44. bool _visible = false;
  45. bool _isAdd = false;
  46. List<TabPaneItem> tabList = new List<TabPaneItem>() {
  47. new TabPaneItem(){ Key ="myList", Tab ="本月待确认绩效" },
  48. new TabPaneItem(){ Key ="myAll", Tab ="往期已计算绩效"},
  49. };
  50. [Inject] public PerformanceItemServices _ItemService { get; set; }
  51. [Inject] public MessageService _message { get; set; }
  52. [Inject] protected NavigationManager NavigationManager { get; set; }
  53. [Inject] protected IUserService _userService { get; set; }
  54. [Inject] protected CalMonthServices _CalMonthService { get; set; }
  55. private bool isFirstInit = true;
  56. private Table<PerformanceItem> table;
  57. private CurrentUser _user;
  58. protected async override Task OnInitializedAsync()
  59. {
  60. if (isFirstInit)
  61. {
  62. _loading = true;
  63. await RefreshMyStatistics();
  64. _Datas = new List<PerformanceItem>();// data.Results;
  65. _total = 0;//data.TotalCount;
  66. _loading = false;
  67. }
  68. isFirstInit = false;
  69. await apTypeService.GetItems();
  70. _user =await _userService.GetUser();
  71. StateHasChanged();
  72. }
  73. private async Task RefreshMyStatistics()
  74. {
  75. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  76. if (HandlingCalMonth != null)
  77. {
  78. var _user = await _userService.GetUser(); ;
  79. if (_user.Userid != null)
  80. {
  81. MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _user.Userid.Value);
  82. }
  83. else
  84. {
  85. NavigationManager.NavigateTo("/LoginPages");
  86. }
  87. }
  88. }
  89. private string GetStatistics(string strType)
  90. {
  91. try
  92. {
  93. if (strType != "ALL")
  94. {
  95. var tem = MyStatistics.Where<StaffStatistics>(s => s.jxType == strType).FirstOrDefault();
  96. if (tem != null)
  97. {
  98. return (tem.totalBasePoint.HasValue ? tem.totalBasePoint.Value.ToString("0.00") : "");
  99. }
  100. else
  101. {
  102. return "";
  103. }
  104. }
  105. else
  106. {
  107. return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
  108. }
  109. }
  110. catch
  111. {
  112. return "";
  113. }
  114. }
  115. private int serialNumber(int pageIndex, int pageSize, int id)
  116. {
  117. int iIndex = 0;
  118. foreach (PerformanceItem sf in _Datas)
  119. {
  120. iIndex++;
  121. if (sf.Id == id)
  122. {
  123. break;
  124. }
  125. }
  126. return (pageIndex - 1) * pageSize + iIndex;
  127. }
  128. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  129. {
  130. var _user = await _userService.GetUser();
  131. if (_CurrentKey == tabList[0].Key)
  132. {
  133. _loading = true;
  134. var data = await _ItemService.Query(_user.Userid.Value, jxType.doing, queryModel);
  135. _Datas = data.Results;
  136. _total = data.TotalCount;
  137. _loading = false;
  138. StateHasChanged();
  139. }
  140. else
  141. {
  142. _loading = true;
  143. var data = await _ItemService.Query(_user.Userid.Value, jxType.finished, queryModel);
  144. _Datas = data.Results;
  145. _total = data.TotalCount;
  146. _loading = false;
  147. StateHasChanged();
  148. }
  149. }
  150. private void OnsubShensu(PerformanceItem Item)
  151. {
  152. EditingItem = Item;
  153. _visible = true;
  154. //return new EventCallback();
  155. }
  156. bool _ShowJXModal = false;
  157. private void OnJXCal(PerformanceItem Item)
  158. {
  159. EditingItem = Item;
  160. _ShowJXModal = true;
  161. }
  162. private shensuType _SelectedItem;
  163. private void OnSelectedItemChangedHandler(shensuType value)
  164. {
  165. _SelectedItem = value;
  166. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  167. }
  168. #region 特殊绩效字段选择框变更时处理代码
  169. void SelectChanged(Reason value)
  170. {
  171. if (!_loading && EditingItem != null)
  172. {
  173. var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  174. EditingItem = null;
  175. _ = RefreshMyStatistics();
  176. table.ReloadData();
  177. }
  178. }
  179. void ClearSelect(int itemId)
  180. {
  181. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  182. EditingItem = null;
  183. _ = RefreshMyStatistics();
  184. table.ReloadData();
  185. }
  186. #endregion
  187. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  188. {
  189. Dictionary<string, object> ret = new Dictionary<string, object>();
  190. ret.Add("onclick", ((Action)delegate
  191. {
  192. EditingItem = row.Data;
  193. }));
  194. return ret;
  195. }
  196. void OnFocus(PerformanceItem item)
  197. {
  198. EditingItem = item;
  199. }
  200. string _CurrentKey = "myList";
  201. void OnTabChange(string key)
  202. {
  203. _CurrentKey = key;
  204. table.ReloadData();
  205. StateHasChanged();
  206. }
  207. private ModalRef _modalRef;
  208. [Inject] ModalService _ModalService { get; set; }
  209. [Inject]protected AppealTypeService _atService { get; set; }
  210. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  211. {
  212. var templateOptions = new Models.CreateAppealModel();
  213. await templateOptions.Init(_atService,Item, appealType);
  214. var modalConfig = new ModalOptions();
  215. modalConfig.Title = appealType.Name;
  216. modalConfig.Width = 650;
  217. //modalConfig.Footer = null;
  218. modalConfig.DestroyOnClose = true;
  219. _modalRef = await _ModalService
  220. .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
  221. _modalRef.OnOpen = () =>
  222. {
  223. return Task.CompletedTask;
  224. };
  225. _modalRef.OnOk = async () =>
  226. {
  227. try
  228. {
  229. await _atService.CreateAppeal(templateOptions);
  230. await _modalRef.CloseAsync();
  231. StateHasChanged();
  232. var SuccessConfig = new ConfirmOptions()
  233. {
  234. Content = @"保存申诉信息成功!"
  235. };
  236. //modalConfig.Footer = null;
  237. modalConfig.DestroyOnClose = true;
  238. _ModalService.Success(SuccessConfig);
  239. }
  240. catch (Exception ex)
  241. {
  242. _ModalService.Error(new ConfirmOptions()
  243. {
  244. Title = "保存申诉信息错误",
  245. Content = ex.Message,
  246. });
  247. //_ErrorMessage = ex.Message;
  248. }
  249. //return Task.CompletedTask;
  250. };
  251. _modalRef.OnCancel = () =>
  252. {
  253. return Task.CompletedTask;
  254. };
  255. _modalRef.OnClose = () =>
  256. {
  257. return Task.CompletedTask;
  258. };
  259. StateHasChanged();
  260. }
  261. void goAssignPoint()
  262. {
  263. NavigationManager.NavigateTo("/Project/AssignPoint");
  264. }
  265. }
  266. }