MyCaselist.razor.cs 12 KB

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