king
2022-07-26 1e3e316b0d64a04fade0a006bec78475dddc06bd
src/views/design/header/editfirstmenu/menuform/index.jsx
@@ -1,13 +1,13 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Select, Radio } from 'antd'
import { Form, Row, Col, Input, Radio } from 'antd'
import Utils from '@/utils/utils.js'
import './index.scss'
class MainSearch extends Component {
  static propTpyes = {
    menu: PropTypes.any,         // 菜单信息,新建时为null
    dict: PropTypes.object,      // 字典项
    type: PropTypes.string,      // 操作类型
    inputSubmit: PropTypes.func
  }
@@ -18,7 +18,7 @@
      {
        type: 'text',
        key: 'menuName',
        label: this.props.dict['model.menu'] + this.props.dict['model.name'],
        label: '菜单名称',
        initVal: '',
        required: true,
        readonly: false
@@ -26,12 +26,12 @@
      {
        type: 'radio',
        key: 'openType',
        label: this.props.dict['model.openway'],
        label: '打开方式',
        initVal: 'menu',
        required: true,
        options: [{
          id: 'menu',
          text: this.props.dict['model.menu']
          text: '菜单'
        }, {
          id: 'outpage',
          text: '外部页面'
@@ -51,7 +51,7 @@
  UNSAFE_componentWillMount () {
    const { menu } = this.props
    if (this.props.type === 'add') {
    if (!menu) {
      this.setState({
        formlist: this.state.defaultMenu
      })
@@ -113,14 +113,14 @@
                rules: [
                  {
                    required: !!item.required,
                    message: this.props.dict['form.required.input'] + item.label + '!'
                    message: '请输入' + item.label + '!'
                  }
                ]
              })(<Input placeholder="" autoFocus={item.key.toLowerCase() === 'menuname'} autoComplete="off" disabled={item.readonly} />)}
            </Form.Item>
          </Col>
        )
      } else if (item.type === 'select') { // 下拉搜索
      } else if (item.type === 'radio') {
        fields.push(
          <Col span={24} key={index}>
            <Form.Item label={item.label}>
@@ -129,34 +129,7 @@
                rules: [
                  {
                    required: !!item.required,
                    message: this.props.dict['form.required.select'] + item.label + '!'
                  }
                ]
              })(
                <Select
                  showSearch
                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  onChange={(value) => {this.openTypeChange(item.key, value)}}
                  getPopupContainer={() => document.getElementById('first-menu-form-box')}
                >
                  {item.options.map(option =>
                    <Select.Option key={option.id} value={option.id}>{option.text}</Select.Option>
                  )}
                </Select>
              )}
            </Form.Item>
          </Col>
        )
      } else if (item.type === 'radio') { // 下拉搜索
        fields.push(
          <Col span={24} key={index}>
            <Form.Item label={item.label}>
              {getFieldDecorator(item.key, {
                initialValue: item.initVal || '',
                rules: [
                  {
                    required: !!item.required,
                    message: this.props.dict['form.required.select'] + item.label + '!'
                    message: '请选择' + item.label + '!'
                  }
                ]
              })(
@@ -180,11 +153,14 @@
  }
  handleConfirm = () => {
    const { menu } = this.props
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          if (this.props.type === 'add') {
        if (err) return
        if (!menu) {
            resolve({
              MenuID: Utils.getuuid(),
              MenuName: values.menuName,
@@ -195,16 +171,13 @@
            })
          } else {
            resolve({
              MenuID: this.props.menu.MenuID,
            MenuID: menu.MenuID,
              MenuName: values.menuName,
              PageParam: JSON.stringify({
                OpenType: values.openType,
                linkUrl: values.openType !== 'menu' ? values.linkUrl : ''
              })
            })
          }
        } else {
          reject(err)
        }
      })
    })