导出文件(antD+react)
ex = () => {
const { validateFields } = this.props.form
const { currentPage } = this.state
validateFields((error, value) => {
console.log('导出数据', value.toString())
if (error) return null
this.setState({ querySpin: true })
fetch(secondExport, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
bm: value, page: currentPage, size: 10
})
}).then(res => {
if (res.ok) {
this.setState({ querySpin: false })
return
}
throw new Error(res.status)
}, rej => { throw new Error('导出 reject') })
.catch(error => { this.setState({ querySpin: false }); errorTip(error.message) })
})
}
// 注:secondExport是导出接口。