king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/components/editor/index.jsx
@@ -4,7 +4,7 @@
import BraftEditor from 'braft-editor'
import 'braft-editor/dist/index.css'
import 'braft-extensions/dist/table.css'
import 'braft-editor/dist/output.css'
// import 'braft-editor/dist/output.css'
import Table from 'braft-extensions/dist/table'
import SparkMD5 from 'spark-md5'
import moment from 'moment'
@@ -23,31 +23,60 @@
class NormalEditor extends Component {
  static propTpyes = {
    card: PropTypes.object,  // 条码设置
    value: PropTypes.any,    // 条码值
    config: PropTypes.object,
    onChange: PropTypes.func
  }
  state = {
    editorState: ''
    editorState: '',
    encryption: 'false',
  }
  UNSAFE_componentWillMount () {
    const { config, defaultValue } = this.props
    let initVal = null
    let encryption = 'false'
    if (this.props['data-__meta']) {
      initVal = this.props['data-__meta'].initialValue || null
    if (config && config.initval) {
      initVal = config.initval
    } else if (defaultValue) {
      initVal = defaultValue
    }
    if (config && config.encryption === 'true') {
      encryption = 'true'
      if (initVal) {
        try {
          initVal = window.decodeURIComponent(window.atob(initVal))
        } catch (e) {
          initVal = this.props['data-__meta'].initialValue || null
        }
      }
    }
    
    this.setState({editorState: BraftEditor.createEditorState(initVal)})
    this.setState({
      editorState: BraftEditor.createEditorState(initVal),
      encryption
    })
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps))
  }
  handleEditorChange = (editorState) => {
    const { encryption } = this.state
    this.setState({ editorState })
    if (this.props.onChange) {
      this.props.onChange(editorState.toHTML())
      let val = editorState.toHTML()
      if (encryption === 'true') {
        try {
          val = window.btoa(window.encodeURIComponent(val))
        } catch (e) {
          val = editorState.toHTML()
        }
      }
      this.props.onChange(val)
    }
  }
@@ -64,6 +93,7 @@
    form.append('fileExt', params.file.fileType)
    form.append('shardingCnt', _param.chunks)
    form.append('shardingNo', _param.chunk)
    form.append('LoginUID', sessionStorage.getItem('LoginUID') || '')
    Api.getLargeFileUpload(form).then(res => {
      if (res.status) {