mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-04 19:26:41 +08:00
85 lines
1.5 KiB
JavaScript
85 lines
1.5 KiB
JavaScript
// 处理table操作按钮
|
|
const tableAction = (h, array) => {
|
|
let btnArray = [];
|
|
let btnMore = [];
|
|
array.map((item, index) => {
|
|
if (index < 2) {
|
|
let btn = h(
|
|
'a',
|
|
{
|
|
props: {
|
|
type: !index ? 'primary' : 'info',
|
|
size: 'small',
|
|
to: item.to ? item.to : '',
|
|
target: item.target ? item.target : '_self',
|
|
ghost: true
|
|
},
|
|
style: {
|
|
marginLeft: '5px'
|
|
},
|
|
directives: item.directives,
|
|
on: {
|
|
click: item.action
|
|
}
|
|
},
|
|
item.title
|
|
);
|
|
btnArray.push(btn);
|
|
} else {
|
|
btnMore.push(
|
|
h(
|
|
'DropdownItem',
|
|
{
|
|
nativeOn: {
|
|
click: item.action
|
|
}
|
|
},
|
|
item.title
|
|
)
|
|
);
|
|
}
|
|
});
|
|
let dropdown = h(
|
|
'Dropdown',
|
|
{
|
|
props: {
|
|
transfer: true
|
|
}
|
|
},
|
|
[
|
|
h(
|
|
'a',
|
|
{
|
|
props: {
|
|
type: 'default',
|
|
size: 'small'
|
|
},
|
|
style: {
|
|
marginLeft: '5px'
|
|
}
|
|
},
|
|
[
|
|
h('span', '更多'),
|
|
h('Icon', {
|
|
props: {
|
|
type: 'ios-arrow-down'
|
|
}
|
|
})
|
|
]
|
|
),
|
|
h(
|
|
'DropdownMenu',
|
|
{
|
|
slot: 'list'
|
|
},
|
|
btnMore
|
|
)
|
|
]
|
|
);
|
|
if (array.length > 2) {
|
|
btnArray.push(dropdown);
|
|
}
|
|
return btnArray;
|
|
};
|
|
export default tableAction;
|