fix: action绑定
parent
cf27fd8ce9
commit
cc3bf7e8a3
|
@ -4,7 +4,7 @@ import type { PropType } from 'vue';
|
||||||
|
|
||||||
import type { ActionItem, PopConfirm } from './typing';
|
import type { ActionItem, PopConfirm } from './typing';
|
||||||
|
|
||||||
import { computed, unref } from 'vue';
|
import { computed, unref, watch } from 'vue';
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
import { useAccess } from '@vben/access';
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
@ -60,21 +60,20 @@ function isIfShow(action: ActionItem): boolean {
|
||||||
|
|
||||||
/** 处理按钮 actions */
|
/** 处理按钮 actions */
|
||||||
const getActions = computed(() => {
|
const getActions = computed(() => {
|
||||||
return (props.actions || []).filter((action: ActionItem) => isIfShow(action));
|
const actions = props.actions || [];
|
||||||
|
return actions.filter((action: ActionItem) => isIfShow(action));
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 处理下拉菜单 actions */
|
/** 处理下拉菜单 actions */
|
||||||
const getDropdownList = computed(() => {
|
const getDropdownList = computed(() => {
|
||||||
return (props.dropDownActions || []).filter((action: ActionItem) =>
|
const dropDownActions = props.dropDownActions || [];
|
||||||
isIfShow(action),
|
return dropDownActions.filter((action: ActionItem) => isIfShow(action));
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Space 组件的 size */
|
/** Space 组件的 size */
|
||||||
const spaceSize = computed(() => {
|
const spaceSize = computed(() => {
|
||||||
return unref(getActions)?.some((item: ActionItem) => item.type === 'link')
|
const actions = unref(getActions);
|
||||||
? 0
|
return actions?.some((item: ActionItem) => item.type === 'link') ? 0 : 8;
|
||||||
: 8;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 获取 PopConfirm 属性 */
|
/** 获取 PopConfirm 属性 */
|
||||||
|
@ -137,6 +136,15 @@ function handleButtonClick(action: ActionItem) {
|
||||||
action.onClick();
|
action.onClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听props变化,强制重新计算
|
||||||
|
watch(
|
||||||
|
() => [props.actions, props.dropDownActions],
|
||||||
|
() => {
|
||||||
|
// 这里不需要额外处理,computed会自动重新计算
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue