Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Mar 19, 2020
2 parents 1834bb2 + 7557c0e commit 69056f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/before-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/el-data-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export default {
default: false
},
/**
* 点击查询按钮, 查询前执行的函数, 需要返回Promise
* 点击查询按钮, 查询前执行的函数,参数form表单数据,需要返回Promise
*/
beforeSearch: {
type: Function,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 69056f9

Please sign in to comment.