@@ -7,8 +7,8 @@ | |||||
// web:"http://112.230.201.53/:8081/"//web地址,用于配置logo | // web:"http://112.230.201.53/:8081/"//web地址,用于配置logo | ||||
//}; | //}; | ||||
var config = { | var config = { | ||||
webapi: 'http://localhost:31173/', | |||||
web: "http://localhost:20472/"//web地址,用于配置logo | |||||
webapi: 'http://localhost:8088/', | |||||
web: "http://localhost:8087/"//web地址,用于配置logo | |||||
}; | }; | ||||
// var config = { | // var config = { | ||||
// webapi: 'http://123.57.209.16:31173/', | // webapi: 'http://123.57.209.16:31173/', | ||||
@@ -316,6 +316,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
public ActionResult GetFormData(string keyValue) | public ActionResult GetFormData(string keyValue) | ||||
{ | { | ||||
var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); | var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); | ||||
StuInfoFreshData.Files = StuInfoFreshData.ID; | |||||
//获取头像地址 | //获取头像地址 | ||||
var url = Config.GetValue("defaultheadimg"); | var url = Config.GetValue("defaultheadimg"); | ||||
if (StuInfoFreshData.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshData.Photo)) | if (StuInfoFreshData.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshData.Photo)) | ||||
@@ -61,9 +61,9 @@ | |||||
<div id="ResidenceNo"></div> | <div id="ResidenceNo"></div> | ||||
</div> | </div> | ||||
@*<div class="col-xs-6 lr-form-item" data-table="StuInfoFresh"> | @*<div class="col-xs-6 lr-form-item" data-table="StuInfoFresh"> | ||||
<div class="lr-form-item-title">考生类型 </div> | |||||
<div id="TestStuSortNo"></div> | |||||
</div>*@ | |||||
<div class="lr-form-item-title">考生类型 </div> | |||||
<div id="TestStuSortNo"></div> | |||||
</div>*@ | |||||
<div class="col-xs-6 lr-form-item" data-table="StuInfoFresh"> | <div class="col-xs-6 lr-form-item" data-table="StuInfoFresh"> | ||||
<div class="lr-form-item-title">第几志愿 <font face="宋体">*</font> </div> | <div class="lr-form-item-title">第几志愿 <font face="宋体">*</font> </div> | ||||
<input id="WillNo" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | <input id="WillNo" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | ||||
@@ -129,6 +129,10 @@ | |||||
<div class="lr-form-item-title">精准贫困户</div> | <div class="lr-form-item-title">精准贫困户</div> | ||||
<div id="IsPoor"></div> | <div id="IsPoor"></div> | ||||
</div> | </div> | ||||
@*<div class="col-xs-12 lr-form-item" data-table="StuInfoFresh"> | |||||
<div class="lr-form-item-title">附件</div> | |||||
<div id="Files"></div> | |||||
</div>*@ | |||||
<div class="col-xs-12" id="photoBox"> | <div class="col-xs-12" id="photoBox"> | ||||
@@ -25,6 +25,8 @@ var bootstrap = function ($, learun) { | |||||
$("#MatriculateSort").lrDataItemSelect({ code: 'enrollType' }); | $("#MatriculateSort").lrDataItemSelect({ code: 'enrollType' }); | ||||
$('#ResidenceNo').lrDataItemSelect({ code: 'ResidenceNo' }); | $('#ResidenceNo').lrDataItemSelect({ code: 'ResidenceNo' }); | ||||
$('#IsPoor').lrDataItemSelect({ code: 'YesOrNoInt' }); | $('#IsPoor').lrDataItemSelect({ code: 'YesOrNoInt' }); | ||||
//附件 | |||||
//$('#Files').lrUploader(); | |||||
$('#StuInfoFreshFamily').jfGrid({ | $('#StuInfoFreshFamily').jfGrid({ | ||||
headData: [ | headData: [ | ||||
@@ -26,6 +26,8 @@ namespace Learun.Application.WebApi.Modules | |||||
Get["/pageList"] = GetPageList; | Get["/pageList"] = GetPageList; | ||||
Get["/form"] = GetForm; | Get["/form"] = GetForm; | ||||
Post["/save"] = SaveForm; | Post["/save"] = SaveForm; | ||||
Post["/upload"] = Upload; | |||||
Post["/deleteFiles"] = DeleteFiles; | |||||
} | } | ||||
@@ -99,8 +101,20 @@ namespace Learun.Application.WebApi.Modules | |||||
if (annexesFileEntity != null) | if (annexesFileEntity != null) | ||||
{ | { | ||||
url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource")); | url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource")); | ||||
StuInfoFreshEntity.Url = url; | |||||
} | } | ||||
} | } | ||||
//获取附件列表 | |||||
var annexesFileList = annexesFileIBLL.GetList(StuInfoFreshEntity.ID); | |||||
if (annexesFileList.Any()) | |||||
{ | |||||
foreach (var item in annexesFileList) | |||||
{ | |||||
item.F_FilePath = item.F_FilePath.Substring(item.F_FilePath.IndexOf("Resource")); | |||||
} | |||||
StuInfoFreshEntity.FilesList = annexesFileList.ToList(); | |||||
} | |||||
StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID); | StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID); | ||||
if (StuInfoFreshEntity.IsPoor != "1") | if (StuInfoFreshEntity.IsPoor != "1") | ||||
{ | { | ||||
@@ -335,6 +349,87 @@ namespace Learun.Application.WebApi.Modules | |||||
return Success("保存成功!"); | return Success("保存成功!"); | ||||
} | } | ||||
/// <summary> | |||||
/// 上传附件图片文件 | |||||
/// <summary> | |||||
/// <returns></returns> | |||||
public Response Upload(dynamic _) | |||||
{ | |||||
var files = (List<HttpFile>)this.Context.Request.Files; | |||||
var folderId = this.GetReq<FileModel>().folderId;//文件夹id=新生id | |||||
string filePath = Config.GetValue("AnnexesFile"); | |||||
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); | |||||
string FileEextension = Path.GetExtension(files[0].Name); | |||||
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_FolderId = folderId; | |||||
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 = FileEextension.Replace(".", ""); | |||||
fileAnnexesEntity.F_CreateUserId = userInfo.userId; | |||||
fileAnnexesEntity.F_CreateUserName = userInfo.realName; | |||||
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); | |||||
} | |||||
//文件地址截取到resource后 | |||||
fileAnnexesEntity.F_FilePath = fileAnnexesEntity.F_FilePath.Substring(fileAnnexesEntity.F_FilePath.IndexOf("Resource")); | |||||
return Success(fileAnnexesEntity); | |||||
} | |||||
/// <summary> | |||||
/// 删除附件 | |||||
/// </summary> | |||||
/// <param name="_"></param> | |||||
/// <returns></returns> | |||||
public Response DeleteFiles(dynamic _) | |||||
{ | |||||
var fileId = this.GetReqData<FileModel>().id; | |||||
AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId); | |||||
if (fileInfoEntity != null) | |||||
{ | |||||
//删除附件表 | |||||
annexesFileIBLL.DeleteEntity(fileId); | |||||
//删除文件 | |||||
if (System.IO.File.Exists(fileInfoEntity.F_FilePath)) | |||||
{ | |||||
System.IO.File.Delete(fileInfoEntity.F_FilePath); | |||||
} | |||||
//下载 | |||||
//if (FileDownHelper.FileExists(fileInfoEntity.F_FilePath)) | |||||
//{ | |||||
// FileDownHelper.DownLoadnew(fileInfoEntity.F_FilePath); | |||||
//} | |||||
} | |||||
return Success("删除成功"); | |||||
} | |||||
#region 私有类 | #region 私有类 | ||||
/// <summary> | /// <summary> | ||||
@@ -389,6 +484,7 @@ namespace Learun.Application.WebApi.Modules | |||||
/// </summary> | /// </summary> | ||||
public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; } | public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; } | ||||
} | } | ||||
public class PhotoModel | public class PhotoModel | ||||
@@ -397,5 +493,10 @@ namespace Learun.Application.WebApi.Modules | |||||
public string account { get; set; } | public string account { get; set; } | ||||
} | } | ||||
public class FileModel | |||||
{ | |||||
public string folderId { get; set; } | |||||
public string id { get; set; } | |||||
} | |||||
} | } | ||||
} | } |
@@ -65,7 +65,7 @@ | |||||
<add key="userKey" value="14B417B0-463D-4F2B-8075-0A20EEDB773A" /> | <add key="userKey" value="14B417B0-463D-4F2B-8075-0A20EEDB773A" /> | ||||
<!-- ==================注意附件上传地址 修改到主网站部署目录下的Resource要不然飞星会报错================== --> | <!-- ==================注意附件上传地址 修改到主网站部署目录下的Resource要不然飞星会报错================== --> | ||||
<add key="AnnexesFile" value="D:\leiprojects\西昌单校区\Learun.Application.Web\Resource" /> | |||||
<add key="AnnexesFile" value="D:\Job\DigitalScholl\Learun.Framework.Ultimate V7\Learun.Application.Web\Resource" /> | |||||
<add key="ReportFile" value="~/Reports" /> | <add key="ReportFile" value="~/Reports" /> | ||||
<!-- ================== 工作流服务地址 ================== --> | <!-- ================== 工作流服务地址 ================== --> | ||||
<add key="workflowapi" value="http://localhost:8013" /> | <add key="workflowapi" value="http://localhost:8013" /> | ||||
@@ -13,7 +13,7 @@ namespace Learun.Application.Base.SystemModule | |||||
/// 日 期:2017.03.08 | /// 日 期:2017.03.08 | ||||
/// 描 述:附件管理 | /// 描 述:附件管理 | ||||
/// </summary> | /// </summary> | ||||
public class AnnexesFileService:RepositoryFactory | |||||
public class AnnexesFileService : RepositoryFactory | |||||
{ | { | ||||
#region 属性 构造函数 | #region 属性 构造函数 | ||||
private string fieldSql; | private string fieldSql; | ||||
@@ -188,7 +188,7 @@ namespace Learun.Application.Base.SystemModule | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
this.BaseRepository().Delete(new AnnexesFileEntity() { F_Id = fileId }); | |||||
this.BaseRepository().Delete<AnnexesFileEntity>(x => x.F_Id == fileId); | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -1,5 +1,7 @@ | |||||
using Learun.Util; | |||||
using Learun.Application.Base.SystemModule; | |||||
using Learun.Util; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | |||||
using System.ComponentModel.DataAnnotations.Schema; | using System.ComponentModel.DataAnnotations.Schema; | ||||
namespace Learun.Application.TwoDevelopment.EducationalAdministration | namespace Learun.Application.TwoDevelopment.EducationalAdministration | ||||
@@ -716,6 +718,23 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
[NotMapped] | [NotMapped] | ||||
public bool? IsStudentEdit { get; set; } | public bool? IsStudentEdit { get; set; } | ||||
/// <summary> | |||||
/// 图片显示地址 | |||||
/// </summary> | |||||
[NotMapped] | |||||
public string Url { get; set; } | |||||
/// <summary> | |||||
/// 附件(文件夹id) | |||||
/// </summary> | |||||
[NotMapped] | |||||
public string Files { get; set; } | |||||
/// <summary> | |||||
/// 附件列表 | |||||
/// </summary> | |||||
[NotMapped] | |||||
public List<AnnexesFileEntity> FilesList { get; set; } | |||||
#endregion | #endregion | ||||
} | } | ||||
} | } | ||||
@@ -263,6 +263,12 @@ export default { | |||||
return this.handleResult(err, res) | return this.handleResult(err, res) | ||||
}, | }, | ||||
async HTTP_UPLOAD2(url,filePath, formData) { | |||||
const [err, res] = await this.UPLOAD(url, filePath, formData) | |||||
return this.handleResult(err, res) | |||||
}, | |||||
// 封装的文件下载,集成了验证信息 | // 封装的文件下载,集成了验证信息 | ||||
// 返回临时文件路径或 null | // 返回临时文件路径或 null | ||||
@@ -654,6 +660,7 @@ export default { | |||||
title: '登录状态无效,正在跳转到登录页…', | title: '登录状态无效,正在跳转到登录页…', | ||||
icon: 'none' | icon: 'none' | ||||
}) | }) | ||||
return null | |||||
this.CLEAR_GLOBAL() | this.CLEAR_GLOBAL() | ||||
uni.reLaunch({ | uni.reLaunch({ | ||||
url: '/pages/login' | url: '/pages/login' | ||||
@@ -673,6 +680,14 @@ export default { | |||||
return null | return null | ||||
} | } | ||||
if(result.data.code != 200){ | |||||
uni.hideLoading() | |||||
uni.showToast({ | |||||
title: result.data.info, | |||||
icon: 'none' | |||||
}) | |||||
return null | |||||
} | |||||
return result.data.data | return result.data.data | ||||
}, | }, | ||||
@@ -3,14 +3,13 @@ | |||||
<view class="grid col-4 grid-square flex-sub"> | <view class="grid col-4 grid-square flex-sub"> | ||||
<view | <view | ||||
v-for="(item, index) in imgList" | v-for="(item, index) in imgList" | ||||
@tap="viewImg" | |||||
@tap="viewImg(index)" | |||||
:key="index" | :key="index" | ||||
class="bg-img" | class="bg-img" | ||||
> | > | ||||
<!-- {{API + '/user/img?data=' + (path.path ? path.path : path)}} --> | |||||
<image | <image | ||||
v-if="showfile()" | v-if="showfile()" | ||||
:src="API + item.url" | |||||
:src="item.id?CONFIG('webHost')+item.url:item.url" | |||||
mode="aspectFill" | mode="aspectFill" | ||||
></image> | ></image> | ||||
<view v-if="!readonly" @tap.stop="delImg(index)" class="cu-tag bg-red" style="width: 18px; height: 18px; font-size: 24px"> | <view v-if="!readonly" @tap.stop="delImg(index)" class="cu-tag bg-red" style="width: 18px; height: 18px; font-size: 24px"> | ||||
@@ -90,8 +89,26 @@ export default { | |||||
}, | }, | ||||
uploadImage(){ | uploadImage(){ | ||||
// 单图上传 多图没写 | |||||
// let array = | |||||
// function apiFn(item){ | |||||
// return this.HTTP_POST('StuInfoFresh/savePhoto', postData, '图片上传失败!').then((data) => { | |||||
// if (data) { | |||||
// reslove([{ | |||||
// url:data.Url, | |||||
// id:data.AnnexesFileId | |||||
// }]) | |||||
// }else{ | |||||
// reject('图片上传失败!') | |||||
// } | |||||
// }) | |||||
// } | |||||
// return this.promiseAllLimit(5,array,apiFn) | |||||
// 单图上传 | |||||
return new Promise(async (reslove,reject)=>{ | return new Promise(async (reslove,reject)=>{ | ||||
let hasNotUpdatedList = this.imgList.every(item=>item.id) | |||||
if(hasNotUpdatedList){ | |||||
reslove(this.imgList) | |||||
} | |||||
if(this.imgList.length){ | if(this.imgList.length){ | ||||
var postData = { | var postData = { | ||||
Base64Url: await this.imgToBase64(this.imgList[0].url) | Base64Url: await this.imgToBase64(this.imgList[0].url) | ||||
@@ -110,11 +127,41 @@ export default { | |||||
reslove("") | reslove("") | ||||
} | } | ||||
}) | }) | ||||
}, | |||||
/** | |||||
* @description 控制promise.all并发数量 | |||||
* @param limit 并发数 | |||||
* @param array 参数列表 | |||||
* @param apiFn 执行函数 | |||||
* @returns {Promise<Awaited<unknown>[]>} | |||||
*/ | |||||
async promiseAllLimit(limit, array, apiFn) { | |||||
const ret = [] // 用于存放所有的promise实例 | |||||
const executing = [] // 用于存放目前正在执行的promise | |||||
for (const item of array) { | |||||
const p = apiFn(item) | |||||
ret.push(p) | |||||
if (limit <= array.length) { | |||||
// then回调中,当这个promise状态变为fulfilled后,将其从正在执行的promise列表executing中删除 | |||||
const e = p.then(() => executing.splice(executing.indexOf(e), 1)) | |||||
executing.push(e) | |||||
if (executing.length >= limit) { | |||||
// 一旦正在执行的promise列表数量等于限制数,就使用Promise.race等待某一个promise状态发生变更, | |||||
// 状态变更后,就会执行上面then的回调,将该promise从executing中删除, | |||||
// 然后再进入到下一次for循环,生成新的promise进行补充 | |||||
await Promise.race(executing) | |||||
} | |||||
} | |||||
} | |||||
return Promise.all(ret) | |||||
}, | }, | ||||
imgToBase64(url){ | imgToBase64(url){ | ||||
return new Promise((resolve,reject)=>{ | return new Promise((resolve,reject)=>{ | ||||
if(!url){ | |||||
resolve("") | |||||
} | |||||
var canvas = document.createElement('canvas'), | var canvas = document.createElement('canvas'), | ||||
ctx = canvas.getContext('2d'), | ctx = canvas.getContext('2d'), | ||||
img = new Image; | img = new Image; | ||||
@@ -133,18 +180,18 @@ export default { | |||||
}, | }, | ||||
validate(array){ | validate(array){ | ||||
let type = array.every(item=>{ | |||||
return item.type && item.type.substring(0,6) == "image/" | |||||
}) | |||||
if(!type){ | |||||
this.TOAST('文件类型错误'); | |||||
return false | |||||
} | |||||
// let type = array.every(item=>{ | |||||
// return item.type && item.type.substring(0,6) == "image/" | |||||
// }) | |||||
// if(!type){ | |||||
// this.TOAST('文件类型错误'); | |||||
// return false | |||||
// } | |||||
let size = array.every(item=>{ | let size = array.every(item=>{ | ||||
return item.size && item.size <= 2 * 1024 * 1024 | |||||
return item.size && item.size <= 100 * 1024 * 1024 | |||||
}) | }) | ||||
if(!size){ | if(!size){ | ||||
this.TOAST('文件大小不得超过2M'); | |||||
this.TOAST('文件大小不得超过100M'); | |||||
return false | return false | ||||
} | } | ||||
return true | return true | ||||
@@ -152,8 +199,8 @@ export default { | |||||
viewImg(index) { | viewImg(index) { | ||||
uni.previewImage({ | uni.previewImage({ | ||||
urls: this.imgList, | |||||
current: this.imgList[index], | |||||
urls: this.imgList.map(item=>item.id?this.CONFIG('webHost')+item.url:item.url), | |||||
current: this.imgList[index].id?this.CONFIG('webHost')+this.imgList[index].url:this.imgList[index].url, | |||||
}); | }); | ||||
}, | }, | ||||
@@ -0,0 +1,300 @@ | |||||
<template> | |||||
<view class="cu-form-group"> | |||||
<view class="grid col-4 grid-square flex-sub"> | |||||
<view | |||||
v-for="(item, index) in imgList" | |||||
@tap="viewImg(item)" | |||||
:key="index" | |||||
class="bg-img" | |||||
> | |||||
<!-- {{API + '/user/img?data=' + (path.path ? path.path : path)}} --> | |||||
<!-- <image | |||||
v-if="showfile()" | |||||
:src="API + item.url" | |||||
mode="aspectFill" | |||||
></image> --> | |||||
<l-icon v-if="showfile()" type="text" /> | |||||
<text class="file-name">{{item.name}}</text> | |||||
<view v-if="!readonly" @tap.stop="delImg(index)" class="cu-tag bg-red" style="width: 18px; height: 18px; font-size: 24px"> | |||||
<l-icon | |||||
type="close" | |||||
style="width: 18px; height: 18px; font-size: 12px" | |||||
/> | |||||
</view> | |||||
</view> | |||||
<view | |||||
v-if="!readonly && imgList.length < Number(number)" | |||||
@tap="chooseImg" | |||||
class="solids" | |||||
> | |||||
<l-icon type="file" /> | |||||
</view> | |||||
</view> | |||||
</view> | |||||
</template> | |||||
<script> | |||||
export default { | |||||
props: { | |||||
number: { default: 1 }, | |||||
readonly: {}, | |||||
value: { default: () => [] }, | |||||
folderId:{}, | |||||
}, | |||||
data(){ | |||||
return{ | |||||
imgList:[], | |||||
} | |||||
}, | |||||
methods: { | |||||
delImg(index) { | |||||
this.LOADING('正在删除…'); | |||||
const newList = JSON.parse(JSON.stringify(this.imgList)); | |||||
this.HTTP_POST('StuInfoFresh/deleteFiles', {id:this.imgList[index].id},"文件删除失败").then((data) => { | |||||
this.HIDE_LOADING(); | |||||
if (data) { | |||||
newList.splice(index, 1); | |||||
this.imgList = newList | |||||
this.$emit("update:value", newList); | |||||
this.$emit("input", newList); | |||||
this.$emit("change"); | |||||
this.$emit("del"); | |||||
} | |||||
}) | |||||
}, | |||||
showfile() { | |||||
return true; | |||||
}, | |||||
chooseImg() { | |||||
uni.chooseFile({ | |||||
// count: (Number(this.number) - this.imgList.length), | |||||
count: 1, | |||||
type:"all", | |||||
success: async (res) => { | |||||
let {tempFilePaths,tempFiles} = res | |||||
if(!this.validate(tempFiles))return | |||||
let uploadImageRes = await this.uploadImage(tempFilePaths[0]) | |||||
let newList = this.imgList || [] | |||||
if(uploadImageRes){ | |||||
newList = JSON.parse(JSON.stringify(newList)).concat(uploadImageRes); | |||||
} | |||||
this.imgList = newList | |||||
this.$emit("update:value", newList); | |||||
this.$emit("input", newList); | |||||
this.$emit("change",newList); | |||||
this.$emit("add"); | |||||
}, | |||||
}); | |||||
}, | |||||
uploadImage(url){ | |||||
// 文件上传 | |||||
return new Promise(async (reslove,reject)=>{ | |||||
this.LOADING('正在上传…'); | |||||
this.HTTP_UPLOAD2('StuInfoFresh/upload', url||this.imgList[0].url,{folderId:this.folderId}).then((data) => { | |||||
this.HIDE_LOADING(); | |||||
if (data) { | |||||
// this.HTTP_GET('StuInfoFresh/upload', {fileId:data}) | |||||
reslove([{ | |||||
id:data.F_Id, | |||||
name:data.F_FileName, | |||||
url:data.F_FilePath | |||||
}]) | |||||
}else{ | |||||
reject('上传失败!') | |||||
} | |||||
}) | |||||
}) | |||||
}, | |||||
// 图片文件转为 base64 | |||||
getPictureBase64(file) { | |||||
return new Promise((resolve, reject) => { | |||||
const reader = new FileReader(); | |||||
reader.readAsDataURL(file); | |||||
reader.onload = () => resolve(reader.result); | |||||
reader.onerror = (error) => reject(error); | |||||
}); | |||||
}, | |||||
base64ToBlob (base64) { | |||||
const parts = base64.split(";base64,"); | |||||
const contentType = parts[0].split(":")[1]; | |||||
const raw = window.atob(parts[1]); | |||||
const rawLength = raw.length; | |||||
const uInt8Array = new Uint8Array(rawLength); | |||||
for (let i = 0; i < rawLength; i += 1) { | |||||
uInt8Array[i] = raw.charCodeAt(i); | |||||
} | |||||
return new Blob([uInt8Array], { type: contentType }); | |||||
}, | |||||
imgToBase64(url){ | |||||
return new Promise((resolve,reject)=>{ | |||||
var canvas = document.createElement('canvas'), | |||||
ctx = canvas.getContext('2d'), | |||||
img = new Image; | |||||
img.crossOrigin = 'Anonymous'; | |||||
img.onload = function () { | |||||
canvas.height = img.height; | |||||
canvas.width = img.width; | |||||
ctx.drawImage(img, 0, 0); | |||||
var dataURL = canvas.toDataURL('image/png'); | |||||
canvas = null; | |||||
resolve(dataURL) | |||||
}; | |||||
img.src = url; | |||||
}) | |||||
}, | |||||
ceshi(){ | |||||
function apiFn(params){ | |||||
return new Promise((resolve,reject)=>{ | |||||
this.LOADING('正在上传…'); | |||||
this.HTTP_UPLOAD2('StuInfoFresh/upload', params.url,{folderId:this.folderId}).then((data) => { | |||||
this.HIDE_LOADING(); | |||||
if (data) { | |||||
// this.HTTP_GET('StuInfoFresh/upload', {fileId:data}) | |||||
this.imgList[params.index] = [{ | |||||
id:data.F_Id, | |||||
name:data.F_FileName, | |||||
url:data.F_FilePath | |||||
}] | |||||
reslove(this.imgList[params.index]) | |||||
}else{ | |||||
reject('上传失败!') | |||||
} | |||||
}) | |||||
}) | |||||
} | |||||
let array = this.imgList.map(item=>{ | |||||
if(item.id){ | |||||
return "" | |||||
}else{ | |||||
return { | |||||
url:"learun/adms/annexes/upload" | |||||
} | |||||
} | |||||
}) | |||||
this.promiseAllLimit(2,[1,2,3,4,5,6,7,8,9],a).then(res=>{ | |||||
console.log(res) | |||||
}) | |||||
}, | |||||
/** | |||||
* @description 控制promise.all并发数量 | |||||
* @param limit 并发数 | |||||
* @param array 参数列表 | |||||
* @param apiFn 执行函数 | |||||
* @returns {Promise<Awaited<unknown>[]>} | |||||
*/ | |||||
async promiseAllLimit(limit, array, apiFn) { | |||||
const ret = [] // 用于存放所有的promise实例 | |||||
const executing = [] // 用于存放目前正在执行的promise | |||||
for (const item of array) { | |||||
const p = apiFn(item) | |||||
ret.push(p) | |||||
if (limit <= array.length) { | |||||
// then回调中,当这个promise状态变为fulfilled后,将其从正在执行的promise列表executing中删除 | |||||
const e = p.then(() => executing.splice(executing.indexOf(e), 1)) | |||||
executing.push(e) | |||||
if (executing.length >= limit) { | |||||
// 一旦正在执行的promise列表数量等于限制数,就使用Promise.race等待某一个promise状态发生变更, | |||||
// 状态变更后,就会执行上面then的回调,将该promise从executing中删除, | |||||
// 然后再进入到下一次for循环,生成新的promise进行补充 | |||||
await Promise.race(executing) | |||||
} | |||||
} | |||||
} | |||||
return Promise.all(ret) | |||||
}, | |||||
validate(array){ | |||||
// let type = array.every(item=>{ | |||||
// return item.type && item.type.substring(0,6) == "image/" | |||||
// }) | |||||
// if(!type){ | |||||
// this.TOAST('文件类型错误'); | |||||
// return false | |||||
// } | |||||
let size = array.every(item=>{ | |||||
return item.size && item.size <= 200 * 1024 * 1024 | |||||
}) | |||||
if(!size){ | |||||
this.TOAST('文件大小不得超过200M'); | |||||
return false | |||||
} | |||||
return true | |||||
}, | |||||
viewImg(item) { | |||||
window.location.href = this.CONFIG("webHost")+item.url | |||||
}, | |||||
// previewFile() { | |||||
// var file = document.querySelector('input[type=file]').files[0]; | |||||
// var reader = new FileReader(); | |||||
// // fileReader.readAsDataURL(blob); | |||||
// // fileReader.onerror = () => { | |||||
// // reject(new Error('blobToBase64 error')); | |||||
// // }; | |||||
// // var encodedData = window.btoa("Hello, world"); | |||||
// reader.onloadend = function () { | |||||
// //$('#PhotoImg').attr('src', reader.result); | |||||
// var postData = { | |||||
// Base64Url: reader.result | |||||
// } | |||||
// this.HTTP_POST(config.webapi + "StuInfoFresh/savePhoto", postData, (data) => { | |||||
// if (data) { | |||||
// $('#Photo').val(data.AnnexesFileId); | |||||
// $('#PhotoImg').attr('src', config.web + data.Url); | |||||
// } else { | |||||
// learun.layer.toast('采集照片信息失败!'); | |||||
// } | |||||
// }); | |||||
// } | |||||
// if (file) { | |||||
// reader.readAsDataURL(file); | |||||
// } | |||||
// }, | |||||
}, | |||||
created() { | |||||
// id name | |||||
console.log(this.value) | |||||
this.imgList = JSON.parse(JSON.stringify(this.value.map(item=>{ | |||||
return { | |||||
id:item.F_Id, | |||||
name:item.F_FileName, | |||||
url:item.F_FilePath | |||||
} | |||||
}))) | |||||
// [{url:"",id:""}] | |||||
} | |||||
}; | |||||
</script> | |||||
<style scoped> | |||||
.file-name{ | |||||
position: absolute; | |||||
bottom: 0; | |||||
width: 100%; | |||||
color: #606266; | |||||
font-size: 13px; | |||||
text-align: center; | |||||
text-overflow: ellipsis; | |||||
overflow: hidden; | |||||
white-space: nowrap; | |||||
} | |||||
</style> |
@@ -22,12 +22,13 @@ export default { | |||||
// ], | // ], | ||||
"apiHost": [ | "apiHost": [ | ||||
// "http://localhost:31173/" | // "http://localhost:31173/" | ||||
"http://192.168.10.58:8012/" | |||||
"http://192.168.10.85:8088/" | |||||
], | ], | ||||
"webHost":"http://192.168.10.85:8087/", | |||||
// 开发环境下自动填充登录账号密码,与接口地址一一对应,只在开发环境下显示 | // 开发环境下自动填充登录账号密码,与接口地址一一对应,只在开发环境下显示 | ||||
"devAccount": [ | "devAccount": [ | ||||
// 20201130230 | |||||
{ username: "420528200606205026", password: "www.qj.com" } | |||||
// 20201130230 21364200000400266 老师 420528196310072253 学生 420528200606205026 420528200507261428 | |||||
{ username: "21364200000400558", password: "www.qj.com" } | |||||
], | ], | ||||
//是否分布式部署 指WebApi与Web不在一台服务器 | //是否分布式部署 指WebApi与Web不在一台服务器 | ||||
"isDistributed":true, | "isDistributed":true, | ||||
@@ -14,7 +14,7 @@ | |||||
<view style="flex: 1;"> | <view style="flex: 1;"> | ||||
<view style="display: flex;"> | <view style="display: flex;"> | ||||
<view style="flex: 1;color: #303133;font-size: 14px;padding: 8px 0;"> | <view style="flex: 1;color: #303133;font-size: 14px;padding: 8px 0;"> | ||||
<view class="wrap1">{{item.bigGroup}}</view> | |||||
<view class="wrap1">{{item.bigGroup}}{{item.smallGroup?"-"+item.smallGroup:""}}</view> | |||||
<view style="color: #909399;font-size: 12px;"> | <view style="color: #909399;font-size: 12px;"> | ||||
<view> | <view> | ||||
餐次:{{item.seg||"--"}} | 餐次:{{item.seg||"--"}} | ||||
@@ -231,7 +231,8 @@ | |||||
this.multipleData.StartTime = this.dateRange.start | this.multipleData.StartTime = this.dateRange.start | ||||
this.multipleData.EndTime = this.dateRange.end | this.multipleData.EndTime = this.dateRange.end | ||||
} else{ | } else{ | ||||
this.multipleData.StartTime = "" | |||||
this.multipleData.EndTime = "" | |||||
} | } | ||||
// console.log(this.dateRange,"==========") | // console.log(this.dateRange,"==========") | ||||
@@ -63,7 +63,9 @@ | |||||
<view class="welDel" @click="del('StuInfoFreshEmergePeopleEntities', i)"><text class="text-xxl cuIcon cuIcon-move"></text></view> | <view class="welDel" @click="del('StuInfoFreshEmergePeopleEntities', i)"><text class="text-xxl cuIcon cuIcon-move"></text></view> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<view class="btn" @click="tapBtn">保存</view> | |||||
<view class="welT" style="padding-top: 10px;">附件</view> | |||||
<uploadFile v-if="uploadVisiable" :number="10" :folderId="queryData.ID" :value="fileList"></uploadFile> | |||||
<view class="btn" @click="submit">保存</view> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
@@ -71,11 +73,16 @@ | |||||
import moment from 'moment'; | import moment from 'moment'; | ||||
import get from 'lodash/get'; | import get from 'lodash/get'; | ||||
import set from 'lodash/set'; | import set from 'lodash/set'; | ||||
import uploadFile from '@/components/upload-file.vue' | |||||
export default { | export default { | ||||
components:{ | |||||
uploadFile, | |||||
}, | |||||
data() { | data() { | ||||
return { | return { | ||||
photo:[], | photo:[], | ||||
uploadVisiable:true, | |||||
fileList:[], | |||||
uploadVisiable:false, | |||||
imgSrc: '', | imgSrc: '', | ||||
scheme: { | scheme: { | ||||
PartyFaceNo: { | PartyFaceNo: { | ||||
@@ -141,8 +148,10 @@ export default { | |||||
_this.queryData.StuInfoFreshFamilyEntities = _this.COPY(res.StuInfoFreshFamilyList); | _this.queryData.StuInfoFreshFamilyEntities = _this.COPY(res.StuInfoFreshFamilyList); | ||||
_this.queryData.StuInfoFreshEmergePeopleEntities = _this.COPY(res.StuInfoFreshEmergePeopleList); | _this.queryData.StuInfoFreshEmergePeopleEntities = _this.COPY(res.StuInfoFreshEmergePeopleList); | ||||
_this.queryData.ID = res.StuInfoFreshEntity.ID; | _this.queryData.ID = res.StuInfoFreshEntity.ID; | ||||
_this.queryData.Photo = res.StuInfoFreshEntity.Photo; | _this.queryData.Photo = res.StuInfoFreshEntity.Photo; | ||||
_this.photo = [{url:res.StuInfoFreshEntity.Photo}]; | |||||
_this.photo = res.StuInfoFreshEntity.Photo?[{url:res.StuInfoFreshEntity.Url,id:res.StuInfoFreshEntity.Photo}]:[]; | |||||
_this.fileList = res.StuInfoFreshEntity.FilesList||[] | |||||
_this.refreshComponent() | _this.refreshComponent() | ||||
_this.queryData.telephone = res.StuInfoFreshEntity.telephone; | _this.queryData.telephone = res.StuInfoFreshEntity.telephone; | ||||
_this.queryData.FamilyAddress = res.StuInfoFreshEntity.FamilyAddress; | _this.queryData.FamilyAddress = res.StuInfoFreshEntity.FamilyAddress; | ||||
@@ -150,16 +159,16 @@ export default { | |||||
// _this.imgSrc = this.API.slice(0,-1) + res.Url; | // _this.imgSrc = this.API.slice(0,-1) + res.Url; | ||||
}); | }); | ||||
}, | }, | ||||
async tapBtn() { | |||||
async submit() { | |||||
this.LOADING('正在提交数据…'); | this.LOADING('正在提交数据…'); | ||||
let res = await this.$refs["upload"].uploadImage() | let res = await this.$refs["upload"].uploadImage() | ||||
if(res){ | |||||
this.queryData.Photo = res[0]["AnnexesFileId"]; | |||||
if(res&&res.length){ | |||||
this.queryData.Photo = res[0]["id"]; | |||||
}else{ | |||||
this.queryData.Photo = "" | |||||
} | } | ||||
console.log(this.queryData) | |||||
this.HTTP_GET('StuInfoFresh/saveStuInfoFresh', this.queryData, '加载数据时出错').then(res => { | |||||
this.HTTP_GET('StuInfoFresh/saveStuInfoFresh', this.queryData).then(res => { | |||||
this.HIDE_LOADING(); | this.HIDE_LOADING(); | ||||
// console.log(res); | |||||
if (res) { | if (res) { | ||||
this.TOAST('保存成功'); | this.TOAST('保存成功'); | ||||
} | } | ||||