From 880a41a2135d944169d94028f19344ca66b673a0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 02 十一月 2020 18:23:45 +0800 Subject: [PATCH] 2020-11-02 --- src/templates/sharecomponent/columncomponent/columnform/index.jsx | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/templates/sharecomponent/columncomponent/columnform/index.jsx b/src/templates/sharecomponent/columncomponent/columnform/index.jsx index 0deb323..4d1d544 100644 --- a/src/templates/sharecomponent/columncomponent/columnform/index.jsx +++ b/src/templates/sharecomponent/columncomponent/columnform/index.jsx @@ -8,8 +8,8 @@ import './index.scss' const columnTypeOptions = { - text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'fieldlength', 'blacklist', 'linkmenu', 'rowspan'], - number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'blacklist', 'linkmenu', 'sum'], + text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'fieldlength', 'blacklist', 'perspective', 'rowspan'], + number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'blacklist', 'perspective', 'sum'], link: ['label', 'field', 'type', 'nameField', 'Align', 'Hide', 'IsSort', 'joint', 'Width', 'fieldlength', 'blacklist'], textarea: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'fieldlength', 'blacklist'], picture: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale', 'maxHeight'] @@ -26,6 +26,7 @@ state = { formlist: null, + type: '', menulist: null } @@ -34,8 +35,16 @@ let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' let _options = JSON.parse(JSON.stringify(columnTypeOptions[card.type])) + if (card.type === 'text' || card.type === 'number') { + if (card.perspective !== 'linkurl') { + _options.push('linkmenu') + } else { + _options.push('linkurl') + } + } this.setState({ + type: card.type, menulist: _menulist.options || [], formlist: this.props.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -62,8 +71,18 @@ } typeChange = (key, value) => { + const { card } = this.props if (key === 'type') { let _options = JSON.parse(JSON.stringify(columnTypeOptions[value])) + + if (card.type === 'text' || card.type === 'number') { + if (card.perspective !== 'linkurl') { + _options.push('linkmenu') + } else { + _options.push('linkurl') + } + } + let fieldlength = 50 if (value !== 'text') { @@ -71,6 +90,7 @@ } this.setState({ + type: value, formlist: this.props.formlist.map(item => { item.hidden = !_options.includes(item.key) @@ -84,6 +104,27 @@ } else if (key === 'format' && value === 'percent') { this.props.form.setFieldsValue({postfix: '%'}) } + } + + changeRadio = (key, value) => { + if (key === 'perspective') { + let _options = JSON.parse(JSON.stringify(columnTypeOptions[this.state.type])) + + if (value !== 'linkurl') { + _options.push('linkmenu') + } else { + _options.push('linkurl') + } + + this.setState({ + formlist: this.props.formlist.map(item => { + item.hidden = !_options.includes(item.key) + + return item + }) + }) + } + } handleSubmit = (e) => { @@ -110,7 +151,7 @@ max: formRule.field.max, message: formRule.field.maxMessage }] - } else { + } else if (item.key !== 'linkurl') { rules = [{ max: formRule.input.max, message: formRule.input.message @@ -206,7 +247,7 @@ } ] })( - <Radio.Group> + <Radio.Group onChange={(e) => {this.changeRadio(item.key, e.target.value)}}> { item.options.map(option => { return ( @@ -318,7 +359,6 @@ return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - values.id = this.props.card.id values.uuid = this.props.card.uuid values.marks = this.props.card.marks || '' -- Gitblit v1.8.0