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
d4434f8f
Commit
d4434f8f
authored
Dec 10, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 封装树
parent
6039d9c8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
16 deletions
+54
-16
index.js
src/components/ExpendableTree/index.js
+51
-0
checkBox.jsx
src/pages/webConfig/menuconfig/checkBox.jsx
+0
-7
editForm.jsx
src/pages/webConfig/menuconfig/editForm.jsx
+0
-1
webMenu.jsx
src/pages/webConfig/menuconfig/webMenu.jsx
+3
-8
No files found.
src/components/ExpendableTree/index.js
0 → 100644
View file @
d4434f8f
import
{
Tree
}
from
'antd'
;
import
{
uniq
,
remove
}
from
'lodash'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
const
getChildKeys
=
tree
=>
{
let
childKeys
=
tree
.
children
?.
map
(
c
=>
getChildKeys
(
c
)).
flat
(
Infinity
)
||
[];
return
[
tree
.
key
,
...
childKeys
];
};
export
default
props
=>
{
const
{
expandedKeys
,
onExpand
,
onSelect
,
selectedKeys
,
...
rest
}
=
props
;
const
[
epKeys
,
setEpKeys
]
=
useState
([
expandedKeys
]);
const
handleExpand
=
(
keys
,
{
expanded
,
node
})
=>
{
if
(
!
expanded
)
{
let
childKeys
=
getChildKeys
(
node
);
remove
(
keys
,
k
=>
childKeys
.
includes
(
k
));
}
setEpKeys
(
keys
);
};
const
handleSelect
=
(
keys
,
e
)
=>
{
let
result
=
[];
if
(
keys
.
length
>
0
&&
epKeys
.
includes
(
keys
[
0
]))
{
remove
(
epKeys
,
k
=>
keys
.
includes
(
k
));
result
=
[...
epKeys
];
}
else
if
(
keys
[
0
])
{
result
=
[...
epKeys
,
keys
[
0
]];
}
else
{
if
(
epKeys
.
includes
(
e
.
node
.
key
))
{
remove
(
epKeys
,
k
=>
k
===
e
.
node
.
key
);
}
else
{
epKeys
.
push
(
e
.
node
.
key
);
}
result
=
[...
epKeys
];
}
// eslint-disable-next-line no-unused-expressions
onSelect
&&
onSelect
(
keys
,
e
);
setEpKeys
(
result
);
};
return
(
<
Tree
onSelect
=
{
handleSelect
}
onExpand
=
{
handleExpand
}
expandedKeys
=
{
epKeys
}
selectedKeys
=
{
selectedKeys
}
{...
rest
}
/
>
);
};
src/pages/webConfig/menuconfig/checkBox.jsx
View file @
d4434f8f
...
...
@@ -3,9 +3,7 @@ import { Checkbox, Empty } from 'antd';
import
styles
from
'./checkBox.less'
;
const
CheckList
=
props
=>
{
const
{
info
,
valueCallback
,
nodeType
}
=
props
;
console
.
log
(
info
,
'info'
);
const
[
list
,
setList
]
=
useState
([]);
const
[
checkList
,
setCheckList
]
=
useState
([]);
const
[
flag
,
setFlag
]
=
useState
(
false
);
const
a
=
'a'
;
useEffect
(()
=>
{
...
...
@@ -17,20 +15,15 @@ const CheckList = props => {
arr2
.
push
(
item
.
relatedRoleCode
);
}
});
console
.
log
(
arr2
,
'arr2'
);
setCheckList
(
arr2
);
setList
(
arr
);
setFlag
(
true
);
}
return
()
=>
{
setFlag
(
false
);
setCheckList
([]);
};
},
[
info
]);
const
handleSelect
=
(
e
,
val
)
=>
{
console
.
log
(
e
.
target
,
'e'
,
val
);
let
arr
=
[];
list
.
forEach
(
item
=>
{
if
(
item
.
relatedRoleCode
===
val
)
{
...
...
src/pages/webConfig/menuconfig/editForm.jsx
View file @
d4434f8f
...
...
@@ -9,7 +9,6 @@ const EditForm = props => {
const
{
submitCallback
,
nodeType
,
info
,
configFiles
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
otherForm
]
=
Form
.
useForm
();
console
.
log
(
info
);
const
layout
=
{
layout
:
'horizontal'
,
labelCol
:
{
span
:
4
,
offset
:
1
},
...
...
src/pages/webConfig/menuconfig/webMenu.jsx
View file @
d4434f8f
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
notification
,
Tree
,
Tooltip
,
Modal
,
Spin
,
Empty
}
from
'antd'
;
import
{
notification
,
Tooltip
,
Modal
,
Spin
,
Empty
}
from
'antd'
;
import
Tree
from
'@/components/ExpendableTree'
;
import
{
FileAddTwoTone
,
FolderAddTwoTone
,
...
...
@@ -79,13 +80,10 @@ const MiniMenu = props => {
};
// 树的点击事件
const
handleSelect
=
(
prop
,
treeNode
)
=>
{
console
.
log
(
prop
,
treeNode
);
if
(
treeNode
)
{
const
{
node
,
node
:
{
menuType
},
}
=
treeNode
;
console
.
log
(
menuType
);
setCurMenuType
(
menuType
);
switch
(
menuType
)
{
case
'Web4MenuGroup'
:
...
...
@@ -123,7 +121,6 @@ const MiniMenu = props => {
description
:
res
.
message
||
'获取失败'
,
});
}
console
.
log
(
res
,
'resss'
);
})
.
catch
(
err
=>
{
setLoading
(
false
);
...
...
@@ -133,7 +130,6 @@ const MiniMenu = props => {
// 删除的回调
const
deleteMenuTip
=
(
val
,
e
)
=>
{
e
.
stopPropagation
();
console
.
log
(
val
,
'val'
);
setModalTitle
(
val
.
text
);
setNodeObj
(
val
);
setDelVisible
(
true
);
...
...
@@ -167,7 +163,7 @@ const MiniMenu = props => {
})
.
catch
(
err
=>
{
setModalLoading
(
false
);
console
.
log
(
err
);
console
.
error
(
err
);
});
};
// 新增菜单组
...
...
@@ -228,7 +224,6 @@ const MiniMenu = props => {
duration
:
10
,
});
}
console
.
log
(
res
,
'resadd'
);
})
.
catch
(
err
=>
{
setSubmitLoading
(
false
);
...
...
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