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

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. 189
      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; package com.keyware.shandan.bianmu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.DirectoryTableVo;
import com.keyware.shandan.bianmu.entity.DirectoryVo;
import com.keyware.shandan.bianmu.mapper.DirectoryTableMapper; 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.bianmu.service.DirectoryTableService;
import com.keyware.shandan.common.service.BaseServiceImpl; import com.keyware.shandan.common.service.BaseServiceImpl;
import com.keyware.shandan.dynacmicform.core.basic.entity.FormInfoPo; 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.beans.factory.annotation.Autowired;
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.util.Assert;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service @Service
public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMapper, DirectoryTableVo, Integer> implements DirectoryTableService { public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMapper, DirectoryTableVo, Integer> implements DirectoryTableService {
@ -19,10 +25,13 @@ public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMap
@Autowired @Autowired
private FormInfoService formInfoService; private FormInfoService formInfoService;
@Autowired
private DirectoryService directoryService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean addFormBatch(String dirId, List<String> formIdList) { public boolean addFormBatch(String dirId, List<String> formIdList) {
formIdList.forEach(formId ->{ formIdList.forEach(formId -> {
FormInfoPo formInfo = formInfoService.getById(formId); FormInfoPo formInfo = formInfoService.getById(formId);
DirectoryTableVo dtv = DirectoryTableVo.builder() DirectoryTableVo dtv = DirectoryTableVo.builder()
.dirId(dirId) .dirId(dirId)
@ -35,6 +44,19 @@ public class DirectoryTableServiceImpl extends BaseServiceImpl<DirectoryTableMap
return true; 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 @Override
public boolean removeFormBatch(String dirId, List<String> formIdList) { public boolean removeFormBatch(String dirId, List<String> formIdList) {
QueryWrapper<DirectoryTableVo> wrapper = new QueryWrapper<>(); QueryWrapper<DirectoryTableVo> wrapper = new QueryWrapper<>();

@ -35,6 +35,7 @@ function startRender() {
toolbar: '#tableToolBar', toolbar: '#tableToolBar',
searchFieldNames: 'formComment', searchFieldNames: 'formComment',
url: `${ctx}/directory/form/page?dirId=${dirId}`, url: `${ctx}/directory/form/page?dirId=${dirId}`,
where: {dirId},
height: 'full-110', height: 'full-110',
//method: 'get', //method: 'get',
text: {none: permis.viewPermis ? '没有数据' : '没有权限'}, text: {none: permis.viewPermis ? '没有数据' : '没有权限'},
@ -104,51 +105,67 @@ function startRender() {
// 加载并渲染目录树 // 加载并渲染目录树
let currentNode, currentParentNode; let currentNode, currentParentNode;
let treeChildrenUrl = `${ctx}/business/directory/tree?busType=${bus_type}` let treeChildrenUrl = `${ctx}/business/directory/tree?busType=${bus_type}`;
let treeOps = { const toolbarExt = [
id: 'directoryTree', {
url: treeChildrenUrl, toolbarId: "toolbar_dir_add",
cache: false, icon: "dtreefont dtree-icon-weibiaoti5",
//type: 'all', title: "新建目录",
initLevel: 1, // 默认展开一级 handler: function (node, elem) {
scroll: '#tree-toobar-div', const {id, basicData} = node;
width: 'fit-content', openDirectoryEditLayer({parentId: id}, function (data) {
toolbar: true, if (id === DIR_ROOT_ID) {
toolbarShow: [], //置空默认菜单项 dirTree.partialRefreshAdd(elem);
sendSuccess: function (res) { } else {
if (res.flag) { setTimeout(function () {
res.data.forEach(item => { let $newDom = $(`#directoryTree div.dtree-nav-div.dtree-theme-item[data-id="${basicData.id}"]`)
dirCache.set(item.id, item); dirTree.partialRefreshAdd($newDom);
}) }, 50)
setTimeout(() => {
$('.dtree-nav-div.dtree-theme-item').each((index, elem) => {
let data = $(elem).data('basic');
if (data) {
if (typeof data === 'string') {
data = JSON.parse(data);
}
let title = data.metadataComment || data.directoryName || data.fileName + data.fileSuffix;
$(elem).attr('title', title)
} }
}); });
}, 200)
} }
}, },
done: function (nodes, elem) { {
// 模拟鼠标点击事件展开第一层目录 toolbarId: "toolbar_dir_rename",
elem.find('li:first>div:first>i:first').click(); icon: "dtreefont dtree-icon-bianji",
elem.find('li:first>div:first').click(); title: "修改目录",
handler: function (node, elem) {
const {basicData} = node;
openDirectoryEditLayer(basicData, function (data) {
dirTree.partialRefreshEdit(elem, data);
dirTree.getChild(elem);
elem[0].click();
});
}
}, },
onClick: function (node) { {
tempNode = node; toolbarId: "toolbar_dir_delete",
currentNode = getCurrentNode(); icon: "dtreefont dtree-icon-delete1",
currentParentNode = getCurrentParentNode(); title: "删除目录",
const {basicData} = node.param; handler: function (node, elem) {
setLocation(basicData.directoryPath) const {id, parentId} = node;
loadMetadataList(node.param) deleteDirectory(id).then(() => {
//dirTree.partialRefreshDel(elem)
reZhanKai(currentParentNode);
// 点击父节点
$(`div[data-id="${parentId}"]`).click();
})
}
}, },
toolbarFun: { {
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) { loadToolbarBefore: function (buttons, param, $div) {
const {basicData} = param; const {basicData} = param;
@ -203,66 +220,52 @@ function startRender() {
return buttons; return buttons;
} }
}, };
toolbarExt: [ let treeOps = {
{ id: 'directoryTree',
toolbarId: "toolbar_dir_add", url: treeChildrenUrl,
icon: "dtreefont dtree-icon-weibiaoti5", cache: false,
title: "新建目录", //type: 'all',
handler: function (node, elem) { initLevel: 1, // 默认展开一级
const {id, basicData} = node; scroll: '#tree-toobar-div',
openDirectoryEditLayer({parentId: id}, function (data) { width: 'fit-content',
if (id === DIR_ROOT_ID) { toolbar: true,
dirTree.partialRefreshAdd(elem); toolbarShow: [], //置空默认菜单项
} else { sendSuccess: function (res) {
setTimeout(function () { if (res.flag) {
let $newDom = $(`#directoryTree div.dtree-nav-div.dtree-theme-item[data-id="${basicData.id}"]`) res.data.forEach(item => {
dirTree.partialRefreshAdd($newDom); dirCache.set(item.id, item);
}, 50) })
setTimeout(() => {
$('.dtree-nav-div.dtree-theme-item').each((index, elem) => {
let data = $(elem).data('basic');
if (data) {
if (typeof data === 'string') {
data = JSON.parse(data);
} }
}); let title = data.metadataComment || data.directoryName || data.fileName + data.fileSuffix;
$(elem).attr('title', title)
} }
},
{
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();
}); });
}, 200)
} }
}, },
{ done: function (nodes, elem) {
toolbarId: "toolbar_dir_delete", // 模拟鼠标点击事件展开第一层目录
icon: "dtreefont dtree-icon-delete1", elem.find('li:first>div:first>i:first').click();
title: "删除目录", elem.find('li:first>div:first').click();
handler: function (node, elem) {
const {id, parentId} = node;
deleteDirectory(id).then(() => {
//dirTree.partialRefreshDel(elem)
reZhanKai(currentParentNode);
// 点击父节点
$(`div[data-id="${parentId}"]`).click();
})
}
}, },
{ onClick: function (node) {
toolbarId: "toolbar_dir_link", tempNode = node;
icon: "layui-icon layui-icon-link", currentNode = getCurrentNode();
title: "关联数据", currentParentNode = getCurrentParentNode();
handler: function (node, elem) { const {basicData} = node.param;
const {basicData, id, parentId, context} = node; setLocation(basicData.directoryPath)
openAddMetadataLayer(basicData, function () { loadMetadataList(node.param)
//dirTree.partialRefreshAdd(elem); },
metaListTable.reloadTable(); toolbarFun: !browser && toolbarFun,
}) toolbarExt: !browser && toolbarExt,
}
}
],
} }
dirTree = globalTree.init(treeOps); dirTree = globalTree.init(treeOps);

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