From c5d636d69794ddab95913a17260976473e2957eb Mon Sep 17 00:00:00 2001 From: JiangCYkk <1581850110@qq.com> Date: Fri, 28 Mar 2025 16:33:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E4=B8=8B=E6=8B=89=E6=A1=86=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=90=8E=E5=8F=B0=E6=95=B0=E6=8D=AE=EF=BC=9B?= =?UTF-8?q?=20=E6=9C=AA=E5=AE=9E=E7=8E=B0=E6=BB=9A=E5=8A=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YiCrudAppService.cs | 40 ++++++--- .../src/components/SelectDataTag/index.vue | 83 +++++++++++++++++++ Yi.RuoYi.Vue3/src/main.js | 3 + 3 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue diff --git a/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs b/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs index 3ead8bcc..dae1a753 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.Ddd.Application/YiCrudAppService.cs @@ -11,12 +11,12 @@ namespace Yi.Framework.Ddd.Application /// /// CRUD应用服务基类 - 基础版本 /// - public abstract class YiCrudAppService + public abstract class YiCrudAppService : YiCrudAppService where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected YiCrudAppService(IRepository repository) + protected YiCrudAppService(IRepository repository) : base(repository) { } @@ -30,7 +30,7 @@ namespace Yi.Framework.Ddd.Application where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected YiCrudAppService(IRepository repository) + protected YiCrudAppService(IRepository repository) : base(repository) { } @@ -44,7 +44,7 @@ namespace Yi.Framework.Ddd.Application where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected YiCrudAppService(IRepository repository) + protected YiCrudAppService(IRepository repository) : base(repository) { } @@ -58,7 +58,7 @@ namespace Yi.Framework.Ddd.Application where TEntity : class, IEntity where TEntityDto : IEntityDto { - protected YiCrudAppService(IRepository repository) + protected YiCrudAppService(IRepository repository) : base(repository) { } @@ -78,7 +78,7 @@ namespace Yi.Framework.Ddd.Application /// private const string TempFilePath = "/wwwroot/temp"; - protected YiCrudAppService(IRepository repository) + protected YiCrudAppService(IRepository repository) : base(repository) { } @@ -96,7 +96,7 @@ namespace Yi.Framework.Ddd.Application // 获取并验证实体 var entity = await GetEntityByIdAsync(id); - + // 检查更新输入 await CheckUpdateInputDtoAsync(entity, input); @@ -124,10 +124,10 @@ namespace Yi.Framework.Ddd.Application { // 检查创建权限 await CheckCreatePolicyAsync(); - + // 检查创建输入 await CheckCreateInputDtoAsync(input); - + // 映射到实体 var entity = await MapToEntityAsync(input); @@ -156,13 +156,13 @@ namespace Yi.Framework.Ddd.Application public override async Task> GetListAsync(TGetListInput input) { List entities; - + // 根据输入类型决定查询方式 if (input is IPagedResultRequest pagedInput) { // 分页查询 entities = await Repository.GetPagedListAsync( - pagedInput.SkipCount, + pagedInput.SkipCount, pagedInput.MaxResultCount, string.Empty ); @@ -176,7 +176,23 @@ namespace Yi.Framework.Ddd.Application // 获取总数并映射结果 var totalCount = await Repository.GetCountAsync(); var dtos = await MapToGetListOutputDtosAsync(entities); - + + return new PagedResultDto(totalCount, dtos); + } + + /// + /// 获取实体动态下拉框列表,子类重写该方法,通过 keywords 进行筛选 + /// + /// 查询关键字 + /// + public virtual async Task> GetSelectDataListAsync(string? keywords = null) + { + List entities = await Repository.GetListAsync(); + + // 获取总数并映射结果 + var totalCount = entities.Count; + var dtos = await MapToGetListOutputDtosAsync(entities); + return new PagedResultDto(totalCount, dtos); } diff --git a/Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue b/Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue new file mode 100644 index 00000000..49ed7803 --- /dev/null +++ b/Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue @@ -0,0 +1,83 @@ + + + diff --git a/Yi.RuoYi.Vue3/src/main.js b/Yi.RuoYi.Vue3/src/main.js index 4e2f787e..cf792a22 100644 --- a/Yi.RuoYi.Vue3/src/main.js +++ b/Yi.RuoYi.Vue3/src/main.js @@ -43,6 +43,8 @@ import ImagePreview from "@/components/ImagePreview" import TreeSelect from '@/components/TreeSelect' // 字典标签组件 import DictTag from '@/components/DictTag' +// 动态数据下拉选择框组件 +import SelectDataTag from '@/components/SelectDataTag' const app = createApp(App) @@ -57,6 +59,7 @@ app.config.globalProperties.selectDictLabel = selectDictLabel app.config.globalProperties.selectDictLabels = selectDictLabels // 全局组件挂载 +app.component('SelectDataTag', SelectDataTag) app.component('DictTag', DictTag) app.component('Pagination', Pagination) app.component('TreeSelect', TreeSelect)