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