diff --git a/projects/Infrastructure/Areas/Admin/Controllers/SettingController.cs b/projects/Infrastructure/Areas/Admin/Controllers/SettingController.cs index d900f26f..03b1f148 100644 --- a/projects/Infrastructure/Areas/Admin/Controllers/SettingController.cs +++ b/projects/Infrastructure/Areas/Admin/Controllers/SettingController.cs @@ -34,7 +34,11 @@ namespace Infrastructure.Web.Mvc { throw new ArgumentNullException(nameof(model)); } - var query = _settingService.ReadonlyTable(); + var query = _settingService.ReadonlyTable() + .WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name)) + .WhereIf(model.Query.Type.HasValue, o => o.Type == model.Query.Type.Value) + .WhereIf(!string.IsNullOrEmpty(model.Query.Value), o => o.Value.Contains(model.Query.Value)) + .OrderBy(o => o.Name); model.TotalCount = query.Count(); model.List.AddRange(query.Skip(model.PageSize * (model.PageIndex - 1)) .Take(model.PageSize) diff --git a/projects/Infrastructure/Extensions/ControllerExtensions.cs b/projects/Infrastructure/Extensions/ControllerExtensions.cs index 53e423b0..f9616150 100644 --- a/projects/Infrastructure/Extensions/ControllerExtensions.cs +++ b/projects/Infrastructure/Extensions/ControllerExtensions.cs @@ -51,7 +51,7 @@ namespace Infrastructure.Extensions public static SelectList GetSelectList(this Controller controller, object selectedValue) { var values = from Enum e in Enum.GetValues(typeof(T)) - select new { Id = e, Name = e.GetDisplayName() }; + select new { Id = e.GetValue(), Name = e.GetDisplayName() }; return new SelectList(values, "Id", "Name", selectedValue); } @@ -77,7 +77,8 @@ namespace Infrastructure.Extensions else if (metadata.IsEnum) { json.type = "string"; - dictionary["enum"] = metadata.IsNullableValueType ? Enum.GetNames(metadata.ModelType.GenericTypeArguments[0]) : Enum.GetNames(metadata.ModelType); + var type = metadata.IsNullableValueType ? metadata.ModelType.GenericTypeArguments[0] : metadata.ModelType; + dictionary["enum"] = from Enum e in Enum.GetValues(type) select new { value = e.GetValue(), text = e.ToString(), title = e.GetDisplayName() }; } else { diff --git a/projects/WebMVC/wwwroot/router/shared/display/selectlist.html b/projects/WebMVC/wwwroot/router/shared/display/selectlist.html index c6ea5b4f..8affb517 100644 --- a/projects/WebMVC/wwwroot/router/shared/display/selectlist.html +++ b/projects/WebMVC/wwwroot/router/shared/display/selectlist.html @@ -1,8 +1,21 @@  \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/router/shared/list.html b/projects/WebMVC/wwwroot/router/shared/list.html index cc0e09a0..5e1bad2e 100644 --- a/projects/WebMVC/wwwroot/router/shared/list.html +++ b/projects/WebMVC/wwwroot/router/shared/list.html @@ -50,7 +50,7 @@ - + 编辑