update:表单按钮优化
This commit is contained in:
@@ -109,7 +109,7 @@
|
|||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div v-if="!$slots.tableActions" class="actions">
|
<div v-if="!$slots.tableActions" class="actions">
|
||||||
<template v-for="(action, aIndex) in actionList" :key="aIndex">
|
<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 }}
|
{{ action.title }}
|
||||||
</el-link>
|
</el-link>
|
||||||
</template>
|
</template>
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<template v-for="(action, aIndex) in actionList" :key="aIndex">
|
<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-link :type="action.type">{{ action.title }}</el-link>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</template>
|
</template>
|
||||||
@@ -228,9 +228,20 @@ const vxeTableRef = ref<any>();
|
|||||||
const tableSearchRef = ref<any>();
|
const tableSearchRef = ref<any>();
|
||||||
const searchList = ref<any>(props.searchItems);
|
const searchList = ref<any>(props.searchItems);
|
||||||
const actionAutoWidth = ref(95);
|
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) => { // 展示按钮数量
|
const visibleNum = (row: any) => { // 展示按钮数量
|
||||||
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
|
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -146,7 +146,7 @@
|
|||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div v-if="!$slots.tableActions" class="actions">
|
<div v-if="!$slots.tableActions" class="actions">
|
||||||
<template v-for="(action, aIndex) in actionList" :key="aIndex">
|
<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 }}
|
{{ action.title }}
|
||||||
</el-link>
|
</el-link>
|
||||||
</template>
|
</template>
|
||||||
@@ -157,7 +157,7 @@
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<template v-for="(action, aIndex) in actionList" :key="aIndex">
|
<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-link :type="action.type">{{ action.title }}</el-link>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</template>
|
</template>
|
||||||
@@ -252,9 +252,20 @@ const formatData = ref<any>([]);
|
|||||||
const filterData = ref<any>({});
|
const filterData = ref<any>({});
|
||||||
let originData: any = [];
|
let originData: any = [];
|
||||||
const actionAutoWidth = ref(95);
|
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) => { // 展示按钮数量
|
const visibleNum = (row: any) => { // 展示按钮数量
|
||||||
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
|
return props.actionList.filter((d: any) => !(d.hide && d.hide(row))).length;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user