From d21b5e9e2b42d287bffb3538520a88bca141e207 Mon Sep 17 00:00:00 2001 From: cshaptx4869 <994774638@qq.com> Date: Mon, 20 May 2024 10:14:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(CURD):=20:sparkles:=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=A1=A8=E5=8D=95=E6=98=BE=E9=9A=90=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PageContent/index.vue | 24 +++++++++++++++--------- src/components/PageSearch/index.vue | 19 +++++++++++++++---- src/hooks/usePage.ts | 5 +++++ src/views/demo/curd/index.vue | 2 ++ 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/components/PageContent/index.vue b/src/components/PageContent/index.vue index 7ec2e6ab..96172935 100644 --- a/src/components/PageContent/index.vue +++ b/src/components/PageContent/index.vue @@ -76,6 +76,10 @@ + + @@ -149,11 +153,7 @@ :disabled="!hasAuth(`${contentConfig.pageName}:modify`)" @change=" pageData.length > 0 && - handleSwitchChange( - col.prop, - scope.row[col.prop], - scope.row - ) + handleModify(col.prop, scope.row[col.prop], scope.row) " /> @@ -316,7 +316,7 @@ export interface IContentConfig { } >; // 表格工具栏右侧图标 - defaultToolbar?: ("refresh" | "filter")[]; + defaultToolbar?: ("refresh" | "filter" | "search")[]; // table组件列属性(额外的属性templet,operat,slotName) cols: Array<{ type?: "default" | "selection" | "index" | "expand"; @@ -365,12 +365,11 @@ const props = defineProps<{ const emit = defineEmits<{ addClick: []; exportClick: []; + searchClick: []; toolbarClick: [name: string]; editClick: [row: IObject]; operatClick: [data: IOperatData]; }>(); -// 暴露的属性和方法 -defineExpose({ fetchPageData, exportPageData }); // 主键 const pk = props.contentConfig.pk ?? "id"; @@ -380,6 +379,7 @@ const toolbar = props.contentConfig.toolbar ?? ["add", "delete"]; const defaultToolbar = props.contentConfig.defaultToolbar ?? [ "refresh", "filter", + "search", ]; // 表格列 const cols = ref( @@ -468,6 +468,9 @@ function handleToolbar(name: string) { case "refresh": handleRefresh(); break; + case "search": + emit("searchClick"); + break; case "add": emit("addClick"); break; @@ -522,7 +525,7 @@ function exportPageData(queryParams: IObject = {}) { } } // 属性修改 -function handleSwitchChange( +function handleModify( field: string, value: boolean | string | number, row: Record @@ -537,6 +540,9 @@ function handleSwitchChange( ElMessage.error("未配置modifyAction"); } } + +// 暴露的属性和方法 +defineExpose({ fetchPageData, exportPageData }); diff --git a/src/components/PageSearch/index.vue b/src/components/PageSearch/index.vue index 21a5e346..33545529 100644 --- a/src/components/PageSearch/index.vue +++ b/src/components/PageSearch/index.vue @@ -1,5 +1,9 @@