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

79 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-09-20 15:02:50 +08:00
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;
2025-11-13 16:58:52 +08:00
const ToolBar = ({ setSearchVal, onSave, storeData, role, tm }) => {
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 warnTypes = [
{
2025-11-13 16:58:52 +08:00
label: "低",
2024-09-20 15:02:50 +08:00
value:1
},
{
2025-11-13 16:58:52 +08:00
label: "中",
2024-09-20 15:02:50 +08:00
value:2
},
{
2025-11-13 16:58:52 +08:00
label: "高",
2024-09-20 15:02:50 +08:00
value:3
2025-11-13 16:58:52 +08:00
}
2024-09-20 15:02:50 +08:00
]
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) => {
2025-11-13 16:58:52 +08:00
if (values.startTime) {
values.startTime = moment(values.startTime).format('YYYY-MM-DD HH:mm:ss');
2024-09-20 15:02:50 +08:00
}
2025-11-13 16:58:52 +08:00
setSearchVal({...values});
2024-09-20 15:02:50 +08:00
}
2025-11-13 16:58:52 +08:00
// 预填开始时间(来自外部 tm
useEffect(() => {
if (tm && Array.isArray(tm) && tm[0]) {
form.setFieldsValue({ startTime: moment(tm[0]) })
}
}, [tm])
2024-09-20 15:02:50 +08:00
return (
<>
<div style={{display:'flex',justifyContent:'space-between'}}>
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish} >
2025-11-13 16:58:52 +08:00
<Form.Item label="事件开始时间" name="startTime">
<DatePicker
2024-09-20 15:02:50 +08:00
allowClear
2025-11-13 16:58:52 +08:00
style={{ width: "200px" }}
showTime
placeholder='请选择时间'
2024-09-20 15:02:50 +08:00
/>
</Form.Item>
2025-11-13 16:58:52 +08:00
<Form.Item label="事件等级" name="eventLevel">
2024-09-20 15:02:50 +08:00
<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;