diff --git a/docs/before-search.md b/docs/before-search.md index 9e513ec9..c11ec1a6 100644 --- a/docs/before-search.md +++ b/docs/before-search.md @@ -22,8 +22,9 @@ export default { el: {placeholder: '请输入用户名'} } ], - beforeSearch: () => { + beforeSearch: (searchData) => { this.url = 'https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b/el-data-table?q=basic' + console.log(searchData) return Promise.resolve() } } diff --git a/src/el-data-table.vue b/src/el-data-table.vue index e62d2474..611ab28c 100644 --- a/src/el-data-table.vue +++ b/src/el-data-table.vue @@ -383,7 +383,7 @@ export default { default: false }, /** - * 点击查询按钮, 查询前执行的函数, 需要返回Promise + * 点击查询按钮, 查询前执行的函数,参数form表单数据,需要返回Promise */ beforeSearch: { type: Function, @@ -1019,11 +1019,12 @@ export default { }) }, async search() { - const valid = await new Promise(r => this.$refs.searchForm.validate(r)) + const form = this.$refs.searchForm + const valid = await new Promise(r => form.validate(r)) if (!valid) return try { - await this.beforeSearch() + await this.beforeSearch(form.getFormValue()) this.page = defaultFirstPage this.getList() } catch (err) {