| | |
| | | formlist: nextProps.formlist.map(item => { |
| | | if (item.key === 'cusfield' && isCusField) { |
| | | item.hidden = false |
| | | } else if (item.key === 'value' && item.type === 'fileupload') { |
| | | item.hidden = true |
| | | item.initval = fieldsvalue.value |
| | | } |
| | | |
| | | return item |
| | |
| | | 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 = [] |
| | | if (nextProps.editItem.type === 'image') { |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(item => { |
| | | if (item.key === 'value' && item.type === 'fileupload') { |
| | | item.hidden = false |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | }) |
| | | delete 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 }) |
| | | updateImg = (val) => { |
| | | this.props.form.setFieldsValue({ value: val }) |
| | | this.handleSubmit() |
| | | } |
| | | } else { |
| | | this.props.form.setFieldsValue({ value: [] }) |
| | | this.handleSubmit() |
| | | } |
| | | } |
| | | |
| | | resetForm = (param) => { |
| | |
| | | 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 = [] |
| | | |
| | | if (param.type === 'image') { |
| | | delete _param.value |
| | | } |
| | | |
| | | this.props.form.setFieldsValue(_param) |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'fileupload') { |
| | | let filelist = [] |
| | | if (item.initval) { |
| | | filelist = [{ |
| | | uid: '1', |
| | | name: item.initval, |
| | | status: 'done', |
| | | url: item.initval |
| | | }] |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={24} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: filelist, |
| | | initialValue: item.initval || '', |
| | | rules: [ |
| | | { |
| | | required: item.required, |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <FileUpload maxFile={1} fileType={'text'} onChange={this.updateImg} /> |
| | | <FileUpload config={{ |
| | | initval: item.initval || '', |
| | | suffix: '', |
| | | maxfile: 1, |
| | | fileType: 'text' |
| | | }} onChange={this.updateImg} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | if (!err) { |
| | | values.uuid = this.props.editItem.uuid |
| | | values.type = this.props.editItem.type |
| | | |
| | | resolve(values) |
| | | } |
| | | }) |