tsg-web/src/views/sz/szzf/clyj/form.js

138 lines
3.5 KiB
JavaScript
Raw Normal View History

2024-09-23 18:03:30 +08:00
import React, { useEffect, useState, useMemo, useRef } from 'react';
2024-09-24 14:37:41 +08:00
import { Space, Table, Radio, DatePicker, Form, Select, Button, message, Upload, Input, Row, Col, Switch, Image } from 'antd';
2024-09-23 18:03:30 +08:00
import { DeleteOutlined, FileWordOutlined, FilePdfOutlined, FileZipOutlined, FileExcelOutlined } from '@ant-design/icons';
import { formItemLayout, btnItemLayout } from '../../../../components/crud/FormLayoutProps';
import apiurl from '../../../../service/apiurl';
// import "./index.less"
import moment from 'moment';
2024-09-24 14:37:41 +08:00
const { TextArea } = Input;
2024-09-23 18:03:30 +08:00
2024-09-24 14:37:41 +08:00
const options=[
{label:'禁用'},
{label:'启用'}
2024-09-23 18:03:30 +08:00
]
const ModalForm = ({ mode, record, onEdit, onSave, onSimilarSave }) => {
const [form] = Form.useForm();
const [fileList, setFileList] = useState([]) //上传文件列表
const [loading, setLoading] = useState(false)
const onfinish = (values) => {
values.eventsDate = values.eventsDate ? moment(values.eventsDate).format("YYYY-MM-DD 00:00:00") : ''
let oldFiles = fileList.map(item => ({ fileId: item.response?.data?.fileId }))
if (mode === 'edit') {
values.files = oldFiles;
values.id = record.id;
onEdit(apiurl.rcgl.gcdsj.edit, values)
}
if (mode === 'save') {
values.files = oldFiles
onSave(apiurl.rcgl.gcdsj.save, values)
}
}
useEffect(() => {
if (mode != 'save') {
const imgFile = record?.files?.map(o => ({
name: o.fileName,
response: {
data: {
filePath: o.filePath,
fileId: o.fileId
}
},
}))
setFileList(imgFile)
}
}, [record, mode])
return (
<>
<Form
form={form}
{...formItemLayout}
onFinish={onfinish}
initialValues={record}
>
<Row>
2024-09-24 14:37:41 +08:00
<Col span={24}>
2024-09-23 18:03:30 +08:00
<Form.Item
2024-09-24 14:37:41 +08:00
label="节点"
2024-09-23 18:03:30 +08:00
name="name"
rules={[{ required: true }]}
>
2024-09-24 14:37:41 +08:00
<Input disabled style={{ width: '100%' }} allowClear />
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
2024-09-24 14:37:41 +08:00
<Col span={24}>
2024-09-23 18:03:30 +08:00
<Form.Item
2024-09-24 14:37:41 +08:00
label="状态"
2024-09-23 18:03:30 +08:00
name="name"
rules={[{ required: true }]}
>
2024-09-24 14:37:41 +08:00
<Radio.Group options={options}/>
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
2024-09-24 14:37:41 +08:00
<Col span={24}>
<Form.Item
label="法律名称"
name="name"
rules={[{ required: true }]}
>
<Input style={{ width: '100%' }} allowClear />
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
2024-09-24 14:37:41 +08:00
<Col span={24}>
2024-09-23 18:03:30 +08:00
<Form.Item
2024-09-24 14:37:41 +08:00
label="法条内容"
name="name"
2024-09-23 18:03:30 +08:00
>
2024-09-24 14:37:41 +08:00
<Input style={{ width: '100%' }} allowClear />
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
2024-09-24 14:37:41 +08:00
<Col span={24}>
2024-09-23 18:03:30 +08:00
<Form.Item
2024-09-24 14:37:41 +08:00
label="违法行为描述"
name="name"
2024-09-23 18:03:30 +08:00
>
2024-09-24 14:37:41 +08:00
<TextArea rows={4} />
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
<Col span={24}>
<Form.Item
2024-09-24 14:37:41 +08:00
label="处罚措施"
name="name"
2024-09-23 18:03:30 +08:00
>
2024-09-24 14:37:41 +08:00
<TextArea rows={4} />
2024-09-23 18:03:30 +08:00
</Form.Item>
</Col>
2024-09-24 14:37:41 +08:00
2024-09-23 18:03:30 +08:00
</Row>
2024-09-24 14:37:41 +08:00
2024-09-23 18:03:30 +08:00
{
mode === 'view' ? null : (
<>
<Form.Item {...btnItemLayout}>
<Button type="primary" htmlType="submit">
{mode === 'save' ? '提交' : '修改'}
</Button>
</Form.Item>
</>
)
}
</Form>
2024-09-24 14:37:41 +08:00
2024-09-23 18:03:30 +08:00
</>
);
}
export default ModalForm;