return (
<>
<ProTable<StatisticalTable, Pagination>
headerTitle="订单执行统计表"
bordered
// dataSource={StatisticalTableArr}
form={{
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
createdAtRange: [values.startDate, values.endDate],
};
}
return values;
}, syncToInitialValues: false
}}
formRef={formRef}
actionRef={actionRef}
rowKey={record => record.id}
toolBarRender={() => [
<Button loading={!!loading.effects['StatisticalTable/exportExcel']}
onClick={handleExportProducts}>导出数据</Button>
]}
request={async (params) => {
const response = await getdata({
...params,dealerId: 3
})
SetFilterBean({...params,dealerId: 3})
return Promise.resolve(response)
}}
columns={columns}
options={{ fullScreen: true, reload: true, setting: true }}
search={{
defaultCollapsed: true,
labelWidth: 'auto',
optionRender: (searchConfig, formProps, dom) => [
...dom.reverse(),
],
}}
/>
</>
)
本来我还写了请求方法,但是看request有请求,所以直接使用了,也不用在接口那边赋值,这边直接可以返回数据渲染表格!!
而且表格头部的搜索框也会根据填的值直接绑定进去请求数据,然后返回渲染表格。
很灵活方便!!!!
一开始没有搞懂这个表格,还坑次坑次找为什么接口请求页面渲染,搜索后接口返回没有渲染数据呢,因为是我使用了dataSource={StatisticalTableArr},自己赋值了,其实不用加。