diff --git a/Api/Ewide.Application/Ewide.Application.xml b/Api/Ewide.Application/Ewide.Application.xml index d00d013..4a7d351 100644 --- a/Api/Ewide.Application/Ewide.Application.xml +++ b/Api/Ewide.Application/Ewide.Application.xml @@ -37,7 +37,7 @@ - + 分页查询 diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs index 636af34..7f6a693 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/Dto/HouseProjectInfoInput.cs @@ -36,4 +36,9 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto { } + + public class PageProjectInput: HouseProjectInfoInput + { + public string pid { get; set; } + } } diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs index dbe658a..11168eb 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs @@ -6,6 +6,7 @@ using Furion.DatabaseAccessor; using Furion.DatabaseAccessor.Extensions; using Furion.DependencyInjection; using Furion.DynamicApiController; +using Furion.FriendlyException; using Mapster; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -83,13 +84,13 @@ namespace Ewide.Application.Service.HouseProjectInfo /// /// [HttpPost("/houseProjectInfo/page")] - public async Task QueryProjectPageList([FromBody] HouseProjectInfoInput input) + public async Task QueryProjectPageList([FromBody] PageProjectInput input) { - var areaID = !string.IsNullOrEmpty(input.AreaCode); var areaCodeRep = Db.GetRepository(); var projects = await _houseProjectInfoRep.DetachedEntities .Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name }) - .Where(areaID, x => x.p.AreaCode == input.AreaCode) + .Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode) + .Where(!string.IsNullOrEmpty(input.pid) , x=> x.p.AreaCode.Contains(input.pid)) .Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaCode, x.AreaName, x.p.Type }.Adapt()).ToPagedListAsync(input.PageNo, input.PageSize); return XnPageResult.PageResult(projects); } @@ -107,5 +108,24 @@ namespace Ewide.Application.Service.HouseProjectInfo return userDto; } + + [HttpGet("/houseProjectInfo/nextSort")] + public async Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input) + { + //var projects = await _houseProjectInfoRep.DetachedEntities + // .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type) + // .Select(p => p.Sort) + // .DefaultIfEmpty() + // .MaxAsync(); + if (input.Type > 2 || input.Type < 1) + { + throw Oops.Oh("类型参数异常"); + } + var p = await _houseProjectInfoRep.DetachedEntities + .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type) + .MaxAsync(p => (int?)p.Sort); + + return p.GetValueOrDefault(0) + 1; + } } } diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs index a004011..d4c74c0 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/IHouseProjectInfoService.cs @@ -16,6 +16,8 @@ namespace Ewide.Application.Service.HouseProjectInfo Task UpdateProject(UpdateProjectInput input); Task GetProjectById([FromRoute] string id); Task GetProject([FromQuery] QueryProjectInput input); - Task QueryProjectPageList([FromQuery] HouseProjectInfoInput input); + Task QueryProjectPageList([FromQuery] PageProjectInput input); + + Task GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input); } } diff --git a/Web/src/pages/business/house/project/form.vue b/Web/src/pages/business/house/project/form.vue index b65d1a6..a1c3836 100644 --- a/Web/src/pages/business/house/project/form.vue +++ b/Web/src/pages/business/house/project/form.vue @@ -51,6 +51,7 @@ export default { name: [{ required: true, message: '请输入项目名称' }], sort: [{ required: true, message: '请输入排序' }], areaCode: [{ required: true, message: '请选择所属区域' }], + type: [{ required: true, message: '请选择类型' }], }, /** 加载异步数据状态 */ @@ -68,7 +69,7 @@ export default { */ onFillData(params) { // 从字符串areaCode查找到整个层级 - const areaCodeDeault = params.record ? params.record.areaId : params.pid ? params.pid : ''; + const areaCodeDeault = params.record ? params.record.areaCode : params.pid ? params.pid : ''; const areaCode = []; const findCode = (data, level) => { level = level || 0; @@ -98,7 +99,7 @@ export default { ...defaultForm, ...params.record, /** 在此处添加其他默认数据转换 */ - areaCode, + areaCode: areaCode.length == 4 ? areaCode : [], /* ... */ }); }, diff --git a/Web/src/pages/system/area/index.vue b/Web/src/pages/system/area/index.vue index 66b6fab..9fa61e7 100644 --- a/Web/src/pages/system/area/index.vue +++ b/Web/src/pages/system/area/index.vue @@ -8,13 +8,7 @@
- + @@ -147,6 +141,10 @@ export default { * 传给yo-table以示意数据接口及其参数和返回的数据结构 */ loadData(params) { + if (!params.sortField) { + params.sortField = 'code'; + params.sortOrder = 'ascend'; + } return this.$api[api.page]({ ...params, ...this.query,