import { sendRequest } from '@/utils/antdUtils';
|
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
|
import { PageContainer, } from '@ant-design/pro-components';
|
import { Button, Select, Row, Col, Input, Card, Space, Form, Upload, Spin, message, InputNumber } from 'antd';
|
import { useState, useEffect } from 'react';
|
import { add,Edit, getDetail } from '../service';
|
import { history, useLocation } from 'umi';
|
import { customRequest } from '@/utils/utils';
|
const AddOrEditOrDetail = () => {
|
|
const config = {
|
name: 'file',
|
action: 'https://huacheng.psciio.com/api/huacheng-communitybackstage/communitypartybuilding/uploadimage',
|
headers: {
|
Authorization: 'Bearer ' + localStorage.getItem('token')
|
},
|
};
|
|
|
|
return (
|
<PageContainer title={searchParams.get('detail') ? '查看详情' : searchParams.get('id') ? '编辑banner' : '添加banner'}>
|
<Spin spinning={loading}>
|
<Form scrollToFirstError layout="horizontal" {...formItemLayout} form={form}>
|
<Card style={{ background: '#fff', paddingTop: '15px' }}>
|
<Row>
|
<Col span={12}>
|
<Form.Item
|
name="name"
|
label='banner名称' rules={[
|
{
|
required: true,
|
message: '请输入banner名称',
|
},
|
]}
|
>
|
<Input disabled={searchParams.get('detail')} placeholder='请输入banner名称'></Input>
|
</Form.Item>
|
|
<Form.Item
|
name="image"
|
label="banner图片"
|
extra={
|
<div>
|
<div>推荐尺寸732px * 320px</div>
|
</div>
|
}
|
rules={[
|
{
|
required: true,
|
message: '请上传banner图片',
|
},
|
]}
|
>
|
<Upload
|
{...config}
|
listType="picture-card"
|
maxCount={1}
|
beforeUpload={beforeUpload}
|
onChange={handleChange}
|
showUploadList={{
|
showPreviewIcon: false,
|
}}
|
// customRequest={customRequest}
|
accept="image/png, image/jpeg, image/jpg"
|
fileList={fileList}
|
disabled={searchParams.get('detail')}
|
>
|
{fileList?.length == 1 || searchParams.get('detail') ? null : uploadButton()}
|
</Upload>
|
</Form.Item>
|
</Col>
|
</Row>
|
<div style={{ display: 'flex', justifyContent: 'center' }}>
|
<Space size='large'>
|
<Button onClick={() => history.back()}>关闭</Button>
|
{
|
!searchParams.get('detail') && <Button type='primary' onClick={submit}>保存</Button>
|
}
|
</Space>
|
</div>
|
</Card>
|
</Form>
|
</Spin>
|
</PageContainer >
|
);
|
}
|
|
export default AddOrEditOrDetail
|