perf: table actions
This commit is contained in:
@@ -43,28 +43,27 @@ const { hasAccessByCodes } = useAccess();
|
|||||||
|
|
||||||
function isIfShow(action: ActionItem): boolean {
|
function isIfShow(action: ActionItem): boolean {
|
||||||
const ifShow = action.ifShow;
|
const ifShow = action.ifShow;
|
||||||
|
|
||||||
let isIfShow = true;
|
let isIfShow = true;
|
||||||
|
|
||||||
if (isBoolean(ifShow)) {
|
if (isBoolean(ifShow)) {
|
||||||
isIfShow = ifShow;
|
isIfShow = ifShow;
|
||||||
}
|
}
|
||||||
if (isFunction(ifShow)) {
|
if (isFunction(ifShow)) {
|
||||||
isIfShow = ifShow(action);
|
isIfShow = ifShow(action);
|
||||||
}
|
}
|
||||||
|
if (isIfShow) {
|
||||||
|
isIfShow =
|
||||||
|
hasAccessByCodes(action.auth || []) || (action.auth || []).length === 0;
|
||||||
|
}
|
||||||
return isIfShow;
|
return isIfShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getActions = computed(() => {
|
const getActions = computed(() => {
|
||||||
return (toRaw(props.actions) || [])
|
const actions = toRaw(props.actions) || [];
|
||||||
.filter((action) => {
|
return actions
|
||||||
return (
|
.filter((action: ActionItem) => {
|
||||||
(hasAccessByCodes(action.auth || []) ||
|
return isIfShow(action);
|
||||||
(action.auth || []).length === 0) &&
|
|
||||||
isIfShow(action)
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.map((action) => {
|
.map((action: ActionItem) => {
|
||||||
const { popConfirm } = action;
|
const { popConfirm } = action;
|
||||||
return {
|
return {
|
||||||
type: action.type || 'link',
|
type: action.type || 'link',
|
||||||
@@ -78,24 +77,21 @@ const getActions = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getDropdownList = computed((): any[] => {
|
const getDropdownList = computed((): any[] => {
|
||||||
return (toRaw(props.dropDownActions) || [])
|
const dropDownActions = toRaw(props.dropDownActions) || [];
|
||||||
.filter((action) => {
|
return dropDownActions
|
||||||
return (
|
.filter((action: ActionItem) => {
|
||||||
(hasAccessByCodes(action.auth || []) ||
|
return isIfShow(action);
|
||||||
(action.auth || []).length === 0) &&
|
|
||||||
isIfShow(action)
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.map((action, index) => {
|
.map((action: ActionItem, index: number) => {
|
||||||
const { label, popConfirm } = action;
|
const { label, popConfirm } = action;
|
||||||
|
delete action.icon;
|
||||||
return {
|
return {
|
||||||
...action,
|
...action,
|
||||||
...popConfirm,
|
...popConfirm,
|
||||||
onConfirm: popConfirm?.confirm,
|
onConfirm: popConfirm?.confirm,
|
||||||
onCancel: popConfirm?.cancel,
|
onCancel: popConfirm?.cancel,
|
||||||
text: label,
|
text: label,
|
||||||
divider:
|
divider: index < dropDownActions.length - 1 ? props.divider : false,
|
||||||
index < props.dropDownActions.length - 1 ? props.divider : false,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user