king
2020-07-03 aed1ff699140de60131bf9cc1332c98063c66721
src/views/printTemplate/mutilform/index.jsx
@@ -3,7 +3,7 @@
import { is, fromJS } from 'immutable'
import { Form, Row, Col, Input, InputNumber, Select } from 'antd'
import { formRule } from '@/utils/option.js'
import FileUpload from '../fileupload'
import FileUpload from '@/tabviews/zshare/fileupload'
import './index.scss'
const { TextArea } = Input
@@ -60,6 +60,17 @@
          if (!isCusField) {
            delete fieldsvalue.cusfield
          }
          if (nextProps.editItem.type === 'image' && fieldsvalue.value) {
            fieldsvalue.value = [{
              uid: '1',
              name: fieldsvalue.value,
              status: 'done',
              url: fieldsvalue.value
            }]
          } else if (nextProps.editItem.type === 'image') {
            fieldsvalue.value = []
          }
          this.props.form.setFieldsValue(fieldsvalue)
        })
        
@@ -101,6 +112,19 @@
    this.handleSubmit()
  }
  updateImg = (list) => {
    if (list && list.length > 0) {
      let url = list[0].url || list[0].response
      if (url) {
        this.props.form.setFieldsValue({ value: list })
        this.handleSubmit()
      }
    } else {
      this.props.form.setFieldsValue({ value: [] })
      this.handleSubmit()
    }
  }
  resetForm = (param) => {
    let _param = JSON.parse(JSON.stringify(param))
    delete _param.type
@@ -109,6 +133,16 @@
    if (_param.field !== 'other_field') {
      delete _param.cusfield
    }
    if (param.type === 'image' && param.value) {
      _param.value = [{
        uid: '1',
        name: param.value,
        status: 'done',
        url: param.value
      }]
    } else if (param.type === 'image') {
      _param.value = []
    }
    this.props.form.setFieldsValue(_param)
@@ -204,23 +238,14 @@
          </Col>
        )
      } else if (item.type === 'fileupload') {
        let filelist = this.props.data ? this.props.data[item.field] : item.initval
        if (filelist && this.state.readin[item.field]) {
          try {
            filelist = filelist.split(',').map((url, index) => {
              return {
                uid: `${index}`,
                name: url.slice(url.lastIndexOf('/') + 1),
        let filelist = []
        if (item.initval) {
          filelist = [{
            uid: '1',
            name: item.initval,
                status: 'done',
                url: url,
                origin: true
              }
            })
          } catch {
            filelist = []
          }
        } else {
          filelist = []
            url: item.initval
          }]
        }
        fields.push(
@@ -235,7 +260,7 @@
                  }
                ]
              })(
                <FileUpload />
                <FileUpload maxFile={1} fileType={'text'} onChange={this.updateImg} />
              )}
            </Form.Item>
          </Col>