123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- using AntDesign;
- using AntDesign.TableModels;
- using Microsoft.AspNetCore.Components;
- using Microsoft.AspNetCore.Components.Web;
- using Microsoft.Extensions.Configuration;
- using ServiceStack;
- using ServiceStack.Script;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.share;
- using wispro.sp.web.Pages.Organization;
- using wispro.sp.web.Services;
- namespace wispro.sp.web.Pages.AppCase
- {
- public partial class CaseManager
- {
- [Inject]
- protected IconService iconService { get; set; }
- public TableFilter<string>[] CaseCoeFilters = new TableFilter<string>[] {
- new() { Text = "S", Value = "S" },
- new() { Text = "A", Value = "A" },
- new() { Text = "B", Value = "B" },
- new() { Text = "C", Value = "C" },
- new() { Text = "D", Value = "D" },
- new() { Text = "S级", Value = "S级" },
- new() { Text = "机电A级", Value = "机电A级" },
- new() { Text = "机电B级", Value = "机电B级" },
- new() { Text = "机电C级", Value = "机电C级" },
- new() { Text = "机电D级", Value = "机电D级" },
- new() { Text = "化学A级", Value = "化学A级" },
- new() { Text = "化学B级", Value = "化学B级" },
- new() { Text = "化学C级", Value = "化学C级" },
- new() { Text = "化学D级", Value = "化学D级" }
- };
- [Inject]
- protected AppealTypeService apTypeService { get; set; }
- private List<PerformanceItem> _Datas;
- private List<StaffStatistics> MyStatistics;
- IEnumerable<PerformanceItem> selectedItems = new List<PerformanceItem>();
- private CalMonth HandlingCalMonth;
- private List<CalMonth> calMonths;
- int _pageIndex = 1;
- int _pageSize = 10;
- int _total;
- bool _loading = false;
- private Table<PerformanceItem> table;
- [Inject] public PerformanceItemServices _ItemService { get; set; }
- [Inject] public MessageService _message { get; set; }
- [Inject] protected NavigationManager NavigationManager { get; set; }
- [Inject] protected IUserService _userService { get; set; }
- [Inject] protected CalMonthServices _CalMonthService { get; set; }
- [Inject] IConfiguration _configuration { get; set; }
- [Inject] protected IAuthService _authService { get; set; }
- [Inject] protected AppealTypeService AppealTypeService { get;set; }
- protected override async Task OnInitializedAsync()
- {
- await _authService.CanVisitResource();
- await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
- calMonths = await _CalMonthService.GetAll();
- if (calMonths != null && calMonths.Count > 0)
- {
- await calMonthClick(calMonths[0]);
- }
- }
- private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
- {
- var _user = await _userService.GetUser();
-
- _loading = true;
-
- var data = await _ItemService.Query(HandlingCalMonth, queryModel);
- _Datas = data.Results;
- _total = data.TotalCount;
- _loading = false;
- StateHasChanged();
- }
- private async Task calMonthClick(CalMonth calMonth)
- {
- HandlingCalMonth = calMonth;
- var data = await _ItemService.Query(HandlingCalMonth,_pageIndex ,_pageSize,null);
- _Datas = data.Results;
- _total = data.TotalCount;
- _loading = false;
- StateHasChanged();
- }
- bool isGuiDang = false;
- private async Task GuidangCalMonth(CalMonth calMonth)
- {
- isGuiDang = true;
- //还未实现,此处需要添加归档代码
- var fileData = await _ItemService.FinishedCalMonth(calMonth);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(1000);
- }
- if (!string.IsNullOrEmpty(fileData.ErrorMessage))
- {
- //calMonths = await _CalMonthService.GetAll();
- calMonth.Status = 4;
- //calMonthClick(calMonth);
- }
- isGuiDang = false;
- StateHasChanged();
- }
- private int serialNumber(int pageIndex, int pageSize, int id)
- {
- int iIndex = 0;
- foreach (PerformanceItem sf in _Datas)
- {
- iIndex++;
- if (sf.Id == id)
- {
- break;
- }
- }
- return (pageIndex - 1) * pageSize + iIndex;
- }
- bool isDownloading = false;
- private async Task ExportDataAsync(CalMonth calMonth)
- {
- isDownloading = true;
- var fileData = await _ItemService.ExportData(calMonth.Id);
- while (!fileData.Finished)
- {
- try
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(100);
- }
- catch {
- await Task.Delay(1000);
- }
-
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
- }
- private async Task ExportJXDataAsync(CalMonth calMonth)
- {
- isDownloading = true;
- var fileData = await _ItemService.ExportJXReport(calMonth.Year,calMonth.Month);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(20);
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
-
- }
- private async Task ExportJXPointAsync(CalMonth calMonth)
- {
- isDownloading = true;
- var fileData = await _ItemService.ExportJXPointReport(calMonth.Year, calMonth.Month);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(20);
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
- }
- private async Task ExportJXMoneyAsync(CalMonth calMonth)
- {
- isDownloading = true;
- var fileData = await _ItemService.ExportJXMoneyAsync(calMonth.Year, calMonth.Month);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(20);
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
- }
- private async Task ExportCCSDataAsync(CalMonth calMonth)
- {
- isDownloading = true;
- var fileData = await AppealTypeService.ExportCustomerCCSFile(calMonth.Id);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(20);
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
- }
- private async Task ExportCurrentMonthJXList()
- {
- isDownloading = true;
- var fileData = await _ItemService.CurrentData2Excel(HandlingCalMonth);
- while (!fileData.Finished)
- {
- fileData = await _ItemService.getExportDataProcessing(fileData.Id);
- await Task.Delay(20);
- }
- NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
- isDownloading = false;
- }
- async Task OnRefresh(PerformanceItem item)
- {
- item = await _ItemService.RefreshItem(item.Id);
- table.ReloadData();
- StateHasChanged();
- }
- private bool ShowSettingModal = false;
- private List<AllocationRatio> allocationRatios = null;
- private PerformanceItem CurrentItem = null;
- async Task ONJXAllocationRatios(PerformanceItem item)
- {
- CurrentItem = item;
- allocationRatios = await _ItemService.getARatios(item);
- if(allocationRatios == null)
- {
- allocationRatios= new List<AllocationRatio>();
- }
- if(item.ReviewerId != null && allocationRatios.Where(p=>p.PersonId == item.ReviewerId ).Count()==0)
- {
- allocationRatios.Add(new AllocationRatio() {
- ItemId = item.Id,
- PersonId = item.ReviewerId.Value,
- Ratio = 0,
- ActualAmount = 0
- });
- }
- if (item.ExternalHandlerId != null && allocationRatios.Where(p => p.PersonId == item.ExternalHandlerId).Count() == 0)
- {
- allocationRatios.Add(new AllocationRatio()
- {
- ItemId = item.Id,
- PersonId = item.ExternalHandlerId.Value,
- Ratio = 0,
- ActualAmount = 0
- });
- }
- foreach(var iStaff in item.ItemStaffs)
- {
- if (allocationRatios.Where(p => p.PersonId == iStaff.DoPersonId).Count() == 0)
- {
- allocationRatios.Add(new AllocationRatio()
- {
- ItemId = item.Id,
- PersonId = iStaff.DoPersonId,
- Ratio = 0,
- ActualAmount = 0
- });
- }
- }
- ShowSettingModal = true;
- }
-
- private AllocationRatio getAllocationRatio(Staff person)
- {
- var retObj= allocationRatios.Where(a => a.PersonId == person.Id).FirstOrDefault();
- if (retObj == null)
- {
- retObj = new AllocationRatio() {
- Person = person,
- PersonId = person.Id,
- Ratio = 0,
- ItemId = CurrentItem.Id
-
- };
- }
- return retObj;
- }
- private async System.Threading.Tasks.Task btnOk(MouseEventArgs e)
- {
- foreach(var ar in allocationRatios)
- {
- ar.Person = null;
- ar.Item = null;
- }
- Console.WriteLine("1");
- var zeros = allocationRatios.Where(i => i.Ratio.Value == 0).ToList();
- foreach(var a in zeros)
- {
- allocationRatios.Remove(a);
- }
- Console.WriteLine("2");
- if (allocationRatios.Sum(i => i.Ratio.Value) == 100)
- {
- await _ItemService.SaveAllocationRatios(allocationRatios);
- ShowSettingModal = false;
- StateHasChanged();
- }
- else
- {
- Console.WriteLine("3");
- await _message.Error("分配比率相加应该等于100!");
- }
- }
- private void btnCancel(MouseEventArgs e)
- {
- ShowSettingModal = false;
- }
- async Task<string> CalItemJX(PerformanceItem item)
- {
- return null;
- }
- private bool isExistAllocationRatios(PerformanceItem item)
- {
- return (item.AllocationRatios != null && item.AllocationRatios.Count > 0);
- }
- private string AllocationRatioString(PerformanceItem item)
- {
- string strTem = string.Empty;
- if (item.AllocationRatios != null)
- {
- foreach (var ra in item.AllocationRatios)
- {
- strTem = $"{strTem},{ra.Person.Name}【{ra.Ratio}%】";
- }
- }
- if (!string.IsNullOrEmpty(strTem))
- {
- strTem = strTem.Substring(1);
- }
- return strTem;
- }
- private async Task getAllocationRatios(PerformanceItem item)
- {
- string strTem = "";
- var ratios = await _ItemService.getARatios(item);
- item.AllocationRatios = ratios;
- StateHasChanged();
- }
- }
- }
|