第一次
This commit is contained in:
107
src/pages/config/banner/edit.tsx
Normal file
107
src/pages/config/banner/edit.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
ProForm,
|
||||
ProFormDigit,
|
||||
ProFormText,
|
||||
ProFormSwitch
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form, Modal, InputNumber } from 'antd';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import FilesManager from '@/components/FilesManage/index';
|
||||
const RoleForm: React.FC = (props: any) => {
|
||||
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const { values } = props;
|
||||
|
||||
useEffect(() => {
|
||||
console.log(values,'values');
|
||||
|
||||
form.resetFields();
|
||||
form.setFieldsValue(values);
|
||||
}, [form, props]);
|
||||
|
||||
const intl = useIntl();
|
||||
const handleOk = () => {
|
||||
form.submit();
|
||||
};
|
||||
const handleCancel = () => {
|
||||
props.onCancel();
|
||||
};
|
||||
const handleFinish = async (values: any) => {
|
||||
props.onSubmit(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
width={640}
|
||||
title={'轮播图'}
|
||||
open={props.open}
|
||||
forceRender
|
||||
destroyOnClose
|
||||
onOk={handleOk}
|
||||
onCancel={handleCancel}
|
||||
>
|
||||
<ProForm
|
||||
form={form}
|
||||
submitter={false}
|
||||
layout="horizontal"
|
||||
onFinish={handleFinish}>
|
||||
<ProFormDigit
|
||||
name="id"
|
||||
label={'ID'}
|
||||
disabled
|
||||
hidden={true}
|
||||
/>
|
||||
|
||||
<ProForm.Group>
|
||||
<ProFormText
|
||||
name="title"
|
||||
label={'标题'}
|
||||
placeholder="请输入标题"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProForm.Item
|
||||
label="排序"
|
||||
name={'sortOrder'}
|
||||
>
|
||||
<InputNumber style={{ width: 200 }} />
|
||||
</ProForm.Item>
|
||||
|
||||
|
||||
<ProFormText
|
||||
name="jumpUrl"
|
||||
label={'跳转地址'}
|
||||
placeholder="请输入跳转地址"
|
||||
/>
|
||||
|
||||
<ProFormSwitch
|
||||
rules={[{ required: true, message: '请输入' }]}
|
||||
checkedChildren="启用"
|
||||
unCheckedChildren="禁用"
|
||||
name="status"
|
||||
label="是否启用"
|
||||
fieldProps={
|
||||
{
|
||||
defaultChecked: true
|
||||
}
|
||||
}
|
||||
/>
|
||||
</ProForm.Group>
|
||||
<ProForm.Group>
|
||||
<ProForm.Item label="图片" name="imageUrl">
|
||||
<FilesManager
|
||||
fileType="image"
|
||||
defaultValue={values?.imageUrl}
|
||||
count={1}
|
||||
mode=""
|
||||
/>
|
||||
</ProForm.Item>
|
||||
</ProForm.Group>
|
||||
</ProForm>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default RoleForm;
|
||||
Reference in New Issue
Block a user