Skip to content

Commit 9611c54

Browse files
committed
refactor: 增加清空逻辑
1 parent 5263751 commit 9611c54

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/components/BootstrapBlazor.Region/Components/SelectCity.razor.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public partial class SelectCity
2828

2929
private async Task OnClearValue()
3030
{
31+
if (IsMultiple)
32+
{
33+
_values.Clear();
34+
}
3135
CurrentValue = "";
3236

3337
if (OnClearAsync != null)
@@ -38,15 +42,18 @@ private async Task OnClearValue()
3842

3943
private void OnSelectCity(string item)
4044
{
41-
if(IsMultiple)
45+
if (IsMultiple)
4246
{
43-
47+
if (!_values.Remove(item))
48+
{
49+
_values.Add(item);
50+
}
51+
CurrentValue = string.Join(",", _values);
4452
}
45-
if (!_values.Remove(item))
53+
else
4654
{
47-
_values.Add(item);
55+
CurrentValue = item;
4856
}
49-
CurrentValue = string.Join(",", _values);
5057
}
5158

5259
private static HashSet<string> GetProvinces()
@@ -86,9 +93,9 @@ private static HashSet<string> GetProvinces()
8693
];
8794
}
8895

89-
private HashSet<string> GetCities(string proviceName)
96+
private HashSet<string> GetCities(string provinceName)
9097
{
91-
if (proviceName == "直辖市")
98+
if (provinceName == "直辖市")
9299
{
93100
return
94101
[
@@ -99,7 +106,7 @@ private HashSet<string> GetCities(string proviceName)
99106
];
100107
}
101108

102-
if (proviceName == "特别行政区")
109+
if (provinceName == "特别行政区")
103110
{
104111
return
105112
[
@@ -108,6 +115,6 @@ private HashSet<string> GetCities(string proviceName)
108115
];
109116
}
110117

111-
return RegionService.GetCities(proviceName);
118+
return RegionService.GetCities(provinceName);
112119
}
113120
}

0 commit comments

Comments
 (0)