|
104 | 104 | <template> |
105 | 105 | <div class="p-4"> |
106 | 106 | <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', // 根据权限控制是否显示: 无权限,不显示 |
128 | 115 | }, |
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', // 根据权限控制是否显示: 有权限,会显示 |
131 | 121 | }, |
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 | + }, |
138 | 133 | }, |
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 | + }, |
141 | 143 | }, |
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 | + }, |
148 | 154 | }, |
149 | | - auth: 'super', // 同时根据权限和业务控制是否显示 |
150 | | - ifShow: () => { |
151 | | - return true; // 根据业务控制是否显示 |
152 | | - }, |
153 | | - }, |
154 | | - ]" |
155 | | - /> |
| 155 | + ]" |
| 156 | + /> |
| 157 | + </template> |
156 | 158 | </template> |
157 | 159 | </BasicTable> |
158 | 160 | </div> |
|
189 | 191 | width: 250, |
190 | 192 | title: 'Action', |
191 | 193 | dataIndex: 'action', |
192 | | - slots: { customRender: 'action' }, |
193 | 194 | }, |
194 | 195 | }); |
195 | 196 | function handleEdit(record: Recordable) { |
|
0 commit comments