解决编目上传文件后数据列表刷新不回显的问题

master
GuoXin 1 year ago
parent d86a677ecd
commit 0dc53ea81a
  1. 87
      shandan-bianmu/src/main/resources/static/js/business/directory/directory.js
  2. 2
      shandan-system/src/main/resources/static/js/sys/file/dirUpload.js

@ -14,6 +14,11 @@ function startRender() {
let dirTree, metaListTable, fileUploadLayerWin, tempNode;
let addMetadataLayerWin;
/**
* 打开关联数据表弹出层
* @param directory
* @param callback
*/
const openAddMetadataLayer = function (directory, callback) {
if (directory.reviewStatus === ReviewStatus.PASS || directory.reviewStatus === ReviewStatus.SUBMITTED) {
addDataConfirm(open);
@ -21,6 +26,9 @@ function startRender() {
open();
}
/**
* 弹出选择数据表窗口
*/
function open() {
layer.open({
id: 'addMetadataLayer',
@ -41,9 +49,11 @@ function startRender() {
}, function (res) {
if (res.flag) {
layer.msg('保存成功');
refreshPermis().then(()=>{
layer.close(index);
refreshDirectoryNode(tempNode, res.data);
callback && callback();
});
} else {
layer.msg('保存失败')
}
@ -182,9 +192,11 @@ function startRender() {
function removeData() {
Util.send(`/business/directory/delete/${obj.directoryId}`, {}, 'delete').then(res => {
if (res.flag) {
showOkMsg('删除成功')
showOkMsg('删除成功');
refreshPermis().then(()=>{
metaListTable.reloadTable();
//refreshDirectoryNode(tempNode, res.data);
})
} else {
showErrorMsg(res.msg);
}
@ -195,11 +207,11 @@ function startRender() {
upload(basicData, `${ctx}/sys/file/layer/dir?directoryId=${basicData.id}&secretLevel=${basicData.secretLevel}`, function (res) {
if (res.success) {
refreshPermis().then(() => {
refreshDirectoryNode(tempNode, basicData);
metaListTable.reloadTable();
/*if (res.data) {
Util.get(`/business/directory/get/${res.data.entityId}`).then(res => refreshDirectoryNode(tempNode, res.data))
}*/
})
}
});
});
@ -215,6 +227,40 @@ function startRender() {
});
})
function upload(basicData, url, callback) {
if (basicData.id === 'ROOT' && !USER_ROLES.includes('ROLE_SA')){
layer.msg('没有权限');
return;
}
if (basicData.reviewStatus == ReviewStatus.PASS || basicData.reviewStatus == ReviewStatus.SUBMITTED) {
addDataConfirm(open);
} else {
open();
}
function open() {
let height = $(document).height();
height = height < 1000 ? height : height * 0.8;
layer.open({
id: 'fileUploadLayer',
title: '上传文件',
type: 2,
area: ['900px', height + 'px'],
maxmin: true,
btn: false,
content: url,
success: function (layero, index) {
fileUploadLayerWin = window[layero.find('iframe')[0]['name']];
fileUploadLayerWin.layerOkCallback = callback;
fileUploadLayerWin.layerCancelCallback = function () {
layer.close(index);
metaListTable.reloadTable()
};
},
});
}
}
// 查看按钮监听
metaListTable.addTableRowEvent('details', function (obj) {
if (obj.resourceType === 'file') {
@ -281,39 +327,6 @@ function startRender() {
})
}
function upload(basicData, url, callback) {
if (basicData.id === 'ROOT' && !USER_ROLES.includes('ROLE_SA')){
layer.msg('没有权限');
return;
}
if (basicData.reviewStatus == ReviewStatus.PASS || basicData.reviewStatus == ReviewStatus.SUBMITTED) {
addDataConfirm(open);
} else {
open();
}
function open() {
let height = $(document).height();
height = height < 1000 ? height : height * 0.8;
layer.open({
id: 'fileUploadLayer',
title: '上传文件',
type: 2,
area: ['900px', height + 'px'],
maxmin: true,
btn: false,
content: url,
success: function (layero, index) {
fileUploadLayerWin = window[layero.find('iframe')[0]['name']];
fileUploadLayerWin.layerOkCallback = callback;
fileUploadLayerWin.layerCancelCallback = function () {
layer.close(index);
metaListTable.reloadTable()
};
},
});
}
}
// 加载并渲染目录树
let currentNode, currentParentNode, tempOwner, tempOwnerType;

@ -32,8 +32,10 @@ layui.use(['layer', 'uploader', 'element', 'form', 'laydate', 'dict', 'datalabel
saveResult.success = true;
//let index = parent.layer.getFrameIndex(window.name);
parent.layer.msg('上传成功');
layerOkCallback && layerOkCallback(saveResult);
closeWindow()
} else {
layerCancelCallback && layerCancelCallback(saveResult);
showErrorMsg("上传失败");
$('#fileUploadAction').removeClass('layui-disabled').removeAttr('disabled')
}