Merge pull request #110 from xiudaozhe/master

feat:  search配置新增函数能力拓展
This commit is contained in:
Ray Hao
2024-05-23 11:13:20 +08:00
committed by GitHub
2 changed files with 18 additions and 5 deletions

View File

@@ -69,7 +69,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { FormInstance } from "element-plus"; import type { FormInstance } from "element-plus";
import { reactive, ref } from "vue"; import { reactive, ref, onMounted } from "vue";
// 对象类型 // 对象类型
type IObject = Record<string, any>; type IObject = Record<string, any>;
@@ -91,6 +91,8 @@ export interface ISearchConfig {
initialValue?: any; initialValue?: any;
// 可选项(适用于select组件) // 可选项(适用于select组件)
options?: { label: string; value: any }[]; options?: { label: string; value: any }[];
// 初始化数据函数扩展适用初始化options
initFn?: Function;
}>; }>;
// 是否开启展开和收缩 // 是否开启展开和收缩
isExpandable?: boolean; isExpandable?: boolean;
@@ -146,6 +148,12 @@ function toggleVisible() {
visible.value = !visible.value; visible.value = !visible.value;
} }
onMounted(() => {
props.searchConfig.formItems.forEach((item) => {
item.initFn && item.initFn();
});
});
// 暴露的属性和方法 // 暴露的属性和方法
defineExpose({ getQueryParams, toggleVisible }); defineExpose({ getQueryParams, toggleVisible });
</script> </script>

View File

@@ -57,10 +57,15 @@ const searchConfig: ISearchConfig = {
width: "100px", width: "100px",
}, },
}, },
options: [ options: [],
{ label: "启用", value: 1 }, initFn() {
{ label: "禁用", value: 0 }, setTimeout(() => {
], this.options = [
{ label: "启用", value: 1 },
{ label: "禁用", value: 0 },
];
}, 300);
},
}, },
{ {
type: "date-picker", type: "date-picker",