diff --git a/front/src/pages/manage/OverView/function.js b/front/src/pages/manage/OverView/function.js index ed9da35..5b82e4e 100644 --- a/front/src/pages/manage/OverView/function.js +++ b/front/src/pages/manage/OverView/function.js @@ -187,7 +187,7 @@ function deleteTreeData(treeData, set) { * @param {*} info */ export function onDrop(info) { - const { treeData, updateTreeData } = this.props; + const { treeData, updateTreeData, loadedKeys, changeLoadedKeys } = this.props; const target = info.node.props.dataRef; if (!info.dropToGap && target.type === 0) { message.error("无法移动到书签内部"); @@ -222,6 +222,10 @@ export function onDrop(info) { const length = target.children.length; body.sort = length > 0 ? target.children[length - 1].sort + 1 : 1; target.children.push(current); + } else if (current.type === 1 && current.children) { + //目标未加载且当前节点为已经展开的目录情况下需要把当前节点从已加载列表中移除,否则在目标节点中展开时会不显示当前节点的子节点 + loadedKeys.splice(loadedKeys.indexOf(current.bookmarkId.toString()), 1); + changeLoadedKeys(loadedKeys); } } if (body.sort !== -1) { diff --git a/front/src/pages/manage/OverView/index.jsx b/front/src/pages/manage/OverView/index.jsx index f6960ad..d20bbc1 100644 --- a/front/src/pages/manage/OverView/index.jsx +++ b/front/src/pages/manage/OverView/index.jsx @@ -23,7 +23,8 @@ function mapDispatchToProps(dispatch) { changeIsInit: value => dispatch(action.changeIsInit(value)), changeCheckedKeys: (keys, nodes) => dispatch(action.changeCheckedKeys(keys, nodes)), changeExpandedKeys: keys => dispatch(action.changeExpandedKeys(keys)), - changeCurrentClickItem: item => dispatch(action.changeCurrentClickItem(item)) + changeCurrentClickItem: item => dispatch(action.changeCurrentClickItem(item)), + changeLoadedKeys: keys => dispatch(action.changeLoadedKeys(keys)) }; } @@ -44,17 +45,20 @@ class OverView extends React.Component { /** * 异步加载 */ - loadData = e => - new Promise(resolve => { + loadData = e => { + const { loadedKeys, treeData } = this.props; + return new Promise(resolve => { const item = e.props.dataRef; const newPath = item.path + "." + item.bookmarkId; httpUtil.get("/bookmark/currentUser/path?path=" + newPath).then(res => { item.children = res; - this.props.updateTreeData([...this.props.treeData]); + this.props.updateTreeData([...treeData]); + loadedKeys.push(item.bookmarkId.toString()); + this.props.changeLoadedKeys(loadedKeys); resolve(); }); }); - + }; /** * 节点选择 * @param {*} key @@ -74,7 +78,7 @@ class OverView extends React.Component { } render() { - const { isEdit, setIsEdit, treeData, addNode, isInit, expandedKeys, checkedKeys } = this.props; + const { isEdit, setIsEdit, treeData, addNode, isInit, expandedKeys, checkedKeys, loadedKeys } = this.props; const { changeExpandedKeys } = this.props; return ( @@ -105,6 +109,7 @@ class OverView extends React.Component { { }; }; +// 修改当前右键点击的节点 export const CHANGE_CURRENT_CLICK_ITEM = "changeCurrentClickItem"; export const changeCurrentClickItem = currentClickItem => { return { @@ -116,3 +119,12 @@ export const changeCurrentClickItem = currentClickItem => { data: { currentClickItem } }; }; + +// 修改已经加载的节点 +export const CHANGE_LOADED_KEYS = "changeLoadedKeys"; +export const changeLoadedKeys = loadedKeys => { + return { + type: CHANGE_LOADED_KEYS, + data: { loadedKeys } + }; +}; diff --git a/front/src/redux/reducer/BookmarkTreeOverview.js b/front/src/redux/reducer/BookmarkTreeOverview.js index 791b577..e6f7cda 100644 --- a/front/src/redux/reducer/BookmarkTreeOverview.js +++ b/front/src/redux/reducer/BookmarkTreeOverview.js @@ -10,6 +10,7 @@ const BookmarkTreeOverviewReducer = (state = info.getInitData(), action) => { case info.CHANGE_CURRENT_CLICK_ITEM: case info.ADD_NODE: case info.EDIT_NODE: + case info.CHANGE_LOADED_KEYS: return { ...state, ...action.data }; default: return state;