From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 21 十月 2021 23:17:08 +0800 Subject: [PATCH] 2021-10-21 --- src/menu/modalconfig/index.jsx | 96 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx index 7aed763..4a8f734 100644 --- a/src/menu/modalconfig/index.jsx +++ b/src/menu/modalconfig/index.jsx @@ -87,7 +87,7 @@ let _config = fromJS(this.state.config).toJS() if (list.length > _config.fields.length) { - _config.fields = list.filter(item => !item.origin) + _config.fields = list this.setState({ config: _config @@ -114,34 +114,51 @@ let _tabfields = [] let _linkableFields = [] let _linksupFields = [{ - value: '', - text: '绌�' + field: '', + label: '绌�' }] let standardform = null - _inputfields = config.fields.filter(item => item.type === 'text' || item.type === 'number' || item.type === 'textarea' || item.type === 'color') - _tabfields = config.fields.filter(item => card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) - _tabfields.unshift({field: '', text: '鍘熻〃鍗�'}) - let uniq = new Map() - uniq.set(card.field, true) let index = null + uniq.set(card.field, true) + + let _inputIndex = 1 + let _tabIndex = 1 + let _linkIndex = 1 config.fields.forEach((item, i) => { if (card.uuid === item.uuid) { index = i } + + if (['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) { + _inputfields.push({ + field: item.field, + label: _inputIndex + '銆�' + item.label + }) + _inputIndex++ + } + if (card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { + _tabfields.push({ + field: item.field, + label: _tabIndex + '銆�' + item.label + }) + _tabIndex++ + } + if (!['select', 'link', 'radio', 'checkcard'].includes(item.type)) return if (item.field && !uniq.has(item.field)) { uniq.set(item.field, true) _linkableFields.push({ - value: item.field, - text: item.label + ' (琛ㄥ崟)' + field: item.field, + label: _linkIndex + '銆�' + item.label + ' (琛ㄥ崟)' }) _linksupFields.push({ - value: item.field, - text: item.label + field: item.field, + label: _linkIndex + '銆�' + item.label }) + _linkIndex++ } }) if (index !== null) { @@ -152,14 +169,17 @@ } } + _tabfields.unshift({field: '', label: '鍘熻〃鍗�'}) + componentConfig.columns.forEach(col => { if (col.field && !uniq.has(col.field)) { uniq.set(col.field, true) _linkableFields.push({ - value: col.field, - text: col.label + ' (鏄剧ず鍒�)' + field: col.field, + label: _linkIndex + '銆�' + col.label + ' (鏄剧ず鍒�)' }) + _linkIndex++ } }) @@ -191,13 +211,10 @@ 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) { @@ -214,16 +231,7 @@ duration: 10 }) return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦紒', - duration: 10 - }) - return } - - _config.fields = _config.fields.filter(item => !item.origin) if (['select', 'multiselect', 'link', 'checkbox', 'radio', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { this.setState({ @@ -301,6 +309,19 @@ setTimeout(() => { MKEmitter.emit('triggerMenuSave') }, 100) + } + + clearConfig = () => { + const _this = this + let _config = {...this.state.config, fields: []} + + confirm({ + content: '纭畾娓呯┖琛ㄥ崟鍚楋紵', + onOk() { + _this.setState({ config: _config }) + }, + onCancel() {} + }) } completeSave = () => { @@ -409,6 +430,20 @@ }) } + plusFields = (items) => { + let _config = fromJS(this.state.config).toJS() + + _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 @@ -423,18 +458,15 @@ 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> <div className="setting"> <Card title={dict['header.menu.form.configurable']} bordered={false} extra={ <div> - <EditComponent dict={dict} options={['form']} config={this.state.config} refresh={(res) => this.updateConfig(res.config)}/> + <Button type="danger" onClick={this.clearConfig}>娓呯┖</Button> + <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> -- Gitblit v1.8.0