From c2e64dd8782455147584d40e55fa019b5797e7a0 Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Tue, 24 May 2022 15:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=9F=A5=E8=AF=A2=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ResourceFileController.cs | 31 ++--- .../LR_OAModule/Views/ResourceFile/Index.js | 21 +++- .../File/FileInfo/FileInfoBLL.cs | 24 ++-- .../File/FileInfo/FileInfoIBLL.cs | 13 +- .../File/FileInfo/FileInfoService.cs | 111 ++++++++++++------ 5 files changed, 121 insertions(+), 79 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/ResourceFileController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/ResourceFileController.cs index 8137f8560..f3dcca402 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/ResourceFileController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/ResourceFileController.cs @@ -117,13 +117,11 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 所有文件(夹)列表 /// - /// 文件夹Id /// 返回列表Json [HttpGet] - public ActionResult GetListJson(string folderId) + public ActionResult GetListJson(string folderId, string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetList(folderId, userId); + var data = fileInfoBLL.GetAllList(folderId, keyword); return JsonResult(data); } /// @@ -131,10 +129,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 返回列表Json [HttpGet] - public ActionResult GetDocumentListJson() + public ActionResult GetDocumentListJson(string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetDocumentList(userId); + var data = fileInfoBLL.GetDocumentList(keyword); return JsonResult(data); } /// @@ -142,10 +139,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 返回列表Json [HttpGet] - public ActionResult GetImageListJson() + public ActionResult GetImageListJson(string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetImageList(userId); + var data = fileInfoBLL.GetImageList(keyword); return JsonResult(data); } /// @@ -153,10 +149,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 返回列表Json [HttpGet] - public ActionResult GetRecycledListJson() + public ActionResult GetRecycledListJson(string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetRecycledList(userId); + var data = fileInfoBLL.GetRecycledList(keyword); return JsonResult(data); } /// @@ -164,10 +159,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 返回列表Json [HttpGet] - public ActionResult GetMyShareListJson() + public ActionResult GetMyShareListJson(string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetMyShareList(userId); + var data = fileInfoBLL.GetMyShareList(keyword); return JsonResult(data); } /// @@ -175,10 +169,9 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers /// /// 返回列表Json [HttpGet] - public ActionResult GetOthersShareListJson() + public ActionResult GetOthersShareListJson(string keyword) { - string userId = LoginUserInfo.Get().userId; - var data = fileInfoBLL.GetOthersShareList(userId); + var data = fileInfoBLL.GetOthersShareList(keyword); return JsonResult(data); } /// diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/ResourceFile/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/ResourceFile/Index.js index c4014d264..05b55f08d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/ResourceFile/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Views/ResourceFile/Index.js @@ -7,6 +7,8 @@ */ var refreshGirdData; +var keyword; +var folderId; var bootstrap = function ($, learun) { "use strict"; @@ -22,8 +24,12 @@ var bootstrap = function ($, learun) { bind: function () { // 查询 $('#btn_Search').on('click', function () { - var keyword = $('#txt_Keyword').val(); - page.search({ keyword: keyword }); + keyword = $('#txt_Keyword').val(); + + $.lrSetForm(top.$.rootUrl + _url + '?keyword=' + keyword, function (data) {// + $('#gridTable').jfGridSet('refreshdata', data); + }); + //page.search(); }); // 刷新 $('#lr_refresh').on('click', function () { @@ -33,17 +39,18 @@ var bootstrap = function ($, learun) { $(".crumb-path span").click(function () { var value = $(this).attr('data-folderId'); var folderId = $(".crumb-path span:last").attr('data-folderId'); + var where = '&keyword=' + keyword; //console.log(value); if (value == "back") { if (folderId == 0) { $(".crumb-path .back").hide(); } - $.lrSetForm(top.$.rootUrl + _url + '?folderId=' + folderId, function (data) {// + $.lrSetForm(top.$.rootUrl + _url + '?folderId=' + folderId + where, function (data) {// $('#gridTable').jfGridSet('refreshdata', data); }); $(".crumb-path span:last").remove(); } else { - $.lrSetForm(top.$.rootUrl + _url + '?folderId=0', function (data) {// + $.lrSetForm(top.$.rootUrl + _url + '?folderId=0' + where, function (data) {// $('#gridTable').jfGridSet('refreshdata', data); }); $(".crumb-path .back").hide(); @@ -268,7 +275,7 @@ var bootstrap = function ($, learun) { $this.addClass('active'); var data_value = $this.context.dataset.value; - + switch (data_value) { case "allFile": _url = "/LR_OAModule/ResourceFile/GetListJson"; @@ -336,7 +343,7 @@ var bootstrap = function ($, learun) { if (options.length != 0) { return "
" + options.F_FileName + "
"; } - } + } }, { label: '大小', name: 'F_FileSize', index: 'F_FileSize', width: 100, align: 'center', @@ -392,6 +399,8 @@ var bootstrap = function ($, learun) { }, search: function (param) { param = param || {}; + param.keyword = keyword; + param.folderId = folderId; $('#gridTable').jfGridSet('reload', { queryJson: JSON.stringify(param) }); }, //初始化页面 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoBLL.cs index fa1010940..6a733d63e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoBLL.cs @@ -21,9 +21,9 @@ namespace Learun.Application.OA.File.FileInfo /// 文件夹Id /// 用户Id /// - public IEnumerable GetList(string folderId, string userId) + public IEnumerable GetAllList(string folderId, string keyword) { - return service.GetList(folderId, userId); + return service.GetAllList(folderId, keyword); } public IEnumerable GetList(string userId) { @@ -38,45 +38,45 @@ namespace Learun.Application.OA.File.FileInfo ///
/// 用户Id /// - public IEnumerable GetDocumentList(string userId) + public IEnumerable GetDocumentList(string keyword) { - return service.GetDocumentList(userId); + return service.GetDocumentList(keyword); } /// /// 图片列表 /// /// 用户Id /// - public IEnumerable GetImageList(string userId) + public IEnumerable GetImageList(string keyword) { - return service.GetImageList(userId); + return service.GetImageList(keyword); } /// /// 回收站文件(夹)列表 /// /// 用户Id /// - public IEnumerable GetRecycledList(string userId) + public IEnumerable GetRecycledList(string keyword) { - return service.GetRecycledList(userId); + return service.GetRecycledList(keyword); } /// /// 我的文件(夹)共享列表 /// /// 用户Id /// - public IEnumerable GetMyShareList(string userId) + public IEnumerable GetMyShareList(string keyword) { - return service.GetMyShareList(userId); + return service.GetMyShareList(keyword); } /// /// 他人文件(夹)共享列表 /// /// 用户Id /// - public IEnumerable GetOthersShareList(string userId) + public IEnumerable GetOthersShareList(string keyword) { - return service.GetOthersShareList(userId); + return service.GetOthersShareList(keyword); } /// /// 文件信息实体 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoIBLL.cs index a717529c8..9ec561205 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoIBLL.cs @@ -12,13 +12,14 @@ namespace Learun.Application.OA.File.FileInfo public interface FileInfoIBLL { #region 获取数据 + /// /// 所有文件(夹)列表 /// /// 文件夹Id /// 用户Id /// - IEnumerable GetList(string folderId, string userId); + IEnumerable GetAllList(string folderId, string keyword); IEnumerable GetList(string userId); IEnumerable GetList(); @@ -27,31 +28,31 @@ namespace Learun.Application.OA.File.FileInfo /// /// 用户Id /// - IEnumerable GetDocumentList(string userId); + IEnumerable GetDocumentList(string keyword); /// /// 图片列表 /// /// 用户Id /// - IEnumerable GetImageList(string userId); + IEnumerable GetImageList(string keyword); /// /// 回收站文件(夹)列表 /// /// 用户Id /// - IEnumerable GetRecycledList(string userId); + IEnumerable GetRecycledList(string keyword); /// /// 我的文件(夹)共享列表 /// /// 用户Id /// - IEnumerable GetMyShareList(string userId); + IEnumerable GetMyShareList(string keyword); /// /// 他人文件(夹)共享列表 /// /// 用户Id /// - IEnumerable GetOthersShareList(string userId); + IEnumerable GetOthersShareList(string keyword); /// /// 文件信息实体 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs index 27aad6bf0..51803ef39 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs @@ -1,4 +1,5 @@ using Learun.DataBase.Repository; +using Learun.Util; using System; using System.Collections.Generic; using System.Data.Common; @@ -30,23 +31,26 @@ namespace Learun.Application.OA.File.FileInfo /// /// 所有文件(夹)列表 /// - /// 文件夹Id - /// 用户Id /// - public IEnumerable GetList(string folderId, string userId) + public IEnumerable GetAllList(string folderId,string keyword) { var strSql = new StringBuilder(); string folderCondition = ""; string fileCondition = ""; if (!string.IsNullOrEmpty(folderId)) { - folderCondition = " AND F_ParentId = @folderId"; - fileCondition=" AND F_FolderId = @folderId"; + folderCondition = $" AND F_ParentId = '{folderId}'"; + fileCondition = $" AND F_FolderId = '{folderId}'"; } else { fileCondition = " AND F_FolderId = '0'"; } + if (!string.IsNullOrEmpty(keyword)) + { + folderCondition = $" AND F_FolderName like '%{keyword}%'"; + fileCondition = $" AND F_FileName like '%{keyword}%'"; + } strSql.Append(@"SELECT * FROM ( SELECT F_FolderId AS F_FileId , F_ParentId AS F_FolderId , @@ -69,17 +73,17 @@ namespace Learun.Application.OA.File.FileInfo F_IsShare FROM LR_OA_FileInfo where F_DeleteMark = 0 "); strSql.Append(fileCondition); - strSql.Append(") t WHERE F_CreateUserId = @userId"); - + strSql.Append(") t WHERE F_CreateUserId = @userId"); + strSql.Append(" ORDER BY CASE WHEN F_FileType = 'folder' THEN 1 ELSE 2 END, F_ModifyDate ASC"); - return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId, folderId = folderId }); + var userId = LoginUserInfo.Get().userId; + return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } /// /// 文档列表 /// - /// 用户Id /// - public IEnumerable GetDocumentList(string userId) + public IEnumerable GetDocumentList(string keyword) { var strSql = new StringBuilder(); strSql.Append(@"SELECT F_FileId , @@ -95,15 +99,20 @@ namespace Learun.Application.OA.File.FileInfo AND F_FileType IN ( 'log', 'txt', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx' ) AND F_CreateUserId = @userId"); + if (!string.IsNullOrEmpty(keyword)) + { + strSql.Append($" and F_FileName like '%{keyword}%'"); + } + strSql.Append(" ORDER BY F_ModifyDate ASC"); + var userId = LoginUserInfo.Get().userId; return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } /// /// 图片列表 /// - /// 用户Id /// - public IEnumerable GetImageList(string userId) + public IEnumerable GetImageList(string keyword) { var strSql = new StringBuilder(); strSql.Append(@"SELECT F_FileId , @@ -118,79 +127,101 @@ namespace Learun.Application.OA.File.FileInfo WHERE F_DeleteMark = 0 AND F_FileType IN ( 'ico', 'gif', 'jpeg', 'jpg', 'png', 'psd' ) AND F_CreateUserId = @userId"); + if (!string.IsNullOrEmpty(keyword)) + { + strSql.Append($" and F_FileName like '%{keyword}%'"); + } + var userId = LoginUserInfo.Get().userId; strSql.Append(" ORDER BY F_ModifyDate ASC"); return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } /// /// 回收站文件(夹)列表 /// - /// 用户Id /// - public IEnumerable GetRecycledList(string userId) + public IEnumerable GetRecycledList(string keyword) { var strSql = new StringBuilder(); strSql.Append(@"SELECT * - FROM ( SELECT F_FolderId AS F_FileId , + FROM ( "); + var folderSql = @"SELECT F_FolderId AS F_FileId , F_ParentId AS F_FolderId , F_FolderName AS F_FileName , '' AS F_FileSize , 'folder' AS F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileFolder where F_DeleteMark = 1 - UNION - SELECT F_FileId , + FROM LR_OA_FileFolder where F_DeleteMark = 1"; + var fileinfoSql = @"SELECT F_FileId , F_FolderId , F_FileName , F_FileSize , F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileInfo where F_DeleteMark = 1 - ) t WHERE F_CreateUserId = @userId"); + FROM LR_OA_FileInfo where F_DeleteMark = 1"; + if (!string.IsNullOrEmpty(keyword)) + { + folderSql = folderSql + $" and F_FolderName like '%{keyword}%'"; + fileinfoSql = fileinfoSql + $" and F_FileName like '%{keyword}%'"; + } + strSql.Append(folderSql + "UNION "); + strSql.Append(fileinfoSql); + strSql.Append(") t WHERE F_CreateUserId = @userId"); + + + var userId = LoginUserInfo.Get().userId; strSql.Append(" ORDER BY F_ModifyDate DESC"); return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } /// /// 我的文件(夹)共享列表 /// - /// 用户Id /// - public IEnumerable GetMyShareList(string userId) + public IEnumerable GetMyShareList(string keyword) { var strSql = new StringBuilder(); strSql.Append(@"SELECT * - FROM ( SELECT F_FolderId AS F_FileId , + FROM ( "); + var folderSql = @"SELECT F_FolderId AS F_FileId , F_ParentId AS F_FolderId , F_FolderName AS F_FileName , '' AS F_FileSize , 'folder' AS F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileFolder WHERE F_DeleteMark = 0 AND F_IsShare = 1 - UNION - SELECT F_FileId , + FROM LR_OA_FileFolder WHERE F_DeleteMark = 0 AND F_IsShare = 1"; + var fileinfoSql = @"SELECT F_FileId , F_FolderId , F_FileName , F_FileSize , F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileInfo WHERE F_DeleteMark = 0 AND F_IsShare = 1 - ) t WHERE F_CreateUserId = @userId"); + FROM LR_OA_FileInfo WHERE F_DeleteMark = 0 AND F_IsShare = 1"; + if (!string.IsNullOrEmpty(keyword)) + { + folderSql = folderSql + $" and F_FolderName like '%{keyword}%'"; + fileinfoSql = fileinfoSql + $" and F_FileName like '%{keyword}%'"; + } + strSql.Append(folderSql + "UNION "); + strSql.Append(fileinfoSql); + strSql.Append(") t WHERE F_CreateUserId = @userId"); + + var userId = LoginUserInfo.Get().userId; strSql.Append(" ORDER BY F_ModifyDate DESC"); return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } /// /// 他人文件(夹)共享列表 /// - /// 用户Id /// - public IEnumerable GetOthersShareList(string userId) + public IEnumerable GetOthersShareList(string keyword) { var strSql = new StringBuilder(); strSql.Append(@"SELECT * - FROM ( SELECT F_FolderId AS F_FileId , + FROM ( "); + var folderSql = @"SELECT F_FolderId AS F_FileId , F_ParentId AS F_FolderId , F_FolderName AS F_FileName , '' AS F_FileSize , @@ -198,9 +229,8 @@ namespace Learun.Application.OA.File.FileInfo F_CreateUserId, F_CreateUserName, F_ShareTime AS F_ModifyDate - FROM LR_OA_FileFolder WHERE F_DeleteMark = 0 AND F_IsShare = 1 - UNION - SELECT F_FileId , + FROM LR_OA_FileFolder WHERE F_DeleteMark = 0 AND F_IsShare = 1"; + var fileinfoSql = @" SELECT F_FileId , F_FolderId , F_FileName , F_FileSize , @@ -208,9 +238,18 @@ namespace Learun.Application.OA.File.FileInfo F_CreateUserId, F_CreateUserName, F_ShareTime AS F_ModifyDate - FROM LR_OA_FileInfo WHERE F_DeleteMark = 0 AND F_IsShare = 1 - ) t WHERE F_CreateUserId != @userId"); + FROM LR_OA_FileInfo WHERE F_DeleteMark = 0 AND F_IsShare = 1"; + if (!string.IsNullOrEmpty(keyword)) + { + folderSql = folderSql + $" and F_FolderName like '%{keyword}%'"; + fileinfoSql = fileinfoSql + $" and F_FileName like '%{keyword}%'"; + } + strSql.Append(folderSql + "UNION "); + strSql.Append(fileinfoSql); + strSql.Append(") t WHERE F_CreateUserId != @userId"); + strSql.Append(" ORDER BY F_ModifyDate DESC"); + var userId = LoginUserInfo.Get().userId; return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId }); } ///