MyCaselist.razor.cs 11 KB

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