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

View File

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