Commit 60f24127 by yuananting

fix:bug修复

parent 0504f8c0
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-23 18:28:50
* @LastEditors: yuananting
* @LastEditTime: 2021-03-22 09:42:28
* @LastEditTime: 2021-03-22 19:49:08
* @Description: 助学工具-题库-主页面分类管理
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -39,12 +39,12 @@ class QuestionCategoryManage extends Component {
}
componentDidMount() {
this.queryCategoryTree();
this.queryCategoryTree("search");
}
// 查询分类树
queryCategoryTree = (categoryName) => {
this.setState({categoryName})
queryCategoryTree = (operateType, categoryName) => {
this.setState({ categoryName });
let query = {
source: 0,
categoryName,
......@@ -79,7 +79,9 @@ class QuestionCategoryManage extends Component {
Object.keys(this.state.treeMap).forEach((item) => {
nodeId.push(item);
});
this.setState({ expandedKeys: nodeId });
if (operateType === "search") {
this.setState({ expandedKeys: nodeId });
}
}
} else {
this.setState({ autoExpandParent: false });
......@@ -92,7 +94,9 @@ class QuestionCategoryManage extends Component {
this.setState({
treeData: this.renderTreeNodes(result, categoryName),
});
this.setState({ expandedKeys: [] });
if (operateType === "search") {
this.setState({ expandedKeys: [] });
}
}
});
};
......@@ -119,7 +123,7 @@ class QuestionCategoryManage extends Component {
QuestionBankService.delCategory(params).then((res) => {
if (res.success) {
message.success("删除分类成功");
this.queryCategoryTree();
this.queryCategoryTree("change");
}
});
},
......@@ -157,7 +161,7 @@ class QuestionCategoryManage extends Component {
title={title}
label={label}
close={() => {
this.queryCategoryTree();
this.queryCategoryTree("change");
this.setState({
NewEditQuestionBankCategory: null,
});
......@@ -202,9 +206,34 @@ class QuestionCategoryManage extends Component {
: [];
};
getDragNodesLevel = (dragNodesKeys) => {
let dragNodes = [];
dragNodesKeys.forEach((item) => {
dragNodes.push(this.state.treeMap[item].categoryLevel);
});
return dragNodes;
// this.drags.push(dragNodes.categoryLevel);
// if (dragNodes.sonCategoryList) {
// dragNodes.sonCategoryList.forEach((item) => {
// console.log("item:", item.sonCategoryList);
// if (item.sonCategoryList) {
// this.getDragNodesLevel(item.sonCategoryList);
// // drags.push(...this.getDragNodesLevel(item.sonCategoryList));
// } else {
// this.drags.push(item.categoryLevel);
// }
// });
// }
// console.log(this.drags);
// return this.drags;
};
onDrop = (info) => {
console.log("info", info);
if (this.state.categoryName) {
return
return;
}
// 未分类不可以拖拽
if (
......@@ -221,12 +250,14 @@ class QuestionCategoryManage extends Component {
return;
let targetParentId = info.dropToGap ? info.node.parentId : info.node.id;
if (this.state.treeMap[targetParentId].categoryLevel === 4) {
return message.info("最多支持5级分类")
return message.info("最多支持5级分类");
} else {
// console.log(this.getDragNodesLevel(info.dragNodesKeys));
}
let relatedNodes = this.getRelatedNodes(targetParentId);
if (relatedNodes && relatedNodes.length === 30) {
return message.info("最多只能添加30个子分类")
return message.info("最多只能添加30个子分类");
}
const dropKey = info.node.key;
const dragKey = info.dragNode.key;
......@@ -325,7 +356,7 @@ class QuestionCategoryManage extends Component {
userId: User.getStoreUserId(),
};
QuestionBankService.editCategoryTree(params).then((res) => {
this.queryCategoryTree();
this.queryCategoryTree("change");
});
};
......@@ -468,17 +499,17 @@ class QuestionCategoryManage extends Component {
let map = {};
let topItem = []
let topItem = [];
data.forEach((item) => {
topItem.push(item);
});
this.setState({
treeMap: Object.assign(this.getTreeMap(data, map), {
"0": {
sonCategoryList: topItem
0: {
sonCategoryList: topItem,
},
})
}),
});
return newTreeData;
};
......@@ -508,22 +539,25 @@ class QuestionCategoryManage extends Component {
} = this.state;
return (
<div className="page question-category-manage">
{getParameterByName('from') === "aid" ? <Breadcrumbs
navList="课程分类"
goBack={() =>
window.RCHistory.push({
pathname: "/question-bank-index",
})
}
/> :
<div className="content-header">课程分类</div>}
{getParameterByName("from") === "aid" ? (
<Breadcrumbs
navList="课程分类"
goBack={() =>
window.RCHistory.push({
pathname: "/question-bank-index",
})
}
/>
) : (
<div className="content-header">课程分类</div>
)}
<div className="box">
<div className="search-condition">
<span className="search-label">搜索名称:</span>
<Search
placeholder="请输入名称"
style={{ width: "calc(100% - 84px)" }}
onSearch={(value) => this.queryCategoryTree(value)}
onSearch={(value) => this.queryCategoryTree("search", value)}
/>
</div>
<Button
......
......@@ -297,7 +297,6 @@ class QuestionEditor extends Component {
limitLength = 1000,
markKey,
} = this.props;
console.log("visiblePlacehold", visiblePlacehold)
return (
<div
className={`question-edtior_box question-edtior_box__${markKey}`}
......
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