king
2021-03-05 e36eb1999794bd71e76482b92a0b0b20f49d0032
src/pc/components/navbar/normal-navbar/wrapsetting/settingform/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Tooltip, Icon, InputNumber } from 'antd'
import { Form, Row, Col, Input, Tooltip, Icon, InputNumber, Select } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
@@ -16,29 +16,37 @@
  }
  state = {
    roleList: []
    appMenus: [],
    logointid: this.props.wrap.linkIntId || ''
  }
  UNSAFE_componentWillMount () {
    let roleList = sessionStorage.getItem('sysRoles')
    if (roleList) {
    let appMenus = sessionStorage.getItem('appMenus')
    if (appMenus) {
      try {
        roleList = JSON.parse(roleList)
        appMenus = JSON.parse(appMenus)
      } catch {
        roleList = []
        appMenus = []
      }
    } else {
      roleList = []
      appMenus = []
    }
    this.setState({roleList})
    this.setState({appMenus})
  }
  handleConfirm = () => {
    const { logointid } = this.state
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          values.linkIntId = ''
          if (values.logolink && logointid) {
            values.linkIntId = logointid
          }
          resolve(values)
        } else {
          reject(err)
@@ -58,6 +66,7 @@
  render() {
    const { wrap } = this.props
    const { getFieldDecorator } = this.props.form
    const { appMenus } = this.state
    const formItemLayout = {
      labelCol: {
@@ -82,6 +91,19 @@
                    {
                      required: true,
                      message: this.props.dict['form.required.input'] + '导航栏名称!'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item label="菜单参数">
                {getFieldDecorator('MenuNo', {
                  initialValue: wrap.MenuNo,
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.input'] + '菜单参数!'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
@@ -127,6 +149,24 @@
                )}
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item label="logo链接">
                {getFieldDecorator('logolink', {
                  initialValue: wrap.logolink || ''
                })(
                  <Select
                    showSearch
                    onChange={(val, { props }) => this.setState({logointid: props.intid})}
                    filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  >
                    <Select.Option key="empty" intid={''} value={''}>无</Select.Option>
                    {appMenus.map(option =>
                      <Select.Option key={option.MenuID} intid={option.menuid_int} value={option.MenuID}>{option.MenuName}</Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col>
          </Row>
        </Form>
      </div>