MyCaselist.razor.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. int DoingOrReview = 0;
  47. List<TabPaneItem> tabList = new List<TabPaneItem>() {
  48. new TabPaneItem(){ Key ="myListDoing", Tab ="本月待确认绩效" },
  49. new TabPaneItem(){ Key ="myAll", Tab ="往期已计算绩效"},
  50. };
  51. [Inject] public PerformanceItemServices _ItemService { get; set; }
  52. [Inject] public MessageService _message { get; set; }
  53. [Inject] protected NavigationManager NavigationManager { get; set; }
  54. [Inject] protected IUserService _userService { get; set; }
  55. [Inject] protected CalMonthServices _CalMonthService { get; set; }
  56. [Inject] protected IJSRuntime JSRuntime { get; set; }
  57. [Inject] IConfiguration configuration{get;set;}
  58. private bool isFirstInit = true;
  59. private Table<PerformanceItem> table;
  60. private CurrentUser _user;
  61. private string strAddProjectJX = "";
  62. class SelectItem
  63. {
  64. public int Value { get; set; }
  65. public string Name { get; set; }
  66. }
  67. List<SelectItem> _Items = new List<SelectItem>()
  68. {
  69. new SelectItem(){Value =0,Name ="我处理的案件"},
  70. new SelectItem(){Value =1,Name ="我审核的案件"}
  71. };
  72. private void OnSelectedItemChangedHandler(SelectItem value)
  73. {
  74. //_selectedItem = value;
  75. //Console.WriteLine($"selected: ${value?.Name}");
  76. table.ReloadData();
  77. StateHasChanged();
  78. }
  79. protected async override Task OnInitializedAsync()
  80. {
  81. if (isFirstInit)
  82. {
  83. _loading = true;
  84. await RefreshMyStatistics();
  85. _Datas = new List<PerformanceItem>();// data.Results;
  86. _total = 0;//data.TotalCount;
  87. _loading = false;
  88. }
  89. isFirstInit = false;
  90. await apTypeService.GetItems();
  91. _user = await _userService.GetUser();
  92. StateHasChanged();
  93. }
  94. private bool ShowMenu()
  95. {
  96. var strlfd = configuration.GetValue<string>("Latest_feedback_date");
  97. if (string.IsNullOrEmpty(strlfd))
  98. {
  99. return true;
  100. }
  101. else
  102. {
  103. if(DateTime.Now.Day <= int.Parse(strlfd))
  104. {
  105. return true;
  106. }
  107. else
  108. {
  109. return false;
  110. }
  111. }
  112. }
  113. private async Task RefreshMyStatistics()
  114. {
  115. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  116. if (HandlingCalMonth != null)
  117. {
  118. var _user = await _userService.GetUser(); ;
  119. if (_user.Userid != null)
  120. {
  121. MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _user.Userid.Value);
  122. }
  123. else
  124. {
  125. NavigationManager.NavigateTo("/LoginPages");
  126. }
  127. }
  128. }
  129. private string GetStatistics(string strType, bool isBasePoint = false)
  130. {
  131. try
  132. {
  133. if (strType != "ALL")
  134. {
  135. var tem = MyStatistics.Where<StaffStatistics>(s => s.jxType == strType).FirstOrDefault();
  136. if (isBasePoint)
  137. {
  138. if (tem != null)
  139. {
  140. return (tem.totalBasePoint.HasValue ? tem.totalBasePoint.Value.ToString("0.00") : "");
  141. }
  142. else
  143. {
  144. return "";
  145. }
  146. }
  147. else
  148. {
  149. if (tem != null)
  150. {
  151. return (tem.totalActuallyPoint.HasValue ? tem.totalActuallyPoint.Value.ToString("0.00") : "");
  152. }
  153. else
  154. {
  155. return "";
  156. }
  157. }
  158. }
  159. else
  160. {
  161. if (isBasePoint)
  162. {
  163. return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
  164. }
  165. else
  166. {
  167. return MyStatistics.Select(s => s.totalActuallyPoint.Value).Sum().ToString("0.00");
  168. }
  169. }
  170. }
  171. catch
  172. {
  173. return "";
  174. }
  175. }
  176. private int serialNumber(int pageIndex, int pageSize, int id)
  177. {
  178. int iIndex = 0;
  179. foreach (PerformanceItem sf in _Datas)
  180. {
  181. iIndex++;
  182. if (sf.Id == id)
  183. {
  184. break;
  185. }
  186. }
  187. return (pageIndex - 1) * pageSize + iIndex;
  188. }
  189. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  190. {
  191. var _user = await _userService.GetUser();
  192. if (_CurrentKey == tabList[0].Key)
  193. {
  194. _loading = true;
  195. var data = await _ItemService.Query(_user.Userid.Value, jxType.doing, queryModel, DoingOrReview);
  196. _Datas = data.Results;
  197. _total = data.TotalCount;
  198. _loading = false;
  199. StateHasChanged();
  200. }
  201. else
  202. {
  203. _loading = true;
  204. var data = await _ItemService.Query(_user.Userid.Value, jxType.finished, queryModel,DoingOrReview);
  205. _Datas = data.Results;
  206. _total = data.TotalCount;
  207. _loading = false;
  208. StateHasChanged();
  209. }
  210. }
  211. [Inject] IConfiguration _configuration { get; set; }
  212. bool isDownloading = false;
  213. private async Task ExportDataAsync(jxType jxType)
  214. {
  215. isDownloading = true;
  216. var fileData =await _ItemService.ExportData(_user.Userid.Value, jxType,DoingOrReview);
  217. while(!fileData.Finished)
  218. {
  219. fileData =await _ItemService.getExportDataProcessing(fileData.Id);
  220. await Task.Delay(20);
  221. }
  222. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  223. isDownloading = false;
  224. }
  225. bool _visible = false;
  226. private void OnsubShensu(PerformanceItem Item)
  227. {
  228. EditingItem = Item;
  229. _visible = true;
  230. //return new EventCallback();
  231. }
  232. bool _ShowJXModal = false;
  233. private void OnJXCal(PerformanceItem Item)
  234. {
  235. EditingItem = Item;
  236. _ShowJXModal = true;
  237. }
  238. private async void menuYSJXClick(PerformanceItem Item)
  239. {
  240. var respone = await _ItemService.SaveFieldChange(Item.Id, strAgentFeedbackMemo, "已算绩效");
  241. var item = await _ItemService.GetPerformancItem(Item.Id);
  242. Item.BasePoint = item.BasePoint;
  243. _ = RefreshMyStatistics();
  244. }
  245. private shensuType _SelectedItem;
  246. private void OnSelectedItemChangedHandler(shensuType value)
  247. {
  248. _SelectedItem = value;
  249. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  250. }
  251. #region 特殊绩效字段选择框变更时处理代码
  252. async void SelectChanged(Reason value)
  253. {
  254. if (!_loading && EditingItem != null)
  255. {
  256. var respone =await _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  257. var item = await _ItemService.GetPerformancItem(EditingItem.Id) ;
  258. EditingItem.BasePoint = item.BasePoint;
  259. _ = RefreshMyStatistics();
  260. EditingItem = null;
  261. //table.ReloadData();
  262. }
  263. }
  264. void ClearSelect(int itemId)
  265. {
  266. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  267. EditingItem = null;
  268. _ = RefreshMyStatistics();
  269. table.ReloadData();
  270. }
  271. #endregion
  272. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  273. {
  274. Dictionary<string, object> ret = new Dictionary<string, object>();
  275. ret.Add("onclick", ((Action)delegate
  276. {
  277. EditingItem = row.Data;
  278. }));
  279. return ret;
  280. }
  281. void OnFocus(PerformanceItem item)
  282. {
  283. EditingItem = item;
  284. }
  285. string _CurrentKey = "myListDoing";
  286. void OnTabChange(string key)
  287. {
  288. _CurrentKey = key;
  289. table.ReloadData();
  290. StateHasChanged();
  291. }
  292. private ModalRef _modalRef;
  293. [Inject] ModalService _ModalService { get; set; }
  294. [Inject]protected AppealTypeService _atService { get; set; }
  295. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  296. {
  297. var templateOptions = new Models.CreateAppealModel();
  298. await templateOptions.Init(_atService,Item, appealType);
  299. var modalConfig = new ModalOptions();
  300. modalConfig.Title = appealType.Name;
  301. modalConfig.Width = 650;
  302. //modalConfig.Footer = null;
  303. modalConfig.DestroyOnClose = true;
  304. modalConfig.MaskClosable = false;
  305. _modalRef = await _ModalService
  306. .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
  307. _modalRef.OnOpen = () =>
  308. {
  309. return Task.CompletedTask;
  310. };
  311. _modalRef.OnOk = async () =>
  312. {
  313. try
  314. {
  315. await _atService.CreateAppeal(templateOptions);
  316. await _modalRef.CloseAsync();
  317. StateHasChanged();
  318. var SuccessConfig = new ConfirmOptions()
  319. {
  320. Content = @"保存申诉信息成功!"
  321. };
  322. //modalConfig.Footer = null;
  323. modalConfig.DestroyOnClose = true;
  324. _ModalService.Success(SuccessConfig);
  325. }
  326. catch (Exception ex)
  327. {
  328. _ModalService.Error(new ConfirmOptions()
  329. {
  330. Title = "保存申诉信息错误",
  331. Content = ex.Message,
  332. });
  333. //_ErrorMessage = ex.Message;
  334. }
  335. //return Task.CompletedTask;
  336. };
  337. _modalRef.OnCancel = () =>
  338. {
  339. return Task.CompletedTask;
  340. };
  341. _modalRef.OnClose = () =>
  342. {
  343. return Task.CompletedTask;
  344. };
  345. StateHasChanged();
  346. }
  347. }
  348. }