king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/pc/components/navbar/normal-navbar/wrapsetting/settingform/index.jsx
@@ -1,11 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Tooltip, Icon, InputNumber, Select } from 'antd'
import { Form, Row, Col, Input, Tooltip, Icon, InputNumber, Select, Radio } from 'antd'
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
const { TextArea } = Input
class SettingForm extends Component {
  static propTpyes = {
@@ -17,7 +18,7 @@
  state = {
    appMenus: [],
    logointid: this.props.wrap.linkIntId || ''
    property: ''
  }
  UNSAFE_componentWillMount () {
@@ -25,28 +26,21 @@
    if (appMenus) {
      try {
        appMenus = JSON.parse(appMenus)
      } catch {
      } catch (e) {
        appMenus = []
      }
    } else {
      appMenus = []
    }
    this.setState({appMenus})
    this.setState({appMenus, property: this.props.wrap.property || ''})
  }
  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)
@@ -66,8 +60,7 @@
  render() {
    const { wrap } = this.props
    const { getFieldDecorator } = this.props.form
    const { appMenus } = this.state
    const { appMenus, property } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -150,22 +143,84 @@
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item label="logo属性">
                {getFieldDecorator('property', {
                  initialValue: wrap.property || ''
                })(
                  <Radio.Group onChange={(e) => this.setState({property: e.target.value})} style={{whiteSpace: 'nowrap'}}>
                    <Radio value="">空</Radio>
                    <Radio value="linkmenu">关联菜单</Radio>
                    <Radio value="link">链接</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
            {property === 'linkmenu' ? <Col span={12}>
              <Form.Item label="logo链接">
                {getFieldDecorator('logolink', {
                  initialValue: wrap.logolink || ''
                {getFieldDecorator('linkmenu', {
                  initialValue: wrap.linkmenu || '',
                  rules: [
                    {
                      required: true,
                      message: this.props.dict['form.required.select'] + '关联菜单!'
                    }
                  ]
                })(
                  <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.Option key={option.MenuID} value={option.MenuID}>{option.MenuName}</Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col> : null}
            {property === 'link' ? <Col span={24}>
              <Form.Item label="logo链接" className="textarea">
                {getFieldDecorator('link', {
                  initialValue: wrap.link || '',
                  rules: [{
                    required: true,
                    message: '请输入链接地址!'
                  }]
                })(<TextArea rows={2} />)}
              </Form.Item>
            </Col> : null}
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="存在登录且取到登录信息时,显示用户头像、用户名及退出。">
                  <Icon type="question-circle" />
                  用户信息
                </Tooltip>
              }>
                {getFieldDecorator('user', {
                  initialValue: wrap.user || 'hidden'
                })(
                  <Radio.Group>
                    <Radio value="hidden">隐藏</Radio>
                    <Radio value="show">显示</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
            <Col span={12}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="默认隐藏菜单栏,鼠标在靠近顶部时显示。">
                  <Icon type="question-circle" />
                  悬浮显示
                </Tooltip>
              }>
                {getFieldDecorator('hover', {
                  initialValue: wrap.hover || 'false'
                })(
                  <Radio.Group>
                    <Radio value="true">启用</Radio>
                    <Radio value="false">不启用</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col>
          </Row>
        </Form>