diff --git a/projects/Infrastructure/Web/Mvc/CrudController.cs b/projects/Infrastructure/Web/Mvc/CrudController.cs index 046dd47c..94451d4b 100644 --- a/projects/Infrastructure/Web/Mvc/CrudController.cs +++ b/projects/Infrastructure/Web/Mvc/CrudController.cs @@ -56,13 +56,7 @@ namespace Infrastructure.Web.Mvc .ToList()); ViewData["EntityTypeExt"] = typeof(TEntity); ViewData["ModelTypeExt"] = typeof(TDisplayModel); - if (this.Request.Headers["accept"].ToString().Contains("json", StringComparison.OrdinalIgnoreCase)) - { - model.ViewData = ViewData; - model.Schema = this.GetSchema(); - return Json(model, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); - } - return View(model); + return Result(model); } [HttpGet] @@ -81,7 +75,7 @@ namespace Infrastructure.Web.Mvc { var model = Activator.CreateInstance(); this.ToEditModel(null, model); - return View(model); + return Result(model); } [HttpPost] @@ -105,7 +99,7 @@ namespace Infrastructure.Web.Mvc } } this.ToEditModel(null, model); - return View(model); + return Result(model); } [HttpGet] @@ -116,7 +110,7 @@ namespace Infrastructure.Web.Mvc var entity = query.FirstOrDefault(o => o.Id == id); var model = entity.To(); this.ToEditModel(entity, model); - return View(model); + return Result(model); } [HttpPost] @@ -142,7 +136,7 @@ namespace Infrastructure.Web.Mvc } } this.ToEditModel(entity, model); - return View(model); + return Result(model); } [HttpPost] @@ -295,14 +289,14 @@ namespace Infrastructure.Web.Mvc { if (this.Request.Headers["accept"].ToString().Contains("json", StringComparison.OrdinalIgnoreCase)) { - return Json(model); + return Json(new + { + schema = this.GetJsonSchema(), + model, + data = ViewData + }, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); } return View(model); } - - public object GetSchema() - { - return this.GetJsonSchema(); - } } } \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/router/admin/list.html b/projects/WebMVC/wwwroot/router/admin/list.html index dbf63d43..b4161b2a 100644 --- a/projects/WebMVC/wwwroot/router/admin/list.html +++ b/projects/WebMVC/wwwroot/router/admin/list.html @@ -10,9 +10,9 @@
- +
- +
@@ -44,12 +44,12 @@ - + - + 编辑 @@ -60,7 +60,7 @@
- + @@ -76,28 +76,33 @@ url: '/IoTCenter/Admin/' + this.$route.query.entity + '/Index', entity: this.$route.query.entity, data: { - pageIndex: 1, - pageSize: 20, - list: [], - schema: {} + schema: { + title: '' + }, + model: { + pageIndex: 1, + pageSize: 20, + list: [], + }, + data: {} } } }, mounted: function () { - this.load(this.data.pageIndex, this.data.pageSize); + this.load(this.data.model.pageIndex, this.data.model.pageSize); }, methods: { load: function (index, size) { if (index) { - this.data.pageIndex = index; + this.data.model.pageIndex = index; } if (size) { - this.data.pageSize = size; + this.data.model.pageSize = size; } var vm = this; var url = config.baseUrl + this.url; var query = $("form.query").serialize(); - var page = 'pageIndex=' + this.data.pageIndex + '&pageSize=' + this.data.pageSize; + var page = 'pageIndex=' + this.data.model.pageIndex + '&pageSize=' + this.data.model.pageSize; if (query) { url += '?' + query + '&' + page; }