Преглед на файлове

Merge branch 'master' of http://git.ycjcjy.com/marketing/pc-admin

baozhangchao преди 3 години
родител
ревизия
3263a02e4f

+ 1
- 1
config/proxy.js Целия файл

@@ -8,7 +8,7 @@
8 8
 export default {
9 9
   dev: {
10 10
     '/api/': {
11
-      target: 'http://81.69.196.8:8567/',
11
+      target: 'https://xlk.njyz.tech/',
12 12
       changeOrigin: true,
13 13
       pathRewrite: {
14 14
         '^': '',

+ 10
- 6
src/models/user.js Целия файл

@@ -13,12 +13,16 @@ const UserModel = {
13 13
   },
14 14
   effects: {
15 15
     *fetchCurrent(_, { call, put }) {
16
-      const response = yield call(getCurrentUser);
17
-
18
-      yield put({
19
-        type: 'saveCurrentUser',
20
-        payload: response,
21
-      });
16
+      try {
17
+        const response = yield call(getCurrentUser);
18
+  
19
+        yield put({
20
+          type: 'saveCurrentUser',
21
+          payload: response,
22
+        });
23
+      } catch (err) {
24
+        console.error(err)
25
+      }
22 26
     },
23 27
   },
24 28
   reducers: {

+ 31
- 0
src/pages/building/Edit/Basic/form.js Целия файл

@@ -0,0 +1,31 @@
1
+export function initForm(form, data) {
2
+  if (!data) return;
3
+
4
+  const formData = { ...data }
5
+  // 交房时间
6
+  if (data.receivedDate) {
7
+    formData.receivedDate = moment(data.receivedDate)
8
+  }
9
+
10
+  // 主图 - 多个
11
+  if (data.buildingImg) {
12
+    formData.avatarImage = data.buildingImg.map((x) => x.url)
13
+  }
14
+
15
+  // 封面 - 一个
16
+  if (data.buildingListImg) {
17
+    formData.listImage = data.buildingListImg.map(item => item.url)[0]
18
+  }
19
+
20
+  // 视频
21
+  if (data.videoUrl) {
22
+    formData.videoUrl = [].concat(data.videoUrl)
23
+  }
24
+
25
+  // 视频封面
26
+  if (data.videoImage) {
27
+    formData.videoImage = data.videoImage[0].url
28
+  }
29
+
30
+  form.setFieldsValue(formData);
31
+}

+ 0
- 53
src/pages/building/Edit/Basic/getData.js Целия файл

@@ -1,53 +0,0 @@
1
-import moment from 'moment'
2
-import { fetch, apis } from '@/utils/request'
3
-
4
-export default (id) => {
5
-  if (!id) {
6
-    return Promise.reject('没有找到有效的项目ID');
7
-  }
8
-
9
-  return new Promise((resolve, reject) => {
10
-    fetch(apis.building.buildingGetById)({ urlData: { id } }).then((res) => {
11
-      const data = { ...res }
12
-
13
-      // 交房时间
14
-      if (res.receivedDate) {
15
-        data.receivedDate = moment(res.receivedDate)
16
-      }
17
-
18
-      // 标签
19
-      if (res.buildingTag) {
20
-        data.tag = res.buildingTag.map((x) => x.tagName)
21
-      }
22
-
23
-      // 主图 - 多个
24
-      if (res.buildingImg) {
25
-        data.avatarImage = res.buildingImg.map((x) => x.url)
26
-      }
27
-
28
-      // 封面 - 一个
29
-      if (res.buildingListImg) {
30
-        data.listImage = res.buildingListImg.map(item => item.url)[0]
31
-      }
32
-
33
-      // 视频
34
-      if (res.videoUrl) {
35
-        data.videoUrl = [].concat(res.videoUrl)
36
-      }
37
-
38
-      // 视频封面
39
-      if (res.videoImage) {
40
-        data.videoImage = res.videoImage[0].url
41
-      }
42
-
43
-      // POI 相关
44
-      if (res.mapJson) {
45
-        data.mapJson = JSON.parse(res.mapJson) || []
46
-      }
47
-
48
-      resolve(data)
49
-    }).catch((err) => {
50
-      reject(err.message || err)
51
-    })
52
-  })
53
-}

+ 315
- 297
src/pages/building/Edit/Basic/index.jsx Целия файл

@@ -12,27 +12,40 @@ import OpenTimePicker from '../components/OpenTimePicker'
12 12
 import EditableArround from '../components/EditableArround'
13 13
 import FormGroupItem, { gourpItemLayout } from '../components/FormGroupItem'
14 14
 import { formItemLayout, validMinNum } from '../utils'
15
-import useTags from './tag'
15
+import useArrounds from './useArrounds'
16
+import usePois from './usePois'
17
+import useQuery from './useQuery'
18
+import { initForm } from './form'
16 19
 
17 20
 const fullWidth= { width: '100%' }
18 21
 const Item = Form.Item
19 22
 
20 23
 const BuildingBasic = React.forwardRef((props, ref) => {
21
-  const { form } = props;
24
+  const { form, history } = props;
22 25
   const { getFieldDecorator, getFieldValue, setFieldsValue } = form;
26
+  const { query } = history.location;
27
+  const { id } = query;
23 28
 
24
-  const [ loading, setLoading ] = useState({ arround: false })
29
+  const [ loading, setLoading ] = useState({ form: false, arround: false })
25 30
   const [
26
-    tags,
27
-    initTags,
28
-    updateTags,
29
-    deletePoi,
31
+    arrounds,
32
+    initArrounds,
33
+    updateArrounds,
34
+    deleteArround,
35
+  ] = useArrounds()
36
+  const [
37
+    pois,
30 38
     initPois,
31
-    pois2Tags,
32
-    // updatePois,
33
-    deleteTag,
34
-    updatePoisAndTags,
35
-  ] = useTags()
39
+    deletePoi,
40
+  ] = usePois()
41
+
42
+  const updateLoading = (key) => (state) => setLoading({ ...loading, [key]: state })
43
+
44
+  useQuery(id, updateLoading('form'), (res) => {
45
+    initPois(res.mapJson)
46
+    initArrounds(res)
47
+    initForm(form, res)
48
+  })
36 49
   
37 50
   // 视频文件上传前 回调
38 51
   const fileUploadBeforeUpload = (file, fileList) => {
@@ -67,322 +80,327 @@ const BuildingBasic = React.forwardRef((props, ref) => {
67 80
         }
68 81
       }, {})
69 82
 
70
-      updatePoisAndTags(pois)
83
+      initPois(pois, true)
71 84
       setLoading({ ...loading, arround: false })
72 85
     }).catch((err) => {
73 86
       setLoading({ ...loading, arround: false })
74 87
       console.error(err)
75 88
       notification.error({ message: '周边数据获取异常' })
76 89
     })
77
-
78
-    // POI_TYPES.forEach(({ key }) => {
79
-    //   getPoiData({ type: key, location: lngLat, radius: e }).then(res => {
80
-    //     updatePois(key, res.pois || [])
81
-    //   }).catch(err => {
82
-    //     console.error(err)
83
-    //     notification.error({ message: '周边数据获取失败' })
84
-    //   })
85
-    // })
86 90
   }
87 91
 
88 92
   return (
89
-    <Form {...formItemLayout}>
90
-      <Item label="项目Id" style={{ display: 'none' }}>
91
-        {getFieldDecorator('buildingId')(<Input disabled />)}
92
-      </Item>
93
-      <Item label="楼盘编号" >
94
-        {getFieldDecorator('code', {
95
-          rules: [{ required: true, message: '请输入楼盘编号' }],
96
-        })(<Input />)}
97
-      </Item>
98
-      <Item label="楼盘名称" >
99
-        {getFieldDecorator('buildingName', {
100
-          rules: [{ required: true, message: '请输入楼盘名' }],
101
-        })(<Input />)}
102
-      </Item>
103
-      <Form.Item label="项目类型">
104
-        {getFieldDecorator('buildingProjectType', {
105
-          rules: [{ required: true, message: '请选择项目类型' }],
106
-        })(<BuildingType />)}
107
-      </Form.Item>
108
-      <Form.Item label="列表均价" help="项目列表展示价格,示例:约10000元/㎡、约1000万元/套起">
109
-        {getFieldDecorator('price')(<Input />)}
110
-      </Form.Item>
111
-      <FormGroupItem>
112
-        <Form.Item label="开盘时间" {...gourpItemLayout.ab.a} >
113
-          {getFieldDecorator('openingDate')(
114
-            <OpenTimePicker placeholder="请选择开盘时间" style={fullWidth} />
115
-          )}
93
+    <Spin spinning={loading.form}>
94
+      <Form {...formItemLayout}>
95
+        <Item label="项目Id" style={{ display: 'none' }}>
96
+          {getFieldDecorator('buildingId')(<Input disabled />)}
97
+        </Item>
98
+        <Item label="楼盘编号" >
99
+          {getFieldDecorator('code', {
100
+            rules: [{ required: true, message: '请输入楼盘编号' }],
101
+          })(<Input />)}
102
+        </Item>
103
+        <Item label="楼盘名称" >
104
+          {getFieldDecorator('buildingName', {
105
+            rules: [{ required: true, message: '请输入楼盘名' }],
106
+          })(<Input />)}
107
+        </Item>
108
+        <Form.Item label="项目类型">
109
+          {getFieldDecorator('buildingProjectType', {
110
+            rules: [{ required: true, message: '请选择项目类型' }],
111
+          })(<BuildingType />)}
116 112
         </Form.Item>
117
-        <Form.Item label="电话" {...gourpItemLayout.ab.b } >
118
-          {getFieldDecorator('tel', {
119
-            rules: [
120
-              {
121
-                pattern: new RegExp('^[0-9]*$'),
122
-                message: '请输入正确的电话号码',
123
-              },
124
-            ],
125
-          })(<Input placeholder="手机或者座机号码" />)}
113
+        <Form.Item label="列表均价" help="项目列表展示价格,示例:约10000元/㎡、约1000万元/套起">
114
+          {getFieldDecorator('price')(<Input />)}
126 115
         </Form.Item>
127
-      </FormGroupItem>
128
-      <Form.Item label="项目说明" >
129
-        {getFieldDecorator('dynamic')(<Input placeholder="项目动态等,不超过30个字" maxLength={30}/>)}
130
-      </Form.Item>
131
-      {/* <Form.Item label="物业类型" >
132
-        {getFieldDecorator('propertyType')(<Input />)}
133
-      </Form.Item> */}
134
-      <Form.Item label="销售状态" >
135
-        {getFieldDecorator('marketStatus', {
136
-          rules: [{ required: true, message: '请选择销售状态' }],
137
-        })(
138
-          <Select placeholder="销售状态" style={fullWidth}>
139
-            <Select.Option value="待售">待售</Select.Option>
140
-            <Select.Option value="在售">在售</Select.Option>
141
-            <Select.Option value="售罄">售罄</Select.Option>
142
-            <Select.Option value="在租">在租</Select.Option>
143
-          </Select>,
144
-        )}
145
-      </Form.Item>
146
-      <Form.Item label="项目标签" >
147
-        {getFieldDecorator('tag')(
148
-          <Select mode="tags" placeholder="输入后选中" style={fullWidth} />
149
-        )}
150
-      </Form.Item>
151
-
152
-      <FormGroupItem>
153
-        <Form.Item label="项目视频" help="视频仅支持mp4格式,建议尺寸:750*600,比例5:4,用于楼盘详情" {...gourpItemLayout.ab.a} >
154
-          {getFieldDecorator('videoUrl')(
155
-            <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频" size={1} />,
156
-          )}
116
+        <FormGroupItem>
117
+          <Form.Item label="开盘时间" {...gourpItemLayout.ab.a} >
118
+            {getFieldDecorator('openingDate')(
119
+              <OpenTimePicker placeholder="请选择开盘时间" style={fullWidth} />
120
+            )}
121
+          </Form.Item>
122
+          <Form.Item label="电话" {...gourpItemLayout.ab.b } >
123
+            {getFieldDecorator('tel', {
124
+              rules: [
125
+                {
126
+                  pattern: new RegExp('^[0-9]*$'),
127
+                  message: '请输入正确的电话号码',
128
+                },
129
+              ],
130
+            })(<Input placeholder="手机或者座机号码" />)}
131
+          </Form.Item>
132
+        </FormGroupItem>
133
+        <Form.Item label="项目说明" >
134
+          {getFieldDecorator('dynamic')(<Input placeholder="项目动态等,不超过30个字" maxLength={30}/>)}
157 135
         </Form.Item>
158
-        <Form.Item label="视频封面图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于视频封面" labelCol={{span: 8}} wrapperCol={{span:16}}>
159
-          {getFieldDecorator('videoImage')(
160
-            <ImageUpload />,
136
+        {/* <Form.Item label="物业类型" >
137
+          {getFieldDecorator('propertyType')(<Input />)}
138
+        </Form.Item> */}
139
+        <Form.Item label="销售状态" >
140
+          {getFieldDecorator('marketStatus', {
141
+            rules: [{ required: true, message: '请选择销售状态' }],
142
+          })(
143
+            <Select placeholder="销售状态" style={fullWidth}>
144
+              <Select.Option value="待售">待售</Select.Option>
145
+              <Select.Option value="在售">在售</Select.Option>
146
+              <Select.Option value="售罄">售罄</Select.Option>
147
+              <Select.Option value="在租">在租</Select.Option>
148
+            </Select>,
161 149
           )}
162 150
         </Form.Item>
163
-      </FormGroupItem>
164
-      <Form.Item label="楼盘主图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘详情">
165
-        {getFieldDecorator('avatarImage', {
166
-          rules: [{ required: true, message: '请选择项目主图' }],
167
-        })(
168
-          <ImageListUpload unlimited />,
169
-        )}
170
-      </Form.Item>
171
-      <Form.Item label="楼盘封面图" help="建议图片尺寸:750*420px,比例16:9,格式:jpg,用于楼盘列表">
172
-        {getFieldDecorator('listImage', {
173
-          rules: [{ required: true, message: '请选择列表图' }],
174
-        })(
175
-          <ImageUpload />,
176
-        )}
177
-      </Form.Item>
178
-      <FormGroupItem>
179
-        <Form.Item label="首页推荐" {...gourpItemLayout.ab.a} >
180
-          {getFieldDecorator('isMain', { initialValue: 1 })(
181
-            <Radio.Group>
182
-              <Radio value={1}>是</Radio>
183
-              <Radio value={2}>否</Radio>
184
-            </Radio.Group>,
151
+        <Form.Item label="项目标签" >
152
+          {getFieldDecorator('tag')(
153
+            <Select mode="tags" placeholder="输入后选中" style={fullWidth} />
185 154
           )}
186 155
         </Form.Item>
187
-        <Form.Item label="排序" help="数值越大,楼盘在小程序列表页中展示越靠前" {...gourpItemLayout.ab.b}>
188
-          {getFieldDecorator('orderNo')(<InputNumber min={0} style={fullWidth} />)}
189
-        </Form.Item>
190
-      </FormGroupItem>
191
-      <FormGroupItem>
192
-        <Form.Item label="所在城市" {...gourpItemLayout.ab.a } >
193
-          {getFieldDecorator('cityId', {
194
-            rules: [{ required: true, message: '请选择城市' }],
156
+
157
+        <FormGroupItem>
158
+          <Form.Item label="项目视频" help="视频仅支持mp4格式,建议尺寸:750*600,比例5:4,用于楼盘详情" {...gourpItemLayout.ab.a} >
159
+            {getFieldDecorator('videoUrl')(
160
+              <FileUpload accept=".mp4" beforeUpload={fileUploadBeforeUpload} label="上传视频" size={1} />,
161
+            )}
162
+          </Form.Item>
163
+          <Form.Item label="视频封面图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于视频封面" labelCol={{span: 8}} wrapperCol={{span:16}}>
164
+            {getFieldDecorator('videoImage')(
165
+              <ImageUpload />,
166
+            )}
167
+          </Form.Item>
168
+        </FormGroupItem>
169
+        <Form.Item label="楼盘主图" help="建议图片尺寸:750*600px,比例5:4,格式:jpg,用于楼盘详情">
170
+          {getFieldDecorator('avatarImage', {
171
+            rules: [{ required: true, message: '请选择项目主图' }],
195 172
           })(
196
-            <SelectCity style={fullWidth} />,
173
+            <ImageListUpload unlimited />,
197 174
           )}
198 175
         </Form.Item>
199
-        <Form.Item label="楼盘区域" {...gourpItemLayout.ab.b } >
200
-          {getFieldDecorator('buildingArea', {
201
-            rules: [{ required: true, message: '请输入楼盘区域' }],
202
-          })(<AreaSelect style={fullWidth} />)}
203
-        </Form.Item>
204
-      </FormGroupItem>
205
-      <Form.Item label="项目地址" >
206
-        {getFieldDecorator('address', {
207
-          rules: [{ required: true, message: '请输入项目地址' }],
208
-        })(<Input />)}
209
-      </Form.Item>
210
-      <Form.Item label="项目坐标" >
211
-        {getFieldDecorator('coordinate', {
212
-          rules: [{ required: true, message: '请输入项目坐标' }],
213
-        })(<Amap onChange={e => setFieldsValue({ coordinate: e })} />)}
214
-      </Form.Item>
215
-      <Form.Item label="周边范围" >
216
-        {getFieldDecorator('mapScope', {
217
-          rules: [{ required: true, message: '请选择周边设施搜索范围' }],
218
-        })(
219
-          <Select placeholder="周边设施搜索范围" style={fullWidth} onChange={handleMapScopeChange}>
220
-            <Select.Option value={1000}>1公里</Select.Option>
221
-            <Select.Option value={3000}>3公里</Select.Option>
222
-            <Select.Option value={5000}>5公里</Select.Option>
223
-            <Select.Option value={10000}>10公里</Select.Option>
224
-          </Select>,
225
-        )}
226
-      </Form.Item>
227
-      <Spin spinning={loading.arround}>
228
-        <Form.Item label="周边交通" >
229
-          <EditableArround
230
-            tags={tags.buildingTransport}
231
-            onChange={(e) => updateTags('buildingTransport', e)}
232
-            onDelete={(tag) => deleteTag('buildingTransport', tag)}
233
-            onPoiDelete={(poi) => deletePoi('Transport', poi)}
234
-          />
235
-        </Form.Item>
236
-        <Form.Item label="周边商业" >
237
-          <EditableArround
238
-            tags={tags.buildingMall}
239
-            onChange={(e) => updateTags('buildingMall', e)}
240
-            onDelete={(tag) => deleteTag('buildingMall', tag)}
241
-            onPoiDelete={(poi) => deletePoi('Mall', poi)}
242
-          />
243
-        </Form.Item>
244
-        <Form.Item label="周边学校" >
245
-          <EditableArround
246
-            tags={tags.buildingEdu}
247
-            onChange={(e) => updateTags('buildingEdu', e)}
248
-            onDelete={(tag) => deleteTag('buildingEdu', tag)}
249
-            onPoiDelete={(poi) => deletePoi('Edu', poi)}
250
-          />
251
-        </Form.Item>
252
-        <Form.Item label="周边医院" >
253
-          <EditableArround
254
-            tags={tags.buildingHospital}
255
-            onChange={(e) => updateTags('buildingHospital', e)}
256
-            onDelete={(tag) => deleteTag('buildingHospital', tag)}
257
-            onPoiDelete={(poi) => deletePoi('Hospital', poi)}
258
-          />
259
-        </Form.Item>
260
-        <Form.Item label="周边银行" >
261
-          <EditableArround
262
-            tags={tags.buildingBank}
263
-            onChange={(e) => updateTags('buildingBank', e)}
264
-            onDelete={(tag) => deleteTag('buildingBank', tag)}
265
-            onPoiDelete={(poi) => deletePoi('Bank', poi)}
266
-          />
267
-        </Form.Item>
268
-        <Form.Item label="周边餐饮" >
269
-          <EditableArround
270
-            tags={tags.buildingRestaurant}
271
-            onChange={(e) => updateTags('buildingRestaurant', e)}
272
-            onDelete={(tag) => deleteTag('buildingRestaurant', tag)}
273
-            onPoiDelete={(poi) => deletePoi('Restaurant', poi)}
274
-          />
275
-        </Form.Item>
276
-      </Spin>
277
-      <FormGroupItem>
278
-        <Form.Item label="绿化率" {...gourpItemLayout.ab.a } >
279
-          {getFieldDecorator('greeningRate')(<Input />)}
280
-        </Form.Item>
281
-        <Form.Item label="容积率" {...gourpItemLayout.ab.b }>
282
-          {getFieldDecorator('volumeRate')(<Input />)}
176
+        <Form.Item label="楼盘封面图" help="建议图片尺寸:750*420px,比例16:9,格式:jpg,用于楼盘列表">
177
+          {getFieldDecorator('listImage', {
178
+            rules: [{ required: true, message: '请选择列表图' }],
179
+          })(
180
+            <ImageUpload />,
181
+          )}
283 182
         </Form.Item>
284
-      </FormGroupItem>
285
-      <FormGroupItem>
286
-        <Form.Item label="车位数量" {...gourpItemLayout.ab.a }>
287
-          {getFieldDecorator('parkingRate', {
288
-            rules: [{ validator: validMinNum }]
289
-          })(<InputNumber min={0} style={fullWidth}/>)}
183
+        <FormGroupItem>
184
+          <Form.Item label="首页推荐" {...gourpItemLayout.ab.a} >
185
+            {getFieldDecorator('isMain', { initialValue: 1 })(
186
+              <Radio.Group>
187
+                <Radio value={1}>是</Radio>
188
+                <Radio value={2}>否</Radio>
189
+              </Radio.Group>,
190
+            )}
191
+          </Form.Item>
192
+          <Form.Item label="排序" help="数值越大,楼盘在小程序列表页中展示越靠前" {...gourpItemLayout.ab.b}>
193
+            {getFieldDecorator('orderNo')(<InputNumber min={0} style={fullWidth} />)}
194
+          </Form.Item>
195
+        </FormGroupItem>
196
+        <FormGroupItem>
197
+          <Form.Item label="所在城市" {...gourpItemLayout.ab.a } >
198
+            {getFieldDecorator('cityId', {
199
+              rules: [{ required: true, message: '请选择城市' }],
200
+            })(
201
+              <SelectCity style={fullWidth} />,
202
+            )}
203
+          </Form.Item>
204
+          <Form.Item label="楼盘区域" {...gourpItemLayout.ab.b } >
205
+            {getFieldDecorator('buildingArea', {
206
+              rules: [{ required: true, message: '请输入楼盘区域' }],
207
+            })(<AreaSelect style={fullWidth} />)}
208
+          </Form.Item>
209
+        </FormGroupItem>
210
+        <Form.Item label="项目地址" >
211
+          {getFieldDecorator('address', {
212
+            rules: [{ required: true, message: '请输入项目地址' }],
213
+          })(<Input />)}
290 214
         </Form.Item>
291
-        <Form.Item label="规划户数" {...gourpItemLayout.ab.b }>
292
-          {getFieldDecorator('familyNum', {
293
-            rules: [{ validator: validMinNum }]
294
-          })(<InputNumber min={0} style={fullWidth}/>)}
215
+        <Form.Item label="项目坐标" >
216
+          {getFieldDecorator('coordinate', {
217
+            rules: [{ required: true, message: '请输入项目坐标' }],
218
+          })(<Amap onChange={e => setFieldsValue({ coordinate: e })} />)}
295 219
         </Form.Item>
296
-      </FormGroupItem>
297
-      <FormGroupItem>
298
-        <Form.Item label="供水" {...gourpItemLayout.abc.a }>
299
-          {getFieldDecorator('waterSupply')(
300
-            <Select style={fullWidth}>
301
-              <Select.Option value="民水">民水</Select.Option>
302
-              <Select.Option value="商用">商用</Select.Option>
303
-            </Select>
220
+        <Form.Item label="周边范围" >
221
+          {getFieldDecorator('mapScope', {
222
+            rules: [{ required: true, message: '请选择周边设施搜索范围' }],
223
+          })(
224
+            <Select placeholder="周边设施搜索范围" style={fullWidth} onChange={handleMapScopeChange}>
225
+              <Select.Option value={1000}>1公里</Select.Option>
226
+              <Select.Option value={3000}>3公里</Select.Option>
227
+              <Select.Option value={5000}>5公里</Select.Option>
228
+              <Select.Option value={10000}>10公里</Select.Option>
229
+            </Select>,
304 230
           )}
305 231
         </Form.Item>
306
-        <Form.Item label="供电" {...gourpItemLayout.abc.b }>
307
-          {getFieldDecorator('powerSupply')(
308
-            <Select style={fullWidth}>
309
-              <Select.Option value="民电">民电</Select.Option>
310
-              <Select.Option value="商用">商用</Select.Option>
311
-            </Select>
312
-          )}
232
+        <Spin spinning={loading.arround}>
233
+          <Form.Item label="周边交通" >
234
+            <EditableArround
235
+              type="Transport"
236
+              pois={pois.Transport}
237
+              tags={arrounds.buildingTransport}
238
+              onChange={(e) => updateArrounds('buildingTransport', e)}
239
+              onDelete={deleteArround}
240
+              onPoiDelete={(poi) => deletePoi('Transport', poi)}
241
+            />
242
+          </Form.Item>
243
+          <Form.Item label="周边商业" >
244
+            <EditableArround
245
+              type="Mall"
246
+              pois={pois.Mall}
247
+              tags={arrounds.buildingMall}
248
+              onChange={(e) => updateArrounds('buildingMall', e)}
249
+              onDelete={deleteArround}
250
+              onPoiDelete={(poi) => deletePoi('Mall', poi)}
251
+            />
252
+          </Form.Item>
253
+          <Form.Item label="周边学校" >
254
+            <EditableArround
255
+              type="Edu"
256
+              pois={pois.Edu}
257
+              tags={arrounds.buildingEdu}
258
+              onChange={(e) => updateArrounds('buildingEdu', e)}
259
+              onDelete={deleteArround}
260
+              onPoiDelete={(poi) => deletePoi('Edu', poi)}
261
+            />
262
+          </Form.Item>
263
+          <Form.Item label="周边医院" >
264
+            <EditableArround
265
+              type="Hospital"
266
+              pois={pois.Hospital}
267
+              tags={arrounds.buildingHospital}
268
+              onChange={(e) => updateArrounds('buildingHospital', e)}
269
+              onDelete={deleteArround}
270
+              onPoiDelete={(poi) => deletePoi('Hospital', poi)}
271
+            />
272
+          </Form.Item>
273
+          <Form.Item label="周边银行" >
274
+            <EditableArround
275
+              type="Bank"
276
+              pois={pois.Bank}
277
+              tags={arrounds.buildingBank}
278
+              onChange={(e) => updateArrounds('buildingBank', e)}
279
+              onDelete={deleteArround}
280
+              onPoiDelete={(poi) => deletePoi('Bank', poi)}
281
+            />
282
+          </Form.Item>
283
+          <Form.Item label="周边餐饮" >
284
+            <EditableArround
285
+              type="Restaurant"
286
+              pois={pois.Restaurant}
287
+              tags={arrounds.buildingRestaurant}
288
+              onChange={(e) => updateArrounds('buildingRestaurant', e)}
289
+              onDelete={deleteArround}
290
+              onPoiDelete={(poi) => deletePoi('Restaurant', poi)}
291
+            />
292
+          </Form.Item>
293
+        </Spin>
294
+        <FormGroupItem>
295
+          <Form.Item label="绿化率" {...gourpItemLayout.ab.a } >
296
+            {getFieldDecorator('greeningRate')(<Input />)}
297
+          </Form.Item>
298
+          <Form.Item label="容积率" {...gourpItemLayout.ab.b }>
299
+            {getFieldDecorator('volumeRate')(<Input />)}
300
+          </Form.Item>
301
+        </FormGroupItem>
302
+        <FormGroupItem>
303
+          <Form.Item label="车位数量" {...gourpItemLayout.ab.a }>
304
+            {getFieldDecorator('parkingRate', {
305
+              rules: [{ validator: validMinNum }]
306
+            })(<InputNumber min={0} style={fullWidth}/>)}
307
+          </Form.Item>
308
+          <Form.Item label="规划户数" {...gourpItemLayout.ab.b }>
309
+            {getFieldDecorator('familyNum', {
310
+              rules: [{ validator: validMinNum }]
311
+            })(<InputNumber min={0} style={fullWidth}/>)}
312
+          </Form.Item>
313
+        </FormGroupItem>
314
+        <FormGroupItem>
315
+          <Form.Item label="供水" {...gourpItemLayout.abc.a }>
316
+            {getFieldDecorator('waterSupply')(
317
+              <Select style={fullWidth}>
318
+                <Select.Option value="民水">民水</Select.Option>
319
+                <Select.Option value="商用">商用</Select.Option>
320
+              </Select>
321
+            )}
322
+          </Form.Item>
323
+          <Form.Item label="供电" {...gourpItemLayout.abc.b }>
324
+            {getFieldDecorator('powerSupply')(
325
+              <Select style={fullWidth}>
326
+                <Select.Option value="民电">民电</Select.Option>
327
+                <Select.Option value="商用">商用</Select.Option>
328
+              </Select>
329
+            )}
330
+          </Form.Item>
331
+          <Form.Item label="供暖" {...gourpItemLayout.abc.c }>
332
+            {getFieldDecorator('heatingSupply')(
333
+              <Select style={fullWidth}>
334
+                <Select.Option value="集中供暖">集中供暖</Select.Option>
335
+                <Select.Option value="自采暖">自采暖</Select.Option>
336
+              </Select>
337
+            )}
338
+          </Form.Item>
339
+        </FormGroupItem>
340
+        <Form.Item label="物业公司" >
341
+          {getFieldDecorator('serviceCompany', {
342
+            rules: [{ max: 30, message: '不超过30个字' }]
343
+          })(<Input placeholder="不超过30个字"/>)}
313 344
         </Form.Item>
314
-        <Form.Item label="供暖" {...gourpItemLayout.abc.c }>
315
-          {getFieldDecorator('heatingSupply')(
316
-            <Select style={fullWidth}>
317
-              <Select.Option value="集中供暖">集中供暖</Select.Option>
318
-              <Select.Option value="自采暖">自采暖</Select.Option>
319
-            </Select>
320
-          )}
345
+        <Form.Item label="物业费" >
346
+          {getFieldDecorator('serviceFee', {
347
+            rules: [{ max: 30, message: '不超过30个字' }]
348
+          })(<Input placeholder="不超过30个字"/>)}
321 349
         </Form.Item>
322
-      </FormGroupItem>
323
-      <Form.Item label="物业公司" >
324
-        {getFieldDecorator('serviceCompany', {
325
-          rules: [{ max: 30, message: '不超过30个字' }]
326
-        })(<Input placeholder="不超过30个字"/>)}
327
-      </Form.Item>
328
-      <Form.Item label="物业费" >
329
-        {getFieldDecorator('serviceFee', {
330
-          rules: [{ max: 30, message: '不超过30个字' }]
331
-        })(<Input placeholder="不超过30个字"/>)}
332
-      </Form.Item>
333
-      <FormGroupItem>
334
-        <Form.Item label="装修标准" {...gourpItemLayout.ab.a }>
335
-          {getFieldDecorator('decoration')(
336
-            <Select style={fullWidth}>
337
-              <Select.Option value="精装">精装</Select.Option>
338
-              <Select.Option value="毛坯">毛坯</Select.Option>
339
-            </Select>
340
-          )}
350
+        <FormGroupItem>
351
+          <Form.Item label="装修标准" {...gourpItemLayout.ab.a }>
352
+            {getFieldDecorator('decoration')(
353
+              <Select style={fullWidth}>
354
+                <Select.Option value="精装">精装</Select.Option>
355
+                <Select.Option value="毛坯">毛坯</Select.Option>
356
+              </Select>
357
+            )}
358
+          </Form.Item>
359
+          <Form.Item label="楼栋总数" {...gourpItemLayout.ab.b }>
360
+            {getFieldDecorator('buildingNum', {
361
+              rules: [{ validator: validMinNum }]
362
+            })(<InputNumber style={fullWidth}/>)}
363
+          </Form.Item>
364
+        </FormGroupItem>
365
+        <FormGroupItem>
366
+          <Form.Item label="交房时间" {...gourpItemLayout.ab.a }>
367
+            {getFieldDecorator('receivedDate')(<DatePicker style={fullWidth}/>)}
368
+          </Form.Item>
369
+          <Form.Item label="产权年限" {...gourpItemLayout.ab.b }>
370
+            {getFieldDecorator('rightsYear', {
371
+              rules: [{ validator: validMinNum }]
372
+            })(<InputNumber style={fullWidth}/>)}
373
+          </Form.Item>
374
+        </FormGroupItem>
375
+        <Form.Item label="品牌开发商" help="【品牌开发商】与【开发商】二选一">
376
+          {getFieldDecorator('brandId')(<Select style={fullWidth}></Select>)}
341 377
         </Form.Item>
342
-        <Form.Item label="楼栋总数" {...gourpItemLayout.ab.b }>
343
-          {getFieldDecorator('buildingNum', {
344
-            rules: [{ validator: validMinNum }]
345
-          })(<InputNumber style={fullWidth}/>)}
378
+        <Form.Item label="开发商" >
379
+          {getFieldDecorator('propertyDeveloper', {
380
+            rules: [{ max: 30, message: '不超过30个字' }]
381
+          })(<Input placeholder="不超过30个字"/>)}
346 382
         </Form.Item>
347
-      </FormGroupItem>
348
-      <FormGroupItem>
349
-        <Form.Item label="交房时间" {...gourpItemLayout.ab.a }>
350
-          {getFieldDecorator('receivedDate')(<DatePicker style={fullWidth}/>)}
383
+        <Form.Item label="备案名" >
384
+          {getFieldDecorator('recordName', {
385
+            rules: [{ max: 30, message: '不超过30个字' }]
386
+          })(<Input placeholder="不超过30个字" />)}
351 387
         </Form.Item>
352
-        <Form.Item label="产权年限" {...gourpItemLayout.ab.b }>
353
-          {getFieldDecorator('rightsYear', {
354
-            rules: [{ validator: validMinNum }]
355
-          })(<InputNumber style={fullWidth}/>)}
388
+        <Form.Item label="预售许可证" >
389
+          {getFieldDecorator('preSalePermit')(
390
+            <ImageUpload />,
391
+          )}
356 392
         </Form.Item>
357
-      </FormGroupItem>
358
-      <Form.Item label="品牌开发商" help="【品牌开发商】与【开发商】二选一">
359
-        {getFieldDecorator('brandId')(<Select style={fullWidth}></Select>)}
360
-      </Form.Item>
361
-      <Form.Item label="开发商" >
362
-        {getFieldDecorator('propertyDeveloper', {
363
-          rules: [{ max: 30, message: '不超过30个字' }]
364
-        })(<Input placeholder="不超过30个字"/>)}
365
-      </Form.Item>
366
-      <Form.Item label="备案名" >
367
-        {getFieldDecorator('recordName', {
368
-          rules: [{ max: 30, message: '不超过30个字' }]
369
-        })(<Input placeholder="不超过30个字" />)}
370
-      </Form.Item>
371
-      <Form.Item label="预售许可证" >
372
-        {getFieldDecorator('preSalePermit')(
373
-          <ImageUpload />,
374
-        )}
375
-      </Form.Item>
376 393
 
377
-      <Form.Item label=" " colon={false}>
378
-        <Button style={{marginLeft: '6em'}} type="primary" htmlType="submit">
379
-            确定
380
-        </Button>
381
-        <Button style={{marginLeft: '2em'}} onClick={() => router.go(-1)}>
382
-            取消
383
-        </Button>
384
-      </Form.Item>
385
-    </Form>
394
+        <Form.Item label=" " colon={false}>
395
+          <Button style={{marginLeft: '6em'}} type="primary" htmlType="submit">
396
+              确定
397
+          </Button>
398
+          <Button style={{marginLeft: '2em'}} onClick={() => router.go(-1)}>
399
+              取消
400
+          </Button>
401
+        </Form.Item>
402
+      </Form>
403
+    </Spin>
386 404
   )
387 405
 })
388 406
 

+ 0
- 116
src/pages/building/Edit/Basic/tag.js Целия файл

@@ -1,116 +0,0 @@
1
-import { useCallback, useState, useRef } from "react";
2
-
3
-export default function useTags(form) {
4
-  const [tags, setTags] = useState({})
5
-  const poisRef = useRef({})
6
-
7
-  // const updatePoi2Form = pois => form.setFieldsValue('mapJson', Object.keys(pois).map((key) => ({ key, data: pois[key] })))
8
-
9
-  // initPois 必须先于 initTags 执行
10
-  // initPois, initTags 是在请求远程数据结束后执行
11
-  const initPois = useCallback((raw) => {
12
-    const newPois = !raw ? {} : raw.reduce((acc, poi) => {
13
-      const { key, data } = poi
14
-      return {
15
-        ...acc,
16
-        [key]: data || []
17
-      }
18
-    }, {})
19
-
20
-    poisRef.current = newPois
21
-  }, [])
22
-
23
-  // 主要用于地图搜索周边结果
24
-  const updatePois = useCallback((key, val) => {
25
-    poisRef.current[key] = val
26
-
27
-    // 先把 tags 中的 poi 去掉, 再更新
28
-    const tagKey = `building${key}`
29
-    const newTags = (tags[tagKey] || []).filter((tag) => !tag.id).concat(val)
30
-    setTags({
31
-      ...tags,
32
-      [tagKey]: newTags,
33
-    })
34
-
35
-    // 更新form
36
-    // updatePoi2Form(poisRef.current)
37
-    // form.setFieldsValue({ [key]: newTags.map((tag) => tag.name).join(',') })
38
-  }, [tags])
39
-
40
-  // 主要用于单个 poi 删除
41
-  const deletePoi = useCallback((key, val) => {
42
-    if (!poisRef.current[key] || !poisRef.current[key].length) return;
43
-
44
-    const newPois = poisRef.current[key].filter((poi) => poi.name !== val.name)
45
-    poisRef.current[key] = newPois
46
-
47
-    // 更新form
48
-    // updatePoi2Form(poisRef.current)
49
-  }, [])
50
-
51
-  const updatePoisAndTags = useCallback((pois) => {
52
-    poisRef.current = pois
53
-    const keys = Object.keys(pois)
54
-    
55
-    const newTags = keys.reduce((acc, key) => {
56
-      const tagKey = `building${key}`
57
-      const arr = (tags[tagKey] || []).filter((tag) => !tag.id).concat(pois[key])
58
-      return { ...acc, [tagKey]: arr }
59
-    }, tags)
60
-
61
-    setTags(newTags)
62
-  }, [tags])
63
-
64
-  const initTags = useCallback((key, raw) => {
65
-    const tagArr = !raw ? [] : raw.split(',').filter(Boolean)
66
-
67
-    if (!tagArr.length) return;
68
-
69
-    const pois = poisRef.current[key] || []
70
-
71
-    const newTags = tagArr.map((tag) => {
72
-      const found = pois.filter((poi) => poi.name === tag)[0]
73
-
74
-      return found || { name: tag }
75
-    })
76
-
77
-    setTags({
78
-      ...tags,
79
-      [key]: newTags,
80
-    })
81
-  }, [tags])
82
-
83
-  const updateTags = useCallback((key, newTags = []) => {
84
-    setTags({
85
-      ...tags,
86
-      [key]: newTags,
87
-    })
88
-
89
-    // form.setFieldsValue({ [key]: newTags.map((tag) => tag.name).join(',') })
90
-  }, [tags])
91
-
92
-  // 主要用户单个 tag 删除
93
-  const deleteTag = useCallback((key, tag) => {
94
-    if (!tags[key] || !tags[key].length) return;
95
-
96
-    const leftTags = tags[key].filter((x) => x.name !== tag.name)
97
-
98
-    setTags({
99
-      ...tags,
100
-      [key]: leftTags,
101
-    })
102
-
103
-    // form.setFieldsValue({ [key]: leftTags.map((tag) => tag.name).join(',') })
104
-  })
105
-
106
-  return [
107
-    tags,
108
-    initTags,
109
-    updateTags,
110
-    deletePoi,
111
-    initPois,
112
-    updatePois,
113
-    deleteTag,
114
-    updatePoisAndTags,
115
-  ]
116
-}

+ 48
- 0
src/pages/building/Edit/Basic/useArrounds.js Целия файл

@@ -0,0 +1,48 @@
1
+import { useCallback, useState, useRef } from "react";
2
+
3
+const formateArroundTag = str => (str || '').split(',').filter(Boolean).map(x => ({name: x}));
4
+
5
+export default function useArrounds() {
6
+  const [arrounds, setArrounds] = useState({})
7
+
8
+  // 用来初始化数据库数据
9
+  const initArrounds = useCallback((data) => {
10
+    const tags = {
11
+      buildingTransport: formateArroundTag(data.buildingTransport),
12
+      buildingMall: formateArroundTag(data.buildingMall),
13
+      buildingEdu: formateArroundTag(data.buildingEdu),
14
+      buildingHospital: formateArroundTag(data.buildingHospital),
15
+      buildingBank: formateArroundTag(data.buildingBank),
16
+      buildingRestaurant: formateArroundTag(data.buildingRestaurant),
17
+    }
18
+
19
+    setArrounds(tags)
20
+  }, [])
21
+
22
+  // 用于周边 onChange 事件
23
+  const updateArrounds = useCallback((key, vals) => {
24
+    setArrounds({
25
+      ...arrounds,
26
+      [key]: vals || [],
27
+    })
28
+  }, [arrounds])
29
+
30
+  // 主要用户单个 tag 删除
31
+  const deleteArround = useCallback((key, tag) => {
32
+    if (!arrounds[key] || !arrounds[key].length) return;
33
+
34
+    const leftArrounds = arrounds[key].filter((x) => x.name !== tag.name)
35
+
36
+    setArrounds({
37
+      ...arrounds,
38
+      [key]: leftArrounds,
39
+    })
40
+  }, [arrounds])
41
+
42
+  return [
43
+    arrounds,
44
+    initArrounds,
45
+    updateArrounds,
46
+    deleteArround,
47
+  ]
48
+}

+ 40
- 0
src/pages/building/Edit/Basic/usePois.js Целия файл

@@ -0,0 +1,40 @@
1
+import { useCallback, useState } from "react";
2
+
3
+export default function usePois() {
4
+  const [pois, setPois] = useState({})
5
+
6
+  const initPois = useCallback((data, formated) => {
7
+    if (!data) return;
8
+
9
+    if (formated) {
10
+      setPois(data)
11
+      return;
12
+    }
13
+
14
+    const nwPois = data.reduce((acc, poi) => {
15
+      return {
16
+        ...acc,
17
+        [poi.key]: poi.data ? JSON.parse(poi.data) : [],
18
+      }
19
+    }, {})
20
+
21
+    setPois(nwPois)
22
+  }, [])
23
+  
24
+  const deletePoi = useCallback((key, val) => {
25
+    if (!pois[key] || !pois[key].length) return;
26
+
27
+    const newPois = pois[key].filter((poi) => poi.name !== val.name)
28
+
29
+    setPois({
30
+      ...pois,
31
+      [key]: newPois
32
+    })
33
+  }, [pois])
34
+
35
+  return [
36
+    pois,
37
+    initPois,
38
+    deletePoi,
39
+  ]
40
+}

+ 40
- 0
src/pages/building/Edit/Basic/useQuery.js Целия файл

@@ -0,0 +1,40 @@
1
+import { useEffect, useState } from 'react'
2
+import { fetch, apis } from '@/utils/request'
3
+import { notification } from 'antd'
4
+
5
+export default function useData(id, setLoading, callback) {
6
+  const [data, setData] = useState()
7
+
8
+  useEffect(() => {
9
+    if (!id) {
10
+      setData();
11
+      return;
12
+    }
13
+
14
+    setLoading(true);
15
+    fetch(apis.building.buildingGetById)({ urlData: { id } }).then((res) => {
16
+
17
+      // 标签
18
+      if (res.buildingTag) {
19
+        res.tag = res.buildingTag.map((x) => x.tagName)
20
+      }
21
+
22
+      // POI 相关
23
+      if (res.mapJson) {
24
+        res.mapJson = JSON.parse(res.mapJson) || []
25
+      }
26
+
27
+      setData(res)
28
+      setLoading(false);
29
+
30
+      if (callback) {
31
+        callback(res)
32
+      }
33
+    }).catch((err) => {
34
+      setLoading(false);
35
+      notification.error({message: err.message || err})
36
+    })
37
+  }, [id])
38
+
39
+  return [data, setData]
40
+}

+ 11
- 5
src/pages/building/Edit/components/Amap/index.jsx Целия файл

@@ -22,13 +22,11 @@ export default (props) => {
22 22
 
23 23
   useEffect(() => {
24 24
     // 只加载一次 amap 相关 js
25
-    sdk.loadMapModule({
26
-      plugins,
27
-    }).then((AMap) => {
25
+    sdk.loadMapModule({ plugins }).then((AMap) => {
28 26
       const instance = new AMap.Map(container.current, { zoom: 12 })
29 27
       instance.addControl(new AMap.Scale())
30 28
       instance.addControl(new AMap.ToolBar())
31
-      
29
+
32 30
       // 尝试自动定位到当前位置
33 31
       if (!props.value) {
34 32
         instance.addControl(autoPos(AMap))
@@ -60,7 +58,15 @@ export default (props) => {
60 58
 
61 59
   useEffect(() => {
62 60
     if (currentPos.length) {
63
-      posMarker.current.setPosition(currentPos)
61
+      if (posMarker.current) {
62
+        posMarker.current.setPosition(currentPos)
63
+      }
64
+      if (map.current) {
65
+        map.current.setCenter(currentPos);
66
+      }
67
+      if (currentPos.length && map.current) {
68
+        posMarker.current.setMap(map.current)
69
+      }
64 70
     }
65 71
   }, [currentPos])
66 72
 

+ 0
- 26
src/pages/building/Edit/components/EditableArround/MapPois.jsx Целия файл

@@ -1,26 +0,0 @@
1
-import React, { useRef, useEffect, forwardRef } from 'react'
2
-
3
-export default forwardRef((props, ref) => {
4
-  const tags = useRef((props.pois || '').split(','))
5
-
6
-  // 用来记录上一次传值
7
-  const previous = useRef()
8
-
9
-  // 监控 props.pois 的变化, 触发 onChange
10
-  // 实际场景中 props.pois 只会由地图引起变化
11
-  useEffect(() => {
12
-    const changed = previous.current !== props.pois
13
-    if (changed) {
14
-      tags.current = (props.pois || '').split(',')
15
-      previous.current = props.pois
16
-
17
-      if (props.onChange) {
18
-        props.onChange(tags.current)
19
-      }
20
-    }
21
-  }, [props.pois, props.onChange])
22
-
23
-  return (
24
-    <></>
25
-  )
26
-})

+ 0
- 41
src/pages/building/Edit/components/EditableArround/hooks/usePoi.js Целия файл

@@ -1,41 +0,0 @@
1
-import { useCallback, useEffect, useRef } from "react";
2
-
3
-export default function usePoi(pois, tags, setTags) {
4
-  const poiRef = useRef([])
5
-
6
-  useEffect(() => {
7
-    const len1 = !pois ? 0 : pois.length
8
-    const len2 = poiRef.current.length
9
-
10
-    // 空数据
11
-    if (len1 === len2 && len1 === 0) {
12
-      return
13
-    }
14
-
15
-    // 如果是 poiRef 更新导致了 pois 更新
16
-    if (len1 > 0 && poiRef.current === pois) {
17
-      return
18
-    }
19
-
20
-    // 如果是初始化
21
-    poiRef.current = pois || []
22
-  }, [pois])
23
-
24
-  const updatePois = useCallback((pois) => {
25
-    const newTags = tags.filter((tag) => !tag.id)
26
-    setTags(newTags.concat(pois))
27
-  }, [tags])
28
-
29
-  const deletePoi = useCallback((poi) => {
30
-    const newTags = tags.filter((tag) => tag.id !== poi.id)
31
-
32
-    const newPois = !poiRef.current.length ? [] : poiRef.current.filter((p) => p.id !== poi.id)
33
-    poiRef.current = newPois
34
-
35
-    setTags(newTags)
36
-
37
-    return newPois
38
-  }, [tags])
39
-
40
-  return [updatePois, deletePoi]
41
-}

+ 0
- 43
src/pages/building/Edit/components/EditableArround/hooks/useTag.js Целия файл

@@ -1,43 +0,0 @@
1
-import { useCallback, useRef } from "react";
2
-
3
-export default function useTag(inited, tags, setTags) {
4
-  const getNewTag = useRef()
5
-  getNewTag.current = (tag) => {
6
-    const matched = tags.filter((item) => (tag.name === item.name))[0]
7
-
8
-    if (matched && matched.id) {
9
-      return matched
10
-    }
11
-
12
-    return tag
13
-  }
14
-
15
-  const updateTags = useCallback((nwTags) => {
16
-    if (!nwTags || !nwTags.length) {
17
-      return tags
18
-    }
19
-
20
-    const nwVals = nwTags.map((tag) => getNewTag.current(tag))
21
-    setTags(nwVals)
22
-    inited.current = true
23
-  }, [tags])
24
-
25
-  const appendTags = useCallback((tag) => {
26
-    const found = tags.filter((item) => (tag.name === item.name))[0]
27
-    if (found) {
28
-      return
29
-    }
30
-
31
-    setTags(tags.concat(tag))
32
-    inited.current = true
33
-  }, [tags])
34
-
35
-
36
-  const deleteTags = useCallback((tag) => {
37
-    const nwVal = tags.filter((it) => it.name !== tag.name)
38
-    
39
-    setTags(nwVal)
40
-  }, [tags])
41
-
42
-  return [updateTags, appendTags, deleteTags]
43
-}

+ 0
- 17
src/pages/building/Edit/components/EditableArround/hooks/useValue.js Целия файл

@@ -1,17 +0,0 @@
1
-import { useEffect, useRef } from "react"
2
-
3
-export default function useValue(value, poiRef, updateTags) {
4
-  const valueInited = useRef(false)
5
-
6
-  useEffect(() => {
7
-    if (!valueInited.current && value) {
8
-      const vals = value.split(',').filter(Boolean).map((tag) => ({ name: tag }))
9
-      const newTags = !poiRef.length ? vals : vals.map((val) => {
10
-        const found = poiRef.current.filter((poi) => poi.name === val.name)[0]
11
-        return found || val
12
-      })
13
-      updateTags(newTags)
14
-      valueInited.current = true
15
-    }
16
-  }, [value])
17
-}

+ 8
- 9
src/pages/building/Edit/components/EditableArround/index.jsx Целия файл

@@ -1,10 +1,8 @@
1
-import React, { useEffect, useRef, useState } from 'react'
1
+import React, { useRef, useState } from 'react'
2 2
 import { Typography, Tag, Input, Icon } from 'antd'
3
-import MapPois from './MapPois'
4
-import { arrRemove, arrAdd } from './utils'
5 3
 
6 4
 export default React.forwardRef((props, ref) => {
7
-  const { tags = [], onPoiDelete, onDelete, onChange } = props
5
+  const { tags = [], pois = [], type, onPoiDelete, onDelete, onChange } = props
8 6
 
9 7
   const inputRef = useRef()
10 8
   const [inputValue, setInputValue] = useState()
@@ -12,18 +10,19 @@ export default React.forwardRef((props, ref) => {
12 10
 
13 11
   const handleClose = (tag) => {
14 12
     if (tag.id && onPoiDelete) {
15
-      onPoiDelete(tag)
13
+      onPoiDelete(type, tag)
14
+      return
16 15
     }
17 16
 
18 17
     if (onDelete) {
19
-      onDelete(tag)
18
+      onDelete(`building${type}`, tag)
20 19
     }
21 20
   }
22 21
 
23 22
   const handleInputConfirm = () => {
24
-    const exists = tags.filter((tag) => tag.name === inputValue)[0]
23
+    const exists = tags.concat(pois).filter((tag) => tag.name === inputValue)[0]
25 24
     if (!exists) {
26
-      onChange(tags.concat({ name: inputValue }))
25
+      onChange(`building${type}`, tags.concat({ name: inputValue }))
27 26
     }
28 27
     setInputVisible(false)
29 28
     setInputValue()
@@ -32,7 +31,7 @@ export default React.forwardRef((props, ref) => {
32 31
   return (
33 32
     <div>
34 33
       {
35
-        tags.map((tag) => (
34
+        tags.concat(pois).map((tag) => (
36 35
           <Tag key={tag.name} closable onClose={() => handleClose(tag)}>
37 36
             <Typography.Text>{tag.name}</Typography.Text>
38 37
           </Tag>

+ 0
- 35
src/pages/building/Edit/components/EditableArround/utils.js Целия файл

@@ -1,35 +0,0 @@
1
-
2
-export function arrRemove(src, target) {
3
-  if (!target || target.length < 1) {
4
-    return src;
5
-  }
6
-
7
-  if (!src || src.length < 1) {
8
-    return src;
9
-  }
10
-
11
-  const arr = src.filter((it) => target.indexOf(it) === -1)
12
-  if (arr.length === src.length) return src;
13
-
14
-  return arr;
15
-}
16
-
17
-export function arrAdd(src, add) {
18
-  if (!add || add.length < 1) {
19
-    return src;
20
-  }
21
-
22
-  if (!src && add.length > 0) {
23
-    return [...add]
24
-  }
25
-
26
-  
27
-  const nwTags = src.slice()
28
-  add.forEach((it) => {
29
-    if (nwTags.indexOf(it) === -1) {
30
-      nwTags.push(it)
31
-    }
32
-  })
33
-
34
-  return nwTags;
35
-}

+ 9
- 9
src/pages/building/Edit/index.jsx Целия файл

@@ -21,45 +21,45 @@ export default (props) => {
21 21
       <Tabs defaultActiveKey="1">
22 22
         <TabPane tab="基础信息" key="1">
23 23
           <div className={styles['tab-wrapper']} style={{maxWidth: 1000}}>
24
-            <Basic />
24
+            <Basic {...props} />
25 25
           </div>
26 26
         </TabPane>
27 27
         <TabPane tab="户型设置" key="2">
28 28
           <div className={styles['tab-wrapper']}>
29
-            <Apartment />
29
+            <Apartment {...props} />
30 30
           </div>
31 31
         </TabPane>
32 32
         <TabPane tab="项目相册" key="3">
33 33
           <div className={styles['tab-wrapper']}>
34
-            <AlbumList />
34
+            <AlbumList {...props} />
35 35
           </div>
36 36
         </TabPane>
37 37
         <TabPane tab="全景照片" key="4">
38 38
           <div className={styles['tab-wrapper']}>
39
-            <Panorama />
39
+            <Panorama {...props} />
40 40
           </div>
41 41
         </TabPane>
42 42
         <TabPane tab="项目动态" key="8">
43 43
           <div className={styles['tab-wrapper']}>
44
-            <News />
44
+            <News {...props} />
45 45
           </div>
46 46
         </TabPane>
47 47
         <TabPane tab="特价房源" key="9">
48 48
           <div className={styles['tab-wrapper']}>
49
-            <SpecialRoom />
49
+            <SpecialRoom {...props} />
50 50
           </div>
51 51
         </TabPane>
52 52
         <TabPane tab="渠道设置" key="7">
53 53
           <div className={styles['tab-wrapper']} style={{maxWidth: '800px'}}>
54
-            <Channel />
54
+            <Channel {...props} />
55 55
           </div>
56 56
         </TabPane>
57 57
         <TabPane tab="海报图片" key="5">
58
-          <Poster target={target} />
58
+          <Poster target={target} {...props} />
59 59
         </TabPane>
60 60
         <TabPane tab="分享设置" key="6">
61 61
           <div className={styles['tab-wrapper']} style={{maxWidth: '800px'}}>
62
-            <Share target={target} />
62
+            <Share target={target} {...props} />
63 63
           </div>
64 64
         </TabPane>
65 65
       </Tabs>

+ 1
- 1
src/utils/image.js Целия файл

@@ -3,5 +3,5 @@ export function getImgURL(img) {
3 3
     if (!img) return undefined;
4 4
 
5 5
     const isProd = process.env.NODE_ENV === 'production'
6
-    return isProd ? img : `http://81.69.196.8:8567${img}`;
6
+    return isProd ? img : `https://xlk.njyz.tech${img}`;
7 7
 }