| | |
| | | state = { |
| | | openType: null, |
| | | resourceType: null, |
| | | formlist: null |
| | | formlist: null, |
| | | linkSubFields: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let formlist = JSON.parse(JSON.stringify(this.props.formlist)) |
| | | |
| | | let type = formlist.filter(cell => cell.key === 'type')[0].initVal |
| | | let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal |
| | | let type = '' |
| | | let resourceType = '' |
| | | let linkSubFields = [] |
| | | |
| | | formlist.forEach(cell => { |
| | | if (cell.key === 'type') { |
| | | type = cell.initVal |
| | | } else if (cell.key === 'resourceType') { |
| | | resourceType = cell.initVal |
| | | } else if (cell.key === 'linkSubField') { |
| | | let arr = [] |
| | | linkSubFields = cell.options.filter(option => { |
| | | if (!['Value', 'Text'].includes(option.field) && cell.initVal.includes(option.field) && !arr.includes(option.field)) { |
| | | arr.push(option.field) |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin'] // 默认显示项 |
| | | |
| | | if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 选择类型、自定义资源 |
| | |
| | | } else if (type === 'linkMain') { |
| | | _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength'] |
| | | } |
| | | |
| | | |
| | | this.setState({ |
| | | openType: type, |
| | | resourceType: resourceType, |
| | | linkSubFields: linkSubFields, |
| | | formlist: formlist.map(form => { |
| | | if (dateOptions.hasOwnProperty(type) && form.key === 'initval') { |
| | | form.options = dateOptions[type] |
| | |
| | | form.show = false |
| | | } else if (form.key === 'resourceType') { |
| | | form.initVal = this.state.resourceType |
| | | } else if (form.key === 'linkSubField') { |
| | | form.initVal = this.state.linkSubFields.map(_field => _field.field) |
| | | } |
| | | return form |
| | | }) |
| | |
| | | |
| | | multiselectChange = (key, value, options) => { |
| | | if (key === 'linkSubField') { |
| | | let arr = [] |
| | | let linkSubFields = options.filter(option => { |
| | | if (!['Value', 'Text'].includes(option.field) && value.includes(option.field) && !arr.includes(option.field)) { |
| | | arr.push(option.field) |
| | | return true |
| | | } else { |
| | | return false |
| | | } |
| | | }) |
| | | |
| | | this.setState({linkSubFields: linkSubFields}) |
| | | } |
| | | console.log(key) |
| | | console.log(value) |
| | | console.log(options) |
| | | } |
| | | |
| | | onChange = (e, key) => { |
| | |
| | | } else if (item.type === 'options') { |
| | | fields.push( |
| | | <Col span={20} offset={4} key={index}> |
| | | <EditTable data={item.initVal} type={this.state.openType} ref="editTable"/> |
| | | <EditTable data={item.initVal} type={this.state.openType} linkSubFields={this.state.linkSubFields} ref="editTable"/> |
| | | </Col> |
| | | ) |
| | | } |