king
2021-12-22 bd1dfc9e6c9b9f8076ca2783ce598e0936b4c664
src/templates/sharecomponent/actioncomponent/actionform/index.jsx
@@ -1,10 +1,11 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd'
import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { btnIcons, btnClasses, formRule } from '@/utils/option.js'
import MkIcon from '@/components/mk-icon'
import Utils from '@/utils/utils.js'
import './index.scss'
@@ -15,8 +16,8 @@
  exec: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output'],
  excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'icon', 'class', 'sheet', 'execSuccess', 'execError'],
  excelOut: ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search'],
  popview: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose', 'display', 'ratio', 'placement'],
  tab: ['label', 'Ot', 'OpenType', 'tabTemplate', 'icon', 'class', 'position'],
  popview: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose', 'display', 'ratio', 'placement', 'clickouter'],
  tab: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position'],
  innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'],
  funcbutton: ['label', 'OpenType', 'funcType', 'icon', 'class']
}
@@ -38,6 +39,7 @@
    funcType: null,  // 功能类型
    position: null,  // 按钮位置
    procMode: null,  // 外部接口参数处理方式
    control: '',
    pageTemplate: null,
    Ot: null,
    requireOptions: [{
@@ -65,10 +67,10 @@
    }],
    deleteOptions: [{
      value: 'LogicDelete',
      text: this.props.dict['header.form.action.LogicDelete']
      text: '逻辑删除'
    }, {
      value: 'delete',
      text: this.props.dict['header.form.action.delete']
      text: '物理删除'
    }, {
      value: 'custom',
      text: this.props.dict['header.form.custom']
@@ -97,9 +99,9 @@
    let _intertype = card.intertype || 'system' // 接口类型
    let _procMode = card.procMode || 'system'   // 参数处理方式
    let _funcType = card.funcType || ''         // 功能按钮默认类型
    let _tabTemplate = card.tabTemplate         // 按钮为标签页时,标签类型:三级菜单或表单标签页
    let _pageTemplate = card.pageTemplate       // 新页面类型
    let _Ot = card.Ot || 'requiredSgl'
    let control = card.control || ''
    if (_opentype === 'outerpage') {
      card.pageTemplate = 'custom'
@@ -107,9 +109,10 @@
    }
    let _tabs = this.props.tabs.filter(tab => tab.type === 'SubTable')
    let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode, _Ot)
    let _options = this.getOptions(_opentype, _intertype, _funcType, _pageTemplate, _procMode, _Ot, control)
    
    this.setState({
      control: control,
      Ot: _Ot,
      openType: _opentype,
      pageTemplate: _pageTemplate,
@@ -176,7 +179,7 @@
    }
  }
  getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _tabTemplate, _procMode, _Ot) => {
  getOptions = (_opentype, _intertype, _funcType, _pageTemplate, _procMode, _Ot, _control) => {
    let _options = fromJS(actionTypeOptions[_opentype]).toJS() // 选项列表
    
    if (_opentype === 'innerpage') {         // 新页面,可选模板(自定义时,可填入外部链接)
@@ -186,7 +189,7 @@
        _options.push('printTemp')
      }
    } else if (_opentype === 'tab') {         // 标签页
      if (_tabTemplate === 'ThdMenu') {
      if (this.props.card.tabTemplate !== 'FormTab') {
        _options.push('linkmenu')
      }
    } else if (_opentype === 'excelOut') {    // 导入导出
@@ -203,7 +206,7 @@
      }
    } else if (_opentype === 'funcbutton') {
      if (_funcType === 'print') {
        _options.push('execMode', 'intertype', 'Ot', 'execSuccess', 'execError', 'controlField', 'controlVal')
        _options.push('execMode', 'intertype', 'Ot', 'execSuccess', 'execError')
        if (_intertype === 'outer') {
          _options.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc')
        } else if (_intertype === 'inner') {
@@ -233,8 +236,11 @@
      _options.push('resetPageIndex')
    }
    if (_Ot !== 'notRequired' && _opentype !== 'excelOut' && _opentype !== 'funcbutton') {
      _options.push('controlField', 'controlVal')
    if (_Ot !== 'notRequired' && _opentype !== 'excelOut') {
      _options.push('control')
      if (_control) {
        _options.push('controlField', 'controlVal')
      }
    }
    return _options
@@ -244,11 +250,11 @@
   * @description 切换
   */
  optionChange = (key, value) => {
    const { openType, funcType, procMode, Ot } = this.state
    const { openType, funcType, procMode, Ot, control } = this.state
    const { card } = this.props
    if (key === 'OpenType') {
      let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, card.tabTemplate, 'system', Ot)
      let _options = this.getOptions(value, 'system', '', this.state.pageTemplate, 'system', Ot, control)
      let _fieldval = {}
      let _formlist = this.state.formlist.map(item => {
        item.hidden = !_options.includes(item.key)
@@ -256,6 +262,8 @@
        if (item.key === 'intertype') {
          let iscustom = ['pop', 'prompt', 'exec'].includes(value)
          item.options = this.state.interTypeOptions.filter(op => (iscustom || op.value !== 'custom'))
        } else if (item.key === 'control') {
          item.initVal = control
        }
        if (item.hidden) return item
@@ -333,7 +341,7 @@
        this.props.form.setFieldsValue(_fieldval)
      })
    } else if (key === 'funcType') {
      let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, card.tabTemplate, procMode, Ot)
      let _options = this.getOptions('funcbutton', this.state.interType, value, card.pageTemplate, procMode, Ot, control)
      let _fieldval = {}
      if (value === 'print') {
@@ -393,7 +401,7 @@
        this.props.form.setFieldsValue(_fieldval)
      })
    } else if (key === 'pageTemplate') {
      let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, card.tabTemplate, procMode, Ot)
      let _options = this.getOptions('innerpage', this.state.interType, this.state.funcType, value, procMode, Ot, control)
      let _fieldval = {}
      this.setState({
@@ -418,23 +426,8 @@
      }, () => {
        this.props.form.setFieldsValue(_fieldval)
      })
    } else if (key === 'tabTemplate') {
      let _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate']
      if (value === 'ThdMenu') {
        _options.push('linkmenu')
      }
      this.setState({
        openType: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          return item
        })
      })
    } else if (key === 'intertype') {
      let _options = this.getOptions(openType, value, funcType, '', '', procMode, Ot)
      let _options = this.getOptions(openType, value, funcType, '', procMode, Ot, control)
      this.setState({
        interType: value,
@@ -454,7 +447,7 @@
        })
      })
    } else if (key === 'procMode') {
      let _options = this.getOptions(openType, this.state.interType, funcType, '', '', value, Ot)
      let _options = this.getOptions(openType, this.state.interType, funcType, '', value, Ot, control)
      this.setState({
        procMode: value,
@@ -468,10 +461,20 @@
        })
      })
    } else if (key === 'Ot') {
      let _options = this.getOptions(openType, this.state.interType, funcType, this.state.pageTemplate, card.tabTemplate, procMode, value)
      let _options = this.getOptions(openType, this.state.interType, funcType, this.state.pageTemplate, procMode, value, control)
      this.setState({
        Ot: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          return item
        })
      })
    } else if (key === 'control') {
      let _options = this.getOptions(openType, this.state.interType, funcType, this.state.pageTemplate, procMode, Ot, value)
      this.setState({
        control: value,
        formlist: this.state.formlist.map(item => {
          item.hidden = !_options.includes(item.key)
          return item
@@ -607,7 +610,7 @@
                >
                  {item.options.map((option, index) =>
                    <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value || option.field}>
                      {item.key === 'icon' && option.value ? <Icon type={option.value} /> : null} {option.text || option.label}
                      {item.key === 'icon' && option.value ? <MkIcon type={option.value} /> : null} {option.text || option.label}
                    </Select.Option>
                  )}
                </Select>