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';
|
2025-04-10 14:27:15 +08:00
|
|
|
const ToolBar = ({ setSearchVal, setDmName, exportFile, role,list,setWyObj }) => {
|
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();
|
2025-04-10 14:27:15 +08:00
|
|
|
const [source, setSource] = useState()
|
2024-09-20 15:02:50 +08:00
|
|
|
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
|
|
|
}
|
2025-04-10 14:27:15 +08:00
|
|
|
|
|
|
|
|
const valuesChange = (v) => {
|
|
|
|
|
if ('wy' in v) {
|
|
|
|
|
setWyObj(v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-20 15:02:50 +08:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let time = moment()
|
|
|
|
|
form.setFieldValue("tm", time)
|
2025-04-10 14:27:15 +08:00
|
|
|
form.setFieldValue("wy","WY-01")
|
|
|
|
|
setSearchVal({ year: moment().format("YYYY")})
|
|
|
|
|
setWyObj({ wy: "WY-01"})
|
|
|
|
|
}, [])
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (list.length > 0) {
|
|
|
|
|
const newList = list.map(item => ({
|
|
|
|
|
label: item.stationCode,
|
|
|
|
|
value:item.stationCode
|
|
|
|
|
}))
|
|
|
|
|
setSource(newList)
|
|
|
|
|
}
|
|
|
|
|
}, [list])
|
|
|
|
|
|
2024-09-20 15:02:50 +08:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div style={{display:'flex',justifyContent:'space-between'}}>
|
2025-04-10 14:27:15 +08:00
|
|
|
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish} onValuesChange={valuesChange}>
|
2024-09-20 15:02:50 +08:00
|
|
|
<Form.Item label="上报时间" name="tm">
|
|
|
|
|
<DatePicker
|
|
|
|
|
allowClear
|
|
|
|
|
picker="year"
|
|
|
|
|
style={{ width: "200px" }}
|
|
|
|
|
format={'YYYY'}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
2025-04-10 14:27:15 +08:00
|
|
|
<Form.Item label="位移" name="wy">
|
|
|
|
|
<NormalSelect options={source} style={{ width: '180px' }} />
|
|
|
|
|
</Form.Item>
|
2024-09-20 15:02:50 +08:00
|
|
|
{searchBtn ? <Form.Item>
|
|
|
|
|
<Button type="primary" htmlType="submit">查询</Button>
|
|
|
|
|
</Form.Item> : null }
|
|
|
|
|
{exportBtn ? <Form.Item>
|
|
|
|
|
<Button onClick={()=>exportFile()}>导出</Button>
|
|
|
|
|
</Form.Item>: null}
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ToolBar;
|