update:表单按钮优化

This commit is contained in:
2025-11-26 13:44:11 +08:00
parent f6e004215b
commit 0d34e71b8d
2 changed files with 30 additions and 8 deletions

View File

@@ -109,7 +109,7 @@
<template #default="{ row }">
<div v-if="!$slots.tableActions" class="actions">
<template v-for="(action, aIndex) in actionList" :key="aIndex">
<el-link v-if="!(action.hide && action.hide(row)) && (aIndex < visibleIndex(row))" class="action-item" :type="action.type" @click="actionClickFun(row, action)">
<el-link v-if="!(action.hide && action.hide(row)) && (findVisibleIndex(row, action) <= 2)" class="action-item" :type="action.type" @click="actionClickFun(row, action)">
{{ action.title }}
</el-link>
</template>
@@ -120,7 +120,7 @@
<template #dropdown>
<el-dropdown-menu>
<template v-for="(action, aIndex) in actionList" :key="aIndex">
<el-dropdown-item v-if="!(action.hide && action.hide(row)) && (aIndex >= visibleIndex(row))" @click="actionClickFun(row, action)">
<el-dropdown-item v-if="!(action.hide && action.hide(row)) && (findVisibleIndex(row, action) > 2)" @click="actionClickFun(row, action)">
<el-link :type="action.type">{{ action.title }}</el-link>
</el-dropdown-item>
</template>
@@ -228,9 +228,20 @@ const vxeTableRef = ref<any>();
const tableSearchRef = ref<any>();
const searchList = ref<any>(props.searchItems);
const actionAutoWidth = ref(95);
const visibleIndex = (row: any) => { // 按钮index扣除隐藏的按钮大于2个则放入下拉中
return 2 + props.actionList.length - props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
const findVisibleIndex = (row: any, action: any) => {
let index = 0;
props.actionList.some((item: any) => {
if (!(item.hide && item.hide(row))) {
index++;
}
if (action.title === item.title) {
return true;
}
});
return index;
};
const visibleNum = (row: any) => { // 展示按钮数量
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
};

View File

@@ -146,7 +146,7 @@
<template #default="{ row }">
<div v-if="!$slots.tableActions" class="actions">
<template v-for="(action, aIndex) in actionList" :key="aIndex">
<el-link v-if="!(action.hide && action.hide(row)) && (aIndex < visibleIndex(row))" class="action-item" :type="action.type" @click="actionClickFun(row, action)">
<el-link v-if="!(action.hide && action.hide(row)) && (findVisibleIndex(row, action) <= 2)" class="action-item" :type="action.type" @click="actionClickFun(row, action)">
{{ action.title }}
</el-link>
</template>
@@ -157,7 +157,7 @@
<template #dropdown>
<el-dropdown-menu>
<template v-for="(action, aIndex) in actionList" :key="aIndex">
<el-dropdown-item v-if="!(action.hide && action.hide(row)) && (aIndex >= visibleIndex(row))" @click="actionClickFun(row, action)">
<el-dropdown-item v-if="!(action.hide && action.hide(row)) && (findVisibleIndex(row, action) > 2)" @click="actionClickFun(row, action)">
<el-link :type="action.type">{{ action.title }}</el-link>
</el-dropdown-item>
</template>
@@ -252,9 +252,20 @@ const formatData = ref<any>([]);
const filterData = ref<any>({});
let originData: any = [];
const actionAutoWidth = ref(95);
const visibleIndex = (row: any) => { // 按钮index扣除隐藏的按钮大于2个则放入下拉中
return 2 + props.actionList.length - props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
const findVisibleIndex = (row: any, action: any) => {
let index = 0;
props.actionList.some((item: any) => {
if (!(item.hide && item.hide(row))) {
index++;
}
if (action.title === item.title) {
return true;
}
});
return index;
};
const visibleNum = (row: any) => { // 展示按钮数量
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
};