😎1、删除组件jwchat 2、简化调整导入导出相关代码

This commit is contained in:
zuohuaijun 2025-07-24 21:24:50 +08:00
parent aac51ac1b1
commit 45b8e46935
10 changed files with 24 additions and 39 deletions

View File

@ -52,7 +52,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.5" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.11.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.13.0" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.230" />
<PackageReference Include="SqlSugar.MongoDbCore" Version="5.1.4.232" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.198" />
<PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.6" />

View File

@ -36,9 +36,9 @@ public class SysProcService : IDynamicApiController, ITransient
headers.Add(val.Key.ToUpper(), new Tuple<string, int>(val.Value, index));
index++;
}
var excelExporter = new ExcelExporter();
var da = await excelExporter.ExportAsByteArray(dt, new ProcExporterHeaderFilter(headers));
return new FileContentResult(da, "application/octet-stream") { FileDownloadName = input.ProcId + ".xlsx" };
var res = await new ExcelExporter().ExportAsByteArray(dt, new ProcExporterHeaderFilter(headers));
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = input.ProcId + ".xlsx" };
}
/// <summary>
@ -52,10 +52,9 @@ public class SysProcService : IDynamicApiController, ITransient
var db = _db.AsTenant().GetConnectionScope(input.ConfigId);
var dt = await db.Ado.UseStoredProcedure().GetDataTableAsync(input.ProcId, input.ProcParams);
var excelExporter = new ExcelExporter();
string template = AppDomain.CurrentDomain.BaseDirectory + "/wwwroot/template/" + input.Template + ".xlsx";
var bs = await excelExporter.ExportBytesByTemplate(dt, template);
return new FileContentResult(bs, "application/octet-stream") { FileDownloadName = input.ProcId + ".xlsx" };
var template = AppDomain.CurrentDomain.BaseDirectory + "/wwwroot/template/" + input.Template + ".xlsx";
var res = await new ExcelExporter().ExportBytesByTemplate(dt, template);
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = input.ProcId + ".xlsx" };
}
/// <summary>

View File

@ -81,7 +81,7 @@ public class SysLogExService : IDynamicApiController, ITransient
if (logExList == null || logExList.Count < 1)
throw Oops.Oh("日志数据为空,导出已取消");
var res = await ((IExcelExporter)new ExcelExporter()).ExportAsByteArray(logExList);
var res = await new ExcelExporter().ExportAsByteArray(logExList);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "异常日志.xlsx" };
}
}

View File

@ -79,7 +79,7 @@ public class SysLogOpService : IDynamicApiController, ITransient
if (logOpList == null || logOpList.Count < 1)
throw Oops.Oh("日志数据为空,导出已取消");
var res = await ((IExcelExporter)new ExcelExporter()).ExportAsByteArray(logOpList);
var res = await new ExcelExporter().ExportAsByteArray(logOpList);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "操作日志.xlsx" };
}

View File

@ -138,8 +138,7 @@ public class SysPosService : IDynamicApiController, ITransient
//var tFile = await sysFileService.UploadFile(new UploadFileInput { File = file });
//var filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, tFile.FilePath, tFile.Id.ToString() + tFile.Suffix);
IImporter importer = new ExcelImporter();
var res = await importer.Import<PosDto>(stream);
var res = await new ExcelImporter().Import<PosDto>(stream);
//// 删除上传的临时文件(避免文件冗余)
//await sysFileService.DeleteFile(new BaseIdInput { Id = tFile.Id });
@ -162,12 +161,12 @@ public class SysPosService : IDynamicApiController, ITransient
var posList = await _sysPosRep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name == input.Name)
.WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code == input.Code)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.OrderBy(u => u.Name, OrderByType.Desc)
.Select<PosDto>().ToListAsync();
if (posList == null || posList.Count < 1)
throw Oops.Oh("数据为空,导出已取消");
var res = await ((IExcelExporter)new ExcelExporter()).ExportAsByteArray(posList);
var res = await new ExcelExporter().ExportAsByteArray(posList);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "职位列表.xlsx" };
}
@ -177,8 +176,7 @@ public class SysPosService : IDynamicApiController, ITransient
/// <returns></returns>
public async Task<IActionResult> DownloadTemplate()
{
IImporter Importer = new ExcelImporter();
var res = await Importer.GenerateTemplateBytes<PosDto>();
var res = await new ExcelImporter().GenerateTemplateBytes<PosDto>();
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = "职位导入模板.xlsx" };
}
}

View File

@ -191,9 +191,7 @@ public static class CommonHelper
/// <returns></returns>
public static async Task<IActionResult> ExportExcelTemplate<T>(string fileName = null) where T : class, new()
{
var importer = new ExcelImporter();
var res = await importer.GenerateTemplateBytes<T>();
var res = await new ExcelImporter().GenerateTemplateBytes<T>();
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? typeof(T).Name : fileName)}.xlsx" };
}
@ -203,9 +201,7 @@ public static class CommonHelper
/// <returns></returns>
public static async Task<IActionResult> ExportExcelData<T>(ICollection<T> data, string fileName = null) where T : class, new()
{
var export = new ExcelExporter();
var res = await export.ExportAsByteArray<T>(data);
var res = await new ExcelExporter().ExportAsByteArray<T>(data);
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = $"{(string.IsNullOrEmpty(fileName) ? typeof(T).Name : fileName)}.xlsx" };
}
@ -260,9 +256,8 @@ public static class CommonHelper
}
result.Add(newData);
}
var export = new ExcelExporter();
var res = await export.ExportAsByteArray(result);
var res = await new ExcelExporter().ExportAsByteArray(result);
return new FileContentResult(res, "application/octet-stream") { FileDownloadName = typeof(TTarget).Name + ".xlsx" };
}
@ -273,7 +268,7 @@ public static class CommonHelper
/// <returns></returns>
public static async Task<ICollection<T>> ImportExcelData<T>([Required] IFormFile file) where T : class, new()
{
var res = await ((IImporter)new ExcelImporter()).Import<T>(file.OpenReadStream());
var res = await new ExcelImporter().Import<T>(file.OpenReadStream());
if (!res.HasError) return res.Data;
var message = string.Empty;
@ -299,7 +294,7 @@ public static class CommonHelper
public static async Task<ICollection<T>> ImportExcelData<T>([Required] IFormFile file, Func<ImportResult<T>, ImportResult<T>> importResultCallback = null) where T : class, new()
{
var resultStream = new MemoryStream();
var res = await ((IImporter)new ExcelImporter()).Import<T>(file.OpenReadStream(), resultStream, importResultCallback);
var res = await new ExcelImporter().Import<T>(file.OpenReadStream(), resultStream, importResultCallback);
resultStream.Seek(0, SeekOrigin.Begin);
if (!res.HasError) return res.Data;

View File

@ -63,9 +63,8 @@ public class ExcelHelper
/// <returns></returns>
public static IActionResult ExportData(dynamic list, string fileName = "导入记录")
{
var exporter = new ExcelExporter();
var fs = new MemoryStream(exporter.ExportAsByteArray(list).GetAwaiter().GetResult());
return new XlsxFileResult(stream: fs, fileDownloadName: $"{fileName}-{DateTime.Now:yyyy-MM-dd_HHmmss}");
var res = new ExcelExporter().ExportAsByteArray(list).GetAwaiter().GetResult();
return new XlsxFileResult(stream: new MemoryStream(res), fileDownloadName: $"{fileName}-{DateTime.Now:yyyy-MM-dd_HHmmss}");
}
/// <summary>

View File

@ -28,10 +28,8 @@ public class XlsxFileResult<T> : XlsxFileResultBase where T : class, new()
public override async Task ExecuteResultAsync(ActionContext context)
{
var exporter = new ExcelExporter();
var bytes = await exporter.ExportAsByteArray(Data);
var fs = new MemoryStream(bytes);
await DownloadExcelFileAsync(context, fs, FileDownloadName);
var res = await new ExcelExporter().ExportAsByteArray(Data);
await DownloadExcelFileAsync(context, new MemoryStream(res), FileDownloadName);
}
}

View File

@ -48,7 +48,6 @@
"js-table2excel": "^1.1.2",
"json-editor-vue": "^0.18.1",
"jsplumb": "^2.15.6",
"jwchat": "^2.0.3",
"lodash-es": "^4.17.21",
"magic-string": "^0.30.17",
"md-editor-v3": "^5.8.2",
@ -84,7 +83,7 @@
"vue-signature-pad": "^3.0.2",
"vue3-tree-org": "^4.2.2",
"vxe-pc-ui": "^4.7.24",
"vxe-table": "^4.14.5",
"vxe-table": "^4.14.6",
"xe-utils": "^3.7.8",
"xlsx-js-style": "^1.2.0"
},

View File

@ -21,9 +21,6 @@ import VForm3 from 'vform3-builds';
import 'vform3-builds/dist/designer.style.css';
// Vxe-Table
import { setupVXETable } from '/@/hooks/setupVXETableHook';
// IM聊天框
import JwChat from 'jwchat';
import 'jwchat/lib/style.css';
// 自定义字典组件
import sysDict from '/@/components/sysDict/sysDict.vue';
// AI组件
@ -39,4 +36,4 @@ other.elSvg(app);
// 注册全局字典组件
app.component('GSysDict', sysDict);
app.use(pinia).use(i18n).use(router).use(ElementPlus).use(setupVXETable).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).use(JwChat).use(ElementPlusX).mount('#app');
app.use(pinia).use(i18n).use(router).use(ElementPlus).use(setupVXETable).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).use(ElementPlusX).mount('#app');