king
2021-02-01 b23db4e1b9e8bc813b4b3b95d35552e5e2e980c6
src/tabviews/zshare/fileupload/index.jsx
@@ -24,12 +24,18 @@
  state = {
    percent: 0,
    showprogress: false
    showprogress: false,
    filelist: []
  }
  UNSAFE_componentWillMount () {
    const { value } = this.props
    if (!value) return
    this.setState({filelist: fromJS(value).toJS()})
  }
  onChange = ({ fileList }) => {
    const { onChange } = this.props
    fileList = fileList.map(item => {
      if (item.status === 'error' && /^<!DOCTYPE html>/.test(item.response)) {
        item.response = ''
@@ -37,45 +43,35 @@
      return item
    })
    if (onChange) {
      onChange([...fileList])
    }
    this.setState({filelist: fileList})
    this.props.onChange(fileList)
  }
  onRemove = file => {
    const { value, onChange } = this.props
    const files = this.state.filelist.filter(v => v.uid !== file.uid)
    const files = value.filter(v => v.url !== file.url)
    if (onChange) {
      onChange(files)
    }
    this.setState({filelist: files})
    this.props.onChange(files)
  }
  onUpdate = (url) => {
    const { value, onChange } = this.props
    let filelist = fromJS(this.state.filelist).toJS()
    let filelist = fromJS(value).toJS()
    if (filelist[filelist.length -1]) {
    filelist[filelist.length -1].status = 'done'
    filelist[filelist.length -1].response = url
    filelist[filelist.length -1].origin = false
    if (onChange) {
      onChange([...filelist])
    }
    this.setState({filelist})
    this.props.onChange(filelist)
  }
  onDelete = (msg) => {
    const { value, onChange } = this.props
    let filelist = value.filter(v => !v.url && !v.response)
    let filelist = this.state.filelist.filter(v => !v.url && !v.response)
    if (onChange) {
      onChange([...filelist])
    }
    this.setState({
      showprogress: false
    })
    this.setState({filelist, showprogress: false})
    this.props.onChange(filelist)
    notification.warning({
      top: 92,
@@ -269,12 +265,12 @@
  }
  render() {
    const { value, maxFile, fileType, accept } = this.props
    const { showprogress, percent } = this.state
    const { maxFile, fileType, accept } = this.props
    const { showprogress, percent, filelist } = this.state
    let uploadable = 'fileupload-form-container '
    if (maxFile && maxFile > 0 && value && value.length >= maxFile) {
    if (maxFile && maxFile > 0 && filelist.length >= maxFile) {
      uploadable += 'limit-fileupload'
    }
@@ -282,7 +278,7 @@
      name: 'file',
      disabled: showprogress,
      listType: fileType,
      fileList: value,
      fileList: filelist,
      action: null,
      accept: accept || '',
      method: 'post',