51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
|
|
import React, { useEffect,useState } from 'react';
|
||
|
|
import { Form, Input, Button, DatePicker } from 'antd';
|
||
|
|
|
||
|
|
import moment from 'moment';
|
||
|
|
const { RangePicker } = DatePicker;
|
||
|
|
const ToolBar = ({ setSearchVal, onSave, exportFile, role }) => {
|
||
|
|
const searchBtn = role?.rule?.find(item => item.menuName == "查询");
|
||
|
|
const exportBtn = role?.rule?.find(item => item.menuName == "导出");
|
||
|
|
const [form] = Form.useForm();
|
||
|
|
const onFinish = (values) => {
|
||
|
|
let dataSo;
|
||
|
|
if (values.year) {
|
||
|
|
dataSo = moment(values.year).format('YYYY')
|
||
|
|
}
|
||
|
|
delete values.year
|
||
|
|
setSearchVal({...values, year:Number(dataSo)});
|
||
|
|
}
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
form.setFieldValue("year", moment())
|
||
|
|
setSearchVal({year: moment().format('YYYY')})
|
||
|
|
}, [])
|
||
|
|
|
||
|
|
return (
|
||
|
|
<>
|
||
|
|
<div style={{display:'flex',justifyContent:'space-between'}}>
|
||
|
|
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish}>
|
||
|
|
<Form.Item label="年份" name="year">
|
||
|
|
<DatePicker
|
||
|
|
allowClear
|
||
|
|
style={{ width: "150px" }}
|
||
|
|
picker="year"
|
||
|
|
/>
|
||
|
|
</Form.Item>
|
||
|
|
{searchBtn ? <Form.Item>
|
||
|
|
<Button type="primary" htmlType="submit">查询</Button>
|
||
|
|
</Form.Item> : null }
|
||
|
|
{
|
||
|
|
exportBtn ?
|
||
|
|
<Form.Item>
|
||
|
|
<Button onClick={()=>exportFile()}>导出</Button>
|
||
|
|
</Form.Item>
|
||
|
|
:null
|
||
|
|
}
|
||
|
|
</Form>
|
||
|
|
</div>
|
||
|
|
</>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export default ToolBar;
|