91 lines
2.7 KiB
JavaScript
91 lines
2.7 KiB
JavaScript
|
|
import React,{useEffect,useState,useMemo,useRef} from 'react';
|
||
|
|
import { Form, Button, Input, Row,Upload, Col, Table, DatePicker, InputNumber,message,Image,Modal,Radio ,Popconfirm } from 'antd';
|
||
|
|
import { DeleteOutlined,VideoCameraOutlined } from '@ant-design/icons';
|
||
|
|
import { formItemLayout, btnItemLayout } from '../../../components/crud/FormLayoutProps';
|
||
|
|
import apiurl from '../../../service/apiurl';
|
||
|
|
import NormalSelect from '../../../components/Form/NormalSelect';
|
||
|
|
import moment from 'moment';
|
||
|
|
const ModalForm = ({ mode, record, onEdit, onSave, onSimilarSave }) => {
|
||
|
|
const [form] = Form.useForm();
|
||
|
|
const onfinish = (values) => {
|
||
|
|
const userId = localStorage.getItem('userId')
|
||
|
|
values.userId = userId
|
||
|
|
if (mode === 'edit') {
|
||
|
|
onEdit(apiurl.rcgl.wxyh.edit,{...record,...values})
|
||
|
|
}
|
||
|
|
if (mode === 'save') {
|
||
|
|
onSave(apiurl.rcgl.wxyh.save,values)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
return (
|
||
|
|
<>
|
||
|
|
<Form
|
||
|
|
form={form}
|
||
|
|
{...formItemLayout}
|
||
|
|
onFinish={onfinish}
|
||
|
|
initialValues={record}
|
||
|
|
>
|
||
|
|
<Row>
|
||
|
|
<Col span={12}>
|
||
|
|
<Form.Item
|
||
|
|
label="规则名称"
|
||
|
|
name="ruleName"
|
||
|
|
rules={[{ required: true }]}
|
||
|
|
>
|
||
|
|
<Input style={{ width: '100%' }} allowClear disabled={mode === 'view'} />
|
||
|
|
</Form.Item>
|
||
|
|
</Col>
|
||
|
|
<Col span={12}>
|
||
|
|
<Form.Item
|
||
|
|
label="预警等级"
|
||
|
|
name="warningLevel"
|
||
|
|
rules={[{ required: true }]}
|
||
|
|
>
|
||
|
|
<NormalSelect
|
||
|
|
options={[
|
||
|
|
{ label: '蓝色', value: 0 },
|
||
|
|
{ label: '黄色', value: 1 },
|
||
|
|
{ label: '橙色', value: 2 },
|
||
|
|
{ label: '红色', value: 3 }
|
||
|
|
]}
|
||
|
|
allowClear={true}
|
||
|
|
style={{ width: '100%' }}
|
||
|
|
disabled={mode === 'view'}
|
||
|
|
/>
|
||
|
|
</Form.Item>
|
||
|
|
</Col>
|
||
|
|
<Col span={12}>
|
||
|
|
<Form.Item
|
||
|
|
label="启用状态"
|
||
|
|
name="status"
|
||
|
|
rules={[{ required: true }]}
|
||
|
|
>
|
||
|
|
<Radio.Group disabled={mode === 'view'}>
|
||
|
|
<Radio value={0}>未启用</Radio>
|
||
|
|
<Radio value={1}>启用</Radio>
|
||
|
|
</Radio.Group>
|
||
|
|
</Form.Item>
|
||
|
|
</Col>
|
||
|
|
</Row>
|
||
|
|
|
||
|
|
{
|
||
|
|
mode==='view'?null:(
|
||
|
|
<>
|
||
|
|
<Form.Item {...btnItemLayout}>
|
||
|
|
<Button type="primary" htmlType="submit">
|
||
|
|
{mode === 'save' ? '提交' : '修改'}
|
||
|
|
</Button>
|
||
|
|
</Form.Item>
|
||
|
|
</>
|
||
|
|
)
|
||
|
|
}
|
||
|
|
</Form>
|
||
|
|
</>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export default ModalForm;
|