From 7e7f57bfe672e083dc10fb41bbca23fce7ff5fad Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Tue, 14 Jul 2020 15:44:22 +0800 Subject: [PATCH] update Former-commit-id: 083c0cdfff0a33b827e60afee530eeee16121b54 Former-commit-id: 99334f50806c700c938899038b3b04f66a8fa8ab --- .../Admin/Controllers/SettingController.cs | 6 +++++- .../Extensions/ControllerExtensions.cs | 5 +++-- .../router/shared/display/selectlist.html | 17 +++++++++++++++-- projects/WebMVC/wwwroot/router/shared/list.html | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) 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 @@ - + 编辑