Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
najiu-frontend
najiu-admin-template
Commits
8b62fa0c
Commit
8b62fa0c
authored
Mar 02, 2021
by
Vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(tree): actionItem added show attribute close #314
parent
b6bb8163
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
3 deletions
+14
-3
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
index.vue
src/components/Tree/src/index.vue
+10
-2
types.ts
src/components/Tree/src/types.ts
+2
-1
EditTree.vue
src/views/demo/tree/EditTree.vue
+1
-0
No files found.
CHANGELOG.zh_CN.md
View file @
8b62fa0c
...
...
@@ -12,6 +12,7 @@
-
新增部门管理示例界面
-
新增 WebSocket 示例和服务脚本
-
BasicTree 组件新增
`renderIcon`
属性用于控制层级图标显示
-
BasicTree->actionItem 新增 show 属性,用于动态控制按钮显示
### ⚡ Performance Improvements
...
...
src/components/Tree/src/index.vue
View file @
8b62fa0c
...
...
@@ -16,7 +16,7 @@
// import { DownOutlined } from '@ant-design/icons-vue';
import
{
omit
,
get
}
from
'
lodash-es
'
;
import
{
isFunction
}
from
'
/@/utils/is
'
;
import
{
is
Boolean
,
is
Function
}
from
'
/@/utils/is
'
;
import
{
extendSlots
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
useTree
}
from
'
./useTree
'
;
...
...
@@ -116,6 +116,14 @@
const
{
actionList
}
=
props
;
if
(
!
actionList
||
actionList
.
length
===
0
)
return
;
return
actionList
.
map
((
item
,
index
)
=>
{
if
(
isFunction
(
item
.
show
))
{
return
item
.
show
?.(
node
);
}
if
(
isBoolean
(
item
.
show
))
{
return
item
.
show
;
}
return
(
<
span
key
=
{
index
}
class
=
{
`
${
prefixCls
}
__action`
}
>
{
item
.
render
(
node
)}
...
...
@@ -147,7 +155,7 @@
>
{
get
(
item
,
titleField
)}
<
/span
>
<
span
class
=
{
`
${
prefixCls
}
__actions`
}
>
{
renderAction
(
item
)}
<
/span
>
<
span
class
=
{
`
${
prefixCls
}
__actions`
}
>
{
renderAction
(
{
...
item
,
level
}
)}
<
/span
>
<
/span
>
),
default
:
()
=>
...
...
src/components/Tree/src/types.ts
View file @
8b62fa0c
import
type
{
TreeDataItem
}
from
'
ant-design-vue/es/tree/Tree
'
;
export
interface
ActionItem
{
render
:
(
record
:
any
)
=>
any
;
render
:
(
record
:
Recordable
)
=>
any
;
show
?:
boolean
|
((
record
:
Recordable
)
=>
boolean
);
}
export
interface
TreeItem
extends
TreeDataItem
{
...
...
src/views/demo/tree/EditTree.vue
View file @
8b62fa0c
...
...
@@ -46,6 +46,7 @@
}
const
actionList
:
ActionItem
[]
=
[
{
// show:()=>boolean;
render
:
(
node
)
=>
{
return
h
(
PlusOutlined
,
{
class
:
'
ml-2
'
,
...
...
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