king
2021-01-24 d36c27e80e668b3bc1dcd687a18a2f2d125b32db
src/menu/components/share/actioncomponent/actionform/index.jsx
@@ -34,6 +34,7 @@
    openType: null,  // 打开方式
    interType: null, // 接口类型:内部、外部
    funcType: null,  // 功能类型
    procMode: null,  // 参数方式
    requireOptions: [{
      value: 'notRequired',
      text: this.props.dict['header.form.notRequired']
@@ -66,6 +67,19 @@
    }, {
      value: 'custom',
      text: this.props.dict['header.form.custom']
    }],
    interTypeOptions: [{
      value: 'system',
      text: this.props.dict['model.interface.system']
    }, {
      value: 'inner',
      text: this.props.dict['model.interface.inner']
    }, {
      value: 'outer',
      text: this.props.dict['model.interface.outer']
    }, {
      value: 'custom',
      text: '自定义'
    }]
  }
@@ -76,16 +90,23 @@
    let _opentype = card.OpenType                // 打开方式
    let _intertype = card.intertype || 'system'  // 接口类型
    let _funcType = card.funcType || 'print'     // 功能按钮默认类型
    let _procMode = card.procMode || 'system'     // 参数请求方式
    let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate)
    let _options = this.getOptions(_opentype, _intertype, _funcType, card.pageTemplate, _procMode)
    this.setState({
      openType: _opentype,
      interType: _intertype,
      procMode: _procMode,
      funcType: _funcType,
      formlist: this.props.formlist.map(item => {
        if (item.key === 'class') {
          item.options = btnCustomClasses
        } else if (item.key === 'innerFunc' && _procMode === 'inner') {
          item.required = true
        } else if (item.key === 'intertype') {
          let iscustom = ['pop', 'prompt', 'exec'].includes(_opentype)
          item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom'))
        } else if (item.key === 'icon') {
          item.options = btnIcons
        } else if (item.key === 'Ot') {
@@ -116,7 +137,7 @@
    })
  }
  getOptions = (_opentype, _intertype, _funcType, _pageTemplate) => {
  getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode) => {
    let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 选项列表
    
    if (_opentype === 'innerpage') {         // 新页面,可选模板(自定义时,可填入外部链接)
@@ -145,7 +166,14 @@
        }
      }
    } else if (_opentype !== 'popview' && _opentype !== 'tab') {
      if (_intertype === 'outer') {
      if (_intertype === 'custom') {
        _options.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method')
        if (_procMode === 'system') {
          _options.push('sql', 'sqlType')
        } else {
          _options.push('innerFunc')
        }
      } else if (_intertype === 'outer') {
        _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc')
      } else if (_intertype === 'inner') {
        _options.push('innerFunc')
@@ -176,21 +204,27 @@
   * 2、显示位置切换,重置选择行
   * 3、切换标签类型,重置可选标签
   */
  openTypeChange = (key, value) => {
  optionChange = (key, value) => {
    const { card, type } = this.props
    const { openType, procMode } = this.state
    if (key === 'OpenType') {
      let _options = this.getOptions(value, this.state.interType, this.state.funcType, card.pageTemplate)
      let _options = this.getOptions(value, 'system', this.state.funcType, card.pageTemplate, 'system')
      let _fieldval = {}
      
      let _formlist = this.state.formlist.map(item => {
        item.hidden = !_options.includes(item.key)
        if (item.key === 'intertype') {
          let iscustom = ['pop', 'prompt', 'exec'].includes(value)
          item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom'))
        }
        if (item.hidden) return item
        if (item.key === 'intertype') {
          _fieldval.intertype = this.state.interType
          _fieldval.intertype = 'system'
        } else if (item.key === 'Ot') {
          if (type === 'card') {
            item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value))
@@ -217,6 +251,8 @@
      this.setState({
        openType: value,
        intertype: 'system',
        procMode: 'system',
        formlist: _formlist
      }, () => {
        if (value === 'excelIn') {
@@ -230,7 +266,7 @@
        this.props.form.setFieldsValue(_fieldval)
      })
    } else if (key === 'funcType') {
      let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate)
      let _options = this.getOptions(this.state.openType, this.state.interType, value, card.pageTemplate, procMode)
      let _fieldval = {}
      this.setState({
@@ -294,7 +330,7 @@
      })
    } else if (key === 'pageTemplate') {
      let _fieldval = {}
      let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value)
      let _options = this.getOptions(this.state.openType, this.state.interType, this.state.funcType, value, procMode)
      this.setState({
        openType: value,
@@ -317,16 +353,8 @@
      }, () => {
        this.props.form.setFieldsValue(_fieldval)
      })
    }
  }
  onChange = (e, key) => {
    const { type } = this.props
    const { openType } = this.state
    let value = e.target.value
    if (key === 'intertype') {
      let _options = this.getOptions(openType, value, this.state.funcType)
    } else if (key === 'intertype') {
      let _options = this.getOptions(openType, value, this.state.funcType, '', procMode)
      this.setState({
        interType: value,
@@ -346,10 +374,20 @@
          }
          return item
        })
      }, () => {
        if (this.props.form.getFieldValue('sqlType') !== undefined) {
          this.props.form.setFieldsValue({sqlType: ''})
        }
      })
    } else if (key === 'procMode') {
      let _options = this.getOptions(openType, this.state.interType, this.state.funcType, '', value)
      this.setState({
        procMode: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          if (item.key === 'innerFunc') {
            item.required = true
          }
          return item
        })
      })
    } else if (key === 'sysInterface') {
      if (value === 'true') {
@@ -475,7 +513,7 @@
                <Select
                  showSearch
                  filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  onChange={(value) => {this.openTypeChange(item.key, value)}}
                  onChange={(value) => {this.optionChange(item.key, value)}}
                  getPopupContainer={() => document.getElementById('winter')}
                >
                  {item.options.map((option, index) =>
@@ -501,7 +539,7 @@
                  }
                ]
              })(
                <Radio.Group onChange={(e) => {this.onChange(e, item.key)}} disabled={item.readonly}>
                <Radio.Group onChange={(e) => {this.optionChange(item.key, e.target.value)}} disabled={item.readonly}>
                  {
                    item.options.map(option => {
                      return (
@@ -520,7 +558,7 @@
            <Form.Item label={item.label} className="textarea">
              {getFieldDecorator(item.key, {
                initialValue: item.initVal
              })(<TextArea rows={4} />)}
              })(<TextArea rows={2} />)}
            </Form.Item>
          </Col>
        )