1、更改ChangeModalViewModel.cs类,增加下拉选项:
public class ChangeModalViewModel
{
public string TenancyName { get; set; }
public List<ComboboxItemDto> TeneacyItems { get; set; }
}
2、更改AccountController.cs的TenantChangeModal()方法:
public async Task<ActionResult> TenantChangeModal()
{
var loginInfo = await _sessionCache.GetCurrentLoginInformationsAsync();
var viewModel = new ChangeModalViewModel
{
TenancyName = loginInfo.Tenant?.TenancyName
};
viewModel.TeneacyItems= _tenantManager.Tenants
.Select(p => new ComboboxItemDto(p.TenancyName, p.Name) { IsSelected = viewModel.TenancyName == p.TenancyName })
.ToList();
return View("/Views/Shared/Components/TenantChange/_ChangeModal.cshtml", viewModel);
}
3、更改_ChangeModal.cshtml内容,增加下拉控件:
<form name="TenantChangeForm" role="form" novalidate class="form-validation">
<div class="form-group">
<label>@L("TenancyName")</label>
@Html.DropDownList(
"TenancyNames",
Model.TeneacyItems.Select(i => i.ToSelectListItem()),
new { @class = "form-control edited", id = "TenancyName" })
<span class="m-form__help">@L("LeaveEmptyToSwitchToHost")</span>
</div>
</form>
4、更改_ChangeModal.js的save方法
var tenancyName = document.getElementById("TenancyName").value;