MyCaselist.razor.cs 14 KB

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