|
@@ -0,0 +1,249 @@
|
|
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 ImageListUpload from '../../../../../components/XForm/ImageListUpload'
|
|
9
|
+import Wangedit from '../../../../../components/Wangedit/Wangedit'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+const { Option } = Select;
|
|
13
|
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+const { Meta } = Card;
|
|
15
|
+
|
|
16
|
+const { TextArea } = Input;
|
|
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
|
+const houseType = [
|
|
45
|
+ {
|
|
46
|
+ id: '1',
|
|
47
|
+ name: '1室',
|
|
48
|
+ },
|
|
49
|
+ {
|
|
50
|
+ id: '2',
|
|
51
|
+ name: '2室',
|
|
52
|
+ },
|
|
53
|
+ {
|
|
54
|
+ id: '3',
|
|
55
|
+ name: '3室',
|
|
56
|
+ },
|
|
57
|
+ {
|
|
58
|
+ id: '4',
|
|
59
|
+ name: '4室',
|
|
60
|
+ },
|
|
61
|
+ {
|
|
62
|
+ id: '5',
|
|
63
|
+ name: '5室及以上',
|
|
64
|
+ },
|
|
65
|
+]
|
|
66
|
+
|
|
67
|
+/**
|
|
68
|
+ * 图片信息
|
|
69
|
+ *
|
|
70
|
+ * @param {*} props
|
|
71
|
+ * @returns
|
|
72
|
+ */
|
|
73
|
+class ModalPanoramaImage extends React.Component {
|
|
74
|
+ constructor(props) {
|
|
75
|
+ super(props);
|
|
76
|
+ this.state = {
|
|
77
|
+ visibleData: { visible: false, apartmentId: '', buildingId: '',panoramaType: "apartment" },
|
|
78
|
+ }
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ // 挂载之后
|
|
82
|
+ // componentDidMount() {
|
|
83
|
+ //
|
|
84
|
+ // }
|
|
85
|
+
|
|
86
|
+ componentDidUpdate(preProps, preState) {
|
|
87
|
+ if (this.props.visibleData.visible !== preState.visibleData.visible) {
|
|
88
|
+ console.log(this.props.visibleData)
|
|
89
|
+ this.getById()
|
|
90
|
+ this.setState({ visibleData: this.props.visibleData });
|
|
91
|
+ }
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ // 弹框确定按钮
|
|
95
|
+ // eslint-disable-next-line react/sort-comp
|
|
96
|
+ handleOk() {
|
|
97
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ // 弹框取消按钮
|
|
101
|
+ handleCancel() {
|
|
102
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ getById(params) {
|
|
106
|
+ const { apartmentId } = this.props.visibleData
|
|
107
|
+ if (apartmentId === '' || apartmentId === undefined) {
|
|
108
|
+ return
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ // 网路请求
|
|
112
|
+ request({ ...apis.building.buildingApartmentGetById, urlData: { id: apartmentId }, params: { ...params } }).then(res => {
|
|
113
|
+ // res.img = res.buildingImgList.map(item => item.url)
|
|
114
|
+ if (res.buildingImgList) {
|
|
115
|
+ res.img = res.buildingImgList[0].url
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ this.props.form.setFieldsValue(res)
|
|
119
|
+ }).catch(err => {
|
|
120
|
+ this.openNotificationWithIcon('error', err)
|
|
121
|
+ })
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ openNotificationWithIcon = (type, message) => {
|
|
125
|
+ notification[type]({
|
|
126
|
+ message,
|
|
127
|
+ description:
|
|
128
|
+ '',
|
|
129
|
+ });
|
|
130
|
+ };
|
|
131
|
+
|
|
132
|
+ // 提交
|
|
133
|
+ handleSubmit(e) {
|
|
134
|
+ e.preventDefault();
|
|
135
|
+ this.props.form.validateFields((err, values) => {
|
|
136
|
+ if (!err) {
|
|
137
|
+ this.submitData(values)
|
|
138
|
+ }
|
|
139
|
+ });
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ submitData(data) {
|
|
143
|
+ data.buildingId = this.props.visibleData.buildingId;
|
|
144
|
+ const api = apis.paorama.add;
|
|
145
|
+
|
|
146
|
+ // 网路请求
|
|
147
|
+ request({ ...api, data: { ...data } }).then(() => {
|
|
148
|
+ // eslint-disable-next-line no-unused-expressions
|
|
149
|
+ this.openNotificationWithIcon('success', '操作成功')
|
|
150
|
+
|
|
151
|
+ // 传递父组件事件
|
|
152
|
+ // onSuccess() 是自定义
|
|
153
|
+ this.props.onSuccess()
|
|
154
|
+
|
|
155
|
+ // this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } }, () => console.log('回调:', this.state.visibleData))
|
|
156
|
+ }).catch(err => {
|
|
157
|
+ // eslint-disable-next-line no-unused-expressions
|
|
158
|
+ this.openNotificationWithIcon('error', err)
|
|
159
|
+ })
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ radioOnChange(e) {
|
|
163
|
+ this.setState({ visibleData: { ...this.state.visibleData, panoramaType: e.target.value } })
|
|
164
|
+ }
|
|
165
|
+
|
|
166
|
+ /**
|
|
167
|
+ * 取消按钮
|
|
168
|
+ *
|
|
169
|
+ * @memberof ModalImage
|
|
170
|
+ */
|
|
171
|
+ closeModal() {
|
|
172
|
+ this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } })
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ render() {
|
|
176
|
+ const { getFieldDecorator } = this.props.form;
|
|
177
|
+ return (
|
|
178
|
+ <>
|
|
179
|
+ <Modal
|
|
180
|
+ title="新增全景图"
|
|
181
|
+ width={1100}
|
|
182
|
+ destroyOnClose="true"
|
|
183
|
+ footer={null}
|
|
184
|
+ visible={this.state.visibleData.visible}
|
|
185
|
+ onOk={() => this.handleOk()}
|
|
186
|
+ onCancel={e => this.handleCancel(e)}
|
|
187
|
+ >
|
|
188
|
+ <Form {...formItemLayout} onSubmit={e => this.handleSubmit(e)}>
|
|
189
|
+ <Form.Item label="全景类型">
|
|
190
|
+ {getFieldDecorator('panoramaType', {
|
|
191
|
+ rules: [
|
|
192
|
+ {
|
|
193
|
+ required: true,
|
|
194
|
+ message: '请选择全景类型',
|
|
195
|
+ },
|
|
196
|
+ ],
|
|
197
|
+ })(
|
|
198
|
+ <Radio.Group onChange={(e) => this.radioOnChange(e)}>
|
|
199
|
+ <Radio value="apartment">户型</Radio>
|
|
200
|
+ <Radio value="building">项目</Radio>
|
|
201
|
+ </Radio.Group>,
|
|
202
|
+ )}
|
|
203
|
+ </Form.Item>
|
|
204
|
+ { this.state.visibleData.panoramaType == "apartment" && <Form.Item label="全景内容">
|
|
205
|
+ {getFieldDecorator('apartmentId', {
|
|
206
|
+ rules: [{ required: true, message: '请选择全景内容' }],
|
|
207
|
+ })(
|
|
208
|
+ <Select placeholder="户型">
|
|
209
|
+ {
|
|
210
|
+ (this.state.visibleData.panoramaList || []).map((item, _) => <Option value={item.apartmentId}>{item.apartmentName}</Option>)
|
|
211
|
+ }
|
|
212
|
+ </Select>,
|
|
213
|
+ )}
|
|
214
|
+ </Form.Item>}
|
|
215
|
+ { this.state.visibleData.panoramaType == "building" && <Form.Item label="全景内容">
|
|
216
|
+ {getFieldDecorator('content', {
|
|
217
|
+ rules: [{ required: true, message: '请输入全景内容' }],
|
|
218
|
+ })(
|
|
219
|
+ <Input />,
|
|
220
|
+ )}
|
|
221
|
+ </Form.Item>}
|
|
222
|
+ <Form.Item label="选择封面" help="建议图片尺寸750px*600px,比例5:4,格式:jpg">
|
|
223
|
+ {getFieldDecorator('coverImg', {
|
|
224
|
+ rules: [{ required: true, message: '请上传封面图片' }],
|
|
225
|
+ })(
|
|
226
|
+ // <ImageListUpload />,
|
|
227
|
+ <ImageUpload />,
|
|
228
|
+ )}
|
|
229
|
+ </Form.Item>
|
|
230
|
+ <Form.Item label="链接地址">
|
|
231
|
+ {getFieldDecorator('panoramaLink', {
|
|
232
|
+ rules: [{ required: true, message: '请输入链接地址' }],
|
|
233
|
+ })(<Input />)}
|
|
234
|
+ </Form.Item>
|
|
235
|
+ <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
|
|
236
|
+ <Button type="primary" htmlType="submit">保存</Button>
|
|
237
|
+
|
|
238
|
+ <Button onClick={() => this.closeModal()}>取消</Button>
|
|
239
|
+ </Form.Item>
|
|
240
|
+ </Form>
|
|
241
|
+ </Modal>
|
|
242
|
+ </>
|
|
243
|
+ );
|
|
244
|
+ }
|
|
245
|
+}
|
|
246
|
+
|
|
247
|
+const WrappedModalPanoramaImageForm = Form.create({ name: 'modalPanoramaImage' })(ModalPanoramaImage);
|
|
248
|
+
|
|
249
|
+export default WrappedModalPanoramaImageForm
|