chore
This commit is contained in:
@@ -26,21 +26,8 @@
|
||||
<FormItem Label="国家">
|
||||
<Input @bind-Value="@country.Name" Placeholder="国家名称" Disabled />
|
||||
</FormItem>
|
||||
<FormItem Label="州/省">
|
||||
<Select TItemValue="long" TItem="int" Style="width:250px;" @bind-Value="@context.StateProvinceId">
|
||||
<SelectOption Value="0" Label="请选择运行平台"></SelectOption>
|
||||
<SelectOption Value="1" Label="Windows桌面"></SelectOption>
|
||||
<SelectOption Value="2" Label="安卓系统"></SelectOption>
|
||||
<SelectOption Value="3" Label="iOS系统"></SelectOption>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem Label="城市">
|
||||
<Select TItemValue="long" TItem="int" Style="width:250px;" @bind-Value="@context.ParentId">
|
||||
<SelectOption Value="0" Label="请选择运行平台"></SelectOption>
|
||||
<SelectOption Value="1" Label="Windows桌面"></SelectOption>
|
||||
<SelectOption Value="2" Label="安卓系统"></SelectOption>
|
||||
<SelectOption Value="3" Label="iOS系统"></SelectOption>
|
||||
</Select>
|
||||
<FormItem Label="州/省/城市">
|
||||
<Cascader Options="@stateProvinceTrees" @bind-Value="cities" SelectedNodesChanged="OnCitiesChange"></Cascader>
|
||||
</FormItem>
|
||||
<FormItem Label="名称" Required>
|
||||
<Input @bind-Value="@context.Name" Placeholder="名称" />
|
||||
@@ -79,8 +66,9 @@
|
||||
Form<AreaModel> editform = null!;
|
||||
List<KeyValue> languageList = new();
|
||||
Country country = new();
|
||||
List<KeyValue> stateProvinceList = new();
|
||||
StateProvinceLocalizedModel stateProvince = new();
|
||||
List<CascaderNode> stateProvinceTrees = new();
|
||||
AreaLocalizedModel area = new();
|
||||
string cities = string.Empty;
|
||||
bool pageLoading = false;
|
||||
bool saving = false;
|
||||
|
||||
@@ -95,7 +83,7 @@
|
||||
|
||||
_ = LoadLanguage();
|
||||
_ = LoadCountry();
|
||||
_ = LoadStateProvince();
|
||||
_ = LoadStateProvinceAndCities();
|
||||
if (Id > 0)
|
||||
{
|
||||
LoadData();
|
||||
@@ -121,41 +109,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
async Task LoadStateProvince()
|
||||
async Task LoadStateProvinceAndCities()
|
||||
{
|
||||
var url = $"/api/stateprovince/select/{CountryId}";
|
||||
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
|
||||
var url = $"/api/stateprovince/tree/{CountryId}";
|
||||
var apiResult = await HttpService.Get<ApiResult<List<KeyValueTree>>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
stateProvinceList = apiResult.Data;
|
||||
stateProvinceTrees = apiResult.Data.Adapt<List<CascaderNode>>();
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list");
|
||||
}
|
||||
stateProvinceList.Insert(0, new KeyValue() { Key = "0", Value = "请选择州/省" });
|
||||
}
|
||||
}
|
||||
|
||||
async Task LoadStateProvince(long id)
|
||||
{
|
||||
var url = $"/api/stateprovince/select/{CountryId}";
|
||||
var apiResult = await HttpService.Get<ApiResult<List<KeyValue>>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data != null)
|
||||
{
|
||||
stateProvinceList = apiResult.Data;
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
Navigation.NavigateTo($"/country/list");
|
||||
}
|
||||
stateProvinceList.Insert(0, new KeyValue() { Key = "0", Value = "请选择州/省" });
|
||||
// stateProvinceTrees.Insert(0, new KeyValue() { Key = "0", Value = "请选择州/省" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +141,7 @@
|
||||
else
|
||||
{
|
||||
languageList = apiResult.Data;
|
||||
languageList.Insert(0, new KeyValue() { Key = "0", Value = "标准" });
|
||||
languageList.Insert(0, new KeyValue() { Label = "0", Value = "标准" });
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +153,7 @@
|
||||
{
|
||||
pageLoading = true;
|
||||
var url = $"/api/stateprovince/detail?id={Id}";
|
||||
var apiResult = await HttpService.Get<ApiResult<StateProvinceLocalizedModel>>(url);
|
||||
var apiResult = await HttpService.Get<ApiResult<AreaLocalizedModel>>(url);
|
||||
if (apiResult.Success)
|
||||
{
|
||||
if (apiResult.Data == null)
|
||||
@@ -193,8 +162,16 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
stateProvince = apiResult.Data;
|
||||
model = apiResult.Data.Adapt<StateProvinceModel>();
|
||||
area = apiResult.Data;
|
||||
model = apiResult.Data.Adapt<AreaModel>();
|
||||
if (model.ParentId > 0)
|
||||
{
|
||||
cities = $"{model.StateProvinceId},{model.ParentId}";
|
||||
}
|
||||
else if (model.StateProvinceId > 0)
|
||||
{
|
||||
cities = $"{model.StateProvinceId}";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -206,6 +183,16 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void OnCitiesChange(CascaderNode[] selectedNodes)
|
||||
{
|
||||
model.StateProvinceId = long.Parse(selectedNodes.First().Value.ToString() ?? "0");
|
||||
model.ParentId = long.Parse(selectedNodes.Last().Value.ToString() ?? "0");
|
||||
if (model.StateProvinceId == model.ParentId)
|
||||
{
|
||||
model.ParentId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
async void OnFormFinishAsync()
|
||||
{
|
||||
if (editform.Validate())
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</TabPane> *@
|
||||
@foreach (var item in languageList)
|
||||
{
|
||||
<TabPane Key="@item.Key.ToString()">
|
||||
<TabPane Key="@item.Label.ToString()">
|
||||
<TabTemplate>
|
||||
<span>@item.Value</span>
|
||||
</TabTemplate>
|
||||
@@ -118,7 +118,7 @@
|
||||
else
|
||||
{
|
||||
languageList = apiResult.Data;
|
||||
languageList.Insert(0, new KeyValue() { Key = "0", Value = "标准" });
|
||||
languageList.Insert(0, new KeyValue() { Label = "0", Value = "标准" });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
else
|
||||
{
|
||||
languageList = apiResult.Data;
|
||||
languageList.Insert(0, new KeyValue() { Key = "0", Value = "标准" });
|
||||
languageList.Insert(0, new KeyValue() { Label = "0", Value = "标准" });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Atomx.Admin.Controllers
|
||||
|
||||
var data = await _cacheService.GetLanguages();
|
||||
|
||||
var list = data.Where(p => p.Enabled).Select(p => new KeyValue() { Key = p.Id.ToString(), Value = p.Name }).ToList();
|
||||
var list = data.Where(p => p.Enabled).Select(p => new KeyValue() { Label = p.Id.ToString(), Value = p.Name }).ToList();
|
||||
|
||||
result = result.IsSuccess(list);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Atomx.Admin.Controllers
|
||||
var query = from p in _dbContext.StateProvinces
|
||||
where p.CountryId == countryId && p.Enabled
|
||||
select p;
|
||||
list = query.OrderByDescending(p => p.DisplayOrder).Select(p => new KeyValue() { Key = p.Id.ToString(), Value = p.Name }).ToList();
|
||||
list = query.OrderByDescending(p => p.DisplayOrder).Select(p => new KeyValue() { Label = p.Id.ToString(), Value = p.Name }).ToList();
|
||||
|
||||
return new JsonResult(new ApiResult<List<KeyValue>>().IsSuccess(list));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public class KeyValue
|
||||
{
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public string Label { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public class KeyValueTree
|
||||
{
|
||||
public string Key { get; set; } = string.Empty;
|
||||
public string Label { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public List<KeyValueTree> Children { get; set; } = new List<KeyValueTree>();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Atomx.Data.CacheServices
|
||||
{
|
||||
var item = new KeyValueTree
|
||||
{
|
||||
Key = state.Id.ToString(),
|
||||
Label = state.Id.ToString(),
|
||||
Value = state.Name,
|
||||
Children = new List<KeyValueTree>()
|
||||
};
|
||||
@@ -243,7 +243,7 @@ namespace Atomx.Data.CacheServices
|
||||
{
|
||||
var item = new KeyValueTree
|
||||
{
|
||||
Key = area.Id.ToString(),
|
||||
Label = area.Id.ToString(),
|
||||
Value = area.Name,
|
||||
Children = new List<KeyValueTree>()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user