diff --git a/Tiobon.Core.Api/Controllers/Base/BaseController.cs b/Tiobon.Core.Api/Controllers/Base/BaseController.cs index b85d9e71..f45cad9a 100644 --- a/Tiobon.Core.Api/Controllers/Base/BaseController.cs +++ b/Tiobon.Core.Api/Controllers/Base/BaseController.cs @@ -231,9 +231,9 @@ public class BaseController DownloadExcel() + public async Task DownloadExcel(string menuName) { - var result = (await InvokeServiceAsync("DownloadExcel", [])) as ServiceResult; + var result = (await InvokeServiceAsync("DownloadExcel", [menuName])) as ServiceResult; string path = result.Data; FileStream fs = new FileStream(path, FileMode.OpenOrCreate); fs.Close(); diff --git a/Tiobon.Core.Api/Controllers/CommonController.cs b/Tiobon.Core.Api/Controllers/CommonController.cs index 1ea80485..7b022355 100644 --- a/Tiobon.Core.Api/Controllers/CommonController.cs +++ b/Tiobon.Core.Api/Controllers/CommonController.cs @@ -55,9 +55,9 @@ public class CommonController : BaseApiController /// /// [HttpPost, Route("GetSelect/{type}")] - public async Task> GetSelectAsync(string type) + public async Task> GetSelectAsync(string type, string Keywords) { - return await _commonServices.GetSelectAsync(type); + return await _commonServices.GetSelectAsync(type, Keywords); } #endregion diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs index 88131643..e329fa5a 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_CourseController.cs @@ -54,9 +54,9 @@ public class Ghre_CourseController : BaseController /// [HttpPost, Route("QuerySelect")] - public async Task> QuerySelectAsync(long? linkId) + public async Task> QuerySelectAsync(long? linkId, string KeyWords) { - return await _service.GetSelectAsync(linkId); + return await _service.GetSelectAsync(linkId, KeyWords); } #endregion diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs index a995734c..021f8e1e 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamPaperController.cs @@ -100,9 +100,9 @@ public class Ghre_ExamPaperController : BaseController /// [HttpPost, Route("GetSelect")] - public async Task> GetSelectAsync(long? linkId) + public async Task> GetSelectAsync(long? linkId, string KeyWords) { - return await _service.GetSelectAsync(linkId); + return await _service.GetSelectAsync(linkId, KeyWords); } #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 7481ff14..c25704dc 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -251,7 +251,7 @@ - + 获取模块信息接口 @@ -588,7 +588,7 @@ 条件 - + 获取通用列表下拉 @@ -747,7 +747,7 @@ - + 获取通用列表下拉 diff --git a/Tiobon.Core.IServices/BASE/IBaseServices.cs b/Tiobon.Core.IServices/BASE/IBaseServices.cs index b5b1a74a..6c59c0e1 100644 --- a/Tiobon.Core.IServices/BASE/IBaseServices.cs +++ b/Tiobon.Core.IServices/BASE/IBaseServices.cs @@ -155,7 +155,7 @@ namespace Tiobon.Core.IServices.BASE Task> ImportExcel(IFormFile file); - Task> DownloadExcel(); + Task> DownloadExcel(string menuName); Task> QueryMuch( Expression> joinExpression, diff --git a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs index 450759c9..6f8e3ce3 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_CourseServices.cs @@ -4,19 +4,19 @@ using Tiobon.Core.Model; using Tiobon.Core.Model.Models; namespace Tiobon.Core.IServices -{ - /// - /// 课程(自定义服务接口) - /// - public interface IGhre_CourseServices :IBaseServices - { +{ + /// + /// 课程(自定义服务接口) + /// + public interface IGhre_CourseServices : IBaseServices + { - Task> QueryList(QueryBody filter, string status); + Task> QueryList(QueryBody filter, string status); - Task> QueryDeptID(int StaffID); - Task> QueryTeacher(long? linkId); - Task UpdateStatus(long[] ids, string status); - Task> GetSelectAsync(long? linkId); + Task> QueryDeptID(int StaffID); + Task> QueryTeacher(long? linkId); + Task UpdateStatus(long[] ids, string status); + Task> GetSelectAsync(long? linkId, string keyWords); } } \ No newline at end of file diff --git a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs index 99c51b9f..cc991fef 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_ExamPaperServices.cs @@ -21,6 +21,6 @@ namespace Tiobon.Core.IServices Task> QueryList(QueryBody body, string status); - Task> GetSelectAsync(long? linkId); + Task> GetSelectAsync(long? linkId, string KeyWords); } } \ No newline at end of file diff --git a/Tiobon.Core.IServices/ICommonServices.cs b/Tiobon.Core.IServices/ICommonServices.cs index f28f367b..1ead0442 100644 --- a/Tiobon.Core.IServices/ICommonServices.cs +++ b/Tiobon.Core.IServices/ICommonServices.cs @@ -22,7 +22,7 @@ public interface ICommonServices : IBaseServices> Task> GetModuleInfoAsync([FromBody] ModuleParam param); - Task> GetSelectAsync(string type); + Task> GetSelectAsync(string type, string keyWords); Task> ExportExcelAsync(QueryExport param); diff --git a/Tiobon.Core.Services/BASE/BaseServices.cs b/Tiobon.Core.Services/BASE/BaseServices.cs index 32ebd7b3..4504b518 100644 --- a/Tiobon.Core.Services/BASE/BaseServices.cs +++ b/Tiobon.Core.Services/BASE/BaseServices.cs @@ -835,16 +835,57 @@ public class BaseServices : IBaseServ return ServiceResult.OprateSuccess("导入成功!"); } - public async virtual Task> DownloadExcel() + public virtual async Task> DownloadExcel(string menuName) { - var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; - var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}"; - if (!Directory.Exists(physicsPath + path)) - Directory.CreateDirectory(physicsPath + path); + var tableNmae = string.Empty; Type entityType = typeof(TEntity); - var fileName = entityType.GetEntityTableName() + ".xlsx"; - var result = ServiceResult.OprateSuccess(fileName, physicsPath + path + fileName); + + + var sql = $@"SELECT Row_Number () + OVER (ORDER BY CONVERT (INT, rowNum), CONVERT (INT, colNum)) + sortNum, + field, + [dbo].[FLangKeyToValue] (mkey, 1, label) + label, + dbo.FS_GetdataSourceBySet + (dataSource, APIDataSourceType, Ghrs_PageSettingEdit.APIDataSourceID) + dataSource, + required, + dataType, + CONVERT (NVARCHAR (1000), '') + commentText -- StaffWith + , + elementType + + CASE WHEN multipleSelect = 'true' THEN '_multiple' ELSE '' END + elementType -- 增加多选判断 + FROM Ghrs_PageSettingEdit + WHERE IsEnable = 1 + AND elementType NOT IN ('FnKey', 'PageGroup') + AND pageNo = '{menuName}' + --and editable = 'true' + AND defaultHidden ! = 'true' + AND elementType ! = 'FileUpload' + AND dataType ! = ''"; + + var columns = await Db.Ado.SqlQueryAsync(sql); + + var dt = await Db.Ado.GetDataTableAsync("SELECT * FROM " + entityType.GetEntityTableName() + " WHERE IsEnable=1"); + + //columns = columns.WhereIF(param.exportSet.ExFields.Any(), x => param.exportSet.ExFields.Contains(x.field)).ToList(); + + await ReportHelper.ImportTemplate(Db, columns, dt, menuName); + + + //var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; + //var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}"; + //if (!Directory.Exists(physicsPath + path)) + // Directory.CreateDirectory(physicsPath + path); + + //Type entityType = typeof(TEntity); + //var fileName = entityType.GetEntityTableName() + ".xlsx"; + //var result = ServiceResult.OprateSuccess(fileName, physicsPath + path + fileName); + var result = ServiceResult.OprateSuccess(null, null); return result; } diff --git a/Tiobon.Core.Services/CommonServices.cs b/Tiobon.Core.Services/CommonServices.cs index 3bc0b718..096b809f 100644 --- a/Tiobon.Core.Services/CommonServices.cs +++ b/Tiobon.Core.Services/CommonServices.cs @@ -851,9 +851,9 @@ public partial class CommonServices : BaseServices>, ICommon result.DT_Procedure.IUDProcedure = dt.Rows[0]["IUDProcedure"].ToString(); if (!string.IsNullOrWhiteSpace(result.DT_Procedure.EditProcedure)) { - result.DT_Procedure.ImportExcel = "/api" + result.DT_Procedure.EditProcedure.Replace("QueryForm", "ImportExcel"); - result.DT_Procedure.DownExcelTemplate = "/api" + result.DT_Procedure.EditProcedure.Replace("QueryForm", "DownExcelTemplate"); - result.DT_Procedure.ExportExcel = "/api" + result.DT_Procedure.EditProcedure.Replace("QueryForm", "ExportExcel"); + result.DT_Procedure.ImportExcel = result.DT_Procedure.EditProcedure.Replace("QueryForm", "ImportExcel"); + result.DT_Procedure.DownExcelTemplate = result.DT_Procedure.EditProcedure.Replace("QueryForm", "DownExcelTemplate?menuName=" + param.menuName); + result.DT_Procedure.ExportExcel = result.DT_Procedure.EditProcedure.Replace("QueryForm", "ExportExcel"); } } @@ -1057,7 +1057,7 @@ public partial class CommonServices : BaseServices>, ICommon /// /// /// - public async Task> GetSelectAsync(string type) + public async Task> GetSelectAsync(string type, string keyWords) { var result = new CommonSelect(); JArray TableColumn = new JArray(); @@ -1083,6 +1083,8 @@ public partial class CommonServices : BaseServices>, ICommon TableColumn.Add(searchItem); sql = "SELECT Id, CourseNo, CourseName FROM Ghre_Course WHERE IsEnable=1 AND Status='Released'"; + if (string.IsNullOrWhiteSpace(keyWords)) + sql += $"AND ( CourseNo like '%{keyWords}%' or CourseName like '%{keyWords}%')"; dt = await Db.Ado.GetDataTableAsync(sql); for (int i = 0; i < dt.Rows.Count; i++) @@ -1118,6 +1120,8 @@ public partial class CommonServices : BaseServices>, ICommon TableColumn.Add(searchItem); sql = "SELECT Id, SceneNo, SceneName FROM Ghre_CourseScene"; + if (string.IsNullOrWhiteSpace(keyWords)) + sql += $"AND ( SceneNo like '%{keyWords}%' or SceneName like '%{keyWords}%')"; dt = await Db.Ado.GetDataTableAsync(sql); for (int i = 0; i < dt.Rows.Count; i++) diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index 18f73583..f80103d1 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -17,6 +17,7 @@ using AgileObjects.AgileMapper; using Microsoft.AspNetCore.Http; using Tiobon.Core.Common.UserManager; using Tiobon.Core.Common.Helper; +using static Microsoft.Extensions.Logging.EventSource.LoggingEventSource; namespace Tiobon.Core.Services; @@ -371,7 +372,7 @@ public class Ghre_CourseServices : BaseServices /// /// - public async Task> GetSelectAsync(long? linkId) + public async Task> GetSelectAsync(long? linkId, string keyWords) { var result = new CommonSelect(); var TableColumn = new JArray(); @@ -394,6 +395,8 @@ public class Ghre_CourseServices : BaseServices /// /// - public async Task> GetSelectAsync(long? linkId) + public async Task> GetSelectAsync(long? linkId, string keyWords) { var result = new CommonSelect(); var TableColumn = new JArray(); @@ -833,7 +833,10 @@ delete from Ghre_ExamPaperQuestion WHERE ExamPaperId='{id}';"); ]; TableColumn.Add(searchItem); - sql = $"SELECT Id, PaperNo, PaperName FROM Ghre_ExamPaper WHERE LinkId='{linkId}' AND Status ='Released' AND IsEnable=1 ORDER BY CreateTime DESC"; + sql = $"SELECT Id, PaperNo, PaperName FROM Ghre_ExamPaper WHERE LinkId='{linkId}' AND Status ='Released' AND IsEnable=1"; + if (string.IsNullOrWhiteSpace(keyWords)) + sql += $"AND ( PaperNo like '%{keyWords}%' or PaperName like '%{keyWords}%')"; + sql += $" ORDER BY CreateTime DESC"; dt = await Db.Ado.GetDataTableAsync(sql); for (int i = 0; i < dt.Rows.Count; i++) diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index e865c09b..95dbf960 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using SqlSugar; using Tiobon.Core.Common; using Tiobon.Core.Common.Caches; +using Tiobon.Core.Common.DB.Dapper.Extensions; using Tiobon.Core.Common.Helper; using Tiobon.Core.IRepository.Base; using Tiobon.Core.IServices; @@ -1040,5 +1041,18 @@ public class Ghre_QuestionServices : BaseServices.OprateSuccess("导入成功!", data); } + + public override async Task> DownloadExcel(string menuName) + { + var physicsPath = $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot"; + var path = $"{$"{Path.DirectorySeparatorChar}files{Path.DirectorySeparatorChar}ExcelTemplate{Path.DirectorySeparatorChar}"}"; + if (!Directory.Exists(physicsPath + path)) + Directory.CreateDirectory(physicsPath + path); + + Type entityType = typeof(Ghre_Question); + var fileName = entityType.GetEntityTableName() + ".xlsx"; + var result = ServiceResult.OprateSuccess(fileName, physicsPath + path + fileName); + return result; + } #endregion } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 7481ff14..c25704dc 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -251,7 +251,7 @@ - + 获取模块信息接口 @@ -588,7 +588,7 @@ 条件 - + 获取通用列表下拉 @@ -747,7 +747,7 @@ - + 获取通用列表下拉