Merge pull request #666 from ariesjia/feat-1.4.0
add reject event for drag not accepted files to upload componentpull/802/head
						commit
						c483390dbc
					
				| 
						 | 
					@ -136,6 +136,9 @@ export default {
 | 
				
			||||||
        fileList,
 | 
					        fileList,
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    onReject(fileList) {
 | 
				
			||||||
 | 
					      this.$emit('reject', fileList);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    handleRemove(file) {
 | 
					    handleRemove(file) {
 | 
				
			||||||
      const { remove } = getOptionProps(this);
 | 
					      const { remove } = getOptionProps(this);
 | 
				
			||||||
      const { status } = file;
 | 
					      const { status } = file;
 | 
				
			||||||
| 
						 | 
					@ -232,6 +235,7 @@ export default {
 | 
				
			||||||
        error: this.onError,
 | 
					        error: this.onError,
 | 
				
			||||||
        progress: this.onProgress,
 | 
					        progress: this.onProgress,
 | 
				
			||||||
        success: this.onSuccess,
 | 
					        success: this.onSuccess,
 | 
				
			||||||
 | 
					        reject: this.onReject,
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      ref: 'uploadRef',
 | 
					      ref: 'uploadRef',
 | 
				
			||||||
      class: `${prefixCls}-btn`,
 | 
					      class: `${prefixCls}-btn`,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
| --- | --- | --- |
 | 
					| --- | --- | --- |
 | 
				
			||||||
| change | A callback function, can be executed when uploading state is changing. See [change](#change) | Function | - |
 | 
					| change | A callback function, can be executed when uploading state is changing. See [change](#change) | Function | - |
 | 
				
			||||||
| preview | A callback function, will be executed when file link or preview icon is clicked. | Function(file) | - |
 | 
					| preview | A callback function, will be executed when file link or preview icon is clicked. | Function(file) | - |
 | 
				
			||||||
 | 
					| reject | A callback function, will be executed when drop files is not accept. | Function(fileList) | - |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### change
 | 
					### change
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,7 @@
 | 
				
			||||||
| --- | --- | --- |
 | 
					| --- | --- | --- |
 | 
				
			||||||
| change | 上传文件改变时的状态,详见 [change](#change) | Function | 无 |
 | 
					| change | 上传文件改变时的状态,详见 [change](#change) | Function | 无 |
 | 
				
			||||||
| preview | 点击文件链接或预览图标时的回调 | Function(file) | 无 |
 | 
					| preview | 点击文件链接或预览图标时的回调 | Function(file) | 无 |
 | 
				
			||||||
 | 
					| reject | 拖拽文件不符合accept类型时的回调 | Function(fileList) | 无 |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### change
 | 
					### change
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import PropTypes from '../../_util/vue-types';
 | 
					import PropTypes from '../../_util/vue-types';
 | 
				
			||||||
import BaseMixin from '../../_util/BaseMixin';
 | 
					import BaseMixin from '../../_util/BaseMixin';
 | 
				
			||||||
 | 
					import partition from 'lodash/partition';
 | 
				
			||||||
import classNames from 'classnames';
 | 
					import classNames from 'classnames';
 | 
				
			||||||
import defaultRequest from './request';
 | 
					import defaultRequest from './request';
 | 
				
			||||||
import getUid from './uid';
 | 
					import getUid from './uid';
 | 
				
			||||||
| 
						 | 
					@ -74,10 +75,13 @@ const AjaxUploader = {
 | 
				
			||||||
          attrAccept(_file, this.accept),
 | 
					          attrAccept(_file, this.accept),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        const files = Array.prototype.slice
 | 
					        const files = partition(Array.prototype.slice.call(e.dataTransfer.files), file =>
 | 
				
			||||||
          .call(e.dataTransfer.files)
 | 
					          attrAccept(file, this.accept),
 | 
				
			||||||
          .filter(file => attrAccept(file, this.accept));
 | 
					        );
 | 
				
			||||||
        this.uploadFiles(files);
 | 
					        this.uploadFiles(files[0]);
 | 
				
			||||||
 | 
					        if (files[1].length) {
 | 
				
			||||||
 | 
					          this.$emit('reject', files[1]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    uploadFiles(files) {
 | 
					    uploadFiles(files) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue