From 8b31c66abd0c57141cf671c2ff2dd95cb64b936d Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Sat, 26 Feb 2022 09:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=9B=E7=94=9F=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/EnrollDataController.cs | 147 +++++++++++- .../LR_Desktop/Views/EnrollData/Index.cshtml | 16 +- .../LR_Desktop/Views/EnrollData/Index.js | 45 +++- .../Learun.Application.Web.csproj | 217 +----------------- .../LR_Desktop/EnrollData/EnrollDataEntity.cs | 3 + .../EnrollData/EnrollDataService.cs | 15 +- 6 files changed, 223 insertions(+), 220 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/EnrollDataController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/EnrollDataController.cs index 3b204427f..26d66566e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/EnrollDataController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Controllers/EnrollDataController.cs @@ -3,6 +3,8 @@ using System.Data; using Learun.Application.TwoDevelopment.LR_Desktop; using System.Web.Mvc; using System.Collections.Generic; +using Learun.Application.OA.File.FilePreview; +using Learun.Application.Base.SystemModule; namespace Learun.Application.Web.Areas.LR_Desktop.Controllers { @@ -16,6 +18,8 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers public class EnrollDataController : MvcControllerBase { private EnrollDataIBLL enrollDataIBLL = new EnrollDataBLL(); + private FilePreviewIBLL filePreviewIBLL = new FilePreviewBLL(); + private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); #region 视图功能 @@ -26,7 +30,7 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers [HttpGet] public ActionResult Index() { - return View(); + return View(); } /// /// 表单页 @@ -35,8 +39,18 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers [HttpGet] public ActionResult Form() { - return View(); + return View(); } + /// + /// + /// + /// + [HttpGet] + public ActionResult IndexPersonnel() + { + return View(); + } + #endregion #region 获取数据 @@ -71,8 +85,9 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers [AjaxOnly] public ActionResult GetFormData(string keyValue) { - var EnrollDataData = enrollDataIBLL.GetEnrollDataEntity( keyValue ); - var jsonData = new { + var EnrollDataData = enrollDataIBLL.GetEnrollDataEntity(keyValue); + var jsonData = new + { EnrollData = EnrollDataData, }; return Success(jsonData); @@ -105,7 +120,7 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers public ActionResult SaveForm(string keyValue, string strEntity) { EnrollDataEntity entity = strEntity.ToObject(); - enrollDataIBLL.SaveEntity(keyValue,entity); + enrollDataIBLL.SaveEntity(keyValue, entity); if (string.IsNullOrEmpty(keyValue)) { } @@ -113,5 +128,127 @@ namespace Learun.Application.Web.Areas.LR_Desktop.Controllers } #endregion + #region MyRegion + + /// + /// 下载文件 + /// + /// 主键 + /// + [HttpPost] + public void DownloadFile(string folderid) + { + var data = annexesFileIBLL.GetEntityByFolderId(folderid); + string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 + string filepath = data.F_FilePath;//this.Server.MapPath(data.F_FilePath); + if (FileDownHelper.FileExists(filepath)) + { + FileDownHelper.DownLoadold(filepath, filename); + } + } + + /// + /// 文件预览 + /// + /// 文件ID + /// + public void PreviewFile(string folderid) + { + var data = annexesFileIBLL.GetEntityByFolderId(folderid); + if (data == null) + { + return; + } + string filename = Server.UrlDecode(data.F_FileName);//客户端保存的文件名 + string filepath = data.F_FilePath;// DirFileHelper.GetAbsolutePath(data.F_FilePath);//路径 + if (data.F_FileType == "xlsx" || data.F_FileType == "xls") + { + filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名 + if (!DirFileHelper.IsExistFile(filepath)) + { + filePreviewIBLL.GetExcelData(DirFileHelper.GetAbsolutePath(data.F_FilePath)); + } + } + if (data.F_FileType == "docx" || data.F_FileType == "doc") + { + filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名 + if (!DirFileHelper.IsExistFile(filepath)) + { + filePreviewIBLL.GetWordData(DirFileHelper.GetAbsolutePath(data.F_FilePath)); + } + } + if (data.F_FileType == "ppt" || data.F_FileType == "pptx") + { + filepath = filepath.Substring(0, filepath.LastIndexOf(".")) + ".pdf";//文件名 + if (!DirFileHelper.IsExistFile(filepath)) + { + filePreviewIBLL.GetPptData(DirFileHelper.GetAbsolutePath(data.F_FilePath)); + } + } + //FileDownHelper.DownLoadold(filepath, filename); + + + + //FileStream files = new FileStream(filepath, FileMode.Open); + //byte[] fileByte = new byte[files.Length]; + //files.Read(fileByte, 0, fileByte.Length); + //files.Close(); + //System.IO.MemoryStream ms = new MemoryStream(fileByte, 0, fileByte.Length); + Response.ClearContent(); + switch (data.F_FileType) + { + case "jpg": + Response.ContentType = "image/jpeg"; + break; + case "gif": + Response.ContentType = "image/gif"; + break; + case "png": + Response.ContentType = "image/png"; + break; + case "bmp": + Response.ContentType = "application/x-bmp"; + break; + case "jpeg": + Response.ContentType = "image/jpeg"; + break; + case "doc": + Response.ContentType = "application/pdf"; + break; + case "docx": + Response.ContentType = "application/pdf"; + break; + case "ppt": + Response.ContentType = "application/x-ppt"; + break; + case "pptx": + Response.ContentType = "application/x-ppt"; + break; + case "xls": + Response.ContentType = "application/pdf"; + break; + case "xlsx": + Response.ContentType = "application/pdf"; + break; + case "pdf": + Response.ContentType = "application/pdf"; + break; + case "txt": + Response.ContentType = "text/plain"; + break; + case "csv": + Response.ContentType = ""; + break; + default: + Response.ContentType = "application/pdf"; + break; + } + Response.Charset = "GB2312"; + Response.WriteFile(filepath); + //Response.BinaryWrite(ms.ToArray()); + } + + #endregion + } } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.cshtml index 242551b7e..77eaffc86 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.cshtml @@ -7,15 +7,27 @@
+
+ +
+
+  查询 +
+ diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.js index 03a94dfd3..9c2bdf769 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_Desktop/Views/EnrollData/Index.js @@ -13,6 +13,12 @@ var bootstrap = function ($, learun) { page.bind(); }, bind: function () { + // 查询 + $('#btn_Search').on('click', function () { + var keyword = $('#txt_Keyword').val(); + page.search({ keyword: keyword }); + }); + // 刷新 $('#lr_refresh').on('click', function () { location.reload(); @@ -63,21 +69,56 @@ var bootstrap = function ($, learun) { $('#lr_print').on('click', function () { $('#gridtable').jqprintTable(); }); + + //文件下载 + $('#lr-download').on('click', function () { + var keyValue = $('#gridtable').jfGridValue('Id'); + var Path = $("#gridtable").jfGridValue("Path"); + if (keyValue) { + learun.download({ url: top.$.rootUrl + '/LR_Desktop/EnrollData/DownloadFile', param: { folderid: Path }, method: 'POST' }); + } else { + learun.alert.warning('请选择要下载的文件!'); + } + }); + //文件预览 + $('#lr-preview').on('click', function () { + var keyValue = $("#gridtable").jfGridValue("Id"); + var Path = $("#gridtable").jfGridValue("Path"); + if (keyValue) { + learun.layerForm({ + id: 'PreviewForm', + title: '文件预览', + url: top.$.rootUrl + '/LR_Desktop/EnrollData/PreviewFile?folderid=' + Path, + width: 1080, + height: 850, + btn: null, + callBack: function (id) { + return top[id].acceptClick(refreshGirdData); + } + }); + } else { + learun.alert.warning('请选择要预览的文件!'); + } + }); + }, // 初始化列表 initGird: function () { - $('#gridtable').lrAuthorizeJfGrid({ + $('#gridtable').jfGrid({ url: top.$.rootUrl + '/LR_Desktop/EnrollData/GetPageList', headData: [ + { label: "文件名", name: "F_FileName", width: 200, align: "left"}, { label: "上传时间", name: "UploadTime", width: 100, align: "left"}, ], mainId:'Id', - isPage: true + isPage: true, + sidx: 'UploadTime desc', }); page.search(); }, search: function (param) { param = param || {}; + param.Type = 1; $('#gridtable').jfGridSet('reload',{ queryJson: JSON.stringify(param) }); } }; diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index 99924348a..29e3cbd0e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -315,7 +315,6 @@ - @@ -327,37 +326,19 @@ - - - - - - - - - - - - - - - - - - @@ -380,10 +361,8 @@ - - @@ -842,6 +821,7 @@ + @@ -1001,51 +981,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1054,8 +993,6 @@ - - @@ -1080,9 +1017,6 @@ - - - @@ -1122,15 +1056,11 @@ + + + - - - - - - - @@ -1163,39 +1093,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1332,8 +1232,6 @@ - - @@ -1341,11 +1239,6 @@ - - - - - @@ -1429,6 +1322,7 @@ + @@ -6402,7 +6296,9 @@ + + @@ -6413,10 +6309,7 @@ - - - @@ -7634,101 +7527,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataEntity.cs index 2b95074ed..8af07e092 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataEntity.cs @@ -60,6 +60,9 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop } #endregion #region 扩展字段 + [NotMapped] + public string F_FileName { get; set; } + #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataService.cs index 30b4e44a9..74aaaf79a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LR_Desktop/EnrollData/EnrollDataService.cs @@ -29,17 +29,28 @@ namespace Learun.Application.TwoDevelopment.LR_Desktop { try { + var basedbname = BaseRepository().getDbConnection().Database; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(@" - t.Id, - t.UploadTime + t.*,f.F_FileName "); strSql.Append(" FROM EnrollData t "); + strSql.Append(" left join "+ basedbname + ".dbo.LR_Base_AnnexesFile f on t.[Path]=f.f_folderid "); strSql.Append(" WHERE 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); + if (!queryParam["Type"].IsEmpty()) + { + dp.Add("Type", queryParam["Type"].ToString(), DbType.String); + strSql.Append(" AND t.Type = @Type "); + } + if (!queryParam["keyword"].IsEmpty()) + { + dp.Add("keyword", queryParam["keyword"].ToString(), DbType.String); + strSql.Append(" AND f.F_FileName like @keyword "); + } return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(),dp, pagination); } catch (Exception ex)