Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 943f4b7

Browse files
authored
Update table.md (#155)
change add action column demo, the slots option was deprecated.
1 parent 4b7c4a2 commit 943f4b7

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

components/table.md

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -104,55 +104,57 @@
104104
<template>
105105
<div class="p-4">
106106
<BasicTable @register="registerTable">
107-
<template #action="{ record }">
108-
<TableAction
109-
:actions="[
110-
{
111-
label: '编辑',
112-
onClick: handleEdit.bind(null, record),
113-
auth: 'other', // 根据权限控制是否显示: 无权限,不显示
114-
},
115-
{
116-
label: '删除',
117-
icon: 'ic:outline-delete-outline',
118-
onClick: handleDelete.bind(null, record),
119-
auth: 'super', // 根据权限控制是否显示: 有权限,会显示
120-
},
121-
]"
122-
:dropDownActions="[
123-
{
124-
label: '启用',
125-
popConfirm: {
126-
title: '是否启用?',
127-
confirm: handleOpen.bind(null, record),
107+
<template #bodyCell="{ column, record }">
108+
<template v-if="column.key === 'action'">
109+
<TableAction
110+
:actions="[
111+
{
112+
label: '编辑',
113+
onClick: handleEdit.bind(null, record),
114+
auth: 'other', // 根据权限控制是否显示: 无权限,不显示
128115
},
129-
ifShow: (_action) => {
130-
return record.status !== 'enable'; // 根据业务控制是否显示: 非enable状态的不显示启用按钮
116+
{
117+
label: '删除',
118+
icon: 'ic:outline-delete-outline',
119+
onClick: handleDelete.bind(null, record),
120+
auth: 'super', // 根据权限控制是否显示: 有权限,会显示
131121
},
132-
},
133-
{
134-
label: '禁用',
135-
popConfirm: {
136-
title: '是否禁用?',
137-
confirm: handleOpen.bind(null, record),
122+
]"
123+
:dropDownActions="[
124+
{
125+
label: '启用',
126+
popConfirm: {
127+
title: '是否启用?',
128+
confirm: handleOpen.bind(null, record),
129+
},
130+
ifShow: (_action) => {
131+
return record.status !== 'enable'; // 根据业务控制是否显示: 非enable状态的不显示启用按钮
132+
},
138133
},
139-
ifShow: () => {
140-
return record.status === 'enable'; // 根据业务控制是否显示: enable状态的显示禁用按钮
134+
{
135+
label: '禁用',
136+
popConfirm: {
137+
title: '是否禁用?',
138+
confirm: handleOpen.bind(null, record),
139+
},
140+
ifShow: () => {
141+
return record.status === 'enable'; // 根据业务控制是否显示: enable状态的显示禁用按钮
142+
},
141143
},
142-
},
143-
{
144-
label: '同时控制',
145-
popConfirm: {
146-
title: '是否动态显示?',
147-
confirm: handleOpen.bind(null, record),
144+
{
145+
label: '同时控制',
146+
popConfirm: {
147+
title: '是否动态显示?',
148+
confirm: handleOpen.bind(null, record),
149+
},
150+
auth: 'super', // 同时根据权限和业务控制是否显示
151+
ifShow: () => {
152+
return true; // 根据业务控制是否显示
153+
},
148154
},
149-
auth: 'super', // 同时根据权限和业务控制是否显示
150-
ifShow: () => {
151-
return true; // 根据业务控制是否显示
152-
},
153-
},
154-
]"
155-
/>
155+
]"
156+
/>
157+
</template>
156158
</template>
157159
</BasicTable>
158160
</div>
@@ -189,7 +191,6 @@
189191
width: 250,
190192
title: 'Action',
191193
dataIndex: 'action',
192-
slots: { customRender: 'action' },
193194
},
194195
});
195196
function handleEdit(record: Recordable) {

0 commit comments

Comments
 (0)