Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
0e033d8d
Commit
0e033d8d
authored
Nov 26, 2021
by
邓超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 重构app菜单拖拽逻辑
parent
cf398fb9
Pipeline
#38841
passed with stages
in 22 minutes 19 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
41 deletions
+73
-41
miniMenu.jsx
src/pages/mobileConfig/menuconfig/miniMenu.jsx
+73
-41
No files found.
src/pages/mobileConfig/menuconfig/miniMenu.jsx
View file @
0e033d8d
...
@@ -377,62 +377,94 @@ const MiniMenu = props => {
...
@@ -377,62 +377,94 @@ const MiniMenu = props => {
});
});
setRoleList
(
arr2
);
setRoleList
(
arr2
);
};
};
const
loop
=
(
data
,
key
,
parentID
,
callback
)
=>
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
data
[
i
].
menuID
===
key
)
{
return
callback
(
data
[
i
],
i
,
data
,
parentID
);
}
if
(
data
[
i
].
children
)
{
loop
(
data
[
i
].
children
,
key
,
data
[
i
].
menuID
,
callback
);
}
}
};
// 树的拖动
// 树的拖动
const
handleDrop
=
infos
=>
{
const
handleDrop
=
infos
=>
{
console
.
log
(
infos
,
'newTree'
);
const
dropKey
=
infos
.
node
.
key
;
const
{
pos
}
=
infos
.
node
.
props
;
const
dragKey
=
infos
.
dragNode
.
key
;
const
dragKey
=
infos
.
dragNode
.
props
.
eventKey
;
const
dropPos
=
infos
.
node
.
pos
.
split
(
'-'
);
const
dragPos
=
infos
.
dragNode
.
props
.
pos
.
split
(
'-'
);
// 拖动的节点
const
dropKey
=
infos
.
node
.
props
.
eventKey
;
const
dropPos
=
infos
.
node
.
props
.
pos
.
split
(
'-'
);
// 拖动结束的节点
const
endIndex
=
Number
(
dropPos
[
dropPos
.
length
-
1
]);
const
dropPosition
=
const
dropPosition
=
infos
.
dropPosition
-
Number
(
dropPos
[
dropPos
.
length
-
1
]);
infos
.
dropPosition
-
Number
(
dropPos
[
dropPos
.
length
-
1
]);
// let obj = findNum(newTreeList, dragKey, getArrList);
const
data
=
[...
treeData
];
let
obj
;
// 找到拖拽的元素
findNum
(
newTreeList
,
dragKey
,
(
arr
,
id
,
parentId
,
index
)
=>
{
let
dragObj
;
obj
=
{
arr
,
id
,
parentId
,
index
};
let
dropObj
;
return
{
arr
,
id
,
parentId
,
index
};
let
id
;
let
dragList
;
loop
(
data
,
dropKey
,
-
1
,
item
=>
{
dropObj
=
item
;
});
});
console
.
log
(
obj
,
'obj'
);
loop
(
data
,
dragKey
,
-
1
,
(
item
,
index
,
arr
)
=>
{
let
arrList
=
[];
if
(
infos
.
dropToGap
)
{
if
(
arr
.
splice
(
index
,
1
);
dragPos
.
length
!==
dropPos
.
length
||
dragObj
=
item
;
dragPos
[
dragPos
.
length
-
2
]
!==
dropPos
[
dropPos
.
length
-
2
]
}
else
if
(
dropObj
.
menuType
!==
'MiniAppMenuThree'
&&
dropObj
.
menuType
!==
'MiniAppMenu'
)
{
)
{
notification
.
warning
({
arr
.
splice
(
index
,
1
);
message
:
'提示'
,
dragObj
=
item
;
duration
:
3
,
description
:
'操作失败'
,
});
return
null
;
}
}
let
idIndex
;
});
obj
.
arr
.
map
((
item
,
index
)
=>
{
if
(
!
infos
.
dropToGap
)
{
if
(
item
.
menuID
===
obj
.
id
)
{
// Drop on the content
idIndex
=
index
;
loop
(
data
,
dropKey
,
-
1
,
item
=>
{
return
;
item
.
children
=
item
.
children
||
[];
if
(
item
.
menuType
!==
'MiniAppMenuThree'
&&
dropObj
.
menuType
!==
'MiniAppMenu'
)
{
// where to insert 示例添加到头部,可以是随意位置
item
.
children
.
unshift
(
dragObj
);
id
=
item
.
menuID
;
dragList
=
item
.
children
.
map
(
val
=>
val
.
menuID
);
}
}
arrList
.
push
(
item
.
menuID
);
});
});
if
(
idIndex
>
endIndex
)
{
}
else
if
(
(
infos
.
node
.
props
.
children
||
[]).
length
>
0
&&
// Has children
infos
.
node
.
props
.
expanded
&&
// Is expanded
dropPosition
===
1
// On the bottom gap
)
{
loop
(
data
,
dropKey
,
-
1
,
item
=>
{
item
.
children
=
item
.
children
||
[];
// where to insert 示例添加到头部,可以是随意位置
item
.
children
.
unshift
(
dragObj
);
id
=
item
.
menuID
;
dragList
=
item
.
children
.
map
(
val
=>
val
.
menuID
);
});
}
else
{
let
ar
;
let
i
;
loop
(
data
,
dropKey
,
-
1
,
(
item
,
index
,
arr
,
parentID
)
=>
{
ar
=
arr
;
i
=
index
;
id
=
parentID
;
});
if
(
dropPosition
===
-
1
)
{
if
(
dropPosition
===
-
1
)
{
ar
rList
.
splice
(
endIndex
,
0
,
obj
.
id
);
ar
.
splice
(
i
,
0
,
dragObj
);
}
else
if
(
dropPosition
===
1
)
{
}
else
{
ar
rList
.
splice
(
endIndex
+
1
,
0
,
obj
.
id
);
ar
.
splice
(
i
+
1
,
0
,
dragObj
);
}
}
}
else
if
(
idIndex
<
endIndex
)
{
dragList
=
ar
.
map
(
val
=>
val
.
menuID
);
if
(
dropPosition
===
-
1
)
{
arrList
.
splice
(
endIndex
-
1
,
0
,
obj
.
id
);
}
else
if
(
dropPosition
===
1
)
{
arrList
.
splice
(
endIndex
,
0
,
obj
.
id
);
}
}
// 如果拖拽到菜单下不做任何处理
if
(
!
dragList
)
{
return
;
}
}
dragMenu
({
dragMenu
({
menuID
:
obj
.
id
,
menuID
:
dragKey
,
newParentID
:
obj
.
parentI
d
.
toString
()
||
'-1'
,
newParentID
:
i
d
.
toString
()
||
'-1'
,
menuList
:
String
(
arr
List
)
||
''
,
menuList
:
String
(
drag
List
)
||
''
,
_version
:
9999
,
_version
:
9999
,
_dc
:
Date
.
now
(),
_dc
:
Date
.
now
(),
}).
then
(
res
=>
{
}).
then
(
res
=>
{
...
...
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