king
2023-03-02 d1f19b794216b37417e114b71c1cd7a2ac3d7748
src/menu/components/share/actioncomponent/actionform/index.jsx
@@ -6,6 +6,7 @@
import { formRule } from '@/utils/option.js'
import asyncComponent from '@/utils/asyncComponent'
import KeyInterface from '@/components/keyInterface'
import './index.scss'
const { TextArea } = Input
@@ -16,8 +17,8 @@
  prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hidden'],
  exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'hidden'],
  excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'color', 'sheet', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'width', 'hidden'],
  excelOut: ['label', 'OpenType', 'intertype', 'show', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'pagination', 'search', 'width', 'hidden'],
  popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'popClose', 'width', 'display', 'ratio', 'syncComponent', 'clickouter', 'hidden'],
  excelOut: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'pagination', 'search', 'width', 'hidden'],
  popview: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'popClose', 'width', 'display', 'ratio', 'syncComponent', 'clickouter', 'maskStyle', 'closeButton', 'hidden'],
  tab: ['label', 'Ot', 'OpenType', 'show', 'icon', 'class', 'color', 'linkmenu', 'width', 'hidden'],
  innerpage: ['label', 'Ot', 'OpenType', 'pageTemplate', 'show', 'swipe', 'icon', 'class', 'color', 'width', 'hidden'],
  funcbutton: ['label', 'OpenType', 'funcType', 'show', 'swipe', 'icon', 'class', 'color', 'width', 'hidden'],
@@ -26,7 +27,6 @@
class ActionForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,      // 字典项
    type: PropTypes.any,         // type为"card"时,只可选单行或不选行
    setting: PropTypes.object,   // 页面设置
    formlist: PropTypes.any,     // 表单信息
@@ -77,13 +77,13 @@
  record = {}
  
  UNSAFE_componentWillMount () {
    const { type, dict } = this.props
    const { type } = this.props
    let requireOptions = [
      { value: 'notRequired', text: dict['header.form.notRequired'] },
      { value: 'requiredSgl', text: dict['header.form.requiredSgl'] },
      { value: 'required', text: dict['header.form.required'] },
      { value: 'requiredOnce', text: dict['header.form.requiredOnce'] }
      { value: 'notRequired', text: '不选择行' },
      { value: 'requiredSgl', text: '选择单行' },
      { value: 'required', text: '选择多行' },
      { value: 'requiredOnce', text: '多行拼接' }
    ]
    if (type === 'card') {
@@ -178,7 +178,7 @@
        reReadonly.interface = false
        reRequired.interface = true
      } else if (intertype === 'outer') {
        shows.push('procMode', 'sysInterface', 'interface', 'outerFunc', 'callbackType', 'output')
        shows.push('procMode', 'sysInterface', 'outerFunc', 'callbackType', 'output')
        if (this.record.procMode === 'system') {
          shows.push('sql', 'sqlType')
        } else if (this.record.procMode === 'inner') {
@@ -195,10 +195,14 @@
          reReadonly.interface = false
          reRequired.interface = true
          shows.push('proInterface')
        } else {
          shows.push('interface', 'proInterface')
        } else if (this.record.sysInterface === 'true') {
          reReadonly.interface = true
          reRequired.interface = false
          shows.push('interface')
        } else if (this.record.sysInterface === 'external') {
          shows.push('exInterface', 'exProInterface')
        }
      } else if (intertype === 'inner') {
        shows.push('innerFunc', 'output')
@@ -209,6 +213,9 @@
      if (Ot === 'required') {
        shows.push('progress')
      }
      if (Ot === 'required' && (intertype === 'inner' || intertype === 'system')) {
        shows.push('execType')
      }
      if (this.record.openmenu && this.record.openmenu !== 'goback') {
        shows.push('open')
@@ -237,7 +244,7 @@
      if (this.record.formType === 'switch') {
        shows.push('field', 'size', 'openVal', 'closeVal', 'openText', 'closeText')
      } else if (this.record.formType === 'radio') {
        shows.push('field', 'openVal', 'closeVal')
        shows.push('field', 'checkType', 'openVal', 'closeVal')
      } else {
        shows.push('field')
      }
@@ -245,7 +252,7 @@
      reOptions.intertype = this.state.interTypeOptions.filter(item => item.value !== 'custom')
      if (intertype === 'outer') {
        shows.push('procMode', 'sysInterface', 'interface', 'outerFunc', 'callbackType')
        shows.push('procMode', 'sysInterface', 'outerFunc', 'callbackType')
        if (this.record.procMode === 'system') {
          shows.push('sql', 'sqlType')
        } else if (this.record.procMode === 'inner') {
@@ -262,10 +269,14 @@
          reReadonly.interface = false
          reRequired.interface = true
          shows.push('proInterface')
        } else {
          shows.push('interface', 'proInterface')
        } else if (this.record.sysInterface === 'true') {
          reReadonly.interface = true
          reRequired.interface = false
          shows.push('interface')
        } else if (this.record.sysInterface === 'external') {
          shows.push('exInterface', 'exProInterface')
        }
      } else if (intertype === 'inner') {
        shows.push('innerFunc')
@@ -294,7 +305,7 @@
      reOptions.Ot = requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value))
      if (this.record.intertype === 'outer') {
        shows.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc')
        shows.push('innerFunc', 'sysInterface', 'outerFunc', 'callbackFunc')
        reRequired.innerFunc = false
        reRequired.callbackFunc = false
@@ -302,10 +313,14 @@
          reReadonly.interface = false
          reRequired.interface = true
          shows.push('proInterface')
        } else {
          shows.push('interface', 'proInterface')
        } else if (this.record.sysInterface === 'true') {
          reReadonly.interface = true
          reRequired.interface = false
          shows.push('interface')
        } else if (this.record.sysInterface === 'external') {
          shows.push('exInterface', 'exProInterface')
        }
      } else if (this.record.intertype === 'inner') {
        shows.push('innerFunc')
@@ -316,19 +331,24 @@
      }
    } else if (openType === 'excelOut') {
      reOptions.intertype = this.state.interTypeOptions.filter(op => op.value !== 'custom')
      reOptions.Ot = requireOptions.filter(op => ['notRequired', 'requiredOnce'].includes(op.value))
      if (this.record.intertype === 'outer') {
        shows.push('innerFunc', 'sysInterface', 'interface', 'outerFunc')
        shows.push('innerFunc', 'sysInterface', 'outerFunc')
        reRequired.innerFunc = false
        if (this.record.sysInterface === 'false') {
          reReadonly.interface = false
          reRequired.interface = true
          shows.push('proInterface')
        } else {
          shows.push('interface', 'proInterface')
        } else if (this.record.sysInterface === 'true') {
          reReadonly.interface = true
          reRequired.interface = false
          shows.push('interface')
        } else if (this.record.sysInterface === 'external') {
          shows.push('exInterface', 'exProInterface')
        }
      } else if (this.record.intertype === 'inner') {
        shows.push('innerFunc')
@@ -337,10 +357,15 @@
      if (this.record.execSuccess === 'grid' || this.record.execError === 'grid') {
        shows.push('resetPageIndex')
      }
      if (this.record.Ot !== 'notRequired' && this.record.Ot !== 'requiredOnce') {
        this.record.Ot = 'notRequired'
      }
    } else if (openType === 'popview') {
      reOptions.Ot = requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value))
      if (this.record.display === 'drawer') {
      if (appType === 'mob') {
        shows.push('placement')
      } else if (this.record.display === 'drawer') {
        shows.push('placement')
      }
      if (this.record.popClose === 'grid') {
@@ -380,18 +405,22 @@
      if (_funcType === 'print') {
        shows.push('execMode', 'intertype', 'Ot', 'execSuccess', 'execError')
        if (this.record.intertype === 'outer') {
          shows.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc')
          shows.push('innerFunc', 'sysInterface', 'outerFunc', 'callbackFunc')
          reRequired.innerFunc = false
          reRequired.callbackFunc = false
          if (this.record.sysInterface === 'false') {
            reReadonly.interface = false
            reRequired.interface = true
            shows.push('proInterface')
          } else {
            shows.push('interface', 'proInterface')
          } else if (this.record.sysInterface === 'true') {
            reReadonly.interface = true
            reRequired.interface = false
            shows.push('interface')
          } else if (this.record.sysInterface === 'external') {
            shows.push('exInterface', 'exProInterface')
          }
        } else if (this.record.intertype === 'inner') {
          shows.push('innerFunc')
@@ -400,12 +429,15 @@
        if (this.record.execSuccess === 'grid' || this.record.execError === 'grid') {
          shows.push('resetPageIndex')
        }
        if (this.record.execMode === 'pop' || this.record.execMode === 'prompt') {
          shows.push('position')
        }
      } else if (_funcType === 'mkBinding' || _funcType === 'mkUnBinding') {
        shows.push('execSuccess', 'execError')
      } else if (_funcType === 'closetab') {
        shows.push('refreshTab')
      } else if (_funcType === 'scan') {
        shows.push('linkmenu')
        shows.push('linkmenu', 'prefix')
        reRequired.linkmenu = false
        reTooltip.linkmenu = '使用扫码登录功能或菜单跳转功能时,需选择跳转的菜单。'
@@ -441,7 +473,7 @@
    }
    
    if (appType === 'mob') {
      if (Ot !== 'notRequired') {
      if (Ot !== 'notRequired' && openType !== 'excelOut') {
        shows.push('control')
        reOptions.control = [
          { value: '', text: '无' },
@@ -456,7 +488,7 @@
        }
      }
    } else {
      if (Ot !== 'notRequired') {
      if (Ot !== 'notRequired' && openType !== 'excelOut') {
        reOptions.control = [
          { value: '', text: '无' },
          { value: 'disabled', text: '禁用' },
@@ -529,21 +561,21 @@
      } else if (value === 'excelIn') {
        _fieldval.intertype = 'system'
        _fieldval.Ot = 'notRequired'
        _fieldval.label = this.props.dict['model.form.excelIn']
        _fieldval.execSuccess = 'grid'
        _fieldval.label = '导入Excel'
        _fieldval.class = 'dgreen'
        this.record.Ot = 'notRequired'
        this.record.label = this.props.dict['model.form.excelIn']
        this.record.label = '导入Excel'
        this.record.class = 'dgreen'
        this.record.execSuccess = 'grid'
      } else if (value === 'excelOut') {
        _fieldval.intertype = 'system'
        _fieldval.label = this.props.dict['model.form.excelOut']
        _fieldval.label = '导出Excel'
        _fieldval.class = 'dgreen'
        _fieldval.execSuccess = 'never'
        this.record.Ot = 'notRequired'
        this.record.label = this.props.dict['model.form.excelOut']
        _fieldval.Ot = 'requiredOnce'
        this.record.Ot = 'requiredOnce'
        this.record.label = '导出Excel'
        this.record.class = 'dgreen'
        this.record.execSuccess = 'never'
  
@@ -568,10 +600,10 @@
  
      }
      if (value === 'excelIn') {
        _fieldval.label = this.props.dict['model.form.excelIn']
        _fieldval.label = '导入Excel'
        _fieldval.class = 'dgreen'
      } else if (value === 'excelOut') {
        _fieldval.label = this.props.dict['model.form.excelOut']
        _fieldval.label = '导出Excel'
        _fieldval.class = 'dgreen'
        _fieldval.control = ''
        this.record.control = ''
@@ -701,7 +733,6 @@
  }
  getFields() {
    const { dict } = this.props
    const { getFieldDecorator } = this.props.form
    const fields = []
@@ -724,7 +755,7 @@
      }
      if (item.type === 'text') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
  
        if (item.key === 'innerFunc') {
@@ -736,7 +767,7 @@
          )
        } else if (item.key === 'sql' || item.key === 'sheet') {
          rules.push(
            { pattern: /^[a-zA-Z_]+$/, message: '表名只可使用字母以及_' },
            { pattern: /^[a-zA-Z0-9@_]+$/, message: '表名只可使用字母、数字以及_' },
            { max: formRule.func.max, message: formRule.func.maxMessage }
          )
        } else if (item.key === 'outerFunc' || item.key === 'callbackFunc') {
@@ -769,13 +800,13 @@
        content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
      } else if (item.type === 'number') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        content = <InputNumber min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>
      } else if (item.type === 'select') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        if (item.extendName) {
@@ -788,7 +819,7 @@
            getPopupContainer={() => document.getElementById('winter')}
          >
            {item.options.map((option, index) =>
              <Select.Option key={index} extend={option[item.extendName] || ''} value={(option.value || option.field)}>
              <Select.Option key={index} title={option.text || option.label} extend={option[item.extendName] || ''} value={(option.value || option.field)}>
                {(option.text || option.label)}
              </Select.Option>
            )}
@@ -802,7 +833,7 @@
            getPopupContainer={() => document.getElementById('winter')}
          >
            {item.options.map((option, index) =>
              <Select.Option key={index} value={(option.value || option.field)}>
              <Select.Option key={index} title={option.text || option.label} value={(option.value || option.field)}>
                {(option.text || option.label)}
              </Select.Option>
            )}
@@ -810,7 +841,7 @@
        }
      } else if (item.type === 'radio') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Radio.Group onChange={(e) => {this.optionChange(item.key, e.target.value)}}>
@@ -818,7 +849,7 @@
        </Radio.Group>
      } else if (item.type === 'checkbox') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Checkbox.Group>
@@ -827,13 +858,13 @@
      } else if (item.type === 'cascader') {
        initVal = item.initVal || []
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Cascader options={item.options || []} expandTrigger="hover" placeholder=""/>
      } else if (item.type === 'icon') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <MkEditIcon options={['edit', 'hint', 'direction', 'normal', 'data']} allowClear/>
@@ -841,10 +872,18 @@
        span = 24
        className = 'textarea'
        rules = [
          { required: item.readonly ? false : item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.readonly ? false : item.required, message: '请输入' + item.label + '!' }
        ]
        content = <TextArea rows={2} readOnly={item.readonly}/>
      } else if (item.type === 'keyinterface') {
        span = 24
        className = 'textarea'
        rules = [
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        content = <KeyInterface type={item.key === 'exInterface' ? 'develop' : 'product'}/>
      }
      fields.push(
@@ -886,6 +925,7 @@
          values.uuid = card.uuid
          values.verify = card.verify || null
          values.modal = card.modal || null
          values.config = card.config || null
          if (values.OpenType === 'form') {
            if (values.formType !== 'scan') {
@@ -898,7 +938,7 @@
              values.icon = 'scan'
            }
          } else if (values.OpenType === 'excelOut') {
            values.Ot = 'notRequired'
            values.Ot = values.Ot || 'notRequired'
          } else if (['pop', 'prompt', 'exec'].includes(values.OpenType) && values.verify) {
            if ((values.Ot === 'requiredOnce' || card.Ot === 'requiredOnce') && card.Ot !== values.Ot) {
              values.verify.uniques = []