Merge branch 'deng' into deng-release

This commit is contained in:
Timer
2026-04-05 23:21:52 +08:00
4 changed files with 33 additions and 13 deletions

View File

@ -20,9 +20,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -391,7 +394,7 @@ public class CommonFileServiceImpl implements CommonFileService {
CommonFile commonFile = new CommonFile(); CommonFile commonFile = new CommonFile();
commonFile.setId(CommUtil.getUUID()); commonFile.setId(CommUtil.getUUID());
commonFile.setMasterid(masterId); commonFile.setMasterid(masterId);
// 20210105 YYJ 用于文件表绑定料节点用字段 tb_doc_file内和masterId一样 // 20210105 YYJ 用于文件表绑定<EFBFBD><EFBFBD>料节点用字段 tb_doc_file内和masterId一样
// commonFile.setPid(masterId); // commonFile.setPid(masterId);
commonFile.setFilename(fileName); // 保存原始文件名用于显示 commonFile.setFilename(fileName); // 保存原始文件名用于显示
commonFile.setType(contentType); commonFile.setType(contentType);
@ -400,6 +403,19 @@ public class CommonFileServiceImpl implements CommonFileService {
commonFile.setAbspath(filePath); // 保存MinIO对象名称 commonFile.setAbspath(filePath); // 保存MinIO对象名称
commonFile.setInsdt(CommUtil.nowDate()); commonFile.setInsdt(CommUtil.nowDate());
commonFile.setSize((int) item.getSize()); commonFile.setSize((int) item.getSize());
// 获取当前用户ID并设置
try {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes != null) {
HttpServletRequest request = attributes.getRequest();
User cu = (User) request.getSession().getAttribute("cu");
if (cu != null) {
commonFile.setInsuser(cu.getId());
}
}
} catch (Exception e) {
logger.warn("无法获取当前用户信息: {}", e.getMessage());
}
res = this.insertByTable(tableName, commonFile); res = this.insertByTable(tableName, commonFile);
} catch (Exception e) { } catch (Exception e) {
logger.error("Failed to update file to MinIO for masterId: {}", masterId, e); logger.error("Failed to update file to MinIO for masterId: {}", masterId, e);

View File

@ -116,8 +116,11 @@ var getFileListMinioPic = function (divId, status, entityId, previews, previewCo
tbName: tbName, tbName: tbName,
bucketName: bucketName bucketName: bucketName
}, function (data) { }, function (data) {
// 清空数组而不是重新赋值,这样可以保持引用不变
previews.length = 0;
previewConfigs.length = 0;
if (data.length > 0) { if (data.length > 0) {
previews = new Array();
$('#maintenancefile').show(); $('#maintenancefile').show();
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
var previewConfig = new Object(); var previewConfig = new Object();
@ -133,10 +136,9 @@ var getFileListMinioPic = function (divId, status, entityId, previews, previewCo
} }
previewConfigs.push(previewConfig); previewConfigs.push(previewConfig);
} }
showFileInput_new(divId, previews, previewConfigs);
} else {
$('#' + divId).hide();
} }
// 无论是否有数据都重新初始化控件
showFileInput_new(divId, previews, previewConfigs);
}, 'json'); }, 'json');
}; };

View File

@ -1,9 +1,10 @@
<%@ page language="java" pageEncoding="UTF-8" %> <%@ page language="java" pageEncoding="UTF-8" %>
<script type="text/javascript"> <script type="text/javascript">
var previews = new Array(); // 不重新定义这些变量,直接使用主页面的全局变量
var previewConfigs = new Array(); // var previews = new Array();
var filelist = new Array(); // var previewConfigs = new Array();
// var filelist = new Array();
//初始化fileinput控件第一次初始化 //初始化fileinput控件第一次初始化
function initFileInput(ctrlName, uploadUrl) { function initFileInput(ctrlName, uploadUrl) {
@ -55,9 +56,10 @@
//导入文件上传完成之后的事件 //导入文件上传完成之后的事件
control.on("fileuploaded", function (event, data, previewId, index) { control.on("fileuploaded", function (event, data, previewId, index) {
if (data.response.suc) { if (data.response.suc) {
<%--getFileListMinioPic('${param.divId}','edit');--%> // 直接使用主页面的全局变量重新加载文件列表
// getFileListMinioPic('abnormityFileId', 'edit', '', previews, previewConfigs);
getFileListMinioPic('${param.divId}', 'edit', '', previews, previewConfigs); getFileListMinioPic('${param.divId}', 'edit', '', previews, previewConfigs);
// 关闭上传弹窗,返回主页面
closeModal('fileInputModal');
} }
}); });
} }

View File

@ -354,7 +354,7 @@
</div>--%> </div>--%>
<div class="form-group" style="margin:8px"> <div class="form-group" style="margin:8px">
<button type="button" class="btn btn-default btn-file" onclick="fileinputPic('maintenanceDetailFile')" <button type="button" class="btn btn-default btn-file" onclick="fileinputPic('abnormityFileId')"
id="btn_save"><i id="btn_save"><i
class="fa fa-paperclip"></i>上传图片 class="fa fa-paperclip"></i>上传图片
</button> </button>