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 ( <>
{searchBtn ? : null }
); } export default ToolBar;