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;
|
|
|
|
|
const ToolBar = ({ setSearchVal, onSave, storeData, 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 warnTypes = [
|
|
|
|
|
{
|
|
|
|
|
label: "人员闯入",
|
|
|
|
|
value:1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "工程车辆识别",
|
|
|
|
|
value:2
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "漂浮物识别",
|
|
|
|
|
value:3
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "游泳识别",
|
|
|
|
|
value:4
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
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) => {
|
|
|
|
|
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(() => {
|
|
|
|
|
getStationCode()
|
|
|
|
|
let time = [moment().subtract(1,"weeks"),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'}}>
|
|
|
|
|
<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>
|
|
|
|
|
<Form.Item label="告警点位" name="indexCode">
|
|
|
|
|
<NormalSelect
|
|
|
|
|
allowClear
|
|
|
|
|
style={{ width: "150px" }}
|
|
|
|
|
options={codeList}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item label="告警类型" name="type">
|
|
|
|
|
<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;
|