You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.6 KiB
116 lines
2.6 KiB
using BlazorComponent;
|
|
using Easy.DDD.Application.Request;
|
|
using Easy.Extensions;
|
|
using IdentityServer.DDD.Application;
|
|
using IdentityServer.DDD.Contracts.Inputs;
|
|
using IdentityServer.DDD.Contracts.Models;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace IdentityServer.Pages.TenantManagement;
|
|
|
|
public partial class TenantManagement
|
|
{
|
|
private readonly List<DataTableHeader<TenantModel>> Headers = new()
|
|
{
|
|
new()
|
|
{
|
|
Text = "租户名称",
|
|
Value = nameof(TenantModel.TenantName),
|
|
Sortable = false,
|
|
},
|
|
new()
|
|
{
|
|
Text = "操作",
|
|
Value = "actions",
|
|
Sortable = false
|
|
}
|
|
};
|
|
private List<TenantModel> TenantModels { get; set; } = new();
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
var result = await TenantAppService.GetListAsync(new GetTenantsInput()
|
|
{
|
|
PageIndex = 0,
|
|
PageSize = 10,
|
|
Sorting = "CreationTime DESC"
|
|
});
|
|
if (result.IsSuccess())
|
|
{
|
|
TenantModels = result.Results;
|
|
}
|
|
|
|
}
|
|
public PagingRequest PagingRequest { get; set; }
|
|
[Inject] TenantAppService TenantAppService { get; set; }
|
|
|
|
private bool _dialog;
|
|
private bool _dialogDelete;
|
|
private int _editedIndex;
|
|
private TenantModel _editedItem = new TenantModel
|
|
{
|
|
TenantName = ""
|
|
};
|
|
public string FormTitle
|
|
{
|
|
get
|
|
{
|
|
return _editedIndex == -1 ? "创建租户" : "修改租户";
|
|
}
|
|
}
|
|
|
|
|
|
public void Close()
|
|
{
|
|
_dialog = false;
|
|
_editedItem = new TenantModel();
|
|
_editedIndex = -1;
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
if (_editedIndex > -1)
|
|
{
|
|
var item = TenantModels[_editedIndex];
|
|
item.TenantName = _editedItem.TenantName;
|
|
}
|
|
else
|
|
{
|
|
TenantModels.Add(_editedItem);
|
|
}
|
|
Close();
|
|
}
|
|
|
|
public void EditItem(TenantModel item)
|
|
{
|
|
_editedIndex = TenantModels.IndexOf(item);
|
|
_editedItem = new TenantModel()
|
|
{
|
|
TenantName = item.TenantName
|
|
};
|
|
_dialog = true;
|
|
}
|
|
|
|
public void DeleteItem(TenantModel item)
|
|
{
|
|
_editedIndex = TenantModels.IndexOf(item);
|
|
_editedItem = new TenantModel()
|
|
{
|
|
TenantName = item.TenantName
|
|
};
|
|
_dialogDelete = true;
|
|
}
|
|
|
|
public void DeleteItemConfirm()
|
|
{
|
|
TenantModels.RemoveAt(_editedIndex);
|
|
CloseDelete();
|
|
}
|
|
|
|
public void CloseDelete()
|
|
{
|
|
_dialogDelete = false;
|
|
_editedItem = new();
|
|
_editedIndex = -1;
|
|
}
|
|
}
|
|
|
|
|