diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.css b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.css similarity index 100% rename from Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.css rename to Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.css diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.html b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.html similarity index 100% rename from Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.html rename to Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.html diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.js b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.js similarity index 95% rename from Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.js rename to Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.js index 8251d5739..861937092 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/form/form.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/EducationalAdministration/StuInfoBasic/StuInfoBasic.js @@ -76,7 +76,7 @@ learun.layer.confirm('确定要删除该笔数据吗?', function (_index) { if (_index === '1') { learun.layer.loading(true, '正在删除该笔数据'); - learun.httppost(config.webapi + 'learun/EducationalAdministration/StuInfoBasic/delete', keyValue, (data) => { + learun.httppost(config.webapi + 'learun/adms/EducationalAdministration/StuInfoBasic/delete', keyValue, (data) => { learun.layer.loading(false); if (data) {// 删除数据成功 learun.nav.closeCurrent(); @@ -103,7 +103,7 @@ _postData.keyValue = keyValue; _postData.strEntity = JSON.stringify($page.find('.lr-form-container').lrformGet()); learun.layer.loading(true, '正在提交数据'); - learun.httppost(config.webapi + 'learun/EducationalAdministration/StuInfoBasic/save', _postData, (data) => { + learun.httppost(config.webapi + 'learun/adms/EducationalAdministration/StuInfoBasic/save', _postData, (data) => { learun.layer.loading(false); if (data) {// 表单数据保存成功 if (keyValue) { @@ -131,7 +131,7 @@ $header.find('.lr-form-header-btnlist').show(); // 获取表单数据 learun.layer.loading(true, '获取表单数据'); - learun.httpget(config.webapi + 'learun/EducationalAdministration/StuInfoBasic/form', keyValue, (data) => { + learun.httpget(config.webapi + 'learun/adms/EducationalAdministration/StuInfoBasic/form', keyValue, (data) => { if (data) { for (var id in data) { if (data[id].length) { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/PersonnelManagement/CommunityMember/CommunityMember.js b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/PersonnelManagement/CommunityMember/CommunityMember.js index 379737943..35caa59a9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/PersonnelManagement/CommunityMember/CommunityMember.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Mobile/www/pages/PersonnelManagement/CommunityMember/CommunityMember.js @@ -61,7 +61,7 @@ if (param.begin && param.end) { _postParam.queryJson = JSON.stringify({ StartTime: param.begin, EndTime: param.end }); } - learun.httpget(config.webapi + 'learun/PersonnelManagement/CommunityInfo/communityMemberpagelist', _postParam, (data) => { + learun.httpget(config.webapi + 'learun/adms/PersonnelManagement/CommunityInfo/communityMemberpagelist', _postParam, (data) => { $page.find('.lr-badge').text('0'); if (data) { $page.find('.lr-badge').text(data.records); @@ -98,7 +98,7 @@ // learun.layer.confirm('确定要删除该笔数据吗?', function (_index) { // if (_index === '1') { // learun.layer.loading(true, '正在删除该笔数据'); - // learun.httppost(config.webapi + 'learun/PersonnelManagement/CommunityInfo/delete', item.Id, (data) => { + // learun.httppost(config.webapi + 'learun/adms/PersonnelManagement/CommunityInfo/delete', item.Id, (data) => { // if (data) {// 删除数据成功 // page.grid.reload(); // } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj index e39ed5caa..d636eb124 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj @@ -190,6 +190,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs new file mode 100644 index 000000000..4795d3d47 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs @@ -0,0 +1,142 @@ +using Learun.Application.Base.SystemModule; +using Learun.Util; +using Nancy; +using System; +using System.Collections.Generic; +using System.IO; + +namespace Learun.Application.WebApi.Modules +{ + public class AnnexesApiWx : BaseApi + { + public AnnexesApiWx() + : base("/learun/adms/annexes") + { + Get["/wxlist"] = WxGetList; + Get["/wxdown"] = WxDownload; + Get["/wxfileinfo"] = WxFileInfo; + Post["/wxupload"] = WxUpload; + Post["/wxdelete"] = WxDeleteFile; + } + private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); + + /// + /// 获取附件列表 + /// + /// + /// + public Response WxGetList(dynamic _) + { + var keyValue = this.GetReqData(); + var list = annexesFileIBLL.GetList(keyValue); + + return Success(list); + } + + /// + /// 上传附件图片文件 + /// + /// + public Response WxUpload(dynamic _) + { + var files = (List)this.Context.Request.Files; + var folderId = this.GetReqData(); + + string filePath = Config.GetValue("AnnexesFile"); + string uploadDate = DateTime.Now.ToString("yyyyMMdd"); + string fileEextension = Path.GetExtension(files[0].Name); + string fileType = fileEextension.Replace(".", ""); + string fileGuid = Guid.NewGuid().ToString(); + + string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension); + + //创建文件夹 + string path = Path.GetDirectoryName(virtualPath); + Directory.CreateDirectory(path); + AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); + if (!System.IO.File.Exists(virtualPath)) + { + byte[] bytes = new byte[files[0].Value.Length]; + files[0].Value.Read(bytes, 0, bytes.Length); + FileInfo file = new FileInfo(virtualPath); + FileStream fs = file.Create(); + fs.Write(bytes, 0, bytes.Length); + fs.Close(); + + //文件信息写入数据库 + fileAnnexesEntity.F_Id = fileGuid; + fileAnnexesEntity.F_FileName = files[0].Name; + fileAnnexesEntity.F_FilePath = virtualPath; + fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString(); + fileAnnexesEntity.F_FileExtensions = fileEextension; + fileAnnexesEntity.F_FileType = fileType; + fileAnnexesEntity.F_CreateUserId = userInfo.userId; + fileAnnexesEntity.F_CreateUserName = userInfo.realName; + + annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); + } + + return SuccessString(fileGuid); + } + + /// + /// 获取文件信息 + /// + /// + /// + public Response WxFileInfo(dynamic _) + { + var fileId = this.GetReqData(); + var fileEntity = annexesFileIBLL.GetEntity(fileId); + + return Success(fileEntity); + } + + /// + /// 删除文件 + /// + /// + /// + public Response WxDeleteFile(dynamic _) + { + var fileId = this.GetReqData(); + AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId); + annexesFileIBLL.DeleteEntity(fileId); + //删除文件 + if (System.IO.File.Exists(fileInfoEntity.F_FilePath)) + { + System.IO.File.Delete(fileInfoEntity.F_FilePath); + } + + return Success("删除成功"); + } + + /// + /// 下载文件,微信小程序用 + /// + /// 微信小程序可以预览图片、文档 + /// 支持的图片格式:.jpg .png .webp .gif + /// 支持的文档格式:.doc(x) .xls(x) .ppt(x) .pdf + /// + /// 对于其他格式的文件,微信小程序官方未提供打开或预览的 API,文件对用户来说不可访问 + /// + /// + /// + public Response WxDownload(dynamic _) + { + string name = this.GetReqData(); + string fileId = name.Split('.')[0]; + var fileEntity = annexesFileIBLL.GetEntity(fileId); + string filepath = fileEntity.F_FilePath; + + if (!FileDownHelper.FileExists(filepath)) + { + return 404; + } + + FileDownHelper.DownLoadWx(filepath, fileEntity.F_FileType); + + return Success(""); + } + } +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/EducationalAdministration/StuConsumptionApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/EducationalAdministration/StuConsumptionApi.cs index b74f311f4..30c464f06 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/EducationalAdministration/StuConsumptionApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/EducationalAdministration/StuConsumptionApi.cs @@ -19,7 +19,7 @@ namespace Learun.Application.WebApi /// 注册接口 /// public StuConsumptionApi() - : base("/Learun/EducationalAdministration/StuConsumption") + : base("/Learun/adms/EducationalAdministration/StuConsumption") { Get["/pagelist"] = GetPageList; Get["/list"] = GetList; diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/JournalApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/JournalApi.cs index 3f7eebf37..366a265ad 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/JournalApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/JournalApi.cs @@ -25,7 +25,7 @@ namespace Learun.Application.WebApi /// 注册接口 /// public JournalApi() - : base("/Learun/EducationalAdministration/Journal") + : base("/Learun/adms/EducationalAdministration/Journal") { Get["/pagelist"] = GetPageList; Get["/list"] = GetList; diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuInfoBasicApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuInfoBasicApi.cs index b79deb779..aab63f7a0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuInfoBasicApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuInfoBasicApi.cs @@ -36,7 +36,7 @@ namespace Learun.Application.WebApi /// 注册接口 /// public StuInfoBasicApi() - : base("/Learun/EducationalAdministration/StuInfoBasic") + : base("/Learun/adms/EducationalAdministration/StuInfoBasic") { Get["/pagelist"] = GetPageList; Get["/form"] = GetForm; diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/File/FileDownHelper.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/File/FileDownHelper.cs index 1ca9d54f3..685dc5dd9 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/File/FileDownHelper.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/File/FileDownHelper.cs @@ -315,5 +315,69 @@ namespace Learun.Util } return true; } + /// + /// 小程序下载文件,对图片采取内联形式 + /// + /// 物理地址 + /// 文件扩展名 + public static void DownLoadWx(string filePath, string fileExt = null) + { + long chunkSize = 204800; //指定块大小 + byte[] buffer = new byte[chunkSize]; //建立一个200K的缓冲区 + long dataToRead = 0; //已读的字节数 + FileStream stream = null; + try + { + //打开文件 + stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); + dataToRead = stream.Length; + + switch (fileExt?.ToLower()) + { + case "jpg": + case "jpeg": + case "bmp": + case "gif": + case "png": + case "webp": + HttpContext.Current.Response.ContentType = "application/" + fileExt.ToLower(); + break; + + default: + HttpContext.Current.Response.ContentType = "application/octet-stream"; + + break; + } + + //添加Http头 + HttpContext.Current.Response.AddHeader("Content-Length", dataToRead.ToString()); + HttpContext.Current.Response.AddHeader("Content-Disposition", "attachement;filename=" + HttpUtility.UrlEncode(Path.GetFileName(filePath))); + + while (dataToRead > 0) + { + if (HttpContext.Current.Response.IsClientConnected) + { + int length = stream.Read(buffer, 0, Convert.ToInt32(chunkSize)); + HttpContext.Current.Response.OutputStream.Write(buffer, 0, length); + HttpContext.Current.Response.Flush(); + HttpContext.Current.Response.Clear(); + dataToRead -= length; + } + else + { + dataToRead = -1; //防止client失去连接 + } + } + } + catch (Exception ex) + { + HttpContext.Current.Response.Write("Error:" + ex.Message); + } + finally + { + if (stream != null) stream.Close(); + HttpContext.Current.Response.Close(); + } + } } } diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js index 413360f4f..a580fd751 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/custompage.js @@ -192,16 +192,18 @@ export default { case 'upload': const uploadUid = [] - for (const { path, uid } of val) { - if (uid) { - uploadUid.push(uid) + for (const entity of val) { + if (entity.uid) { + uploadUid.push(entity.uid) continue - } + } else { - const fileId = await this.HTTP_UPLOAD(path) - if (fileId) { - uploadUid.push(fileId) + const fileId = await this.HTTP_UPLOAD(entity) + if (fileId) { + uploadUid.push(fileId) + } } + } return uploadUid.join(',') @@ -275,8 +277,8 @@ export default { if (!val) { return '' } return moment(val).format( Number(scheme.dateformat) === 0 || scheme.datetime === 'date' ? - 'YYYY-MM-DD' : - 'YYYY-MM-DD HH:mm:ss' + 'YYYY-MM-DD' : + 'YYYY-MM-DD HH:mm:ss' ) default: diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/mixins.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/mixins.js index e42b13581..13979b12e 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/mixins.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/mixins.js @@ -318,28 +318,28 @@ export default { } // #ifdef MP-DINGTALK - return new Promise((res, rej) => { - dd.uploadFile({ - url: uploadUrl, - filePath, - fileName: 'file', - fileType: 'image', - formData: query, - success: dt => { - dt.data = JSON.parse(dt.data) - res([null, dt]) - }, - fail: rs => { - rej([rs, null]) - } - }) - }) + // return new Promise((res, rej) => { + // dd.uploadFile({ + // url: uploadUrl, + // filePath, + // fileName: 'file', + // fileType: 'image', + // formData: query, + // success: dt => { + // dt.data = JSON.parse(dt.data) + // res([null, dt]) + // }, + // fail: rs => { + // rej([rs, null]) + // } + // }) + // }) // #endif // #ifndef MP-DINGTALK return uni.uploadFile({ url: uploadUrl, - filePath, + filePath:filePath, name: 'file', fileType: 'image', formData: query diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue index 062a512eb..969f835be 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-app/upload-file.vue @@ -13,7 +13,7 @@ @@ -54,7 +54,8 @@ export default { isImgFile(type) { const typeString = (type || '').toLowerCase() - return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'image'].includes(typeString) + //return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'image'].includes(typeString) + return true; }, isDocFile(type) { @@ -72,19 +73,19 @@ export default { chooseFile() { // #ifdef MP-DINGTALK - dd.chooseImage({ - count: Number(this.number), - success: ({ filePaths }) => { - if (filePaths) { - const newList = JSON.parse(JSON.stringify(this.value || [])).concat( - filePaths.map(t => ({ path: t, type: this.getFileExt(t) })) - ) - this.$emit('input', newList) - this.$emit('change', newList) - this.$emit('add') - } - } - }) + // dd.chooseImage({ + // count: Number(this.number), + // success: ({ filePaths }) => { + // if (filePaths) { + // const newList = JSON.parse(JSON.stringify(this.value || [])).concat( + // filePaths.map(t => ({ path: t, type: this.getFileExt(t) })) + // ) + // this.$emit('input', newList) + // this.$emit('change', newList) + // this.$emit('add') + // } + // } + // }) // #endif // #ifndef MP-DINGTALK @@ -94,7 +95,7 @@ export default { sourceType: ['album', 'camera'], success: ({ tempFilePaths }) => { const newList = JSON.parse(JSON.stringify(this.value || [])).concat( - tempFilePaths.map(t => ({ path: t, type: this.getFileExt(t) })) + tempFilePaths//.map(t => ({ path: t, type: this.getFileExt(t) })) ) this.$emit('input', newList) this.$emit('change', newList) diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-ali/upload.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-ali/upload.vue index 2e88cc8c3..f2707a429 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-ali/upload.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/components/learun-mpui/learun-ui-ali/upload.vue @@ -1,14 +1,31 @@