feat(CURD): 支持搜索表单显隐控制

This commit is contained in:
cshaptx4869
2024-05-20 10:14:58 +08:00
parent dfc6ffac85
commit d21b5e9e2b
4 changed files with 37 additions and 13 deletions

View File

@@ -76,6 +76,10 @@
</template>
</el-popover>
</template>
<!-- 搜索 -->
<template v-else-if="item === 'search'">
<el-button icon="search" circle @click="handleToolbar(item)" />
</template>
</template>
</div>
</div>
@@ -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)
"
/>
</template>
@@ -316,7 +316,7 @@ export interface IContentConfig<T = any> {
}
>;
// 表格工具栏右侧图标
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<string, any>
@@ -537,6 +540,9 @@ function handleSwitchChange(
ElMessage.error("未配置modifyAction");
}
}
// 暴露的属性和方法
defineExpose({ fetchPageData, exportPageData });
</script>
<style lang="scss" scoped></style>