| | |
| | | this.formRef.handleConfirm().then(res => { |
| | | let _config = fromJS(this.state.config).toJS() |
| | | let fieldrepet = false // 字段重复 |
| | | let labelrepet = false // 提示文字重复 |
| | | |
| | | _config.fields = _config.fields.map(item => { |
| | | if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) { |
| | | fieldrepet = true |
| | | } else if (res.label && item.uuid !== res.uuid && item.label === res.label) { |
| | | labelrepet = true |
| | | } |
| | | |
| | | if (item.uuid === res.uuid) { |
| | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '字段已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } else if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '名称已存在!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | |
| | | }) |
| | | } |
| | | |
| | | plusFields = (items) => { |
| | | let _config = fromJS(this.state.config).toJS() |
| | | |
| | | if (_config.fields[0] && _config.fields[0].origin) { |
| | | _config.fields = _config.fields.filter(item => !item.origin) |
| | | } |
| | | |
| | | _config.fields.push(...items) |
| | | |
| | | this.setState({ |
| | | config: _config |
| | | }, () => { |
| | | if (items.length === 1 && items[0].focus) { |
| | | this.handleForm(items[0]) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | | const { config, dict, saving } = this.state |
| | | |
| | |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <FieldsComponent |
| | | config={config} |
| | | type="form" |
| | | updatefield={this.updateConfig} |
| | | /> |
| | | <FieldsComponent config={config} type="form" plusFields={this.plusFields}/> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | <Card title={dict['header.menu.form.configurable']} bordered={false} extra={ |
| | | <div> |
| | | <Button type="danger" onClick={this.clearConfig}>清空</Button> |
| | | <EditComponent dict={dict} options={['form']} config={this.state.config} refresh={(res) => this.updateConfig(res.config)}/> |
| | | <EditComponent dict={dict} options={['form']} config={this.state.config} plusFields={this.plusFields}/> |
| | | <Button type="primary" loading={saving} onClick={this.submitConfig}>保存</Button> |
| | | <Button onClick={this.cancelConfig}>返回</Button> |
| | | </div> |