ss-system-web/src/views/jczd/jcdmgl/form.js

89 lines
2.7 KiB
JavaScript
Raw Normal View History

2026-01-21 09:46:38 +08:00
import React, { useEffect, useState, useRef } from 'react';
import apiurl from '../../../service/apiurl';
import { message, Tabs, Form, Input, Button, Col, Row, DatePicker, InputNumber, TreeSelect } from 'antd'
import { formItemLayout, btnItemLayout } from '../../../components/crud/FormLayoutProps';
import FileUpload from '../../../components/Form/FileUpload';
const ModalForm = ({ mode, record, onEdit, onSave, onCrudSuccess, close }) => {
const [form] = Form.useForm();
const [fileUploading, setFileUploading] = useState(false)
const onFinish = (val) => {
if (mode == 'save') {
onSave(apiurl.jctx.jcdmgl.save,val)
}
if (mode == 'edit') {
onEdit(apiurl.jctx.jcdmgl.edit,{...record,...val},'post')
}
}
return (
<>
<Form form={form} {...formItemLayout} onFinish={onFinish} initialValues={record}>
<Row>
<Col span={24}>
<Form.Item
label="断面编号"
name="profileCode"
rules={[{ required: true }]}
>
<Input disabled={mode === 'view'} style={{ width: '100%' }} allowClear />
</Form.Item>
</Col>
<Col span={24}>
<Form.Item
label="断面名称"
name="profileName"
rules={[{ required: true }]}
>
<Input disabled={mode === 'view'} style={{ width: '100%' }} allowClear />
</Form.Item>
</Col>
<Col span={24}>
<Form.Item
label="附件"
name="files"
>
<FileUpload
uploadUrl={apiurl.jctx.jcdmgl.upload}
downloadUrl={apiurl.jctx.jcdmgl.download}
mode={mode}
fileNum={1}
onChange={()=>{}}
onLoadingChange={(isLoading) => setFileUploading(isLoading)}
accept=".jpg,.png,.jpeg"
tip="支持扩展名:.jpg .png"
/>
</Form.Item>
</Col>
<Col span={24}>
<Form.Item
label="描述"
name="remark"
>
<Input disabled={mode === 'view'} style={{ width: '100%' }} allowClear />
</Form.Item>
</Col>
</Row>
{
mode === 'view' ? null : (
<>
<Form.Item {...btnItemLayout}>
<Button type="primary" htmlType="submit" disabled={fileUploading}>
{fileUploading ? '文件上传中...' : (mode === 'save' ? '提交' : '修改')}
</Button>
</Form.Item>
</>
)
}
</Form>
</>
)
}
export default ModalForm;