king
2023-09-28 76251922200560a63d0703ce2f936246ce8bc46e
src/tabviews/zshare/fileupload/index.jsx
@@ -5,7 +5,9 @@
import { Upload, Button, Progress, notification } from 'antd'
import { UploadOutlined } from '@ant-design/icons'
import SparkMD5 from 'spark-md5'
import Api from '@/api'
import MKEmitter from '@/utils/events.js'
import './index.scss'
class FileUpload extends Component {
@@ -129,7 +131,9 @@
    this.props.onChange(vals.join(','))
  }
  onUpdate = (url) => {
  onUpdate = (url, file_name) => {
    const { config } = this.props
    let filelist = fromJS(this.state.filelist).toJS()
    if (filelist[filelist.length -1]) {
@@ -151,7 +155,20 @@
    })
    this.setState({filelist})
    if (config.subFields) {
      let other = {}
      config.subFields.forEach((n, i) => {
        other[n.field] = file_name
        setTimeout(() => {
          MKEmitter.emit('mkFC', 'input', n.uuid, file_name)
        }, i * 5)
      })
      this.props.onChange(vals.join(','), other)
    } else {
    this.props.onChange(vals.join(','))
    }
  }
  onFail = (msg) => {
@@ -171,7 +188,7 @@
    })
  }
  shardupload = (param) => {
  shardupload = (param, file_name) => {
    let form = new FormData()
    form.append('file', param.binary)
@@ -189,7 +206,7 @@
    Api.getLargeFileUpload(form).then(res => {
      if (res.status) {
        if (res.urlPath) {
          this.onUpdate(res.urlPath)
          this.onUpdate(res.urlPath, file_name)
        } else {
          this.onFail()
        }
@@ -253,6 +270,8 @@
      percent: 0
    })
    let file_name = file.name.replace(/\.{1}[^.]*$/ig, '')
    if (compress === 'true' || compress === 'base64') {
      let reader = new FileReader()
      let fileSize = file.size / 1024 / 1024
@@ -292,7 +311,7 @@
          let param = {Base64Img: cvs.toDataURL('image/jpeg', compressRate)}
          if (this.props.config.compress === 'base64') {
            this.onUpdate(param.Base64Img)
            this.onUpdate(param.Base64Img, file_name)
  
            this.setState({
              percent: 100
@@ -317,7 +336,7 @@
                  url = rduri.replace(/webapi(.*)$/, '') + result.Images
                }
  
                this.onUpdate(url)
                this.onUpdate(url, file_name)
  
                this.setState({
                  percent: 100
@@ -358,7 +377,7 @@
        if (res.status) {
          if (res.urlPath) {
            let path = (/^\/\//.test(res.urlPath) ? 'https:' : '') + res.urlPath
            this.onUpdate(path)
            this.onUpdate(path, file_name)
            this.setState({
              percent: 100
            }, () => {
@@ -403,7 +422,7 @@
      
      Api.getFilePreUpload(_param).then(res => {
        if (res.status && res.urlPath) {
          this.onUpdate(res.urlPath)
          this.onUpdate(res.urlPath, file_name)
          this.setState({
            percent: 100
          }, () => {
@@ -415,7 +434,7 @@
            }, 200)
          })
        } else {
          this.shardupload(param)
          this.shardupload(param, file_name)
        }
      })
    }