Commit 19120af7 by yuananting

fix:课程管理分类拖拽功能优化

parent fd1db696
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-23 18:28:50 * @Date: 2021-02-23 18:28:50
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-04-15 21:53:13 * @LastEditTime: 2021-06-02 14:25:06
* @Description: 助学工具-课程分类 * @Description: 助学工具-课程分类
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -166,9 +166,7 @@ class CourseCategoryManage extends Component { ...@@ -166,9 +166,7 @@ class CourseCategoryManage extends Component {
<Space className="title-opts" size={16}> <Space className="title-opts" size={16}>
<span <span
onClick={() => { onClick={() => {
let nodesCount = 0;
const { originTreeData } = this.state; const { originTreeData } = this.state;
console.log("orororo", originTreeData);
if ( if (
(item.categoryLevel === 0 && originTreeData.length >= 29) || (item.categoryLevel === 0 && originTreeData.length >= 29) ||
(item.categoryLevel > 0 && (item.categoryLevel > 0 &&
...@@ -387,7 +385,7 @@ class CourseCategoryManage extends Component { ...@@ -387,7 +385,7 @@ class CourseCategoryManage extends Component {
let dragNodes = []; let dragNodes = [];
dragNodes.push(dragNode.id); dragNodes.push(dragNode.id);
if (dragNode.parentId != 0) { if (dragNode.parentId !== "0") {
dragNodes = dragNodes.concat( dragNodes = dragNodes.concat(
this.getParentDragNodesLevel(this.state.treeMap[dragNode.parentId]) this.getParentDragNodesLevel(this.state.treeMap[dragNode.parentId])
); );
...@@ -411,7 +409,16 @@ class CourseCategoryManage extends Component { ...@@ -411,7 +409,16 @@ class CourseCategoryManage extends Component {
// 拖拽 // 拖拽
onDrop = (info) => { onDrop = (info) => {
if (this.state.categoryName) { // 带搜索时的分类树不允许拖拽
// 不允许其他节点拖拽到未分类中
// 不允许其他节点拖拽到未分类之前
if (
this.state.categoryName ||
(info.node.categoryName === "未分类" && info.dropPosition === 0) ||
(info.node.categoryName === "未分类" &&
info.dropToGap &&
info.dropPosition === -1)
) {
return; return;
} }
// 未分类不可以拖拽 // 未分类不可以拖拽
...@@ -419,15 +426,7 @@ class CourseCategoryManage extends Component { ...@@ -419,15 +426,7 @@ class CourseCategoryManage extends Component {
info.dragNode.categoryName === "未分类" && info.dragNode.categoryName === "未分类" &&
info.dragNode.categoryLevel === 0 info.dragNode.categoryLevel === 0
) )
return message.info("未分类”为默认分类暂不支持移动"); return message.info("“未分类”为默认分类暂不支持移动");
// 不允许其他节点拖拽到未分类之前
if (
info.node.categoryName === "未分类" &&
info.dropToGap &&
info.dropPosition === -1
)
return;
let targetParentId = info.dropToGap ? info.node.parentId : info.node.id; let targetParentId = info.dropToGap ? info.node.parentId : info.node.id;
let relatedNodes = this.getRelatedNodes(targetParentId); let relatedNodes = this.getRelatedNodes(targetParentId);
...@@ -447,7 +446,6 @@ class CourseCategoryManage extends Component { ...@@ -447,7 +446,6 @@ class CourseCategoryManage extends Component {
this.state.treeMap[targetParentId] this.state.treeMap[targetParentId]
); );
if (nodesArr.length + parentArr.length > 4) { if (nodesArr.length + parentArr.length > 4) {
console.log(nodesArr.length, parentArr.length);
return message.info("最多支持5级分类"); return message.info("最多支持5级分类");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment