Przeglądaj źródła

Merge branch 'v3.5.1' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager into v3.5.1

魏超 5 lat temu
rodzic
commit
6761d29969

+ 86
- 12
src/pages/building/list/add/components/base.jsx Wyświetl plik

@@ -55,6 +55,24 @@ function AddBuilding(props) {
55 55
       }
56 56
   }, [buildingId])
57 57
 
58
+  useEffect(() => {
59
+    setPoiTagValue()
60
+  }, [poi])
61
+
62
+
63
+  // 把地图设置在的数据设置在 tag控件上 上
64
+  function setPoiTagValue() {
65
+    if (poi) {
66
+      console.log('poi: ', poi)
67
+   
68
+      
69
+      poi.map(x => {
70
+        // console.log('x.data: ', JSON.parse(x.data))
71
+        setFormMapScopeTagValue(x.key, { data: JSON.parse(x.data) })
72
+      })
73
+    }
74
+  }
75
+
58 76
    // 获取详情信息
59 77
    function getById(currentId) {
60 78
     request({ ...apis.building.buildingGetById, urlData: { id: currentId } }).then(res => {
@@ -71,7 +89,8 @@ function AddBuilding(props) {
71 89
       res.avatarImage = res.buildingImg.map(item => item.url)
72 90
       
73 91
       if (res.buildingListImg) {
74
-        res.listImage = res.buildingListImg.map(item => item.url)
92
+        // res.listImage = res.buildingListImg.map(item => item.url)
93
+        res.listImage = res.buildingListImg.map(item => item.url)[0]
75 94
       }
76 95
       res.mapCoordinate = res.coordinate
77 96
       if (res.videoUrl) {
@@ -81,8 +100,35 @@ function AddBuilding(props) {
81 100
       if (res.videoImage) {
82 101
         res.videoImage = res.videoImage[0].url
83 102
       }
84
-      // setPoi(res.mapJson || [])
103
+      if (res.buildingTransport) {
104
+        const arr = res.buildingTransport.split(',')
105
+        res.buildingTransport = arr.map(x => ({ tagName: x, delete: true }))
106
+      }
107
+      if (res.buildingMall) {
108
+        const arr = res.buildingMall.split(',')
109
+        res.buildingMall = arr.map(x => ({ tagName: x, delete: true }))
110
+      }
111
+      if (res.buildingEdu) {
112
+        const arr = res.buildingEdu.split(',')
113
+        res.buildingEdu = arr.map(x => ({ tagName: x, delete: true }))
114
+      }
115
+      if (res.buildingHospital) {
116
+        const arr = res.buildingHospital.split(',')
117
+        res.buildingHospital = arr.map(x => ({ tagName: x, delete: true }))
118
+      }
119
+      if (res.buildingBank) {
120
+        const arr = res.buildingBank.split(',')
121
+        res.buildingBank = arr.map(x => ({ tagName: x, delete: true }))
122
+      }
123
+      if (res.buildingRestaurant) {
124
+        const arr = res.buildingRestaurant.split(',')
125
+        res.buildingRestaurant = arr.map(x => ({ tagName: x, delete: true }))
126
+      }
127
+
128
+      
85 129
       props.form.setFieldsValue(res)
130
+      // console.log('mapJson: ', JSON.parse(res.mapJson))
131
+      setPoi((res.mapJson && JSON.parse(res.mapJson)) || [])
86 132
       props.onSuccess(res)
87 133
     })
88 134
   }
@@ -107,7 +153,7 @@ function AddBuilding(props) {
107 153
     // 项目主图
108 154
     data.img = data.avatarImage && data.avatarImage.map((item, index) => ({ imgType: 'banner', url: item, orderNo: index + 1 }))
109 155
     // 列表图
110
-    data.listImg = data.listImage && data.listImage.map((item, index) => ({ imgType: 'list', url: item, orderNo: index + 1 }))
156
+    data.listImg = data.listImage && [{ imgType: 'list', url: data.listImage, orderNo: 1 }]
111 157
     if (data.videoUrl) {
112 158
       // console.log(data.videoUrl[0])
113 159
       data.videoUrl = data.videoUrl[0]
@@ -121,6 +167,25 @@ function AddBuilding(props) {
121 167
       data.videoImage = [{ imgType: 'videoImage', url: data.videoImage, orderNo: 1 }]
122 168
     }
123 169
 
170
+    if (data.buildingTransport) {
171
+      data.buildingTransport = data.buildingTransport.filter(f => f.delete === true).map(x => x.tagName).join(',')
172
+    }
173
+    if (data.buildingMall) {
174
+      data.buildingMall = data.buildingMall.filter(f => f.delete === true).map(x => x.tagName).join(',')
175
+    }
176
+    if (data.buildingEdu) {
177
+      data.buildingEdu = data.buildingEdu.filter(f => f.delete === true).map(x => x.tagName).join(',')
178
+    }
179
+    if (data.buildingHospital) {
180
+      data.buildingHospital = data.buildingHospital.filter(f => f.delete === true).map(x => x.tagName).join(',')
181
+    }
182
+    if (data.buildingBank) {
183
+      data.buildingBank = data.buildingBank.filter(f => f.delete === true).map(x => x.tagName).join(',')
184
+    }
185
+    if (data.buildingRestaurant) {
186
+      data.buildingRestaurant = data.buildingRestaurant.filter(f => f.delete === true).map(x => x.tagName).join(',')
187
+    }
188
+
124 189
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
125 190
     request({ ...api, data: { ...data } }).then(res => {
126 191
       openNotificationWithIcon('success', '操作成功')
@@ -183,7 +248,7 @@ function AddBuilding(props) {
183 248
     })
184 249
     
185 250
     // 设置表单值
186
-    getFormMapScopeName(key, { data: poiArray })
251
+    setFormMapScopeTagValue(key, { data: poiArray })
187 252
 
188 253
     const poiData = [].concat(POI_TYPES)
189 254
     const newPoi = poiData.map(m => {
@@ -192,28 +257,37 @@ function AddBuilding(props) {
192 257
       }
193 258
       return m
194 259
     })
260
+    
195 261
     setPoi(newPoi)
262
+    return newPoi
196 263
   }
197 264
 
198
-  function getFormMapScopeName(keyType, item) {
265
+  function setFormMapScopeTagValue(keyType, item) {
266
+    const tag = item.data.map(t => ({ tagName: t.name, delete: false }))
199 267
     switch (keyType) {
200 268
       case POI_TYPES_KETY.Transport:
201
-        props.form.setFieldsValue({ buildingTransport: item.data.map(t => t.name).join(',') })
269
+        const buildingTransportValue = (props.form.getFieldValue('buildingTransport') || [])
270
+        props.form.setFieldsValue({ buildingTransport: tag.concat(buildingTransportValue) })
202 271
         return 'buildingTransport';
203 272
       case POI_TYPES_KETY.Bank:
204
-        props.form.setFieldsValue({ buildingBank: item.data.map(t => t.name).join(',') })
273
+        const buildingBankValue = (props.form.getFieldValue('buildingBank') || [])
274
+        props.form.setFieldsValue({ buildingBank: tag.concat(buildingBankValue) })
205 275
         return 'buildingBank';
206 276
       case POI_TYPES_KETY.Edu:
207
-        props.form.setFieldsValue({ buildingEdu: item.data.map(t => t.name).join(',') })
277
+        const buildingEduValue = (props.form.getFieldValue('buildingEdu') || [])
278
+        props.form.setFieldsValue({ buildingEdu: tag.concat(buildingEduValue) })
208 279
         return 'buildingEdu';
209 280
       case POI_TYPES_KETY.Hospital:
210
-        props.form.setFieldsValue({ buildingHospital: item.data.map(t => t.name).join(',') })
281
+        const buildingHospitalValue = (props.form.getFieldValue('buildingHospital') || [])
282
+        props.form.setFieldsValue({ buildingHospital: tag.concat(buildingHospitalValue) })
211 283
         return 'buildingHospital';
212 284
       case POI_TYPES_KETY.Restaurant:
213
-        props.form.setFieldsValue({ buildingRestaurant: item.data.map(t => t.name).join(',') })
285
+        const buildingRestaurantValue = (props.form.getFieldValue('buildingRestaurant') || [])
286
+        props.form.setFieldsValue({ buildingRestaurant: tag.concat(buildingRestaurantValue) })
214 287
         return 'buildingRestaurant';
215 288
       case POI_TYPES_KETY.Mall:
216
-        props.form.setFieldsValue({ buildingMall: item.data.map(t => t.name).join(',') })
289
+        const buildingMallValue = (props.form.getFieldValue('buildingMall') || [])
290
+        props.form.setFieldsValue({ buildingMall: tag.concat(buildingMallValue) })
217 291
         return 'buildingMall';
218 292
       default:
219 293
     }
@@ -312,7 +386,7 @@ function AddBuilding(props) {
312 386
             {getFieldDecorator('listImage', {
313 387
               rules: [{ required: true, message: '请选择列表图' }],
314 388
             })(
315
-              <ImageListUpload />,
389
+              <ImageUpload />,
316 390
             )}
317 391
           </Form.Item>
318 392
           {/* <Form.Item label="地址图片" help="建议图片尺寸:750px*455px">

+ 17
- 6
src/pages/building/list/add/components/buildingImage.jsx Wyświetl plik

@@ -45,11 +45,13 @@ function ModalEdi(props) {
45 45
   function handleOk(e) {
46 46
     // console.log(e);
47 47
     props.onCancel();
48
+    props.form.resetFields();
48 49
   }
49 50
 
50 51
   function handleCancel(e) {
51 52
     // console.log(e);
52 53
     props.onCancel();
54
+    props.form.resetFields();
53 55
   }
54 56
 
55 57
   function handleSubmit(e) {
@@ -200,12 +202,21 @@ function BuildingImageModel(props) {
200 202
   }
201 203
 
202 204
   function deletePhoto() {
203
-    request({ ...apis.building.buildingApartmentDelete, urlData: { id: props.apartment.apartmentId } }).then(() => {
204
-      openNotificationWithIcon('success', '操作成功')
205
-      props.onSuccess()
206
-    }).catch(err => {
207
-
208
-    })
205
+    Modal.confirm({
206
+      title: '确认删除当前相册',
207
+      // content: 'Bla bla ...',
208
+      okText: '确认',
209
+      cancelText: '取消',
210
+      onOk: () => {
211
+        request({ ...apis.building.buildingApartmentDelete, urlData: { id: props.apartment.apartmentId } }).then(() => {
212
+          openNotificationWithIcon('success', '操作成功')
213
+          props.onSuccess()
214
+        }).catch(err => {
215
+    
216
+        })
217
+      },
218
+    });
219
+    
209 220
   }
210 221
 
211 222
   return (

+ 1
- 1
src/pages/building/list/add/components/imageSet.jsx Wyświetl plik

@@ -131,7 +131,7 @@ function imageSet(props) {
131 131
       title: '创建时间',
132 132
       dataIndex: 'createDate',
133 133
       key: 'createDate',
134
-      render: (_, record) => <span>{ moment(record.createDate).format('YYYY-MM-DD') }</span>,
134
+      render: (_, record) => <span>{ moment(record.createDate).format('YYYY-MM-DD HH:mm:ss') }</span>,
135 135
     },
136 136
     {
137 137
       title: '操作',

+ 12
- 8
src/pages/building/list/add/components/tags.jsx Wyświetl plik

@@ -11,7 +11,8 @@ class EditableTagGroup extends React.Component {
11 11
   getTags = () => {
12 12
     // (this.props.value || '').split(',')
13 13
     if (this.props.value) {
14
-      return this.props.value.split(',')
14
+      // return this.props.value.split(',')
15
+      return this.props.value
15 16
     }
16 17
 
17 18
     return []
@@ -19,12 +20,13 @@ class EditableTagGroup extends React.Component {
19 20
 
20 21
   toggleOnChange = tags => {
21 22
     if (typeof this.props.onChange === 'function') {
22
-      this.props.onChange(tags.join(','))
23
+      // this.props.onChange(tags.join(','))
24
+      this.props.onChange(tags)
23 25
     }
24 26
   }
25 27
 
26 28
   handleClose = removedTag => {
27
-    const tags = this.getTags().filter(tag => tag !== removedTag);
29
+    const tags = this.getTags().filter(tag => tag.tagName !== removedTag);
28 30
     // this.setState({ tags });
29 31
     this.toggleOnChange(tags)
30 32
   };
@@ -41,9 +43,11 @@ class EditableTagGroup extends React.Component {
41 43
     const { inputValue } = this.state;
42 44
 
43 45
     const tags = this.getTags()
44
-    if (inputValue && tags.indexOf(inputValue) === -1) {
46
+    const tagList = tags.map(x => x.tagName)
47
+    if (inputValue && tagList.indexOf(inputValue) === -1) {
45 48
       // 如果有新的值,就把这个值追加到 tags 原本值的后面,在通过onChange事件传递出去
46
-      this.toggleOnChange(tags.concat(inputValue))
49
+      console.log(tags.concat([{ tagName: inputValue, delete: true }]))
50
+      this.toggleOnChange(tags.concat([{ tagName: inputValue, delete: true }]))
47 51
     }
48 52
 
49 53
     this.setState({
@@ -62,12 +66,12 @@ class EditableTagGroup extends React.Component {
62 66
         {this.getTags().map((tag, index) => {
63 67
           const isLongTag = tag.length > 20;
64 68
           const tagElem = (
65
-            <Tag key={tag} closable onClose={() => this.handleClose(tag)}>
66
-              {isLongTag ? `${tag.slice(0, 20)}...` : tag}
69
+            <Tag key={`${tag.tagName}${index}`} closable={ tag.delete } onClose={() => this.handleClose(tag.tagName)}>
70
+              {isLongTag ? `${tag.slice(0, 20)}...` : tag.tagName}
67 71
             </Tag>
68 72
           );
69 73
           return isLongTag ? (
70
-            <Tooltip title={tag} key={tag}>
74
+            <Tooltip title={tag.tagName} key={`${tag.tagName}${index}`}>
71 75
               {tagElem}
72 76
             </Tooltip>
73 77
           ) : (

+ 1
- 1
src/pages/customer/customerlist/index.jsx Wyświetl plik

@@ -366,7 +366,7 @@ function body(props) {
366 366
           </AuthButton>
367 367
             &nbsp;
368 368
           <AuthButton name="admin.mine.taPointsRecords.id.get" noRight={null}>
369
-            <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecommend(record.customerId)}>推荐客户</Button>
369
+            <Button className={customerType === 'private' ? Styles.text : Styles.displayS} type="link" onClick={() => showRecommend(record.personId)}>推荐客户</Button>
370 370
           </AuthButton>
371 371
         </>
372 372
       ),