fix: crud组件列表操作栏和列表顶部操作栏增加hidden隐藏字段

This commit is contained in:
YeMingfei666 2025-04-11 16:48:06 +08:00
parent fdc1933bbe
commit 53fdd79a2e
2 changed files with 51 additions and 44 deletions

View File

@ -55,6 +55,7 @@
<!-- 其他 -->
<template v-else-if="typeof item === 'object'">
<el-button
v-if="item.hidden === undefined || item.hidden === false"
v-hasPerm="[`${contentConfig.pageName}:${item.auth}`]"
:icon="item.icon"
:type="item.type ?? 'default'"
@ -284,31 +285,10 @@
</template>
<!-- 其他 -->
<template v-else-if="typeof item === 'object'">
<el-button
v-if="item.isBtn"
v-hasPerm="[`${contentConfig.pageName}:${item.auth}`]"
:icon="item.icon"
:type="item.type ?? 'primary'"
size="small"
link
@click="
handleOperat({
name: item.name,
row: scope.row,
column: scope.column,
$index: scope.$index,
})
"
>
{{ item.text }}
</el-button>
<el-dropdown style="margin-top: 4px" v-else>
<template v-if="item.hidden === undefined || item.hidden === false">
<el-button
v-if="item.render === undefined || item.render(scope.row)"
v-bind="
item.auth ? { 'v-hasPerm': [`${contentConfig.pageName}:${item.auth}`] } : {}
"
v-if="item.isBtn"
v-hasPerm="[`${contentConfig.pageName}:${item.auth}`]"
:icon="item.icon"
:type="item.type ?? 'primary'"
size="small"
@ -324,26 +304,51 @@
>
{{ item.text }}
</el-button>
<template #dropdown v-if="item.options && item.options.length > 0">
<el-dropdown-menu>
<el-dropdown-item
@click="
handleOperat({
name: item.name,
row: scope.row,
column: scope.column,
$index: scope.$index,
command: opt.command ? opt.command : '',
})
"
v-for="opt in item.options"
:key="opt.value"
>
{{ opt.label }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-dropdown style="margin-top: 4px" v-else>
<el-button
v-if="item.render === undefined || item.render(scope.row)"
v-bind="
item.auth
? { 'v-hasPerm': [`${contentConfig.pageName}:${item.auth}`] }
: {}
"
:icon="item.icon"
:type="item.type ?? 'primary'"
size="small"
link
@click="
handleOperat({
name: item.name,
row: scope.row,
column: scope.column,
$index: scope.$index,
})
"
>
{{ item.text }}
</el-button>
<template #dropdown v-if="item.options && item.options.length > 0">
<el-dropdown-menu>
<el-dropdown-item
@click="
handleOperat({
name: item.name,
row: scope.row,
column: scope.column,
$index: scope.$index,
command: opt.command ? opt.command : '',
})
"
v-for="opt in item.options"
:key="opt.value"
>
{{ opt.label }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
</template>
</template>
</template>

View File

@ -148,6 +148,7 @@ export interface IContentConfig<T = any> {
icon?: string;
name: string;
text: string;
hidden?: boolean;
type?: "primary" | "success" | "warning" | "danger" | "info";
}
>;
@ -215,6 +216,7 @@ export interface IContentConfig<T = any> {
name: string;
text: string;
isBtn?: boolean;
hidden?: boolean;
type?: "primary" | "success" | "warning" | "danger" | "info";
render?: (row: IObject) => boolean;
options?: {