MyCaselist.razor.cs 12 KB

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