MyCaselist.razor.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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.IO;
  12. using System.Linq;
  13. using System.Text.Json;
  14. using System.Threading.Tasks;
  15. using wispro.sp.entity;
  16. using wispro.sp.share;
  17. using wispro.sp.web.Models;
  18. using wispro.sp.web.Services;
  19. using static Microsoft.AspNetCore.Hosting.Internal.HostingApplication;
  20. namespace wispro.sp.web.Pages.AppCase
  21. {
  22. [Authorize]
  23. public partial class MyCaselist
  24. {
  25. const string strAgentFeedbackMemo = "AgentFeedbackMemo";
  26. const string strDoItemCoefficient = "DoItemCoefficient";
  27. const string strReturnCasseNo = "ReturnCasseNo";
  28. const string strCaseCoefficient = "CaseCoefficient";
  29. const string strWordCount = "WordCount";
  30. public TableFilter<string>[] CaseCoeFilters = new TableFilter<string>[] {
  31. new() { Text = "S", Value = "S" },
  32. new() { Text = "A", Value = "A" },
  33. new() { Text = "B", Value = "B" },
  34. new() { Text = "C", Value = "C" },
  35. new() { Text = "D", Value = "D" }
  36. };
  37. [Inject]
  38. protected AppealTypeService apTypeService { get; set; }
  39. private List<CalMonth> calMonthList;
  40. private List<PerformanceItem> _Datas;
  41. private List<StaffStatistics> MyStatistics;
  42. IEnumerable<PerformanceItem> selectedItems = new List<PerformanceItem>();
  43. private CalMonth HandlingCalMonth;
  44. int _pageIndex = 1;
  45. int _pageSize = 10;
  46. int _total;
  47. bool _loading = false;
  48. PerformanceItem EditingItem = null;
  49. int DoingOrReview = 0;
  50. int SelectedCalMonthId = 0;
  51. List<TabPaneItem> tabList = new List<TabPaneItem>() {
  52. new TabPaneItem(){ Key ="myListDoing", Tab ="本月待确认绩效" },
  53. new TabPaneItem(){ Key ="myAll", Tab ="往期已计算绩效"},
  54. };
  55. [Inject] public PerformanceItemServices _ItemService { get; set; }
  56. [Inject] public MessageService _message { get; set; }
  57. [Inject] protected NavigationManager NavigationManager { get; set; }
  58. [Inject] protected IUserService _userService { get; set; }
  59. [Inject] protected CalMonthServices _CalMonthService { get; set; }
  60. [Inject] protected IJSRuntime JSRuntime { get; set; }
  61. [Inject] IConfiguration configuration{get;set;}
  62. private bool isFirstInit = true;
  63. private Table<PerformanceItem> table;
  64. private CurrentUser _user;
  65. private string strAddProjectJX = "";
  66. class SelectItem
  67. {
  68. public int Value { get; set; }
  69. public string Name { get; set; }
  70. }
  71. List<SelectItem> _Items = new List<SelectItem>()
  72. {
  73. new SelectItem(){Value =0,Name ="我处理的案件"},
  74. new SelectItem(){Value =1,Name ="我审核的案件"}
  75. };
  76. private void OnSelectedItemChangedHandler(SelectItem value)
  77. {
  78. //_selectedItem = value;
  79. //Console.WriteLine($"selected: ${value?.Name}");
  80. _pageIndex = 1;
  81. table.ReloadData();
  82. StateHasChanged();
  83. }
  84. private async void OnSelectedCalMonthChangedHandler(CalMonth calMonth)
  85. {
  86. _pageIndex = 1;
  87. await RefreshMyStatistics(calMonth);
  88. table.ReloadData();
  89. StateHasChanged();
  90. }
  91. protected async override Task OnInitializedAsync()
  92. {
  93. if (isFirstInit)
  94. {
  95. _loading = true;
  96. await RefreshMyStatistics();
  97. _Datas = new List<PerformanceItem>();// data.Results;
  98. _total = 0;//data.TotalCount;
  99. _loading = false;
  100. }
  101. isFirstInit = false;
  102. calMonthList = await _CalMonthService.GetAll();
  103. if (calMonthList != null)
  104. {
  105. calMonthList = calMonthList.Where(c => c.Status != 0).ToList();
  106. }
  107. await apTypeService.GetItems();
  108. _user = await _userService.GetUser();
  109. StateHasChanged();
  110. }
  111. private bool ShowMenu()
  112. {
  113. var strlfd = configuration.GetValue<string>("Latest_feedback_date");
  114. if (string.IsNullOrEmpty(strlfd))
  115. {
  116. return true;
  117. }
  118. else
  119. {
  120. if(DateTime.Now.Day <= int.Parse(strlfd))
  121. {
  122. return true;
  123. }
  124. else
  125. {
  126. return false;
  127. }
  128. }
  129. }
  130. private async Task RefreshMyStatistics()
  131. {
  132. var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  133. await RefreshMyStatistics(HandlingCalMonth);
  134. }
  135. private async Task RefreshMyStatistics(CalMonth calMonth)
  136. {
  137. if (calMonth != null)
  138. {
  139. var _user = await _userService.GetUser(); ;
  140. if (_user.Userid != null)
  141. {
  142. MyStatistics = await _ItemService.CalMyStatistics(calMonth.Year, calMonth.Month, _user.Userid.Value);
  143. }
  144. else
  145. {
  146. NavigationManager.NavigateTo("/LoginPages");
  147. }
  148. }
  149. }
  150. private string GetStatistics(string strType, bool isBasePoint = false)
  151. {
  152. //Console.WriteLine(strType);
  153. try
  154. {
  155. if (strType != "ALL")
  156. {
  157. var tem = MyStatistics.Where<StaffStatistics>(s => s.jxType == strType).FirstOrDefault();
  158. if (isBasePoint)
  159. {
  160. if (tem != null)
  161. {
  162. return (tem.FinianlPoint .HasValue ? tem.totalBasePoint.Value.ToString("0.00") : "");
  163. }
  164. else
  165. {
  166. return "";
  167. }
  168. }
  169. else
  170. {
  171. if (tem != null)
  172. {
  173. return (tem.FinianlPoint.HasValue ? tem.FinianlPoint.Value.ToString("0.00") : "");
  174. }
  175. else
  176. {
  177. return "";
  178. }
  179. }
  180. }
  181. else
  182. {
  183. if (isBasePoint)
  184. {
  185. return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
  186. }
  187. else
  188. {
  189. return MyStatistics.Where(s=>s.jxType !="其他新申请").Select(s => s.FinianlPoint.Value).Sum().ToString("0.00");
  190. }
  191. }
  192. }
  193. catch
  194. {
  195. return "";
  196. }
  197. }
  198. private int serialNumber(int pageIndex, int pageSize, int id)
  199. {
  200. int iIndex = 0;
  201. foreach (PerformanceItem sf in _Datas)
  202. {
  203. iIndex++;
  204. if (sf.Id == id)
  205. {
  206. break;
  207. }
  208. }
  209. return (pageIndex - 1) * pageSize + iIndex;
  210. }
  211. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  212. {
  213. var _user = await _userService.GetUser();
  214. if (_CurrentKey == tabList[0].Key)
  215. {
  216. _loading = true;
  217. HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
  218. await RefreshMyStatistics();
  219. if (HandlingCalMonth != null)
  220. {
  221. var data = await _ItemService.Query(HandlingCalMonth.Id, _user.Userid.Value, jxType.doing, queryModel, DoingOrReview);
  222. _Datas = data.Results;
  223. _total = data.TotalCount;
  224. }
  225. _loading = false;
  226. StateHasChanged();
  227. }
  228. else
  229. {
  230. _loading = true;
  231. if(SelectedCalMonthId == 0 && calMonthList !=null && calMonthList.Count >0)
  232. {
  233. SelectedCalMonthId = calMonthList[0].Id;
  234. await RefreshMyStatistics(calMonthList[0]);
  235. }
  236. var data = await _ItemService.Query(SelectedCalMonthId, _user.Userid.Value, jxType.finished, queryModel,DoingOrReview);
  237. _Datas = data.Results;
  238. _total = data.TotalCount;
  239. _loading = false;
  240. StateHasChanged();
  241. }
  242. }
  243. [Inject] IConfiguration _configuration { get; set; }
  244. bool isDownloading = false;
  245. private async Task ExportDataAsync(jxType jxType)
  246. {
  247. isDownloading = true;
  248. FileProcessTask fileData = null;
  249. if (jxType == jxType.doing)
  250. {
  251. fileData = await _ItemService.ExportData(HandlingCalMonth.Id, _user.Userid.Value, jxType, DoingOrReview);
  252. }
  253. else
  254. {
  255. fileData = await _ItemService.ExportData(SelectedCalMonthId, _user.Userid.Value, jxType, DoingOrReview);
  256. }
  257. while(!fileData.Finished)
  258. {
  259. fileData =await _ItemService.getExportDataProcessing(fileData.Id);
  260. await Task.Delay(20);
  261. }
  262. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  263. isDownloading = false;
  264. }
  265. bool _visible = false;
  266. private void OnsubShensu(PerformanceItem Item)
  267. {
  268. EditingItem = Item;
  269. _visible = true;
  270. //return new EventCallback();
  271. }
  272. bool _ShowJXModal = false;
  273. private void OnJXCal(PerformanceItem Item)
  274. {
  275. EditingItem = Item;
  276. _ShowJXModal = true;
  277. }
  278. private async void menuYSJXClick(PerformanceItem Item)
  279. {
  280. var respone = await _ItemService.SaveFieldChange(Item.Id, strAgentFeedbackMemo, "已算绩效");
  281. var item = await _ItemService.GetPerformancItem(Item.Id);
  282. Item.BasePoint = item.BasePoint;
  283. _ = RefreshMyStatistics();
  284. }
  285. private shensuType _SelectedItem;
  286. private void OnSelectedItemChangedHandler(shensuType value)
  287. {
  288. _SelectedItem = value;
  289. //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
  290. }
  291. #region 特殊绩效字段选择框变更时处理代码
  292. async void SelectChanged(Reason value)
  293. {
  294. if (!_loading && EditingItem != null)
  295. {
  296. var respone =await _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
  297. var item = await _ItemService.GetPerformancItem(EditingItem.Id) ;
  298. EditingItem.BasePoint = item.BasePoint;
  299. _ = RefreshMyStatistics();
  300. EditingItem = null;
  301. //table.ReloadData();
  302. }
  303. }
  304. void ClearSelect(int itemId)
  305. {
  306. var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
  307. EditingItem = null;
  308. _ = RefreshMyStatistics();
  309. table.ReloadData();
  310. }
  311. #endregion
  312. Dictionary<string, object> OnRow(RowData<PerformanceItem> row)
  313. {
  314. Dictionary<string, object> ret = new Dictionary<string, object>();
  315. ret.Add("onclick", ((Action)delegate
  316. {
  317. EditingItem = row.Data;
  318. }));
  319. return ret;
  320. }
  321. void OnFocus(PerformanceItem item)
  322. {
  323. EditingItem = item;
  324. }
  325. string _CurrentKey = "myListDoing";
  326. void OnTabChange(string key)
  327. {
  328. _CurrentKey = key;
  329. _pageIndex = 1;
  330. //table.PageIndex = 1;
  331. table.ReloadData();
  332. StateHasChanged();
  333. }
  334. private ModalRef _modalRef;
  335. [Inject] ModalService _ModalService { get; set; }
  336. [Inject]protected AppealTypeService _atService { get; set; }
  337. [Inject] IUserService _UserService { get; set; }
  338. private bool isExistAllocationRatios(PerformanceItem item)
  339. {
  340. return (item.AllocationRatios != null && item.AllocationRatios.Count >0);
  341. }
  342. private string AllocationRatioString(PerformanceItem item)
  343. {
  344. string strTem = string.Empty;
  345. if (item.AllocationRatios != null)
  346. {
  347. foreach (var ra in item.AllocationRatios)
  348. {
  349. strTem = $"{strTem},{ra.Person.Name}【{ra.Ratio}%】";
  350. }
  351. }
  352. if (!string.IsNullOrEmpty(strTem))
  353. {
  354. strTem = strTem.Substring(1);
  355. }
  356. return strTem;
  357. }
  358. private async Task getAllocationRatios(PerformanceItem item)
  359. {
  360. string strTem = "";
  361. var ratios = await _ItemService.getARatios(item);
  362. item.AllocationRatios = ratios;
  363. StateHasChanged();
  364. }
  365. async Task ShowModel(PerformanceItem Item,AppealType appealType)
  366. {
  367. var templateOptions = new Models.CreateAppealModel();
  368. await templateOptions.Init(_atService,Item, appealType);
  369. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(Item));
  370. var modalConfig = new ModalOptions();
  371. modalConfig.Title = appealType.Name;
  372. modalConfig.Width = 650;
  373. //modalConfig.Footer = null;
  374. modalConfig.DestroyOnClose = true;
  375. modalConfig.MaskClosable = false;
  376. _modalRef = await _ModalService
  377. .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
  378. _modalRef.OnOpen = () =>
  379. {
  380. return Task.CompletedTask;
  381. };
  382. _modalRef.OnOk = async () =>
  383. {
  384. try
  385. {
  386. #region 案件系数复核 判断20230607修改为不需要判断
  387. //if (templateOptions.AppealType.Name == "案件系数复核")
  388. //{
  389. // var ifValue = templateOptions.inputFieldValues.Where(iv => iv.InputField.FieldName == "案件系数").FirstOrDefault();
  390. // //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
  391. // var temCssObj = new CaseCoefficientStatistics()
  392. // {
  393. // Totals = templateOptions.cssObject.Totals,
  394. // SCount = templateOptions.cssObject.SCount,
  395. // ACount = templateOptions.cssObject.ACount,
  396. // customer = templateOptions.cssObject.customer
  397. // };
  398. // if (ifValue != null)
  399. // {
  400. // switch (ifValue.Value)
  401. // {
  402. // case "S":
  403. // temCssObj.SCount += 1;
  404. // break;
  405. // case "A":
  406. // temCssObj.ACount += 1;
  407. // break;
  408. // }
  409. // }
  410. // switch (templateOptions.Item.CaseCoefficient)
  411. // {
  412. // case "S":
  413. // temCssObj.SCount -= 1;
  414. // break;
  415. // case "A":
  416. // temCssObj.ACount -= 1;
  417. // break;
  418. // }
  419. // Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(temCssObj));
  420. // if (temCssObj.isExceedingLimit())
  421. // {
  422. // var reviewer = await _UserService.GetUser(templateOptions.AppealRecord.ReviewerId.Value);
  423. // if (reviewer.Name != "钟子敏")
  424. // {
  425. // var SuccessConfig1 = new ConfirmOptions()
  426. // {
  427. // Content = $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,需要提交给“钟子敏”审核!"
  428. // };
  429. // _ModalService.Error(SuccessConfig1);
  430. // //await JSRuntime.InvokeAsync<object>("alert", $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,需要提交给“钟子敏”审核!");
  431. // return;
  432. // }
  433. // }
  434. //}
  435. #endregion
  436. await _atService.CreateAppeal(templateOptions);
  437. await _modalRef.CloseAsync();
  438. StateHasChanged();
  439. var SuccessConfig = new ConfirmOptions()
  440. {
  441. Content = @"保存申诉信息成功!"
  442. };
  443. //modalConfig.Footer = null;
  444. modalConfig.DestroyOnClose = true;
  445. _ModalService.Success(SuccessConfig);
  446. }
  447. catch (Exception ex)
  448. {
  449. _ModalService.Error(new ConfirmOptions()
  450. {
  451. Title = "保存申诉信息错误",
  452. Content = ex.Message,
  453. });
  454. //_ErrorMessage = ex.Message;
  455. }
  456. //return Task.CompletedTask;
  457. };
  458. _modalRef.OnCancel = () =>
  459. {
  460. return Task.CompletedTask;
  461. };
  462. _modalRef.OnClose = () =>
  463. {
  464. return Task.CompletedTask;
  465. };
  466. StateHasChanged();
  467. }
  468. }
  469. }