2024-09-20 15:02:50 +08:00
|
|
|
import React, { useEffect,useState } from 'react';
|
|
|
|
|
import { Form, Input, Button, DatePicker, Popconfirm,Segmented } from 'antd';
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
import { AppstoreOutlined, BarsOutlined } from '@ant-design/icons'
|
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
|
|
|
|
|
const ToolBar = ({ setSearchVal, onSave, onChecked,role }) => {
|
2024-09-23 13:49:58 +08:00
|
|
|
const searchBtn = role?.rule?.find(item => item.menuName == "查询")||true;
|
2024-09-20 15:02:50 +08:00
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const [checked, setChecked] = useState("多图单线")
|
|
|
|
|
const options = [
|
|
|
|
|
{
|
|
|
|
|
label: "多图单线",
|
|
|
|
|
value: "多图单线",
|
|
|
|
|
icon:<BarsOutlined />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "单图多线",
|
|
|
|
|
value: "单图多线",
|
|
|
|
|
icon:<BarsOutlined />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "数据表",
|
|
|
|
|
value: "数据表",
|
|
|
|
|
icon:<BarsOutlined />,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
const onFinish = (values) => {
|
|
|
|
|
let dataSo;
|
|
|
|
|
if (values.tm) {
|
|
|
|
|
dataSo = {
|
|
|
|
|
start: moment(values.tm[0]).format('YYYY-MM-DD 00:00:00'),
|
|
|
|
|
end: moment(values.tm[1]).format('YYYY-MM-DD 23:59:59')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete values.tm
|
|
|
|
|
setSearchVal({...values, dateTimeRangeSo:dataSo});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let time = [moment().subtract(1,"months"),moment()]
|
|
|
|
|
let dataSo = {
|
|
|
|
|
start:moment(time[0]).format('YYYY-MM-DD 00:00:00'),
|
|
|
|
|
end:moment(time[1]).format('YYYY-MM-DD 23:59:59'),
|
|
|
|
|
}
|
|
|
|
|
form.setFieldValue("tm",time)
|
|
|
|
|
setSearchVal({dateTimeRangeSo:dataSo})
|
|
|
|
|
}, [])
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center'}}>
|
|
|
|
|
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish}>
|
|
|
|
|
<Form.Item label="时间段" name="tm">
|
|
|
|
|
<RangePicker
|
|
|
|
|
allowClear
|
|
|
|
|
style={{ width: "350px" }}
|
|
|
|
|
format="YYYY-MM-DD"
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
{searchBtn ? <Form.Item>
|
|
|
|
|
<Button type="primary" htmlType="submit">查询</Button>
|
|
|
|
|
</Form.Item> : null }
|
|
|
|
|
<Form.Item
|
|
|
|
|
wrapperCol={{span:14,offset:10}}
|
|
|
|
|
>
|
|
|
|
|
<Segmented
|
|
|
|
|
options={options}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setChecked(e);
|
|
|
|
|
onChecked(e)
|
|
|
|
|
}}
|
|
|
|
|
value={checked}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ToolBar;
|