MyCaselist.razor.cs 12 KB

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