|
|
|
@ -35,6 +35,7 @@ function startRender() { |
|
|
|
|
toolbar: '#tableToolBar', |
|
|
|
|
searchFieldNames: 'formComment', |
|
|
|
|
url: `${ctx}/directory/form/page?dirId=${dirId}`, |
|
|
|
|
where: {dirId}, |
|
|
|
|
height: 'full-110', |
|
|
|
|
//method: 'get',
|
|
|
|
|
text: {none: permis.viewPermis ? '没有数据' : '没有权限'}, |
|
|
|
@ -104,7 +105,122 @@ function startRender() { |
|
|
|
|
|
|
|
|
|
// 加载并渲染目录树
|
|
|
|
|
let currentNode, currentParentNode; |
|
|
|
|
let treeChildrenUrl = `${ctx}/business/directory/tree?busType=${bus_type}` |
|
|
|
|
let treeChildrenUrl = `${ctx}/business/directory/tree?busType=${bus_type}`; |
|
|
|
|
const toolbarExt = [ |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_add", |
|
|
|
|
icon: "dtreefont dtree-icon-weibiaoti5", |
|
|
|
|
title: "新建目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {id, basicData} = node; |
|
|
|
|
openDirectoryEditLayer({parentId: id}, function (data) { |
|
|
|
|
if (id === DIR_ROOT_ID) { |
|
|
|
|
dirTree.partialRefreshAdd(elem); |
|
|
|
|
} else { |
|
|
|
|
setTimeout(function () { |
|
|
|
|
let $newDom = $(`#directoryTree div.dtree-nav-div.dtree-theme-item[data-id="${basicData.id}"]`) |
|
|
|
|
dirTree.partialRefreshAdd($newDom); |
|
|
|
|
}, 50) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_rename", |
|
|
|
|
icon: "dtreefont dtree-icon-bianji", |
|
|
|
|
title: "修改目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData} = node; |
|
|
|
|
openDirectoryEditLayer(basicData, function (data) { |
|
|
|
|
dirTree.partialRefreshEdit(elem, data); |
|
|
|
|
dirTree.getChild(elem); |
|
|
|
|
elem[0].click(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_delete", |
|
|
|
|
icon: "dtreefont dtree-icon-delete1", |
|
|
|
|
title: "删除目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {id, parentId} = node; |
|
|
|
|
deleteDirectory(id).then(() => { |
|
|
|
|
//dirTree.partialRefreshDel(elem)
|
|
|
|
|
reZhanKai(currentParentNode); |
|
|
|
|
// 点击父节点
|
|
|
|
|
$(`div[data-id="${parentId}"]`).click(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_link", |
|
|
|
|
icon: "layui-icon layui-icon-link", |
|
|
|
|
title: "关联数据", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData, id, parentId, context} = node; |
|
|
|
|
openAddMetadataLayer(basicData, function () { |
|
|
|
|
//dirTree.partialRefreshAdd(elem);
|
|
|
|
|
metaListTable.reloadTable(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
]; |
|
|
|
|
const toolbarFun = { |
|
|
|
|
// 显示右键菜单之前的回调,用于设置显示哪些菜单
|
|
|
|
|
loadToolbarBefore: function (buttons, param, $div) { |
|
|
|
|
const {basicData} = param; |
|
|
|
|
// 根据数据审核状态判断是否显示相关功能按钮
|
|
|
|
|
if (basicData && basicData.id !== DIR_ROOT_ID && basicData.id !== DIR_THEME_ROOT_ID && basicData.id !== DIR_BASIC_ROOT_ID) { |
|
|
|
|
switch (basicData.reviewStatus) { |
|
|
|
|
case ReviewStatus.SUBMITTED: |
|
|
|
|
case ReviewStatus.PASS: |
|
|
|
|
// setDisabledButtons(['toolbar_dir_submit', 'toolbar_dir_delete']);
|
|
|
|
|
if (!(user.userId === basicData.ownerId || (user.orgId === basicData.ownerId && user.orgLeader))) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename']) |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case ReviewStatus.UN_SUBMIT: |
|
|
|
|
case ReviewStatus.FAIL: |
|
|
|
|
setDisabledButtons(); |
|
|
|
|
break |
|
|
|
|
case ReviewStatus.REJECTED: |
|
|
|
|
setDisabledButtons([]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 根据数据操作权限判断是否显示相关按钮
|
|
|
|
|
if (!WritePermisDirIds.includes(basicData.id)) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']); |
|
|
|
|
if (user.orgId !== basicData.ownerId) { |
|
|
|
|
// 如果当前用户所在部门 不是 选中目录所属部门ID,则禁用新建按钮
|
|
|
|
|
setDisabledButtons(['toolbar_dir_add']) |
|
|
|
|
} |
|
|
|
|
} else if (!isDirectoryOwner(basicData)) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_delete']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (basicData.directoryType.startsWith('LINK_')) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_add', 'toolbar_dir_link', 'toolbar_dir_mark', 'toolbar_dir_copy']) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置需要禁用的按钮 |
|
|
|
|
* @param buttonIds 按钮ID数组 |
|
|
|
|
*/ |
|
|
|
|
function setDisabledButtons(buttonIds = []) { |
|
|
|
|
for (let btnName of buttonIds) { |
|
|
|
|
let $btn = $(buttons[btnName]); |
|
|
|
|
let $a = $btn.find('a').addClass('layui-disabled'); |
|
|
|
|
$btn.html($a[0]); |
|
|
|
|
buttons[btnName] = $btn[0]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return buttons; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
let treeOps = { |
|
|
|
|
id: 'directoryTree', |
|
|
|
|
url: treeChildrenUrl, |
|
|
|
@ -148,121 +264,8 @@ function startRender() { |
|
|
|
|
setLocation(basicData.directoryPath) |
|
|
|
|
loadMetadataList(node.param) |
|
|
|
|
}, |
|
|
|
|
toolbarFun: { |
|
|
|
|
// 显示右键菜单之前的回调,用于设置显示哪些菜单
|
|
|
|
|
loadToolbarBefore: function (buttons, param, $div) { |
|
|
|
|
const {basicData} = param; |
|
|
|
|
// 根据数据审核状态判断是否显示相关功能按钮
|
|
|
|
|
if (basicData && basicData.id !== DIR_ROOT_ID && basicData.id !== DIR_THEME_ROOT_ID && basicData.id !== DIR_BASIC_ROOT_ID) { |
|
|
|
|
switch (basicData.reviewStatus) { |
|
|
|
|
case ReviewStatus.SUBMITTED: |
|
|
|
|
case ReviewStatus.PASS: |
|
|
|
|
// setDisabledButtons(['toolbar_dir_submit', 'toolbar_dir_delete']);
|
|
|
|
|
if (!(user.userId === basicData.ownerId || (user.orgId === basicData.ownerId && user.orgLeader))) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename']) |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case ReviewStatus.UN_SUBMIT: |
|
|
|
|
case ReviewStatus.FAIL: |
|
|
|
|
setDisabledButtons(); |
|
|
|
|
break |
|
|
|
|
case ReviewStatus.REJECTED: |
|
|
|
|
setDisabledButtons([]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 根据数据操作权限判断是否显示相关按钮
|
|
|
|
|
if (!WritePermisDirIds.includes(basicData.id)) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']); |
|
|
|
|
if (user.orgId !== basicData.ownerId) { |
|
|
|
|
// 如果当前用户所在部门 不是 选中目录所属部门ID,则禁用新建按钮
|
|
|
|
|
setDisabledButtons(['toolbar_dir_add']) |
|
|
|
|
} |
|
|
|
|
} else if (!isDirectoryOwner(basicData)) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_delete']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (basicData.directoryType.startsWith('LINK_')) { |
|
|
|
|
setDisabledButtons(['toolbar_dir_add', 'toolbar_dir_link', 'toolbar_dir_mark', 'toolbar_dir_copy']) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
setDisabledButtons(['toolbar_dir_rename', 'toolbar_dir_delete', 'toolbar_dir_link', 'toolbar_dir_submit', 'toolbar_dir_mark', 'toolbar_dir_copy']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置需要禁用的按钮 |
|
|
|
|
* @param buttonIds 按钮ID数组 |
|
|
|
|
*/ |
|
|
|
|
function setDisabledButtons(buttonIds = []) { |
|
|
|
|
for (let btnName of buttonIds) { |
|
|
|
|
let $btn = $(buttons[btnName]); |
|
|
|
|
let $a = $btn.find('a').addClass('layui-disabled'); |
|
|
|
|
$btn.html($a[0]); |
|
|
|
|
buttons[btnName] = $btn[0]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return buttons; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
toolbarExt: [ |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_add", |
|
|
|
|
icon: "dtreefont dtree-icon-weibiaoti5", |
|
|
|
|
title: "新建目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {id, basicData} = node; |
|
|
|
|
openDirectoryEditLayer({parentId: id}, function (data) { |
|
|
|
|
if (id === DIR_ROOT_ID) { |
|
|
|
|
dirTree.partialRefreshAdd(elem); |
|
|
|
|
} else { |
|
|
|
|
setTimeout(function () { |
|
|
|
|
let $newDom = $(`#directoryTree div.dtree-nav-div.dtree-theme-item[data-id="${basicData.id}"]`) |
|
|
|
|
dirTree.partialRefreshAdd($newDom); |
|
|
|
|
}, 50) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_rename", |
|
|
|
|
icon: "dtreefont dtree-icon-bianji", |
|
|
|
|
title: "修改目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData} = node; |
|
|
|
|
openDirectoryEditLayer(basicData, function (data) { |
|
|
|
|
dirTree.partialRefreshEdit(elem, data); |
|
|
|
|
dirTree.getChild(elem); |
|
|
|
|
elem[0].click(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_delete", |
|
|
|
|
icon: "dtreefont dtree-icon-delete1", |
|
|
|
|
title: "删除目录", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {id, parentId} = node; |
|
|
|
|
deleteDirectory(id).then(() => { |
|
|
|
|
//dirTree.partialRefreshDel(elem)
|
|
|
|
|
reZhanKai(currentParentNode); |
|
|
|
|
// 点击父节点
|
|
|
|
|
$(`div[data-id="${parentId}"]`).click(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
toolbarId: "toolbar_dir_link", |
|
|
|
|
icon: "layui-icon layui-icon-link", |
|
|
|
|
title: "关联数据", |
|
|
|
|
handler: function (node, elem) { |
|
|
|
|
const {basicData, id, parentId, context} = node; |
|
|
|
|
openAddMetadataLayer(basicData, function () { |
|
|
|
|
//dirTree.partialRefreshAdd(elem);
|
|
|
|
|
metaListTable.reloadTable(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
toolbarFun: !browser && toolbarFun, |
|
|
|
|
toolbarExt: !browser && toolbarExt, |
|
|
|
|
} |
|
|
|
|
dirTree = globalTree.init(treeOps); |
|
|
|
|
|
|
|
|
|