king
2022-09-06 fa381753ef2a2b25b1c0722549ac17e333da79be
src/menu/components/form/formaction/actionform/index.jsx
@@ -21,6 +21,8 @@
    formlist: null,  // 表单信息
    interType: null, // 接口类型:内部、外部
    procMode: null,  // 参数方式
    linkmenu: null,
    callbackType: null
  }
  
@@ -29,12 +31,15 @@
    let _intertype = card.intertype || 'system'  // 接口类型
    let _procMode = card.procMode || 'system'    // 参数请求方式
    let _callbackType = card.callbackType || 'script'
    let _options = this.getOptions(_intertype, _procMode)
    let _options = this.getOptions(_intertype, _procMode, card.linkmenu, _callbackType)
    this.setState({
      interType: _intertype,
      procMode: _procMode,
      callbackType: _callbackType,
      linkmenu: card.linkmenu,
      formlist: this.props.formlist.map(item => {
        if (item.key === 'innerFunc' && _procMode === 'inner') {
          item.required = true
@@ -46,7 +51,7 @@
    })
  }
  getOptions = (_intertype, _procMode) => {
  getOptions = (_intertype, _procMode, linkmenu, _callbackType) => {
    const { card } = this.props
    if (card.type === 'prev') {
@@ -54,22 +59,42 @@
    } else if (card.type === 'next') {
      return ['type', 'label', 'enable']
    }
    let _options = ['type', 'label', 'intertype', 'syncComponent', 'anchors', 'linkmenu', 'open', 'enable', 'output', 'reload'] // 选项列表
    let _options = ['type', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'enable', 'output', 'reload'] // 选项列表
    
    if (_intertype === 'custom') {
      _options.pop()
      _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method', 'cross')
      _options.push('procMode', 'interface', 'callbackType', 'proInterface', 'method', 'cross')
      if (_procMode === 'system') {
        _options.push('sql', 'sqlType')
      } else {
        _options.push('innerFunc')
      }
      if (_callbackType === 'func') {
        _options.push('callbackFunc')
      } else if (_callbackType !== 'none') {
        _options.push('cbTable')
      }
    } else if (_intertype === 'outer') {
      _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc')
      _options.push('procMode', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackType')
      if (_procMode === 'system') {
        _options.push('sql', 'sqlType')
      } else if (_procMode === 'inner') {
        _options.push('innerFunc')
      }
      if (_callbackType === 'func') {
        _options.push('callbackFunc')
      } else if (_callbackType !== 'none') {
        _options.push('cbTable')
      }
    } else if (_intertype === 'inner') {
      _options.push('innerFunc')
    } else {
      _options.push('sql', 'sqlType')
    }
    if (linkmenu && linkmenu !== 'goback') {
      _options.push('open')
    }
    return _options
@@ -82,10 +107,10 @@
   * 3、切换标签类型,重置可选标签
   */
  optionChange = (key, value) => {
    const { procMode } = this.state
    const { procMode, linkmenu, callbackType } = this.state
    if (key === 'intertype') {
      let _options = this.getOptions(value, procMode)
      let _options = this.getOptions(value, procMode, linkmenu, callbackType)
      this.setState({
        interType: value,
@@ -101,16 +126,39 @@
        })
      })
    } else if (key === 'procMode') {
      let _options = this.getOptions(this.state.interType, value)
      let _options = this.getOptions(this.state.interType, value, linkmenu, callbackType)
      this.setState({
        procMode: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          if (item.key === 'innerFunc') {
            item.required = true
          if (item.key === 'procMode') {
            item.initVal = value
          }
          return item
        })
      })
    } else if (key === 'linkmenu') {
      let _options = this.getOptions(this.state.interType, procMode, value, callbackType)
      this.setState({
        linkmenu: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          return item
        })
      })
    } else if (key === 'callbackType') {
      let _options = this.getOptions(this.state.interType, procMode, linkmenu, value)
      this.setState({
        callbackType: value,
        formlist: this.state.formlist.map(item => {
          if (item.key === 'callbackType') {
            item.initVal = value
          }
          item.hidden = !_options.includes(item.key)
          return item
        })
      })
@@ -144,6 +192,7 @@
  getFields() {
    const { getFieldDecorator } = this.props.form
    const { interType, callbackType } = this.state
    const fields = []
    this.state.formlist.forEach((item, index) => {
@@ -169,6 +218,24 @@
            max: formRule.func.max,
            message: formRule.func.maxMessage
          }]
        } else if (item.key === 'output') {
          if (interType === 'system' || ((interType === 'outer' || interType === 'custom') && callbackType === 'script')) {
            _rules = [{
              pattern: /^@[0-9a-zA-Z_]+@?$/,
              message: '变量以@符开头,可使用字母、数字以及_'
            }, {
              max: 100,
              message: '最多100个字符。'
            }]
          } else {
            _rules = [{
              pattern: /^[0-9a-zA-Z_]*$/,
              message: '字段可使用字母、数字以及_'
            }, {
              max: 100,
              message: '最多100个字符。'
            }]
          }
        } else {
          _rules = [{
            max: formRule.input.max,