diff --git a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs index 03db164..ab3f341 100644 --- a/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs +++ b/Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs @@ -17,6 +17,7 @@ using Faster.Zheng.Winin.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; +using NPOI.POIFS.Macros; using NPOI.SS.Formula.Functions; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; @@ -295,23 +296,18 @@ public class ZbxBasep.Name!= "Details").ToArray();//去除details属性否则导出时会带出来 - #region 用户个性导出 + #region 用户个性导出 主表 - //获取个型导出的字段 - var show = await _exportCustomUserSettingAppService.GetByUserIdAndExportTableNameAsync(userId, typeof(TEntity).Name); - var notShowUserColumn = show.Where(p => p.CustomUserSetting == Enum_ExportCustomUserSetting.No).Select(p => p.ExportColumnName).ToList(); - if (show.Count == 0) + //获取个性导出的字段 + var mainUserColumn = await _exportCustomUserSettingAppService.GetByUserIdAndExportTableNameAsync(userId, typeof(TEntity).Name); + var mainNotShowUserColumn = mainUserColumn.Where(p => p.CustomUserSetting == Enum_ExportCustomUserSetting.No).Select(p => p.ExportColumnName).ToList(); + if (mainUserColumn.Any()) { - //如果没有就都导出 - } - else - { - mainProperties = mainProperties.Where(p =>!notShowUserColumn.Contains(p.Name)).ToArray();//去除details属性否则导出时会带出来 + mainProperties = mainProperties.Where(p => !mainNotShowUserColumn.Contains(p.Name)).ToArray(); } #endregion - IRow headerRow = sheet.CreateRow(0); for (int i = 0; i < mainProperties.Length; i++) { @@ -323,6 +319,9 @@ public class ZbxBase p.Name == "Details"); + var detailUserColumn = await _exportCustomUserSettingAppService.GetByUserIdAndExportTableNameAsync( + userId, detailDtoName.PropertyType.GenericTypeArguments.First().Name.Replace("Dto", "")); + var detailNotShowUserColumn = detailUserColumn.Where(p => p.CustomUserSetting == Enum_ExportCustomUserSetting.No).Select(p => p.ExportColumnName).ToList(); + if (detailUserColumn.Any()) + { + detailProperties = detailProperties.Where(p => !detailNotShowUserColumn.Contains(p.Name)).ToArray(); + } + + #endregion + for (int i = 0; i < detailProperties.Length; i++) { headerRow.CreateCell(mainProperties.Length + splitDetailsColumnNumber + i)