瀏覽代碼

fix:文件上传回调修改

zhengyingya 5 年之前
父節點
當前提交
7648f49921
共有 4 個檔案被更改,包括 55 行新增53 行删除
  1. 29
    28
      lib/components/Editor/index.js
  2. 1
    1
      lib/components/Editor/index.js.map
  3. 3
    3
      lib/version.json
  4. 22
    21
      src/components/Editor/index.js

+ 29
- 28
lib/components/Editor/index.js 查看文件

@@ -206,6 +206,7 @@ var Editor = function (_React$Component) {
206 206
         }
207 207
         return item;
208 208
       });
209
+      this.props.handleChangeFileList(fileList);
209 210
       this.setState({ fileMap: fileMap, fileList: fileList });
210 211
     }
211 212
 
@@ -218,8 +219,6 @@ var Editor = function (_React$Component) {
218 219
   }, {
219 220
     key: "handleSubmit",
220 221
     value: function handleSubmit() {
221
-      var _this2 = this;
222
-
223 222
       var maxLength = this.props.maxLength;
224 223
       var _state = this.state,
225 224
           value = _state.value,
@@ -244,25 +243,27 @@ var Editor = function (_React$Component) {
244 243
           files.push("" + _constant.OSS_LINK + fileMap[item.uid]);
245 244
         });
246 245
       }
247
-      if (this.props.beforeSubmit) {
248
-        Promise.resolve(this.props.beforeSubmit({ text: value, files: files })).then(function (res) {
249
-          if (!(res === false)) {
250
-            _this2.props.onSubmit({ text: value, files: files }, function () {
251
-              _this2.resetState();
252
-              if (_this2.props.onCommentSuccess) {
253
-                _this2.props.onCommentSuccess();
254
-              }
255
-            });
256
-          }
257
-        });
258
-      } else {
259
-        this.props.onSubmit({ text: value, files: files }, function () {
260
-          _this2.resetState();
261
-          if (_this2.props.onCommentSuccess) {
262
-            _this2.props.onCommentSuccess();
263
-          }
264
-        });
265
-      }
246
+      // if (this.props.beforeSubmit) {
247
+      //   Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
248
+      //     res => {
249
+      //       if (!(res === false)) {
250
+      //         this.props.onSubmit({ text: value, files }, () => {
251
+      //           this.resetState();
252
+      //           if (this.props.onCommentSuccess) {
253
+      //             this.props.onCommentSuccess();
254
+      //           }
255
+      //         });
256
+      //       }
257
+      //     }
258
+      //   );
259
+      // } else {
260
+      //   this.props.onSubmit({ text: value, files }, () => {
261
+      //     this.resetState();
262
+      //     if (this.props.onCommentSuccess) {
263
+      //       this.props.onCommentSuccess();
264
+      //     }
265
+      //   });
266
+      // }
266 267
     }
267 268
   }, {
268 269
     key: "resetState",
@@ -277,7 +278,7 @@ var Editor = function (_React$Component) {
277 278
   }, {
278 279
     key: "render",
279 280
     value: function render() {
280
-      var _this3 = this;
281
+      var _this2 = this;
281 282
 
282 283
       var _props = this.props,
283 284
           value = _props.value,
@@ -320,7 +321,7 @@ var Editor = function (_React$Component) {
320 321
           _react2.default.createElement(TextArea, {
321 322
             value: inputValue,
322 323
             onChange: function onChange(e) {
323
-              return _this3.handleChange(e.target.value);
324
+              return _this2.handleChange(e.target.value);
324 325
             },
325 326
             rows: rows,
326 327
             placeholder: placeholder,
@@ -348,7 +349,7 @@ var Editor = function (_React$Component) {
348 349
                     _react2.default.createElement(_Emoji2.default, {
349 350
                       onClick: this.handleClickEmoji,
350 351
                       ref: function ref(node) {
351
-                        _this3.emoji = node;
352
+                        _this2.emoji = node;
352 353
                       }
353 354
                     })
354 355
                   ),
@@ -367,7 +368,7 @@ var Editor = function (_React$Component) {
367 368
                   autoAdjustOverflow: false,
368 369
                   overlayStyle: { zIndex: 999 },
369 370
                   onVisibleChange: closeUploadWhenBlur ? function (visible) {
370
-                    _this3.handleShowUpload(visible);
371
+                    _this2.handleShowUpload(visible);
371 372
                   } : null,
372 373
                   content: _react2.default.createElement(
373 374
                     "div",
@@ -408,14 +409,14 @@ var Editor = function (_React$Component) {
408 409
                 },
409 410
                 imageToolIcon ? _react2.default.cloneElement(imageToolIcon, {
410 411
                   onClick: function onClick() {
411
-                    return _this3.handleShowUpload(true);
412
+                    return _this2.handleShowUpload(true);
412 413
                   }
413 414
                 }) : _react2.default.createElement(_icon2.default, {
414 415
                   type: "picture",
415 416
                   className: "comment-toolbar-icon",
416 417
                   style: { marginLeft: 10 },
417 418
                   onClick: function onClick() {
418
-                    return _this3.handleShowUpload(true);
419
+                    return _this2.handleShowUpload(true);
419 420
                   }
420 421
                 })
421 422
               ) : null
@@ -429,7 +430,7 @@ var Editor = function (_React$Component) {
429 430
                 _button2.default,
430 431
                 {
431 432
                   onClick: function onClick() {
432
-                    return _this3.handleSubmit();
433
+                    return _this2.handleSubmit();
433 434
                   },
434 435
                   type: "primary",
435 436
                   loading: btnLoading,

+ 1
- 1
lib/components/Editor/index.js.map
文件差異過大導致無法顯示
查看文件


+ 3
- 3
lib/version.json 查看文件

@@ -1,8 +1,8 @@
1 1
 {
2 2
     "name":       "comment",
3
-    "buildDate":  1561033676404,
3
+    "buildDate":  1561169930396,
4 4
     "version":    "1.0.4",
5
-    "numCommits": 149,
6
-    "hash":       "955d349",
5
+    "numCommits": 151,
6
+    "hash":       "1d304ca",
7 7
     "dirty":      true
8 8
 }

+ 22
- 21
src/components/Editor/index.js 查看文件

@@ -113,6 +113,7 @@ class Editor extends React.Component {
113 113
       }
114 114
       return item;
115 115
     });
116
+    this.props.handleChangeFileList(fileList);
116 117
     this.setState({ fileMap, fileList });
117 118
   }
118 119
 
@@ -142,27 +143,27 @@ class Editor extends React.Component {
142 143
         files.push(`${OSS_LINK}${fileMap[item.uid]}`);
143 144
       });
144 145
     }
145
-    if (this.props.beforeSubmit) {
146
-      Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
147
-        res => {
148
-          if (!(res === false)) {
149
-            this.props.onSubmit({ text: value, files }, () => {
150
-              this.resetState();
151
-              if (this.props.onCommentSuccess) {
152
-                this.props.onCommentSuccess();
153
-              }
154
-            });
155
-          }
156
-        }
157
-      );
158
-    } else {
159
-      this.props.onSubmit({ text: value, files }, () => {
160
-        this.resetState();
161
-        if (this.props.onCommentSuccess) {
162
-          this.props.onCommentSuccess();
163
-        }
164
-      });
165
-    }
146
+    // if (this.props.beforeSubmit) {
147
+    //   Promise.resolve(this.props.beforeSubmit({ text: value, files })).then(
148
+    //     res => {
149
+    //       if (!(res === false)) {
150
+    //         this.props.onSubmit({ text: value, files }, () => {
151
+    //           this.resetState();
152
+    //           if (this.props.onCommentSuccess) {
153
+    //             this.props.onCommentSuccess();
154
+    //           }
155
+    //         });
156
+    //       }
157
+    //     }
158
+    //   );
159
+    // } else {
160
+    //   this.props.onSubmit({ text: value, files }, () => {
161
+    //     this.resetState();
162
+    //     if (this.props.onCommentSuccess) {
163
+    //       this.props.onCommentSuccess();
164
+    //     }
165
+    //   });
166
+    // }
166 167
   }
167 168
 
168 169
   resetState() {