| | |
| | | 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 |
| | |
| | | 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) |
| | | }) |
| | | |
| | |
| | | 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 |
| | |
| | | |
| | | 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) |
| | |
| | | </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( |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <FileUpload /> |
| | | <FileUpload maxFile={1} fileType={'text'} onChange={this.updateImg} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |