2024-09-20 15:02:50 +08:00
|
|
|
import React, { useEffect,useState } from 'react';
|
|
|
|
|
import { Form, Input, Button, DatePicker } from 'antd';
|
|
|
|
|
import { getDictService } from '../../../../service/SelectValue'
|
|
|
|
|
import AdcdFuzzyTreeSelect from '../../../../components/Form/AdcdFuzzyTreeSelect';
|
|
|
|
|
import NormalSelect from '../../../../components/Form/NormalSelect';
|
|
|
|
|
import { config } from '../../../../config';
|
|
|
|
|
import moment from 'moment';
|
|
|
|
|
import { httppost2 } from '../../../../utils/request';
|
|
|
|
|
import apiurl from '../../../../service/apiurl';
|
|
|
|
|
const ToolBar = ({ setSearchVal, setDmName, exportFile,role }) => {
|
2024-09-23 13:49:58 +08:00
|
|
|
const exportBtn = role?.rule?.find(item => item.menuName == "导出")||true;
|
|
|
|
|
const searchBtn = role?.rule?.find(item => item.menuName == "查询")||true;
|
2024-09-20 15:02:50 +08:00
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const [dmList, setDmList] = useState([])
|
|
|
|
|
const getDmList = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await httppost2(apiurl.gcaqjc.sjtjcx.sycx.list)
|
|
|
|
|
setDmList(res.data.map(s=>({label:s.profileName,value:s.profileCode})));
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onFinish = (values) => {
|
2024-09-27 17:49:18 +08:00
|
|
|
let dateSo;
|
2024-09-20 15:02:50 +08:00
|
|
|
if (values.tm) {
|
2024-09-27 17:49:18 +08:00
|
|
|
dateSo = moment(values.tm).format('YYYY')
|
2024-09-20 15:02:50 +08:00
|
|
|
}
|
|
|
|
|
delete values.tm
|
2024-09-27 17:49:18 +08:00
|
|
|
setSearchVal({ ...values, year: dateSo });
|
2024-09-20 15:02:50 +08:00
|
|
|
setDmName(dmList.find(item => item.value == values.profileCode).label)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getDmList()
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let time = moment()
|
|
|
|
|
if (dmList.length > 0) {
|
|
|
|
|
form.setFieldValue("tm", time)
|
|
|
|
|
form.setFieldValue("profileCode",dmList[0].value)
|
|
|
|
|
setSearchVal({ year: moment().format("YYYY"), profileCode: dmList[0].value })
|
|
|
|
|
setDmName(dmList[0].label)
|
|
|
|
|
}
|
|
|
|
|
}, [dmList])
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div style={{display:'flex',justifyContent:'space-between'}}>
|
|
|
|
|
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish}>
|
|
|
|
|
<Form.Item label="上报时间" name="tm">
|
|
|
|
|
<DatePicker
|
|
|
|
|
allowClear
|
|
|
|
|
picker="year"
|
|
|
|
|
style={{ width: "200px" }}
|
|
|
|
|
format={'YYYY'}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item label="监测断面" name="profileCode">
|
|
|
|
|
<NormalSelect
|
|
|
|
|
allowClear
|
|
|
|
|
style={{ width: "150px" }}
|
|
|
|
|
options={dmList}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
{searchBtn ? <Form.Item>
|
|
|
|
|
<Button type="primary" htmlType="submit">查询</Button>
|
|
|
|
|
</Form.Item> : null}
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<Button onClick={() => form.resetFields()}>重置</Button>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
{exportBtn ? <Form.Item>
|
|
|
|
|
<Button onClick={()=>exportFile()}>导出</Button>
|
|
|
|
|
</Form.Item>: null}
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ToolBar;
|