董国庆
5 天以前 d0f4c2d4bb7a72b32fb9945de8908e1d4ab6509c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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