@@ -4,6 +4,7 @@ import Icon from '/@/components/Icon/index';
4
4
import { DownOutlined } from '@ant-design/icons-vue' ;
5
5
import { ActionItem } from '/@/components/Table' ;
6
6
import { Button } from '/@/components/Button' ;
7
+ import { snowUuid } from '/@/utils/uuid' ;
7
8
const prefixCls = 'basic-table-action' ;
8
9
export default defineComponent ( {
9
10
name : 'TableAction' ,
@@ -23,7 +24,7 @@ export default defineComponent({
23
24
} ,
24
25
} ,
25
26
setup ( props ) {
26
- function renderButton ( action : ActionItem , index : number ) {
27
+ function renderButton ( action : ActionItem ) {
27
28
const { disabled = false , label, icon, color = '' , type = 'link' , ...actionProps } = action ;
28
29
const button = (
29
30
< Button
@@ -32,7 +33,7 @@ export default defineComponent({
32
33
disabled = { disabled }
33
34
color = { color }
34
35
{ ...actionProps }
35
- key = { `${ index } - ${ label } ` }
36
+ key = { `${ snowUuid ( ) } ` }
36
37
>
37
38
{ ( ) => (
38
39
< >
@@ -45,10 +46,10 @@ export default defineComponent({
45
46
return button ;
46
47
}
47
48
48
- function renderPopConfirm ( action : ActionItem , index : number ) {
49
+ function renderPopConfirm ( action : ActionItem ) {
49
50
const { popConfirm = null } = action ;
50
51
if ( ! popConfirm ) {
51
- return renderButton ( action , index ) ;
52
+ return renderButton ( action ) ;
52
53
}
53
54
const {
54
55
title,
@@ -60,15 +61,15 @@ export default defineComponent({
60
61
} = popConfirm ;
61
62
return (
62
63
< Popconfirm
63
- key = { `p- ${ index } - ${ title } ` }
64
+ key = { `${ snowUuid ( ) } ` }
64
65
title = { title }
65
66
onConfirm = { confirm }
66
67
onCancel = { cancel }
67
68
okText = { okText }
68
69
cancelText = { cancelText }
69
70
icon = { icon }
70
71
>
71
- { ( ) => renderButton ( action , index ) }
72
+ { ( ) => renderButton ( action ) }
72
73
</ Popconfirm >
73
74
) ;
74
75
}
@@ -92,8 +93,8 @@ export default defineComponent({
92
93
return (
93
94
< div class = { prefixCls } >
94
95
{ actions &&
95
- actions . map ( ( action , index ) => {
96
- return renderPopConfirm ( action , index ) ;
96
+ actions . map ( ( action ) => {
97
+ return renderPopConfirm ( action ) ;
97
98
} ) }
98
99
{ dropDownActions && dropDownActions . length && (
99
100
< Dropdown overlayClassName = "basic-tale-action-dropdown" >
@@ -104,13 +105,13 @@ export default defineComponent({
104
105
< Menu >
105
106
{ {
106
107
default : ( ) => {
107
- return dropDownActions . map ( ( action , index ) => {
108
+ return dropDownActions . map ( ( action ) => {
108
109
const { disabled = false } = action ;
109
110
action . ghost = true ;
110
111
return (
111
- < Menu . Item key = { `${ index } ` } disabled = { disabled } >
112
+ < Menu . Item key = { `${ snowUuid ( ) } ` } disabled = { disabled } >
112
113
{ ( ) => {
113
- return renderPopConfirm ( action , index ) ;
114
+ return renderPopConfirm ( action ) ;
114
115
} }
115
116
</ Menu . Item >
116
117
) ;
0 commit comments