From 31499a3e864ca1229493fd7ec901659c0cb54159 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 07 三月 2020 11:49:16 +0800
Subject: [PATCH] 2020-03-07

---
 src/templates/tableshare/menuform/index.jsx |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/src/templates/tableshare/menuform/index.jsx b/src/templates/tableshare/menuform/index.jsx
index f8d1866..302ad7e 100644
--- a/src/templates/tableshare/menuform/index.jsx
+++ b/src/templates/tableshare/menuform/index.jsx
@@ -10,10 +10,40 @@
     formlist: PropTypes.array
   }
 
+  state = {
+    formlist: null
+  }
+
+  UNSAFE_componentWillMount () {
+    this.setState({
+      formlist: this.props.formlist
+    })
+  }
+
+  selectChange = (item, value) => {
+    const { formlist } = this.state
+
+    if (item.key === 'fstMenuId') {
+      let option = item.options.filter(cell => cell.MenuID === value)[0]
+
+      this.setState({
+        formlist: formlist.map(cell => {
+          if (cell.key === 'parentId') {
+            cell.options = option.options
+          }
+          return cell
+        })
+      }, () => {
+        let _id = option.options[0] ? option.options[0].MenuID : ''
+        this.props.form.setFieldsValue({parentId: _id})
+      })
+    }
+  }
+
   getFields() {
     const { getFieldDecorator } = this.props.form
     const fields = []
-    this.props.formlist.forEach((item, index) => {
+    this.state.formlist.forEach((item, index) => {
       if (item.type === 'text') { // 鏂囨湰鎼滅储
         fields.push(
           <Col span={24} key={index}>
@@ -50,6 +80,7 @@
                 <Select
                   showSearch
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+                  onChange={(value) => {this.selectChange(item, value)}}
                   getPopupContainer={() => document.getElementById('subqazxcvbn')}
                 >
                   {item.options.map(option =>

--
Gitblit v1.8.0