Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
56b67270
Commit
56b67270
authored
Jun 15, 2021
by
yuananting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:拖拽时父级节点取值区分
parent
495240cf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
src/modules/teach-tool/components/CourseCategoryManage.jsx
+15
-7
No files found.
src/modules/teach-tool/components/CourseCategoryManage.jsx
View file @
56b67270
...
...
@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-23 18:28:50
* @LastEditors: fusanqiasng
* @LastEditTime: 2021-06-15 1
4:10:53
* @LastEditTime: 2021-06-15 1
5:31:40
* @Description: 助学工具-课程分类
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -379,13 +379,11 @@ class CourseCategoryManage extends Component {
let
targetParentId
=
info
.
dropToGap
?
info
.
node
.
parentId
:
info
.
node
.
id
;
let
relatedNodes
=
this
.
getRelatedNodes
(
targetParentId
);
if
(
!
((
info
.
dropToGap
&&
info
.
node
.
parentId
===
info
.
dragNode
.
parentId
)
||
(
!
info
.
dropToGap
&&
info
.
node
.
id
===
info
.
dragNode
.
parentId
)))
{
console
.
log
(
'this.state.treeMap[targetParentId].categoryLevel'
,
this
.
state
.
treeMap
[
targetParentId
].
categoryLevel
);
if
(
this
.
state
.
treeMap
[
targetParentId
].
categoryLevel
>=
4
)
{
return
message
.
info
(
'最多支持5级分类'
);
}
else
{
let
nodesArr
=
this
.
getDragNodesLevel
(
this
.
state
.
treeMap
[
info
.
dragNode
.
id
]);
let
parentArr
=
this
.
getParentDragNodesLevel
(
this
.
state
.
treeMap
[
targetParentId
]);
console
.
log
(
nodesArr
.
length
,
parentArr
.
length
);
if
(
nodesArr
.
length
+
parentArr
.
length
>
4
)
{
return
message
.
info
(
'最多支持5级分类'
);
}
...
...
@@ -466,7 +464,6 @@ class CourseCategoryManage extends Component {
}
else
{
ar
.
splice
(
i
+
1
,
0
,
dragObj
);
}
console
.
log
(
'ar:'
,
ar
);
}
data
.
shift
();
let
newTreeData
=
this
.
renderTreeNodes
(
this
.
handleLoop
(
data
,
0
));
...
...
@@ -486,9 +483,8 @@ class CourseCategoryManage extends Component {
userId
:
User
.
getStoreUserId
(),
};
let
newTreeMap
=
this
.
getTreeMap
(
newTreeData
,
{});
let
movedCategory
=
_
.
filter
(
newTreeMap
,
(
item
)
=>
item
.
id
===
info
.
dragNode
.
id
)[
0
];
let
parentCategory
=
info
.
dropToGap
?
firstParentNode
:
_
.
filter
(
newTreeMap
,
(
item
)
=>
item
.
id
===
info
.
node
.
id
)[
0
];
let
movedCategory
=
this
.
movedNodeFind
(
newTreeData
,
info
.
dragNode
.
id
);
let
parentCategory
=
movedCategory
.
parentId
===
'0'
?
firstParentNode
:
this
.
movedNodeFind
(
newTreeData
,
targetParentId
);
let
params
=
{
movedCategory
,
parentCategory
,
...
...
@@ -502,6 +498,18 @@ class CourseCategoryManage extends Component {
});
};
// 获取移动节点信息
movedNodeFind
(
categoryList
,
movedId
)
{
for
(
const
item
of
categoryList
)
{
if
(
item
.
id
===
movedId
)
return
item
;
if
(
item
.
sonCategoryList
&&
item
.
sonCategoryList
.
length
>
0
)
{
const
node
=
this
.
movedNodeFind
(
item
.
sonCategoryList
,
movedId
);
if
(
node
)
return
node
;
}
}
return
null
;
}
handleLoop
=
(
data
,
level
)
=>
{
data
.
map
((
item
,
index
)
=>
{
item
.
sort
=
index
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment