| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { datatype } = this.state |
| | | if (nextProps.data && !is(fromJS(this.props.data), fromJS(nextProps.data))) { |
| | | |
| | | let _fieldsvalue = {} |
| | | let _record = {} |
| | | Object.keys(nextProps.data).forEach(key => { |
| | | if (this.props.form.getFieldValue(key) !== undefined) { |
| | | if (datatype[key] === 'multiselect') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key].split(',').filter(Boolean) : [] |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'date') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key] : null |
| | | |
| | | if (_val) { |
| | | _val = moment(_val, 'YYYY-MM-DD') |
| | | } |
| | | |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'datemonth') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key] : null |
| | | |
| | | if (_val) { |
| | | _val = moment(_val, 'YYYY-MM') |
| | | } |
| | | |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'datetime') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key] : null |
| | | |
| | | if (_val) { |
| | | _val = moment(_val, 'YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'fileupload') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key] : '' |
| | | |
| | | if (_val) { |
| | | try { |
| | | _val = _val.split(',').map((url, index) => { |
| | | return { |
| | | uid: `${index}`, |
| | | name: url.slice(url.lastIndexOf('/') + 1), |
| | | status: 'done', |
| | | url: url, |
| | | origin: true |
| | | } |
| | | }) |
| | | } catch { |
| | | _val = [] |
| | | } |
| | | } else { |
| | | _val = [] |
| | | } |
| | | |
| | | _fieldsvalue[key] = _val |
| | | } else { |
| | | _fieldsvalue[key] = nextProps.data[key] |
| | | } |
| | | } else { |
| | | _record[key] = nextProps.data[key] |
| | | } |
| | |
| | | ) |
| | | } else if (item.type === 'datetime') { |
| | | let _initval = this.props.data ? this.props.data[item.field] : '' |
| | | |
| | | if (_initval && this.state.readin[item.field]) { |
| | | _initval = moment(_initval, 'YYYY-MM-DD HH:mm:ss') |
| | | } else { |
| | |
| | | message: formRule.textarea.message |
| | | } |
| | | ] |
| | | })(<TextArea autosize={{ minRows: 2, maxRows: 6 }} disabled={item.readonly === 'true'} />)} |
| | | })(<TextArea autosize={{ minRows: 2, maxRows: item.maxRows || 6 }} disabled={item.readonly === 'true'} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |