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