160 lines
4.6 KiB
JavaScript
160 lines
4.6 KiB
JavaScript
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 { RangePicker } = DatePicker;
|
|
const ToolBar = ({ setSearchVal, onSave, storeData,role }) => {
|
|
const searchBtn = role?.rule?.find(item => item.menuName == "查询")||true;
|
|
const addBtn = role?.rule?.find(item => item.menuName == "新增")||true;
|
|
|
|
const optionsType = [
|
|
{
|
|
label: "今日",
|
|
value:1
|
|
},
|
|
{
|
|
label: "近一周",
|
|
value:2
|
|
},
|
|
{
|
|
label:"近一月",
|
|
value:3
|
|
},
|
|
{
|
|
label:"近三月",
|
|
value:4
|
|
},
|
|
{
|
|
label:"近一年",
|
|
value:5
|
|
},
|
|
]
|
|
const [form] = Form.useForm();
|
|
const [dmList, setDmList] = useState([])
|
|
const [codeList, setCodeList] = useState([])
|
|
const [dmCode,setDmCode] = 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 getStationCode = async () => {
|
|
try {
|
|
const res = await httppost2(apiurl.gcaqjc.gcaqyj.yjgzpz.list)
|
|
setCodeList(res.data.map(s=>({label:s.stationCode,value:s.stationCode,profileCode:s.profileCode})));
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
}
|
|
const onValuesChange = (e) => {
|
|
switch (e.ranger) {
|
|
case 1:
|
|
form.setFieldValue("tm",[moment().startOf("day"),moment()])
|
|
break;
|
|
case 2:
|
|
form.setFieldValue("tm",[moment().subtract(7, 'days'),moment()])
|
|
break;
|
|
case 3:
|
|
form.setFieldValue("tm",[moment().subtract(1, 'months'),moment()])
|
|
break;
|
|
case 4:
|
|
form.setFieldValue("tm",[moment().subtract(3, 'months'),moment()])
|
|
break;
|
|
case 5:
|
|
form.setFieldValue("tm",[moment().subtract(1, 'years'),moment()])
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
const onFinish = (values) => {
|
|
let dateSo;
|
|
if (values.tm) {
|
|
dateSo = {
|
|
start: moment(values.tm[0]).format('YYYY-MM-DD HH:mm:ss'),
|
|
end: moment(values.tm[1]).format('YYYY-MM-DD HH:mm:ss')
|
|
}
|
|
}
|
|
delete values.tm
|
|
setSearchVal({...values, dateTimeRangeSo:dateSo});
|
|
}
|
|
|
|
useEffect(() => {
|
|
getDmList()
|
|
getStationCode()
|
|
}, [])
|
|
|
|
|
|
return (
|
|
<>
|
|
<div style={{display:'flex',justifyContent:'space-between'}}>
|
|
<Form form={form} className='toolbarBox' layout="inline" onFinish={onFinish} onValuesChange={onValuesChange}>
|
|
<Form.Item label="监测时间" name="tm">
|
|
<RangePicker
|
|
allowClear
|
|
showTime
|
|
style={{ width: "350px" }}
|
|
format="YYYY-MM-DD HH:mm:ss"
|
|
onChange={(v)=>{
|
|
form.setFieldValue('ranger',null)
|
|
}}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label="常用时段" name="ranger">
|
|
<NormalSelect
|
|
allowClear
|
|
style={{ width: "150px" }}
|
|
options={optionsType}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label="监测断面" name="profileCode">
|
|
<NormalSelect
|
|
allowClear
|
|
style={{ width: "150px" }}
|
|
options={dmList}
|
|
onChange={(v)=>{
|
|
form.setFieldValue('stationCode',null)
|
|
setDmCode(v)
|
|
}}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label="测点编号" name="stationCode">
|
|
<NormalSelect
|
|
allowClear
|
|
style={{ width: "150px" }}
|
|
options={codeList.filter(o=>dmCode?o.profileCode===dmCode:true)}
|
|
/>
|
|
</Form.Item>
|
|
{searchBtn ?
|
|
<Form.Item>
|
|
<Button type="primary" htmlType="submit">查询</Button>
|
|
</Form.Item>
|
|
:null }
|
|
<Form.Item>
|
|
<Button onClick={() => form.resetFields()}>重置</Button>
|
|
</Form.Item>
|
|
{
|
|
(onSave && addBtn) ?
|
|
<Form.Item>
|
|
<Button onClick={onSave}>新增</Button>
|
|
</Form.Item>
|
|
:null
|
|
}
|
|
</Form>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default ToolBar; |