king
2020-02-09 6d0137932fcc8f9848123743c1aad5cff8172d8a
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 {
      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]
        }
      config.groups.forEach(group => {
        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', {