king
2022-08-06 cbeffcc0902631909c0373f274752a97ddaf2d4e
src/templates/sharecomponent/actioncomponent/actionform/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd'
import { Form, Row, Col, Input, Select, Radio, Tooltip, InputNumber, Cascader, Typography } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { formRule } from '@/utils/option.js'
@@ -12,16 +12,17 @@
const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
const { TextArea } = Input
const { Paragraph } = Typography
const actionTypeOptions = {
  pop: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle'],
  prompt: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle'],
  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', 'clickouter'],
  tab: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'linkmenu'],
  innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'],
  funcbutton: ['label', 'OpenType', 'funcType', 'icon', 'class']
  pop: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle', 'hidden'],
  prompt: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle', 'hidden'],
  exec: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'hidden'],
  excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'hidden'],
  excelOut: ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'pagination', 'search', 'hidden'],
  popview: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose', 'display', 'ratio', 'clickouter', 'hidden'],
  tab: ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'linkmenu', 'hidden'],
  innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position', 'hidden'],
  funcbutton: ['label', 'OpenType', 'funcType', 'icon', 'class', 'hidden']
}
class MainSearch extends Component {
@@ -30,7 +31,8 @@
    setting: PropTypes.object,   // 页面设置
    formlist: PropTypes.any,     // 表单信息
    card: PropTypes.any,         // 按钮信息
    inputSubmit: PropTypes.any   // 回车提交事件
    inputSubmit: PropTypes.func, // 回车提交事件
    updRecord: PropTypes.func
  }
  state = {
@@ -126,6 +128,8 @@
        console.warn('表单focus失败!')
      }
    }
    this.props.updRecord && this.props.updRecord(this.record)
  }
  getMutilOptions = () => {
@@ -145,18 +149,34 @@
      reOptions.intertype = this.state.interTypeOptions
      if (intertype === 'custom') {
        shows.push('procMode', 'interface', 'callbackType', 'cbTable', 'proInterface', 'method', 'cross')
        shows.push('procMode', 'interface', 'callbackType', 'proInterface', 'method', 'cross')
        if (this.record.procMode === 'system') {
          shows.push('sql', 'sqlType')
        } else {
        } else if (this.record.procMode === 'inner') {
          reRequired.innerFunc = true
          shows.push('innerFunc')
        }
        if (this.record.callbackType === 'func') {
          shows.push('callbackFunc')
        } else if (this.record.callbackType !== 'none') {
          shows.push('cbTable')
        }
        reReadonly.interface = false
        reRequired.interface = true
      } else if (intertype === 'outer') {
        shows.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc', 'output')
        reRequired.innerFunc = false
        shows.push('procMode', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackType', 'output')
        // reRequired.innerFunc = false
        if (this.record.procMode === 'system') {
          shows.push('sql', 'sqlType')
        } else if (this.record.procMode === 'inner') {
          reRequired.innerFunc = true
          shows.push('innerFunc')
        }
        if (this.record.callbackType === 'func') {
          shows.push('callbackFunc')
        } else if (this.record.callbackType !== 'none') {
          shows.push('cbTable')
        }
        if (this.record.sysInterface === 'false') {
          reReadonly.interface = false
@@ -165,11 +185,15 @@
          reReadonly.interface = true
          reRequired.interface = false
        }
      } else if (intertype === 'inner') {
      } else if (intertype === 'inner') { // preFunc 前置函数
        shows.push('innerFunc', 'output')
        reRequired.innerFunc = true
      } else {
        shows.push('sql', 'sqlType', 'output')
      }
      if (Ot === 'required') {
        shows.push('progress')
      }
      if (this.record.sqlType === 'insert') {
@@ -190,6 +214,7 @@
      if (this.record.intertype === 'outer') {
        shows.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc')
        reRequired.innerFunc = false
        reRequired.callbackFunc = false
        if (this.record.sysInterface === 'false') {
          reReadonly.interface = false
@@ -252,6 +277,7 @@
        if (this.record.intertype === 'outer') {
          shows.push('innerFunc', 'sysInterface', 'interface', 'proInterface', 'outerFunc', 'callbackFunc')
          reRequired.innerFunc = false
          reRequired.callbackFunc = false
          if (this.record.sysInterface === 'false') {
            reReadonly.interface = false
@@ -266,6 +292,13 @@
        }
      } else if (_funcType === 'closetab') {
        shows.push('refreshTab')
      } else if (_funcType === 'megvii') {
        shows.push('subFunc', 'progress')
      } else if (_funcType === 'filezip') {
        reOptions.Ot = requireOptions
        reRequired.innerFunc = false
        shows.push('innerFunc', 'Ot', 'execSuccess', 'execError', 'urlkey')
      }
    }
@@ -327,7 +360,6 @@
      if (value === 'pop' || value === 'prompt' || value === 'exec') {
        _fieldval.intertype = 'system'
        _fieldval.sqlType = ''
      } else if (value === 'excelIn') {
        _fieldval.intertype = 'system'
        _fieldval.Ot = 'notRequired'
@@ -337,15 +369,15 @@
        this.record.Ot = 'notRequired'
        this.record.label = this.props.dict['model.form.excelIn']
        this.record.class = 'dgreen'
      } else if (value === 'excelOut') {
        _fieldval.intertype = 'system'
        _fieldval.label = this.props.dict['model.form.excelOut']
        _fieldval.class = 'dgreen'
        _fieldval.execSuccess = 'never'
        this.record.Ot = 'notRequired'
        this.record.label = this.props.dict['model.form.excelOut']
        this.record.class = 'dgreen'
        this.record.execSuccess = 'never'
  
      } else if (value === 'popview') {
        _fieldval.display = 'modal'
@@ -383,6 +415,8 @@
      if (!['funcbutton', 'excelIn', 'excelOut'].includes(value)) {
        _fieldval.position = 'toolbar'
      }
      this.props.updRecord && this.props.updRecord(this.record)
    } else if (key === 'position') {
      if (value === 'grid') {
        _fieldval.Ot = 'requiredSgl'
@@ -408,12 +442,14 @@
        _fieldval.class = 'purple'
      } else if (value === 'audit') {
        _fieldval.label = '审核'
        _fieldval.Ot = 'requiredSgl'
        _fieldval.Ot = 'required'
        _fieldval.class = 'primary'
      } else if (value === 'LogicDelete' || value === 'delete') {
        _fieldval.label = '删除'
        _fieldval.Ot = 'requiredSgl'
        _fieldval.Ot = 'required'
        _fieldval.class = 'danger'
      } else if (value === 'custom') {
        _fieldval.Ot = 'required'
      }
      if (this.record.position === 'grid') {
@@ -437,6 +473,8 @@
      }
    } else if (key === 'intertype') {
      this.record.sysInterface = 'false'
      this.props.updRecord && this.props.updRecord(this.record)
    } else if (key === 'sysInterface') {
      if (value === 'true') {
        _fieldval.interface = window.GLOB.mainSystemApi || ''
@@ -499,7 +537,7 @@
        ]
  
        if (item.key === 'innerFunc') {
          let str = '^(' + item.fields.join('|') + ')'
          let str = item.fields && item.fields.length ? '^(' + item.fields.join('|') + ')' : '^'
          let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
          rules.push(
            { pattern: _patten, message: formRule.func.innerMessage },
@@ -510,6 +548,24 @@
            { pattern: formRule.func.pattern, message: formRule.func.message },
            { max: formRule.func.max, message: formRule.func.maxMessage }
          )
        } else if (item.key === 'output') {
          if (this.record.intertype === 'system') {
            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.push({ max: formRule.input.max, message: formRule.input.message })
        }
@@ -586,11 +642,21 @@
        </Col>
      )
    })
    if (window.debugger && this.props.card.uuid) {
      fields.push(
        <Col span={12} key="uuid">
          <Form.Item label="按钮ID">
            <Paragraph copyable>{this.props.card.uuid}</Paragraph>
          </Form.Item>
        </Col>
      )
    }
    return fields
  }
  handleConfirm = () => {
    const { setting, card } = this.props
    const { card } = this.props
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
@@ -600,15 +666,6 @@
          values.position = values.position || 'toolbar'
          if (values.OpenType === 'excelOut') {
            if (values.intertype === 'system' && setting.interType !== 'system') { // 导出excel需使用查询数据源
              notification.warning({
                top: 92,
                message: '表格数据查询未使用系统函数,导出Excel不可使用系统函数!',
                duration: 5
              })
              return
            }
            values.Ot = 'notRequired'
          } else if (values.OpenType === 'popview' && !values.linkTab) { // 没有关联标签(新建时),创建新标签Id
            values.linkTab = Utils.getuuid()