king
2021-01-15 40436544f55558d2c8d1c14c68cce79546c60dff
src/tabviews/zshare/fileupload/index.jsx
@@ -18,6 +18,7 @@
class FileUpload extends Component {
  static propTpyes = {
    value: PropTypes.array,    // 文件数组
    accept: PropTypes.any,     // 文件格式
    maxFile: PropTypes.any,    // 最大文件数
    fileType: PropTypes.string // 文件显示类型
  }
@@ -122,6 +123,27 @@
  }
  beforeUpload = (file) => {
    const { accept } = this.props
    if (accept && file.name) {
      let types = accept.split(',')
      let pass = false
      types.forEach(type => {
        if (new RegExp(type + '$', 'ig').test(file.name)) {
          pass = true
        }
      })
      if (!pass) {
        notification.warning({
          top: 92,
          message: '文件格式错误!',
          duration: 5
        })
        return
      }
    }
    this.setState({
      showprogress: true,
      percent: 0
@@ -231,7 +253,7 @@
  }
  render() {
    const { value, maxFile, fileType } = this.props
    const { value, maxFile, fileType, accept } = this.props
    const { showprogress, percent } = this.state
    let uploadable = 'fileupload-form-container '
@@ -246,6 +268,7 @@
      listType: fileType,
      fileList: value,
      action: null,
      accept: accept || '',
      method: 'post',
      multiple: false,
      onChange: this.onChange,