解决基础数据管理在点击目录时,结果列表总是显示所有数据的问题

master
guoxin 1 year ago
parent 3f4861c867
commit 4d6eb25372
  1. 24
      shandan-system/src/main/java/com/keyware/shandan/bianmu/service/impl/DirectoryTableServiceImpl.java
  2. 235
      shandan-system/src/main/resources/static/js/business/directory/directory-basicdata.js
  3. 1
      shandan-system/src/main/resources/view/business/directory/directory-basicdata.html

@ -1,8 +1,11 @@
package com.keyware.shandan.bianmu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.keyware.shandan.bianmu.entity.DirectoryTableVo;
import com.keyware.shandan.bianmu.entity.DirectoryVo;
import com.keyware.shandan.bianmu.mapper.DirectoryTableMapper;
import com.keyware.shandan.bianmu.service.DirectoryService;
import com.keyware.shandan.bianmu.service.DirectoryTableService;
import com.keyware.shandan.common.service.BaseServiceImpl;
import com.keyware.shandan.dynacmicform.core.basic.entity.FormInfoPo;
@ -10,8 +13,11 @@ import com.keyware.shandan.dynacmicform.core.basic.services.FormInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMapper, DirectoryTableVo, Integer> implements DirectoryTableService {
@ -19,10 +25,13 @@ public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMap
@Autowired
private FormInfoService formInfoService;
@Autowired
private DirectoryService directoryService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean addFormBatch(String dirId, List<String> formIdList) {
formIdList.forEach(formId ->{
formIdList.forEach(formId -> {
FormInfoPo formInfo = formInfoService.getById(formId);
DirectoryTableVo dtv = DirectoryTableVo.builder()
.dirId(dirId)
@ -35,6 +44,19 @@ public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMap
return true;
}
@Override
public Page<DirectoryTableVo> page(Page<DirectoryTableVo> page, QueryWrapper<DirectoryTableVo> wrapper) {
DirectoryTableVo table = wrapper.getEntity();
// 先获取所有子节点
DirectoryVo dir = directoryService.getById(table.getDirId());
Assert.notNull(dir, "目录节点不存在");
Set<String> dirIds = directoryService.allChildrenLists(dir).stream().map(DirectoryVo::getId).collect(Collectors.toSet());
dirIds.add(table.getDirId());
wrapper.clear();
wrapper.in("DIRECTORY_ID", dirIds);
return super.page(page, wrapper);
}
@Override
public boolean removeFormBatch(String dirId, List<String> formIdList) {
QueryWrapper<DirectoryTableVo> wrapper = new QueryWrapper<>();

@ -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);

@ -12,6 +12,7 @@
const user = JSON.parse(user_str);
const ReadPermisDirIds = /*[[${readDirIds}]]*/ [];
const WritePermisDirIds = /*[[${writeDirIds}]]*/ [];
const browser = /*[[${browser}]]*/ false;
// 目录业务类型,0:资源目录;1:基础数据目录
const bus_type = 1;
</script>