Skip to content

Commit

Permalink
perf: 点击查询按钮将触发on_search和onSearch事件。其中on_search为默认的查询操作
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Feb 27, 2024
1 parent 811b940 commit 0f452a4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
28 changes: 28 additions & 0 deletions docs/zh/api/crud-options/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ const crudOptions = {
}
```

## on_search
* 说明:点击查询按钮实际触发的search,覆盖它将不执行默认查询操作,你需要自定义查询
* 类型:`async Function(context)`

```js
const crudOptions = {
search:{
on_search(context:any){
console.log('default search is off')
}
}
}
```

## onSearch
* 说明:监听查询点击事件
* 类型:`async Function(context)`

```js
const crudOptions = {
search:{
onSearch(context:any){
console.log('search clicked',context)
}
}
}
```

## onReset
* 说明:监听重置事件
* 类型:`async Function(context)`
Expand Down
1 change: 1 addition & 0 deletions packages/fast-crud/src/components/search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export default defineComponent({
if (await doValidate()) {
onFormValidated();
await nextTick();
ctx.emit("_search", getContextFn());
ctx.emit("search", getContextFn());
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-crud/src/use/use-crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export function useCrud<T = any, R = any>(ctx: UseCrudProps<T, R>): UseCrudRet<R
baseTableRef.clearSort();
}
},
onSearch() {
on_search() {
crudExpose.doRefresh({ goFirstPage: true });
},
["onUpdate:form"]: (value: any) => {
Expand Down

0 comments on commit 0f452a4

Please sign in to comment.