mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 22:31:21 +00:00
refactor(CURD): 统一工具栏按钮类型和权限命名
标准化工具栏按钮类型定义,移除重复项并统一权限命名 更新多个视图的默认工具栏配置以保持一致 添加批量修改按钮并调整相关权限名称
This commit is contained in:
@@ -44,9 +44,8 @@ defineProps<{
|
||||
|
||||
const TOOLTIPS: Record<string, string> = {
|
||||
import: "导入",
|
||||
imports: "批量导入",
|
||||
export: "导出",
|
||||
exports: "导出",
|
||||
filter: "筛选",
|
||||
search: "搜索显示/隐藏",
|
||||
refresh: "刷新",
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
</el-text>
|
||||
<el-link
|
||||
v-if="props.showTemplateDownload"
|
||||
v-hasPerm="[`${props.contentConfig.permPrefix}:download`]"
|
||||
class="mx-1"
|
||||
type="primary"
|
||||
icon="download"
|
||||
|
||||
@@ -377,18 +377,16 @@ const emit = defineEmits<{
|
||||
// 表格工具栏按钮配置
|
||||
const config = computed(() => props.contentConfig);
|
||||
const buttonConfig = reactive<Record<string, IObject>>({
|
||||
add: { text: "新增", attrs: { icon: "plus", type: "success" }, perm: "add" },
|
||||
add: { text: "新增", attrs: { icon: "plus", type: "success" }, perm: "create" },
|
||||
delete: { text: "删除", attrs: { icon: "delete", type: "danger" }, perm: "delete" },
|
||||
/** 右侧圆形工具条:与业务页手写工具栏(如 user、demo)语义色一致 */
|
||||
patch: { text: "批量修改", attrs: { icon: "edit", type: "warning" }, perm: "patch" },
|
||||
import: { text: "导入", attrs: { icon: "upload", type: "info" }, perm: "import" },
|
||||
export: { text: "导出", attrs: { icon: "download", type: "warning" }, perm: "export" },
|
||||
refresh: { text: "刷新", attrs: { icon: "refresh", type: "success" }, perm: "*:*:*" },
|
||||
filter: { text: "筛选列", attrs: { icon: "operation", type: "danger" }, perm: "*:*:*" },
|
||||
search: { text: "搜索", attrs: { icon: "search", type: "info" }, perm: "search" },
|
||||
imports: { text: "批量导入", attrs: { icon: "upload", type: "success" }, perm: "imports" },
|
||||
exports: { text: "批量导出", attrs: { icon: "download", type: "warning" }, perm: "exports" },
|
||||
view: { text: "查看", attrs: { icon: "view", type: "primary" }, perm: "view" },
|
||||
edit: { text: "编辑", attrs: { icon: "edit", type: "primary" }, perm: "edit" },
|
||||
search: { text: "搜索", attrs: { icon: "search", type: "info" }, perm: "query" },
|
||||
view: { text: "详情", attrs: { icon: "view", type: "primary" }, perm: "detail" },
|
||||
edit: { text: "编辑", attrs: { icon: "edit", type: "primary" }, perm: "update" },
|
||||
});
|
||||
|
||||
// 主键
|
||||
@@ -807,7 +805,7 @@ function handleToolbar(name: string) {
|
||||
case "refresh":
|
||||
handleRefresh();
|
||||
break;
|
||||
case "exports":
|
||||
case "export":
|
||||
handleOpenExportsModal();
|
||||
break;
|
||||
case "imports":
|
||||
@@ -822,12 +820,12 @@ function handleToolbar(name: string) {
|
||||
case "delete":
|
||||
handleDelete();
|
||||
break;
|
||||
case "patch":
|
||||
emit("toolbarClick", name);
|
||||
break;
|
||||
case "import":
|
||||
handleOpenImportModal(true);
|
||||
break;
|
||||
case "export":
|
||||
emit("exportClick");
|
||||
break;
|
||||
default:
|
||||
emit("toolbarClick", name);
|
||||
break;
|
||||
|
||||
@@ -43,8 +43,8 @@ export type IComponentType = DateComponent | InputComponent | OtherComponent;
|
||||
/**
|
||||
* 工具按钮类型定义
|
||||
*/
|
||||
type ToolbarLeft = "add" | "delete" | "import" | "export";
|
||||
type ToolbarRight = "refresh" | "filter" | "import" | "imports" | "exports" | "search";
|
||||
type ToolbarLeft = "add" | "delete" | "patch";
|
||||
type ToolbarRight = "refresh" | "filter" | "import" | "export" | "search";
|
||||
type ToolbarTable = "edit" | "view" | "delete";
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ export interface IContentConfig<T = any> {
|
||||
pk?: string;
|
||||
/** 表格工具栏(默认:add,delete,export,也可自定义) */
|
||||
toolbar?: Array<ToolbarLeft | IToolsButton>;
|
||||
/** 表格工具栏右侧图标(默认:refresh,filter,imports,exports,search) */
|
||||
/** 表格工具栏右侧图标(默认:refresh,filter,import,export,patch,search) */
|
||||
defaultToolbar?: Array<ToolbarRight | IToolsButton>;
|
||||
/** 使用 #table 插槽自定义表格/树表时,为 true 则隐藏「列筛选」按钮(避免与自定义列不同步) */
|
||||
hideColumnFilter?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user