MyCaselist.razor.cs 13 KB

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