From f3167f8371d19d0ea8fe7d0e7af5517ff0b08cd2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 07 四月 2021 23:25:29 +0800
Subject: [PATCH] 2021-04-07

---
 src/pc/components/navbar/normal-navbar/menusetting/menuform/index.jsx |  207 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 207 insertions(+), 0 deletions(-)

diff --git a/src/pc/components/navbar/normal-navbar/menusetting/menuform/index.jsx b/src/pc/components/navbar/normal-navbar/menusetting/menuform/index.jsx
new file mode 100644
index 0000000..fad6b76
--- /dev/null
+++ b/src/pc/components/navbar/normal-navbar/menusetting/menuform/index.jsx
@@ -0,0 +1,207 @@
+import React, {Component} from 'react'
+import PropTypes from 'prop-types'
+import { Form, Row, Col, Input, Radio, Tooltip, Icon, Select } from 'antd'
+
+import './index.scss'
+
+const { TextArea } = Input
+
+class SettingForm extends Component {
+  static propTpyes = {
+    menu: PropTypes.object,    // 鍗$墖琛屼俊鎭�
+    inputSubmit: PropTypes.func  // 鍥炶溅浜嬩欢
+  }
+
+  state = {
+    property: this.props.menu.property || 'menu',
+    appMenus: [],
+  }
+
+  UNSAFE_componentWillMount () {
+    let appMenus = sessionStorage.getItem('appMenus')
+    if (appMenus) {
+      try {
+        appMenus = JSON.parse(appMenus)
+      } catch {
+        appMenus = []
+      }
+    } else {
+      appMenus = []
+    }
+
+    this.setState({appMenus})
+  }
+
+  componentDidMount() {
+    const { menu } = this.props
+
+    if (!menu.MenuID) {
+      let _form = document.getElementById('name')
+      _form && _form.select()
+    }
+  }
+
+  handleConfirm = () => {
+    // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
+    return new Promise((resolve, reject) => {
+      this.props.form.validateFieldsAndScroll((err, values) => {
+        if (!err) {
+          resolve(values)
+        } else {
+          reject(err)
+        }
+      })
+    })
+  }
+
+  handleSubmit = (e) => {
+    e.preventDefault()
+
+    if (this.props.inputSubmit) {
+      this.props.inputSubmit()
+    }
+  }
+
+  changeProperty = (e) => {
+    let val = e.target.value
+
+    this.setState({property: val})
+  }
+
+  render() {
+    const { menu } = this.props
+    const { getFieldDecorator } = this.props.form
+    const { property, appMenus } = this.state
+
+    const formItemLayout = {
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 8 }
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 }
+      }
+    }
+
+    return (
+      <Form {...formItemLayout}>
+        <Row gutter={24}>
+          <Col span={22}>
+            <Form.Item label="鑿滃崟鍚嶇О">
+              {getFieldDecorator('name', {
+                initialValue: menu.name,
+                rules: [
+                  {
+                    required: true,
+                    message: '璇疯緭鍏ヨ彍鍗曞悕绉�!'
+                  }
+                ]
+              })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
+            </Form.Item>
+          </Col>
+          <Col span={22}>
+            <Form.Item label="鑿滃崟鍙傛暟">
+              {getFieldDecorator('MenuNo', {
+                initialValue: menu.MenuNo || '',
+                rules: [
+                  {
+                    required: true,
+                    message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!'
+                  }
+                ]
+              })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)}
+            </Form.Item>
+          </Col>
+          <Col span={22}>
+            <Form.Item label="鑿滃崟灞炴��">
+              {getFieldDecorator('property', {
+                initialValue: menu.property || 'menu'
+              })(
+                <Radio.Group onChange={this.changeProperty}>
+                  <Radio value="menu">鑿滃崟</Radio>
+                  <Radio value="link">閾炬帴</Radio>
+                  <Radio value="linkmenu">鍏宠仈鑿滃崟</Radio>
+                  {menu.level === 1 || menu.level === 2 ? <Radio value="classify">鍒嗙被</Radio> : null}
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+          <Col span={22}>
+            <Form.Item label="闅愯棌">
+              {getFieldDecorator('hidden', {
+                initialValue: menu.hidden || 'false'
+              })(
+                <Radio.Group>
+                  <Radio value="false">鍚�</Radio>
+                  <Radio value="true">鏄�</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+          {property === 'link' ? <Col span={22}>
+            <Form.Item label="閾炬帴鍦板潃">
+              {getFieldDecorator('link', {
+                initialValue: menu.link || '',
+                rules: [{
+                  required: true,
+                  message: '璇疯緭鍏ラ摼鎺ュ湴鍧�!'
+                }]
+              })(<TextArea rows={2} />)}
+            </Form.Item>
+          </Col> : null}
+          {property !== 'classify' ? <Col span={22}>
+            <Form.Item label="鎵撳紑鏂瑰紡">
+              {getFieldDecorator('open', {
+                initialValue: menu.open || 'blank'
+              })(
+                <Radio.Group>
+                  <Radio value="blank">鏂扮獥鍙�</Radio>
+                  <Radio value="self">褰撳墠绐楀彛</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col> : null}
+          {property === 'linkmenu' ? <Col span={22}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="鍏宠仈褰撳墠app涓凡鏈夌殑鑿滃崟銆�">
+                <Icon type="question-circle" style={{color: '#c49f47', marginRight: '3px'}}/>
+                鍏宠仈鑿滃崟
+              </Tooltip>
+            }>
+              {getFieldDecorator('linkMenuId', {
+                initialValue: menu.linkMenuId || '',
+                rules: [{
+                  required: true,
+                  message: '璇烽�夋嫨鍏宠仈鑿滃崟!'
+                }]
+              })(
+                <Select>
+                  {appMenus.map(item => (<Select.Option key={item.MenuID} value={item.MenuID}>{item.MenuName}</Select.Option>))}
+                </Select>
+              )}
+            </Form.Item>
+          </Col> : null}
+          {property === 'menu' ? <Col span={22}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="澶嶅埗鑿滃崟浠呭湪褰撳墠鑿滃崟涓嶅瓨鍦ㄦ椂鏈夋晥銆�">
+                <Icon type="question-circle" style={{color: '#c49f47', marginRight: '3px'}}/>
+                澶嶅埗鑿滃崟
+              </Tooltip>
+            }>
+              {getFieldDecorator('copyMenuId', {
+                initialValue: menu.copyMenuId || ''
+              })(
+                <Select>
+                  {appMenus.map(item => (<Select.Option key={item.MenuID} value={item.MenuID}>{item.MenuName}</Select.Option>))}
+                </Select>
+              )}
+            </Form.Item>
+          </Col> : null}
+        </Row>
+      </Form>
+    )
+  }
+}
+
+export default Form.create()(SettingForm)
\ No newline at end of file

--
Gitblit v1.8.0