MyCaselist.razor.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. private string strAddProjectJX ="";
  59. protected async override Task OnInitializedAsync()
  60. {
  61. if (isFirstInit)
  62. {
  63. var Roles = await _authService.GetRoles("AddProjectJX");
  64. foreach(var role in Roles)
  65. {
  66. strAddProjectJX = (string.IsNullOrEmpty(strAddProjectJX)) ? role : $"{strAddProjectJX},{role}";
  67. }
  68. _loading = true;
  69. await RefreshMyStatistics();
  70. _Datas = new List<PerformanceItem>();// data.Results;
  71. _total = 0;//data.TotalCount;
  72. _loading = false;
  73. }
  74. isFirstInit = false;
  75. await apTypeService.GetItems();
  76. _user =await _userService.GetUser();
  77. StateHasChanged();
  78. }
  79. private async Task RefreshMyStatistics()
  80. {
  81. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  82. if (HandlingCalMonth != null)
  83. {
  84. var _user = await _userService.GetUser(); ;
  85. if (_user.Userid != null)
  86. {
  87. MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _user.Userid.Value);
  88. }
  89. else
  90. {
  91. NavigationManager.NavigateTo("/LoginPages");
  92. }
  93. }
  94. }
  95. private string GetStatistics(string strType)
  96. {
  97. try
  98. {
  99. if (strType != "ALL")
  100. {
  101. var tem = MyStatistics.Where<StaffStatistics>(s => s.jxType == strType).FirstOrDefault();
  102. if (tem != null)
  103. {
  104. return (tem.totalBasePoint.HasValue ? tem.totalBasePoint.Value.ToString("0.00") : "");
  105. }
  106. else
  107. {
  108. return "";
  109. }
  110. }
  111. else
  112. {
  113. return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
  114. }
  115. }
  116. catch
  117. {
  118. return "";
  119. }
  120. }
  121. private int serialNumber(int pageIndex, int pageSize, int id)
  122. {
  123. int iIndex = 0;
  124. foreach (PerformanceItem sf in _Datas)
  125. {
  126. iIndex++;
  127. if (sf.Id == id)
  128. {
  129. break;
  130. }
  131. }
  132. return (pageIndex - 1) * pageSize + iIndex;
  133. }
  134. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  135. {
  136. var _user = await _userService.GetUser();
  137. if (_CurrentKey == tabList[0].Key)
  138. {
  139. _loading = true;
  140. var data = await _ItemService.Query(_user.Userid.Value, jxType.doing, queryModel);
  141. _Datas = data.Results;
  142. _total = data.TotalCount;
  143. _loading = false;
  144. StateHasChanged();
  145. }
  146. else
  147. {
  148. _loading = true;
  149. var data = await _ItemService.Query(_user.Userid.Value, jxType.finished, queryModel);
  150. _Datas = data.Results;
  151. _total = data.TotalCount;
  152. _loading = false;
  153. StateHasChanged();
  154. }
  155. }
  156. private void OnsubShensu(PerformanceItem Item)
  157. {
  158. EditingItem = Item;
  159. _visible = true;
  160. //return new EventCallback();
  161. }
  162. bool _ShowJXModal = false;
  163. private void OnJXCal(PerformanceItem Item)
  164. {
  165. EditingItem = Item;
  166. _ShowJXModal = true;
  167. }
  168. private shensuType _SelectedItem;
  169. private void OnSelectedItemChangedHandler(shensuType value)
  170. {
  171. _SelectedItem = value;
  172. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  173. }
  174. #region 特殊绩效字段选择框变更时处理代码
  175. void SelectChanged(Reason value)
  176. {
  177. if (!_loading && EditingItem != null)
  178. {
  179. var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  180. EditingItem = null;
  181. _ = RefreshMyStatistics();
  182. table.ReloadData();
  183. }
  184. }
  185. void ClearSelect(int itemId)
  186. {
  187. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  188. EditingItem = null;
  189. _ = RefreshMyStatistics();
  190. table.ReloadData();
  191. }
  192. #endregion
  193. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  194. {
  195. Dictionary<string, object> ret = new Dictionary<string, object>();
  196. ret.Add("onclick", ((Action)delegate
  197. {
  198. EditingItem = row.Data;
  199. }));
  200. return ret;
  201. }
  202. void OnFocus(PerformanceItem item)
  203. {
  204. EditingItem = item;
  205. }
  206. string _CurrentKey = "myList";
  207. void OnTabChange(string key)
  208. {
  209. _CurrentKey = key;
  210. table.ReloadData();
  211. StateHasChanged();
  212. }
  213. private ModalRef _modalRef;
  214. [Inject] ModalService _ModalService { get; set; }
  215. [Inject]protected AppealTypeService _atService { get; set; }
  216. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  217. {
  218. var templateOptions = new Models.CreateAppealModel();
  219. await templateOptions.Init(_atService,Item, appealType);
  220. var modalConfig = new ModalOptions();
  221. modalConfig.Title = appealType.Name;
  222. modalConfig.Width = 650;
  223. //modalConfig.Footer = null;
  224. modalConfig.DestroyOnClose = true;
  225. _modalRef = await _ModalService
  226. .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
  227. _modalRef.OnOpen = () =>
  228. {
  229. return Task.CompletedTask;
  230. };
  231. _modalRef.OnOk = async () =>
  232. {
  233. try
  234. {
  235. await _atService.CreateAppeal(templateOptions);
  236. await _modalRef.CloseAsync();
  237. StateHasChanged();
  238. var SuccessConfig = new ConfirmOptions()
  239. {
  240. Content = @"保存申诉信息成功!"
  241. };
  242. //modalConfig.Footer = null;
  243. modalConfig.DestroyOnClose = true;
  244. _ModalService.Success(SuccessConfig);
  245. }
  246. catch (Exception ex)
  247. {
  248. _ModalService.Error(new ConfirmOptions()
  249. {
  250. Title = "保存申诉信息错误",
  251. Content = ex.Message,
  252. });
  253. //_ErrorMessage = ex.Message;
  254. }
  255. //return Task.CompletedTask;
  256. };
  257. _modalRef.OnCancel = () =>
  258. {
  259. return Task.CompletedTask;
  260. };
  261. _modalRef.OnClose = () =>
  262. {
  263. return Task.CompletedTask;
  264. };
  265. StateHasChanged();
  266. }
  267. void goAssignPoint()
  268. {
  269. NavigationManager.NavigateTo("/Project/AssignPoint");
  270. }
  271. }
  272. }