Merge pull request #93 from cshaptx4869/patch-55

feat(PageContent):  增加defaultToolbar配置参数
This commit is contained in:
Ray Hao
2024-05-13 11:29:02 +08:00
committed by GitHub
2 changed files with 45 additions and 34 deletions

View File

@@ -1,8 +1,9 @@
<template> <template>
<el-card shadow="never" class="table-container"> <el-card shadow="never" class="table-container">
<!-- 表格工具栏 -->
<div class="flex-x-between mb-[10px]"> <div class="flex-x-between mb-[10px]">
<!-- 左侧工具栏 -->
<div> <div>
<!-- 表格左上方工具栏 -->
<template v-for="item in contentConfig.toolbar" :key="item"> <template v-for="item in contentConfig.toolbar" :key="item">
<template v-if="typeof item === 'string'"> <template v-if="typeof item === 'string'">
<!-- 新增 --> <!-- 新增 -->
@@ -64,13 +65,16 @@
</template> </template>
</template> </template>
</div> </div>
<!-- 右侧工具栏 -->
<!-- 表格右上方工具栏 -->
<div> <div>
<el-icon class="cursor-pointer" @click="handleToolbar('refresh')"> <template v-for="item in defaultToolbar" :key="item">
<template v-if="item === 'refresh'">
<el-icon class="cursor-pointer ml-2" @click="handleToolbar(item)">
<i-ep-refresh /> <i-ep-refresh />
</el-icon> </el-icon>
</template>
<template v-else-if="item === 'filter'">
<!-- 列设置 --> <!-- 列设置 -->
<el-popover placement="bottom" trigger="click"> <el-popover placement="bottom" trigger="click">
<template #reference> <template #reference>
@@ -100,6 +104,8 @@
</div> </div>
</el-checkbox-group> </el-checkbox-group>
</el-popover> </el-popover>
</template>
</template>
</div> </div>
</div> </div>
<!-- 列表 --> <!-- 列表 -->
@@ -266,9 +272,8 @@ export interface IContentConfig<T = any> {
exportAction?: (queryParams: T) => Promise<any>; exportAction?: (queryParams: T) => Promise<any>;
// 主键名(默认为id) // 主键名(默认为id)
pk?: string; pk?: string;
// 表格工具栏(默认支持refresh,add,delete,export,也可自定义) // 表格工具栏(默认支持add,delete,export,也可自定义)
toolbar: ( toolbar: (
| "refresh"
| "add" | "add"
| "delete" | "delete"
| "export" | "export"
@@ -279,6 +284,8 @@ export interface IContentConfig<T = any> {
text: string; text: string;
} }
)[]; )[];
// 表格工具栏右侧图标
defaultToolbar?: ("refresh" | "filter")[];
// table组件列属性(额外的属性templet,operat,slotName) // table组件列属性(额外的属性templet,operat,slotName)
cols: IObject[]; cols: IObject[];
} }
@@ -298,6 +305,11 @@ defineExpose({ fetchPageData, exportPageData });
// 主键 // 主键
const pk = props.contentConfig.pk ?? "id"; const pk = props.contentConfig.pk ?? "id";
// 表格工具栏右侧图标
const defaultToolbar = props.contentConfig.defaultToolbar ?? [
"refresh",
"filter",
];
// 加载状态 // 加载状态
const loading = ref(false); const loading = ref(false);
// 删除ID集合 用于批量删除 // 删除ID集合 用于批量删除

View File

@@ -21,7 +21,6 @@ const contentConfig: IContentConfig<UserQuery> = {
exportAction: UserAPI.export, exportAction: UserAPI.export,
pk: "id", pk: "id",
toolbar: [ toolbar: [
"refresh",
"add", "add",
"delete", "delete",
"export", "export",