return ( <div> <Space direction="vertical" size="large" style={{display: 'flex', marginTop: '1%'}}> <QueryFilter> <div> <span> 日期: </span> <DatePicker style={{width: '80%'}} onChange={onChange} disabledDate={disabledDate} defaultValue={dayjs()} /> </div> </QueryFilter> <ProTable<API.BatteryInformationControl, API.queryBatteryInformationControlParams & API.PageParams > headerTitle={'深圳市能源换电业务电池总体情况'} rowKey="" bordered search={false} // scroll={{x:true}} scroll={{x: 'max-content', y: 700}} request={async (params) => { const body = { dataQueryTime: selectedDate } console.log(body); const res = await queryBatteryInformationManagement(body); console.log(res); setSummaryData(res) return res }} options={{ // show: true, density: true, fullScreen: true, setting: true, } } columns={columns} summary={ () => ( <> <ProTable.Summary.Row className='total' style={{textAlign: 'center'}}> {/* 合计行内容 */} <ProTable.Summary.Cell colSpan={2} index={0} >总计</ProTable.Summary.Cell> <ProTable.Summary.Cell index={2}>{summaryData && summaryData.total}</ProTable.Summary.Cell> <ProTable.Summary.Cell index={3}>43</ProTable.Summary.Cell> </ProTable.Summary.Row> </> )} /> </Space> </div> )如何把datepicker时间选择器的值,用于作为protable组件的搜索条件
时间: 2024-04-14 14:27:32 浏览: 189
JS 滚动事件[removed]与position:fixed写兼容IE6的回到顶部组件
你可以将DatePicker组件的onChange事件处理函数中的值传递给ProTable组件的request属性中的params参数。具体实现如下:
首先,在函数组件中定义一个状态变量来保存DatePicker选择的日期,例如:
```jsx
const [selectedDate, setSelectedDate] = useState(dayjs()); // 初始值可根据需求设置
```
然后,在DatePicker组件中添加onChange事件处理函数,将选择的日期更新到状态变量中,例如:
```jsx
<DatePicker
style={{width: '80%'}}
onChange={(date) => setSelectedDate(date)}
disabledDate={disabledDate}
defaultValue={dayjs()}
/>
```
最后,在ProTable组件的request属性中使用selectedDate作为查询参数的值,例如:
```jsx
request={async (params) => {
const body = {
dataQueryTime: selectedDate
}
const res = await queryBatteryInformationManagement(body);
setSummaryData(res);
return res;
}}
```
这样,当选择日期发生改变时,ProTable组件会根据选择的日期进行搜索。
阅读全文