From 6d0137932fcc8f9848123743c1aad5cff8172d8a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 09 二月 2020 13:09:39 +0800 Subject: [PATCH] 2020-02-09 --- src/templates/formtabconfig/settingform/index.jsx | 80 ++++++++++++++++++++++++++++++---------- 1 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/templates/formtabconfig/settingform/index.jsx b/src/templates/formtabconfig/settingform/index.jsx index b6b8b60..035ce8d 100644 --- a/src/templates/formtabconfig/settingform/index.jsx +++ b/src/templates/formtabconfig/settingform/index.jsx @@ -4,7 +4,7 @@ import { formRule } from '@/utils/option.js' import './index.scss' -const { TextArea } = Input +// const { TextArea } = Input class SettingForm extends Component { static propTpyes = { @@ -15,10 +15,11 @@ } state = { - interType: null, + interType: (this.props.config.setting && this.props.config.setting.interType) || 'inner', columns: null, currentTabs: null, - selectTabs: [] + selectTabs: [], + interReadonly: false } UNSAFE_componentWillMount() { @@ -28,18 +29,15 @@ let _select = [] let _tabMap = new Map() let _columns = [] - let _interType = 'inner' let _setting = config.setting - + try { - _columns = menu.LongParam.columns.filter(item => item.field && item.type !== 'colspan') + if (menu && menu.LongParam) { + _columns = menu.LongParam.columns.filter(item => item.field && item.type !== 'colspan') + } config.groups.forEach(group => { - if (group.isDefault) { - let list = group.sublist.filter(item => !item.origin) - _columns = [..._columns, ...list] - } else { - _columns = [..._columns, ...group.sublist] - } + let list = group.sublist.filter(item => item.field) + _columns = [..._columns, ...list] }) let _colMap = new Map() @@ -51,7 +49,6 @@ return true } }) - _interType = menu.LongParam.setting.interType } catch { notification.warning({ top: 92, @@ -79,8 +76,8 @@ currentTabs: _tabs, selectTabs: _select, columns: _columns, - interType: _interType, - setting: _setting + setting: _setting, + interReadonly: _setting.sysInterface === 'true' }) } @@ -97,14 +94,45 @@ }) } + onSysChange = (e) => { + if (e.target.value === 'true') { + this.props.form.setFieldsValue({ + interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi + }) + this.setState({ + interReadonly: true + }) + } else { + this.setState({ + interReadonly: false + }) + } + } + onChange = (e) => { this.setState({ interType: e.target.value + }, () => { + if (e.target.value === 'inner') return + + let _type = this.props.form.getFieldValue('sysInterface') + if (_type === 'true') { + this.props.form.setFieldsValue({ + interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi + }) + this.setState({ + interReadonly: true + }) + } else { + this.setState({ + interReadonly: false + }) + } }) } render() { - const { dict, menu, usefulFields } = this.props + const { dict, usefulFields } = this.props const { getFieldDecorator } = this.props.form const { interType, columns, selectTabs, setting } = this.state @@ -179,9 +207,21 @@ </Form.Item> </Col> {interType === 'outer' ? <Col span={12}> + <Form.Item label={dict['header.form.sysInterface']}> + {getFieldDecorator('sysInterface', { + initialValue: setting.sysInterface || 'false' + })( + <Radio.Group onChange={this.onSysChange}> + <Radio value="true">{dict['header.form.true']}</Radio> + <Radio value="false">{dict['header.form.false']}</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={12}> <Form.Item label={dict['header.form.interface']}> {getFieldDecorator('interface', { - initialValue: setting.interface || '', + initialValue: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || window.GLOB.subSystemApi) : (setting.interface || ''), rules: [ { required: true, @@ -192,7 +232,7 @@ message: formRule.input.message } ] - })(<Input placeholder="" autoComplete="off" />)} + })(<Input placeholder="" autoComplete="off" disabled={this.state.interReadonly} />)} </Form.Item> </Col> : null} {interType !== 'outer' ? <Col span={12}> @@ -216,7 +256,7 @@ })(<Input placeholder="" autoComplete="off" />)} </Form.Item> </Col> : null} - {interType !== 'outer' ? <Col span={24}> + {/* {interType !== 'outer' ? <Col span={24}> <Form.Item help={'鏁版嵁ID锛�' + menu.MenuID} label={ <Tooltip placement="topLeft" title="浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愶紝鑷畾涔夊嚱鏁版椂锛屽彲蹇界暐銆�"> <Icon type="question-circle" /> @@ -227,7 +267,7 @@ initialValue: setting.dataresource })(<TextArea rows={4} />)} </Form.Item> - </Col> : null} + </Col> : null} */} {interType === 'outer' ? <Col span={12}> <Form.Item label={dict['header.form.outerFunc']}> {getFieldDecorator('outerFunc', { -- Gitblit v1.8.0