From f8c3c53f9e29541f8c0e3fcbf682c301fd17e06a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 23 十一月 2020 17:49:23 +0800
Subject: [PATCH] 2020-11-23

---
 src/templates/menuconfig/editfirstmenu/menuform/index.jsx |   78 ++++++++++++++++++++++++++------------
 1 files changed, 53 insertions(+), 25 deletions(-)

diff --git a/src/templates/headerconfig/menuform/index.jsx b/src/templates/menuconfig/editfirstmenu/menuform/index.jsx
similarity index 71%
rename from src/templates/headerconfig/menuform/index.jsx
rename to src/templates/menuconfig/editfirstmenu/menuform/index.jsx
index 88760c9..23993be 100644
--- a/src/templates/headerconfig/menuform/index.jsx
+++ b/src/templates/menuconfig/editfirstmenu/menuform/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Select } from 'antd'
+import { Form, Row, Col, Input, Select, Radio } from 'antd'
 import Utils from '@/utils/utils.js'
 import './index.scss'
 
@@ -23,7 +23,7 @@
         readonly: false
       },
       {
-        type: 'select',
+        type: 'radio',
         key: 'openType',
         label: this.props.dict['model.openway'],
         initVal: 'menu',
@@ -31,44 +31,45 @@
         options: [{
           id: 'menu',
           text: this.props.dict['model.menu']
-        // }, {
-        //   id: 'newpage',
-        //   text: this.props.dict['model.new'] + this.props.dict['model.window']
+        }, {
+          id: 'outpage',
+          text: '澶栭儴椤甸潰'
         }]
       },
       {
-        type: 'select',
+        type: 'text',
         key: 'linkUrl',
+        label: '椤甸潰鍦板潃',
+        initVal: '',
         hidden: true,
-        label: this.props.dict['model.new'] + this.props.dict['model.window'],
-        initVal: 'service',
-        required: true,
-        options: []
+        required: true
       }
     ]
   }
 
   UNSAFE_componentWillMount () {
+    const { menu } = this.props
+
     if (this.props.type === 'add') {
       this.setState({
         formlist: this.state.defaultMenu
       })
     } else {
       this.setState({
-        formlist: this.state.defaultMenu.map(menu => {
-          if (menu.key === 'menuName') {
-            menu.initVal = this.props.menu.MenuName
-          } else if (menu.key === 'openType') {
-            menu.initVal = this.props.menu.PageParam.OpenType
-          } else if (menu.key === 'linkUrl') {
-            menu.initVal = this.props.menu.PageParam.linkUrl
-            if (this.props.menu.PageParam.OpenType === 'menu') {
-              menu.hidden = true
-            } else if (this.props.menu.PageParam.OpenType === 'newpage') {
-              menu.hidden = false
+        formlist: this.state.defaultMenu.map(item => {
+          if (item.key === 'menuName') {
+            item.initVal = menu.MenuName
+          } else if (item.key === 'openType') {
+            item.initVal = menu.PageParam.OpenType
+          } else if (item.key === 'linkUrl') {
+            item.initVal = menu.PageParam.linkUrl
+            if (menu.PageParam.OpenType === 'menu') {
+              item.hidden = true
+            } else if (menu.PageParam.OpenType === 'outpage') {
+              item.hidden = false
             }
           }
-          return menu
+          return item
         })
       })
     }
@@ -77,11 +78,11 @@
   openTypeChange = (key, value) => {
     if (key === 'openType') {
       let formlist = this.state.formlist
-      if (value === 'newpage') {
+      if (value === 'outpage') {
         formlist.forEach(item => {
           if (item.key === 'linkUrl') {
             item.hidden = false
-            item.initVal = 'service'
+            item.initVal = ''
           }
         })
       } else {
@@ -91,6 +92,7 @@
           }
         })
       }
+
       this.setState({formlist})
     }
   }
@@ -137,13 +139,39 @@
                   getPopupContainer={() => document.getElementById('form-box')}
                 >
                   {item.options.map(option =>
-                    <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.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 + '!'
+                  }
+                ]
+              })(
+                <Radio.Group onChange={(e) => {this.openTypeChange(item.key, e.target.value)}}>
+                  {
+                    item.options.map(option => {
+                      return (
+                        <Radio key={option.id} value={option.id}>{option.text}</Radio>
+                      )
+                    })
+                  }
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+        )
       }
     })
     

--
Gitblit v1.8.0