feat:【antd/ele】【组件】table-action 封装的代码统一(剩余部分)

This commit is contained in:
YunaiV
2025-11-20 15:24:09 +08:00
parent 5147e75331
commit 76c3632c52
3 changed files with 11 additions and 5 deletions

View File

@@ -137,11 +137,11 @@ function handleButtonClick(action: ActionItem) {
}
}
/** 监听props变化强制重新计算 */
/** 监听 props 变化,强制重新计算 */
watch(
() => [props.actions, props.dropDownActions],
() => {
// 这里不需要额外处理computed会自动重新计算
// 这里不需要额外处理computed 会自动重新计算
},
{ deep: true },
);

View File

@@ -3,13 +3,14 @@ export const ACTION_ICON = {
UPLOAD: 'lucide:upload',
ADD: 'lucide:plus',
EDIT: 'lucide:edit',
DELETE: 'lucide:trash',
DELETE: 'lucide:trash-2',
REFRESH: 'lucide:refresh-cw',
SEARCH: 'lucide:search',
FILTER: 'lucide:filter',
MORE: 'lucide:ellipsis-vertical',
VIEW: 'lucide:eye',
COPY: 'lucide:copy',
CLOSE: 'lucide:x',
BOOK: 'lucide:book',
AUDIT: 'lucide:file-check',
};

View File

@@ -1,5 +1,6 @@
<!-- add by 星语参考 vben2 的方式增加 TableAction 组件 -->
<script setup lang="ts">
// TODO @xingyu要不要和 apps/web-antd/src/components/table-action/table-action.vue 代码风格,进一步风格对齐?现在每个方法,会有一些差异
import type { PropType } from 'vue';
import type { ActionItem, PopConfirm } from './typing';
@@ -42,20 +43,24 @@ const props = defineProps({
const { hasAccessByCodes } = useAccess();
/** 检查是否显示 */
function isIfShow(action: ActionItem): boolean {
const ifShow = action.ifShow;
let isIfShow = true;
if (isBoolean(ifShow)) {
isIfShow = ifShow;
}
if (isFunction(ifShow)) {
isIfShow = ifShow(action);
}
if (isIfShow) {
isIfShow =
hasAccessByCodes(action.auth || []) || (action.auth || []).length === 0;
}
return isIfShow;
}
/** 处理按钮 actions */
const getActions = computed(() => {
return (toRaw(props.actions) || [])
.filter((action) => {