tsg-web/src/views/spjk/aiWarn/toolbar.js

79 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React, { useEffect,useState } from 'react';
import { Form, Input, Button, DatePicker } from 'antd';
import NormalSelect from '../../../components/Form/NormalSelect';
import moment from 'moment';
import { httppost2 } from '../../../utils/request';
import apiurl from '../../../service/apiurl';
const { RangePicker } = DatePicker;
const ToolBar = ({ setSearchVal, onSave, storeData, role, tm }) => {
const searchBtn = role?.rule?.find(item => item.menuName == "查询")|| true;
const warnTypes = [
{
label: "低",
value:1
},
{
label: "中",
value:2
},
{
label: "高",
value:3
}
]
const [form] = Form.useForm();
const [codeList, setCodeList] = useState([])
const getStationCode = async () => {
try {
const res = await httppost2(apiurl.spjk1.aiWarn.list)
setCodeList(res.data.map(s=>({label:s.name,value:s.indexCode})));
} catch (error) {
console.log(error);
}
}
const onFinish = (values) => {
if (values.startTime) {
values.startTime = moment(values.startTime).format('YYYY-MM-DD HH:mm:ss');
}
setSearchVal({...values});
}
// 预填开始时间(来自外部 tm
useEffect(() => {
if (tm && Array.isArray(tm) && tm[0]) {
form.setFieldsValue({ startTime: moment(tm[0]) })
}
}, [tm])
return (
<>
<div style={{display:'flex',justifyContent:'space-between'}}>
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish} >
<Form.Item label="事件开始时间" name="startTime">
<DatePicker
allowClear
style={{ width: "200px" }}
showTime
placeholder='请选择时间'
/>
</Form.Item>
<Form.Item label="事件等级" name="eventLevel">
<NormalSelect
allowClear
style={{ width: "150px" }}
options={warnTypes}
/>
</Form.Item>
{searchBtn ? <Form.Item>
<Button type="primary" htmlType="submit">查询</Button>
</Form.Item> : null }
<Form.Item>
<Button onClick={() => form.resetFields()}>重置</Button>
</Form.Item>
</Form>
</div>
</>
);
}
export default ToolBar;