king
2020-12-03 569ccb3c1ff82f30ffefa7d3700571448d742662
src/menu/actioncomponent/actionform/index.jsx
@@ -4,8 +4,6 @@
import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd'
import { btnIcons, btnCustomClasses, formRule } from '@/utils/option.js'
import Api from '@/api'
import options from '@/store/options.js'
import './index.scss'
const { TextArea } = Input
@@ -50,9 +48,6 @@
      text: this.props.dict['header.form.requiredOnce']
    }],
    insertUpdateOptions: [{
      value: '',
      text: this.props.dict['model.empty']
    }, {
      value: 'insert',
      text: this.props.dict['header.form.action.insert']
    }, {
@@ -81,7 +76,6 @@
  UNSAFE_componentWillMount () {
    const { card, type } = this.props
    let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || ''
    let _opentype = card.OpenType                // 打开方式
    let _intertype = card.intertype || 'system'  // 接口类型
    let _funcType = card.funcType || 'print'     // 功能按钮默认类型
@@ -94,7 +88,6 @@
    this.setState({
      openType: _opentype,
      menulist: _menulist.options || [],
      interType: _intertype,
      funcType: _funcType,
      formlist: this.props.formlist.map(item => {
@@ -157,7 +150,7 @@
          _options.push('execMode', 'intertype', 'innerFunc', 'Ot', 'execSuccess', 'execError')
        }
      }
    } else {
    } else if (_opentype !== 'popview' && _opentype !== 'tab') {
      if (_intertype === 'outer') {
        _options.push('innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc')
      } else if (_intertype === 'inner') {
@@ -176,7 +169,7 @@
    if (card.focus) {
      try {
        let _form = document.getElementById('label')
        _form.select()
        _form && _form.select()
      } catch {
        console.warn('表单focus失败!')
      }
@@ -297,6 +290,10 @@
          _fieldval.label = '删除'
          _fieldval.class = 'danger'
          _fieldval.Ot = 'requiredSgl'
        }
        if (card.$type === 'tableButton') { // 表格按钮
          delete _fieldval.Ot
        }
        this.props.form.setFieldsValue(_fieldval)
@@ -546,11 +543,7 @@
                  }
                ]
              })(
                <Cascader
                  options={this.state.menulist}
                  loadData={this.loadData}
                  placeholder=""
                />
                <Cascader options={item.options || []} placeholder=""/>
              )}
            </Form.Item>
          </Col>
@@ -572,60 +565,8 @@
    return fields
  }
  loadData = selectedOptions => {
    const { MenuID } = this.props
    const targetOption = selectedOptions[selectedOptions.length - 1]
    targetOption.loading = true
    let _param = {
      func: 'sPC_Get_FunMenu',
      ParentID: targetOption.value,
      systemType: options.sysType,
      debug: 'Y'
    }
    Api.getSystemConfig(_param).then(result => {
      if (result.status) {
        targetOption.loading = false
        targetOption.children = result.data.map(item => {
          let submenu = {
            value: item.ParentID,
            label: item.MenuNameP,
            children: item.FunMenu.map(cell => {
              return {
                value: cell.MenuID,
                label: cell.MenuName,
                MenuID: cell.MenuID,
                MenuName: cell.MenuName,
                MenuNo: cell.MenuNo,
                Ot: cell.Ot,
                PageParam: cell.PageParam,
                LinkUrl: cell.LinkUrl,
                disabled: cell.MenuID === MenuID
              }
            })
          }
          return submenu
        })
        this.setState({
          menulist: [...this.state.menulist]
        })
      } else {
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
        targetOption.loading = false
      }
    })
  }
  handleConfirm = () => {
    const { setting } = this.props
    const { menulist } = this.state
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
@@ -658,30 +599,9 @@
              values.OpenType = values.execMode
            }
          } else if (['pop', 'prompt', 'exec'].includes(values.OpenType) && values.verify) {
            if (values.Ot === 'requiredOnce' && ['notRequired', 'requiredSgl', 'required'].includes(this.props.card.Ot)) {
              values.verify.uniques = []
            } else if (this.props.card.Ot === 'requiredOnce' && ['notRequired', 'requiredSgl', 'required'].includes(values.Ot)) {
            if ((values.Ot === 'requiredOnce' || this.props.card.Ot === 'requiredOnce') && this.props.card.Ot !== values.Ot) {
              values.verify.uniques = []
            }
          }
          // 关联三级菜单
          if (values.OpenType === 'tab' && values.linkmenu && values.linkmenu.length > 0) {
            let linkThdMenu = ''
            menulist.forEach(menu => {
              if (menu.value === values.linkmenu[0]) {
                menu.children.forEach(item => {
                  if (item.value === values.linkmenu[1]) {
                    item.children.forEach(cell => {
                      if (cell.value === values.linkmenu[2]) {
                        linkThdMenu = cell
                      }
                    })
                  }
                })
              }
            })
            values.linkThdMenu = linkThdMenu
          }
          
          resolve(values)