|
|
|
@ -152,32 +152,30 @@ function startRender() { |
|
|
|
|
* 增加移动文件功能 |
|
|
|
|
*/ |
|
|
|
|
metaListTable.addTableRowEvent('moveLink', function () { |
|
|
|
|
var table = layui.table, checkStatus = table.checkStatus('dirMetadataTable'), data = checkStatus.data; |
|
|
|
|
var table = layui.table, checkStatus = table.checkStatus('dirMetadataTable'), |
|
|
|
|
datas = checkStatus.data || []; |
|
|
|
|
if (basicData.id === 'ROOT' && !USER_ROLES.includes('ROLE_SA')) { |
|
|
|
|
layer.msg('没有权限'); |
|
|
|
|
return; |
|
|
|
|
showErrorMsg('没有权限'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (data.length < 1) { |
|
|
|
|
layer.confirm("请选择要移动的文件!", function (index) { |
|
|
|
|
layer.close(index); |
|
|
|
|
return; |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
layer.confirm('是否确定移动该数据?', {}, function (index) { |
|
|
|
|
layer.close(index); |
|
|
|
|
moveData(); |
|
|
|
|
}) |
|
|
|
|
if (datas.length === 0) { |
|
|
|
|
showErrorMsg('请选择要移动的文件'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function moveData() { |
|
|
|
|
openDirectoryMoveLayer(data).then(res => { |
|
|
|
|
refreshPermis().then(() => { |
|
|
|
|
metaListTable.reloadTable(); |
|
|
|
|
}) |
|
|
|
|
}).catch(e => { |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
const ids = datas.map(data => data.directoryId); |
|
|
|
|
const parentIdSet = new Set(); |
|
|
|
|
datas.forEach(data => parentIdSet.add(data.parentId)) |
|
|
|
|
openDirectorySelectLayer('move', (node)=>{ |
|
|
|
|
if([...parentIdSet.values()].includes(node.id)){ |
|
|
|
|
showErrorMsg('不能选择当前目录'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}).then(nodes => { |
|
|
|
|
const targetId = nodes[0].id; |
|
|
|
|
moveResource(ids.join(','), targetId).then(res => refreshPermis().then(() => metaListTable.reloadTable())); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
metaListTable.addTableRowEvent('removeLink', function (obj) { |
|
|
|
|
if (basicData.reviewStatus === ReviewStatus.PASS) { |
|
|
|
@ -514,14 +512,24 @@ function startRender() { |
|
|
|
|
title: "移动目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData, id, parentId, context} = node; |
|
|
|
|
openDirectoryCopyLayer(basicData, 'move').then(res => { |
|
|
|
|
refreshPermis().then(() => { |
|
|
|
|
dirTree.partialRefreshAdd(elem); |
|
|
|
|
openDirectorySelectLayer('move', (node) => { |
|
|
|
|
if (node.id === id) { |
|
|
|
|
showErrorMsg('不能选择自己'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (node.basicData.directoryPath.startsWith(basicData.directoryPath + '/')) { |
|
|
|
|
showErrorMsg('不能选择子级目录'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}).then(nodes => { |
|
|
|
|
const targetId = nodes[0].id; |
|
|
|
|
moveResource(id, targetId).then(res => refreshPermis().then(() => { |
|
|
|
|
dirTree.partialRefreshAdd($(`div[data-id="${parentId}"]`)); |
|
|
|
|
dirTree.partialRefreshAdd($(`div[data-id="${targetId}"]`)); |
|
|
|
|
metaListTable.reloadTable(); |
|
|
|
|
}) |
|
|
|
|
}).catch(e => { |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
})); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
@ -556,13 +564,28 @@ function startRender() { |
|
|
|
|
title: "关联目录或文件", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData, id, parentId, context} = node; |
|
|
|
|
openDirectoryCopyLayer(basicData).then(res => { |
|
|
|
|
openDirectorySelectLayer('link', (node)=>{ |
|
|
|
|
if(node.id === id){ |
|
|
|
|
showErrorMsg('不能选择自己'); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if(node.id === parentId){ |
|
|
|
|
showErrorMsg('已经存在于该目录') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if(node.basicData.directoryPath.startsWith(basicData.directoryPath)){ |
|
|
|
|
showErrorMsg('不能选择子级目录') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}).then(nodes=>{ |
|
|
|
|
const chooseNode = nodes[0]; |
|
|
|
|
linkResource(chooseNode.id, id).then(res=>{ |
|
|
|
|
refreshPermis().then(() => { |
|
|
|
|
dirTree.partialRefreshAdd(elem); |
|
|
|
|
dirTree.partialRefreshAdd($(`div[data-id="${id}"]`)); |
|
|
|
|
metaListTable.reloadTable(); |
|
|
|
|
}) |
|
|
|
|
}).catch(e => { |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -663,101 +686,25 @@ function startRender() { |
|
|
|
|
dom.click(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let copyItems = []; |
|
|
|
|
|
|
|
|
|
function openDirectoryCopyLayer(dirData, isMove) { |
|
|
|
|
return new Promise(((resolve, reject) => { |
|
|
|
|
layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
title: isMove ? '请选择目标目录' : '选择目录资源', |
|
|
|
|
area: ['700px'], |
|
|
|
|
btn: ['保存', '取消'], |
|
|
|
|
content: `<div style="width: 100%; height: 700px; border-bottom: 1px solid #eee;" id="copyDirTreeBox"><ul id="copyDirTree"></ul></div>`, |
|
|
|
|
success: function (layerObj, index) { |
|
|
|
|
let copyTreeOps = globalTree.init({ |
|
|
|
|
id: 'copyDirTree', |
|
|
|
|
url: treeChildrenUrl + '&all=true', |
|
|
|
|
// type: 'all',
|
|
|
|
|
cache: true, |
|
|
|
|
scroll: '#copyDirTreeBox', |
|
|
|
|
width: '100%', |
|
|
|
|
checkbar: true, |
|
|
|
|
checkbarType: isMove ? 'only' : 'p-casc', |
|
|
|
|
checkbarFun: { |
|
|
|
|
chooseBefore: function ($i, node) { |
|
|
|
|
if (!isMove && node.id == DIR_ROOT_ID) { |
|
|
|
|
showErrorMsg('不能选择根节点!') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (dirData.id == node.id) { |
|
|
|
|
showErrorMsg('不能选择自己!') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (dirData.id == node.parentId) { |
|
|
|
|
showErrorMsg('该节点已存在!') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// 选中前的回调
|
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
chooseDone: function (nodes) { //复选框点击事件完毕后,返回该树关于复选框操作的全部信息。
|
|
|
|
|
// 选中后的回调
|
|
|
|
|
nodes = nodes || []; |
|
|
|
|
copyItems = nodes.map(node => { |
|
|
|
|
let basicData = node.basicData || {}; |
|
|
|
|
let {id, parentId, directoryType, resourceId} = basicData; |
|
|
|
|
const resourceTypes = ['METADATA', 'LINK_METADATA', 'FILE', 'LINK_FILE']; |
|
|
|
|
if (resourceTypes.includes(directoryType)) { |
|
|
|
|
id = resourceId; |
|
|
|
|
} |
|
|
|
|
return {id, directoryType, parentId}; |
|
|
|
|
}).filter(id => id !== DIR_ROOT_ID); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
done: res => { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
yes: function (index) { |
|
|
|
|
let params = {targetId: dirData.id, items: copyItems} |
|
|
|
|
if (isMove) { |
|
|
|
|
params.targetId = copyItems[0].id; |
|
|
|
|
params.items = [{id: dirData.id, directoryType: 'DIRECTORY', parentId: ''}] |
|
|
|
|
} |
|
|
|
|
Util.post(isMove ? '/business/directory/move' : '/business/directory/copy', params).then(res => { |
|
|
|
|
if (res.flag) { |
|
|
|
|
showOkMsg('保存成功'); |
|
|
|
|
if (isMove) { |
|
|
|
|
window.location.reload() |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
showErrorMsg(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
resolve && resolve(); |
|
|
|
|
layer.close(index); |
|
|
|
|
}, |
|
|
|
|
cancel: function (index) { |
|
|
|
|
reject && reject(); |
|
|
|
|
layer.close(index); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
function openDirectorySelectLayer(operateType, disabledIds) { |
|
|
|
|
let chooseBeforeHandler, selectNodes = []; |
|
|
|
|
if (disabledIds instanceof Function) { |
|
|
|
|
chooseBeforeHandler = disabledIds; |
|
|
|
|
disabledIds = undefined; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function openDirectoryMoveLayer(data) { |
|
|
|
|
return new Promise(((resolve, reject) => { |
|
|
|
|
let directorySelectTree; |
|
|
|
|
layer.open({ |
|
|
|
|
type: 1, |
|
|
|
|
title: '请选择目标目录', |
|
|
|
|
title: '请选择目录', |
|
|
|
|
area: ['700px'], |
|
|
|
|
btn: ['保存', '取消'], |
|
|
|
|
content: `<div style="width: 100%; height: 700px; border-bottom: 1px solid #eee;" id="moveFileTreeBox"><ul id="moveFileTree"></ul></div>`, |
|
|
|
|
success: function (layerObj, index) { |
|
|
|
|
let moveFileTreeOps = globalTree.init({ |
|
|
|
|
directorySelectTree = globalTree.init({ |
|
|
|
|
id: 'moveFileTree', |
|
|
|
|
url: treeChildrenUrl + '&all=true', |
|
|
|
|
// type: 'all',
|
|
|
|
|
url: `${treeChildrenUrl}&all=${operateType !== 'move'}`, |
|
|
|
|
cache: true, |
|
|
|
|
scroll: '#moveFileTreeBox', |
|
|
|
|
width: '100%', |
|
|
|
@ -765,57 +712,32 @@ function startRender() { |
|
|
|
|
checkbarType: 'only', |
|
|
|
|
checkbarFun: { |
|
|
|
|
chooseBefore: function ($i, node) { |
|
|
|
|
if (node.id == DIR_ROOT_ID) { |
|
|
|
|
const chooseDir = node.basicData; |
|
|
|
|
if (node.id === DIR_ROOT_ID && (operateType === 'link')) { |
|
|
|
|
showErrorMsg('不能选择根节点!') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (data[0].parentId == node.id) { |
|
|
|
|
showErrorMsg('不能选择自己!') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (data[0].id == node.parentId) { |
|
|
|
|
showErrorMsg('该节点已存在!') |
|
|
|
|
return false; |
|
|
|
|
if (chooseBeforeHandler) { |
|
|
|
|
return chooseBeforeHandler(node); |
|
|
|
|
} |
|
|
|
|
// 选中前的回调
|
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
chooseDone: function (nodes) { //复选框点击事件完毕后,返回该树关于复选框操作的全部信息。
|
|
|
|
|
chooseDone: function (nodes) { |
|
|
|
|
// 选中后的回调
|
|
|
|
|
nodes = nodes || []; |
|
|
|
|
copyItems = nodes.map(node => { |
|
|
|
|
let basicData = node.basicData || {}; |
|
|
|
|
let {id, parentId, directoryType, resourceId} = basicData; |
|
|
|
|
const resourceTypes = ['METADATA', 'LINK_METADATA', 'FILE', 'LINK_FILE']; |
|
|
|
|
if (resourceTypes.includes(directoryType)) { |
|
|
|
|
id = resourceId; |
|
|
|
|
} |
|
|
|
|
return {id, directoryType, parentId}; |
|
|
|
|
}).filter(id => id !== DIR_ROOT_ID); |
|
|
|
|
selectNodes = nodes || []; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
done: res => { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
yes: function (index) { |
|
|
|
|
let params = {targetId: copyItems[0].id, items: []} |
|
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
|
params.items.push({id: data[i].directoryId, directoryType: 'FILE', parentId: ''}) |
|
|
|
|
} |
|
|
|
|
Util.post('/business/directory/move', params).then(res => { |
|
|
|
|
if (res.flag) { |
|
|
|
|
showOkMsg('保存成功'); |
|
|
|
|
window.location.reload() |
|
|
|
|
} else { |
|
|
|
|
showErrorMsg(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
resolve && resolve(); |
|
|
|
|
layer.close(index); |
|
|
|
|
resolve(selectNodes); |
|
|
|
|
}, |
|
|
|
|
cancel: function (index) { |
|
|
|
|
reject && reject(); |
|
|
|
|
layer.close(index); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -942,3 +864,43 @@ function startRender() { |
|
|
|
|
|
|
|
|
|
initViewDirectoryTree(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 关联资源 |
|
|
|
|
* @param sourceId 源资源ID |
|
|
|
|
* @param targetId 目标资源ID |
|
|
|
|
*/ |
|
|
|
|
function linkResource(sourceId, targetId) { |
|
|
|
|
const params = {targetId, sourceId}; |
|
|
|
|
return new Promise((resolve, rejects) => { |
|
|
|
|
Util.post('/business/directory/link', params).then(res => { |
|
|
|
|
if (res.flag) { |
|
|
|
|
showOkMsg('保存成功'); |
|
|
|
|
resolve(res); |
|
|
|
|
} else { |
|
|
|
|
showErrorMsg(); |
|
|
|
|
rejects(); |
|
|
|
|
} |
|
|
|
|
}).catch(rejects); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 移动资源 |
|
|
|
|
* @param sourceIds 源资源id集合 |
|
|
|
|
* @param targetId 目标id |
|
|
|
|
*/ |
|
|
|
|
function moveResource(sourceIds, targetId) { |
|
|
|
|
const params = {targetId, sourceIds}; |
|
|
|
|
return new Promise((resolve, rejects) => { |
|
|
|
|
Util.post('/business/directory/move', params).then(res => { |
|
|
|
|
if (res.flag) { |
|
|
|
|
showOkMsg('保存成功'); |
|
|
|
|
resolve(res); |
|
|
|
|
} else { |
|
|
|
|
showErrorMsg(); |
|
|
|
|
rejects(); |
|
|
|
|
} |
|
|
|
|
}).catch(rejects); |
|
|
|
|
}) |
|
|
|
|
} |