|
@@ -0,0 +1,223 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
|
|
3
|
+import moment from 'moment';
|
|
4
|
+import request from '../../../../../utils/request';
|
|
5
|
+import apis from '../../../../../services/apis';
|
|
6
|
+import Styles from '../style.less';
|
|
7
|
+import ImageUpload from '../../../../../components/XForm/ImageUpload'
|
|
8
|
+import Wangedit from '../../../../../components/Wangedit/Wangedit'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+const { Option } = Select;
|
|
12
|
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+const { Meta } = Card;
|
|
14
|
+
|
|
15
|
+const { TextArea } = Input;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+const formItemLayout = {
|
|
19
|
+ labelCol: {
|
|
20
|
+ xs: { span: 24 },
|
|
21
|
+ sm: { span: 2 },
|
|
22
|
+ },
|
|
23
|
+ wrapperCol: {
|
|
24
|
+ xs: { span: 24 },
|
|
25
|
+ sm: { span: 16 },
|
|
26
|
+ },
|
|
27
|
+};
|
|
28
|
+
|
|
29
|
+const saleType = [
|
|
30
|
+ {
|
|
31
|
+ id: 1,
|
|
32
|
+ name: '待定',
|
|
33
|
+ },
|
|
34
|
+ {
|
|
35
|
+ id: 2,
|
|
36
|
+ name: '售罄',
|
|
37
|
+ },
|
|
38
|
+ {
|
|
39
|
+ id: 3,
|
|
40
|
+ name: '在售',
|
|
41
|
+ },
|
|
42
|
+]
|
|
43
|
+
|
|
44
|
+/**
|
|
45
|
+ * 图片信息
|
|
46
|
+ *
|
|
47
|
+ * @param {*} props
|
|
48
|
+ * @returns
|
|
49
|
+ */
|
|
50
|
+class ModalImage extends React.Component {
|
|
51
|
+ constructor(props) {
|
|
52
|
+ super(props);
|
|
53
|
+ this.state = {
|
|
54
|
+ visibleData: { visible: false, apartmentId: '', buildingId: '' },
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ // 挂载之后
|
|
59
|
+ // componentDidMount() {
|
|
60
|
+ //
|
|
61
|
+ // }
|
|
62
|
+
|
|
63
|
+ componentDidUpdate(preProps, preState) {
|
|
64
|
+ console.log(this.props.visibleData)
|
|
65
|
+ if (this.props.visibleData.visible !== preState.visibleData.visible) {
|
|
66
|
+ this.getById()
|
|
67
|
+ this.setState({ visibleData: this.props.visibleData });
|
|
68
|
+ }
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ // 弹框确定按钮
|
|
72
|
+ // eslint-disable-next-line react/sort-comp
|
|
73
|
+ handleOk() {
|
|
74
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ // 弹框取消按钮
|
|
78
|
+ handleCancel() {
|
|
79
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ getById(params) {
|
|
83
|
+ const { apartmentId } = this.props.visibleData
|
|
84
|
+ if (apartmentId === '' || apartmentId === undefined) {
|
|
85
|
+ return
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+ // 网路请求
|
|
89
|
+ const { url, method } = apis.building.buildingApartmentGetById
|
|
90
|
+ const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(apartmentId)
|
|
91
|
+
|
|
92
|
+ request({ url: tempUrl, method , params: { ...params } }).then(res => {
|
|
93
|
+ // res.img = res.buildingImgList.map((item, _) => item.url)
|
|
94
|
+ res.img = res.buildingImgList[0].url
|
|
95
|
+ this.props.form.setFieldsValue(res)
|
|
96
|
+ }).catch(err => {
|
|
97
|
+ this.openNotificationWithIcon('error', err)
|
|
98
|
+ })
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ openNotificationWithIcon = (type, message) => {
|
|
102
|
+ notification[type]({
|
|
103
|
+ message,
|
|
104
|
+ description:
|
|
105
|
+ '',
|
|
106
|
+ });
|
|
107
|
+ };
|
|
108
|
+
|
|
109
|
+ // 提交
|
|
110
|
+ handleSubmit(e) {
|
|
111
|
+ e.preventDefault();
|
|
112
|
+ this.props.form.validateFields((err, values) => {
|
|
113
|
+ if (!err) {
|
|
114
|
+ this.submitData(values)
|
|
115
|
+ }
|
|
116
|
+ });
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ submitData(data) {
|
|
120
|
+ // TODO 这里应该是要支持多图,但是封装的控件没有
|
|
121
|
+ data.img = [{ imgType: 'aparment', url: data.img, orderNo: 1 }]
|
|
122
|
+ data.buildingId = this.props.visibleData.buildingId;
|
|
123
|
+ const api = data.apartmentId !== undefined ? apis.building.buildingApartmentUpdate : apis.building.buildingApartmentAdd;
|
|
124
|
+
|
|
125
|
+ // 网路请求
|
|
126
|
+ request({ ...api, data: { ...data } }).then(() => {
|
|
127
|
+ // eslint-disable-next-line no-unused-expressions
|
|
128
|
+ this.openNotificationWithIcon('success', '操作成功')
|
|
129
|
+
|
|
130
|
+ // 传递父组件事件
|
|
131
|
+ // onSuccess() 是自定义
|
|
132
|
+ this.props.onSuccess()
|
|
133
|
+
|
|
134
|
+ this.handleCancel()
|
|
135
|
+ }).catch(err => {
|
|
136
|
+ // eslint-disable-next-line no-unused-expressions
|
|
137
|
+ this.openNotificationWithIcon('error', err)
|
|
138
|
+ })
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ /**
|
|
142
|
+ * 取消按钮
|
|
143
|
+ *
|
|
144
|
+ * @memberof ModalImage
|
|
145
|
+ */
|
|
146
|
+ closeModal() {
|
|
147
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ render() {
|
|
151
|
+ const { getFieldDecorator } = this.props.form;
|
|
152
|
+ return (
|
|
153
|
+ <>
|
|
154
|
+ <Modal
|
|
155
|
+ title="图片信息"
|
|
156
|
+ width={1100}
|
|
157
|
+ destroyOnClose="true"
|
|
158
|
+ footer={null}
|
|
159
|
+ visible={this.state.visibleData.visible}
|
|
160
|
+ onOk={() => this.handleOk()}
|
|
161
|
+ onCancel={e => this.handleCancel(e)}
|
|
162
|
+ >
|
|
163
|
+ <Form {...formItemLayout} onSubmit={e => this.handleSubmit(e)}>
|
|
164
|
+ <Form.Item label="编号" style={{ display: 'none' }}>
|
|
165
|
+ {getFieldDecorator('apartmentId')(<Input />)}
|
|
166
|
+ </Form.Item>
|
|
167
|
+ <Form.Item label="名称">
|
|
168
|
+ {getFieldDecorator('apartmentName')(<Input />)}
|
|
169
|
+ </Form.Item>
|
|
170
|
+ <Form.Item label="类型">
|
|
171
|
+ {getFieldDecorator('apartmentType')(
|
|
172
|
+ <Select placeholder="类型">
|
|
173
|
+ <Option value="apart">户型</Option>
|
|
174
|
+ <Option value="photo">相册</Option>
|
|
175
|
+ </Select>,
|
|
176
|
+ )}
|
|
177
|
+ </Form.Item>
|
|
178
|
+ <Form.Item label="销售状态">
|
|
179
|
+ {getFieldDecorator('marketStatus')(
|
|
180
|
+ <Select placeholder="销售状态">
|
|
181
|
+ {
|
|
182
|
+ saleType.map((item, _) => <Option value={item.id}>{item.name}</Option>)
|
|
183
|
+ }
|
|
184
|
+ </Select>,
|
|
185
|
+ )}
|
|
186
|
+ </Form.Item>
|
|
187
|
+ <Form.Item label="图片">
|
|
188
|
+ {getFieldDecorator('img')(
|
|
189
|
+ <ImageUpload />,
|
|
190
|
+ )}
|
|
191
|
+ </Form.Item>
|
|
192
|
+ <Form.Item label="面积">
|
|
193
|
+ {getFieldDecorator('buildingArea')(<Input />)}
|
|
194
|
+ </Form.Item>
|
|
195
|
+ <Form.Item label="套内面积">
|
|
196
|
+ {getFieldDecorator('insideArea')(<Input />)}
|
|
197
|
+ </Form.Item>
|
|
198
|
+ <Form.Item label="户型总价">
|
|
199
|
+ {getFieldDecorator('apartmentPrice')(<Input />)}
|
|
200
|
+ </Form.Item>
|
|
201
|
+ <Form.Item label="户型简介">
|
|
202
|
+ {getFieldDecorator('apartmentDescription')(
|
|
203
|
+ <Wangedit />,
|
|
204
|
+ )}
|
|
205
|
+ </Form.Item>
|
|
206
|
+ <Form.Item label="备注">
|
|
207
|
+ {getFieldDecorator('remark')(<TextArea rows={10} />)}
|
|
208
|
+ </Form.Item>
|
|
209
|
+ <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
|
|
210
|
+ <Button type="primary" htmlType="submit">保存</Button>
|
|
211
|
+
|
|
212
|
+ <Button onClick={() => this.closeModal()}>取消</Button>
|
|
213
|
+ </Form.Item>
|
|
214
|
+ </Form>
|
|
215
|
+ </Modal>
|
|
216
|
+ </>
|
|
217
|
+ );
|
|
218
|
+ }
|
|
219
|
+}
|
|
220
|
+
|
|
221
|
+const WrappedModalImageForm = Form.create({ name: 'modalImage' })(ModalImage);
|
|
222
|
+
|
|
223
|
+export default WrappedModalImageForm
|