瀏覽代碼

图片设置修复 弹框问题

魏熙美 5 年之前
父節點
當前提交
ab390691c8

+ 10
- 1
src/pages/building/list/add/components/imageSet.jsx 查看文件

61
     })
61
     })
62
   }
62
   }
63
 
63
 
64
+  /**
65
+   *回调事件
66
+   *
67
+   */
68
+  function onModalChange() {
69
+    getList()
70
+    setVisibleData({ visible: false, apartmentId: '', buildingId: '' })
71
+  }
72
+
64
   /**
73
   /**
65
    *打开编辑页
74
    *打开编辑页
66
    *
75
    *
138
 
147
 
139
       {/* 编辑页 */}
148
       {/* 编辑页 */}
140
       {/*  onSuccess是子组件传递事件信息  */}
149
       {/*  onSuccess是子组件传递事件信息  */}
141
-      <ModalImage visibleData={visibleData} key={1} onSuccess={getList}/>
150
+      <ModalImage visibleData={visibleData} key={1} onSuccess={() => onModalChange()}/>
142
     </>
151
     </>
143
   )
152
   )
144
 }
153
 }

+ 6
- 5
src/pages/building/list/add/components/modalImage.jsx 查看文件

5
 import apis from '../../../../../services/apis';
5
 import apis from '../../../../../services/apis';
6
 import Styles from '../style.less';
6
 import Styles from '../style.less';
7
 import ImageUpload from '../../../../../components/XForm/ImageUpload'
7
 import ImageUpload from '../../../../../components/XForm/ImageUpload'
8
+import ImageListUpload from '../../../../../components/XForm/ImageListUpload'
8
 import Wangedit from '../../../../../components/Wangedit/Wangedit'
9
 import Wangedit from '../../../../../components/Wangedit/Wangedit'
9
 
10
 
10
 
11
 
61
   // }
62
   // }
62
 
63
 
63
   componentDidUpdate(preProps, preState) {
64
   componentDidUpdate(preProps, preState) {
64
-    console.log(this.props.visibleData)
65
     if (this.props.visibleData.visible !== preState.visibleData.visible) {
65
     if (this.props.visibleData.visible !== preState.visibleData.visible) {
66
+      console.log(this.props.visibleData)
66
       this.getById()
67
       this.getById()
67
       this.setState({ visibleData: this.props.visibleData });
68
       this.setState({ visibleData: this.props.visibleData });
68
     }
69
     }
91
 
92
 
92
     request({ url: tempUrl, method, params: { ...params } }).then(res => {
93
     request({ url: tempUrl, method, params: { ...params } }).then(res => {
93
       // res.img = res.buildingImgList.map((item, _) => item.url)
94
       // res.img = res.buildingImgList.map((item, _) => item.url)
94
-      res.img = res.buildingImgList[0].url
95
+      res.img = res.buildingImgList.map(item => item.url)
95
       this.props.form.setFieldsValue(res)
96
       this.props.form.setFieldsValue(res)
96
     }).catch(err => {
97
     }).catch(err => {
97
      this.openNotificationWithIcon('error', err)
98
      this.openNotificationWithIcon('error', err)
118
 
119
 
119
   submitData(data) {
120
   submitData(data) {
120
     // TODO 这里应该是要支持多图,但是封装的控件没有
121
     // TODO 这里应该是要支持多图,但是封装的控件没有
121
-    data.img = [{ imgType: 'aparment', url: data.img, orderNo: 1 }]
122
+    data.img = data.img.map((item, index) => ({ imgType: 'aparment', url: item, orderNo: index }))
122
     data.buildingId = this.props.visibleData.buildingId;
123
     data.buildingId = this.props.visibleData.buildingId;
123
     const api = data.apartmentId !== undefined ? apis.building.buildingApartmentUpdate : apis.building.buildingApartmentAdd;
124
     const api = data.apartmentId !== undefined ? apis.building.buildingApartmentUpdate : apis.building.buildingApartmentAdd;
124
 
125
 
131
       // onSuccess() 是自定义
132
       // onSuccess() 是自定义
132
       this.props.onSuccess()
133
       this.props.onSuccess()
133
 
134
 
134
-      this.handleCancel()
135
+      // this.setState({ visibleData: { visible: false, apartmentId: '', buildingId: '' } }, () => console.log('回调:', this.state.visibleData))
135
     }).catch(err => {
136
     }).catch(err => {
136
       // eslint-disable-next-line no-unused-expressions
137
       // eslint-disable-next-line no-unused-expressions
137
       this.openNotificationWithIcon('error', err)
138
       this.openNotificationWithIcon('error', err)
186
               </Form.Item>
187
               </Form.Item>
187
               <Form.Item label="图片">
188
               <Form.Item label="图片">
188
               {getFieldDecorator('img')(
189
               {getFieldDecorator('img')(
189
-                <ImageUpload />,
190
+                <ImageListUpload />,
190
               )}
191
               )}
191
               </Form.Item>
192
               </Form.Item>
192
               <Form.Item label="面积">
193
               <Form.Item label="面积">