Commit 60f24127 by yuananting

fix:bug修复

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