|
@@ -5,6 +5,7 @@ using aipmgr.Models;
|
|
|
using aipmgr.Shared;
|
|
|
using aipmgr.Utilities;
|
|
|
using BootstrapBlazor.Components;
|
|
|
+using Microsoft.AspNetCore.Components.Forms;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
namespace aipmgr.Pages
|
|
@@ -12,64 +13,65 @@ namespace aipmgr.Pages
|
|
|
public sealed partial class Settlement
|
|
|
{
|
|
|
[NotNull]
|
|
|
- private Table<AccountModel>? LabelerTable { get; set; }
|
|
|
+ private Table<SettlementModel>? SettlementTable { get; set; }
|
|
|
private static List<int> PageItemsSource = new List<int> { 10, 20 };
|
|
|
[NotNull]
|
|
|
+ public DistributionRecordModel? ValidateDistributionModel { get; set; }
|
|
|
+ [NotNull]
|
|
|
+ private Modal? DistributionModal { get; set; }
|
|
|
+ [NotNull]
|
|
|
private MessageBase? _messageBaseRef { get; set; }
|
|
|
|
|
|
#region Search
|
|
|
|
|
|
- private AccountModel SearchModel { get; set; } = new AccountModel();
|
|
|
+ private SettlementModel SearchModel { get; set; } = new SettlementModel();
|
|
|
+ private DateTime SearchMonthValue { get; set; } = DateTime.Today;
|
|
|
[NotNull]
|
|
|
- private List<SelectedItem>? _organizationItems { get; set; }
|
|
|
+ private List<SelectedItem>? SearchOrganizationItems { get; set; }
|
|
|
[NotNull]
|
|
|
- private List<SelectedItem>? _institutionItems { get; set; }
|
|
|
+ private List<SelectedItem>? SearchSettlementTypeValues { get; set; }
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
{
|
|
|
await base.OnInitializedAsync();
|
|
|
- _organizationItems = new List<SelectedItem>();
|
|
|
- _institutionItems = new List<SelectedItem>();
|
|
|
+ SettlementTable = new();
|
|
|
+ SearchOrganizationItems = new List<SelectedItem>();
|
|
|
+ SearchSettlementTypeValues = new List<SelectedItem>();
|
|
|
+ foreach (SettlementType item in Enum.GetValues(typeof(SettlementType)))
|
|
|
+ {
|
|
|
+ SearchSettlementTypeValues.Add(new SelectedItem
|
|
|
+ {
|
|
|
+ Value = item.ToString(),
|
|
|
+ Text = item.ToDisplayName(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ var organizations = await AdminManager.Shared.GetOrganizationsAsync();
|
|
|
+ SearchOrganizationItems = organizations.Select(x => new SelectedItem
|
|
|
+ {
|
|
|
+ Value = x.Id.ToString(),
|
|
|
+ Text = x.Name
|
|
|
+ }).ToList();
|
|
|
+ if (organizations != null)
|
|
|
+ {
|
|
|
+ SearchModel.SelectedOrganizationId = organizations.FirstOrDefault().Id;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private async Task<QueryData<AccountModel>> OnQueryAsync(QueryPageOptions options)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (SearchModel.OrganizationId <= 0)
|
|
|
- {
|
|
|
- var organizations = await AdminManager.Shared.GetOrganizationsAsync();
|
|
|
- _organizationItems = organizations.Select(x => new SelectedItem
|
|
|
- {
|
|
|
- Value = x.Id.ToString(),
|
|
|
- Text = x.Name
|
|
|
- }).ToList();
|
|
|
- if (_organizationItems != null)
|
|
|
- {
|
|
|
- await OnOrganizationItemChanged(_organizationItems.FirstOrDefault());
|
|
|
- }
|
|
|
- if (organizations != null)
|
|
|
- {
|
|
|
- SearchModel.OrganizationId = organizations.FirstOrDefault().Id;
|
|
|
- }
|
|
|
- }
|
|
|
var keyword = options.SearchText;
|
|
|
var pageIndex = options.PageIndex - 1;
|
|
|
var pageSize = options.PageItems;
|
|
|
- var labelers = await AdminManager.Shared.GetAccountsAsync(pageIndex, pageSize, keyword, SearchModel.OrganizationId, 0, Role.Labeler);
|
|
|
- var labelerCount = await AdminManager.Shared.GetAccountCountAsync(keyword, SearchModel.OrganizationId, 0, Role.Labeler);
|
|
|
+ var labelers = await AdminManager.Shared.GetAccountsAsync(pageIndex, pageSize, keyword, SearchModel.SelectedOrganizationId, 0, Role.Labeler);
|
|
|
+ var labelerCount = await AdminManager.Shared.GetAccountCountAsync(keyword, SearchModel.SelectedOrganizationId, 0, Role.Labeler);
|
|
|
var items = new List<AccountModel>();
|
|
|
foreach (var item in labelers)
|
|
|
{
|
|
|
var vo = MapHelper.Map<AccountModel, Account>(item);
|
|
|
- //vo.OrganizationValues = vo.Organizations.Select(x => x.Id.ToString()).ToList();
|
|
|
- var findInstitution = _institutionItems.FirstOrDefault(x => x.Value == vo.InstitutionId.ToString());
|
|
|
- if (findInstitution != null)
|
|
|
- {
|
|
|
- vo.InstitutionName = findInstitution.Text;
|
|
|
- }
|
|
|
items.Add(vo);
|
|
|
}
|
|
|
return await Task.FromResult(new QueryData<AccountModel>()
|
|
@@ -80,49 +82,87 @@ namespace aipmgr.Pages
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _messageBaseRef.ShowMessageBaseAsync($"查询用例失败,错误:{ex}");
|
|
|
+ await _messageBaseRef.ShowMessageBaseAsync($"查询失败,错误:{ex}");
|
|
|
return await Task.FromResult(new QueryData<AccountModel>());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private Task OnResetSearchAsync(AccountModel item)
|
|
|
+ private async Task OnSelectedSettlementTypeChanged(IEnumerable<SelectedItem> values, string val)
|
|
|
{
|
|
|
- item.Name = "";
|
|
|
- item.InstitutionId = -1;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var value = values.FirstOrDefault();
|
|
|
|
|
|
- return Task.CompletedTask;
|
|
|
+ StateHasChanged();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _messageBaseRef.ShowMessageBaseAsync($"切换失败,错误:{ex.Translate()}");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private async Task OnEnterSelectAllAsync(string val)
|
|
|
+ #region 编辑发放
|
|
|
+
|
|
|
+ public async Task OnEditDistributionAsync()
|
|
|
{
|
|
|
- SearchModel.Name = val;
|
|
|
- await LabelerTable.QueryAsync();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ await LoadingManager.OpenAsync();
|
|
|
+ ValidateDistributionModel = new DistributionRecordModel();
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _messageBaseRef.ShowMessageBaseAsync($"新建失败,错误:{ex.Translate()}");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ await LoadingManager.CloseAsync();
|
|
|
+ StateHasChanged();
|
|
|
+ }
|
|
|
+ await DistributionModal.Show();
|
|
|
}
|
|
|
|
|
|
- private async Task OnOrganizationItemChanged(SelectedItem item)
|
|
|
+ private async Task OnSubmitAsync(EditContext context)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (item != null)
|
|
|
+ #region 验证
|
|
|
+
|
|
|
+ var model = context.Model as DistributionRecordModel;
|
|
|
+ if (model == null)
|
|
|
{
|
|
|
- //var institutions = new List<Institution>(); //await AdminManager.Shared.GetImageCategoriesByParentIdAsync(long.Parse(item.Value));
|
|
|
- //if (institutions != null && institutions.Count > 0)
|
|
|
- //{
|
|
|
- // _institutionItems = institutions.Select(x => new SelectedItem
|
|
|
- // {
|
|
|
- // Value = x.Id.ToString(),
|
|
|
- // Text = x.Name
|
|
|
- // }).ToList();
|
|
|
- // _institutionItems.Insert(0, new SelectedItem("", "请选择..."));
|
|
|
- //}
|
|
|
+ await _messageBaseRef.ShowMessageBaseAsync("保存失败。");
|
|
|
+ return;
|
|
|
}
|
|
|
- StateHasChanged();
|
|
|
+
|
|
|
+ #endregion 验证
|
|
|
+
|
|
|
+ await LoadingManager.OpenAsync();
|
|
|
+ //foreach (var value in model.CategoryValues)
|
|
|
+ //{
|
|
|
+
|
|
|
+
|
|
|
+ // var price = new DistributionRecord
|
|
|
+ // {
|
|
|
+ // OrganizationIds = model.OrganizationIds,
|
|
|
+
|
|
|
+ // };
|
|
|
+ // await AdminManager.Shared.CreateInstitutionalPriceAsync(price);
|
|
|
+ //}
|
|
|
+ await DistributionModal.Close();
|
|
|
+ await SettlementTable.QueryAsync();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _messageBaseRef.ShowMessageBaseAsync($"选择机构失败,错误:{ex.Translate()}");
|
|
|
+ await _messageBaseRef.ShowMessageBaseAsync($"新建失败,错误:{ex.Translate()}");
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ await LoadingManager.CloseAsync();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|