From b68697ccdce3f7de67c3a918701c814497b6b41a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 十一月 2019 22:05:24 +0800
Subject: [PATCH] 2019-11-12

---
 src/components/sidemenu/comtableconfig/searchform/index.jsx |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/components/sidemenu/comtableconfig/menuform/index.jsx b/src/components/sidemenu/comtableconfig/searchform/index.jsx
similarity index 91%
rename from src/components/sidemenu/comtableconfig/menuform/index.jsx
rename to src/components/sidemenu/comtableconfig/searchform/index.jsx
index 2387c8f..319edf9 100644
--- a/src/components/sidemenu/comtableconfig/menuform/index.jsx
+++ b/src/components/sidemenu/comtableconfig/searchform/index.jsx
@@ -1,5 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+// import { is, fromJS } from 'immutable'
 import { Form, Row, Col, Input, Select, Icon, Radio } from 'antd'
 import moment from 'moment'
 import EditTable from '../editable'
@@ -10,14 +11,15 @@
 class MainSearch extends Component {
   static propTpyes = {
     dict: PropTypes.object, // 瀛楀吀椤�
-    formlist: PropTypes.array
+    formlist: PropTypes.any
   }
 
   state = {
     card: null,
     inputType: 'text',
     selectType: 0,
-    options: null
+    options: null,
+    formlist: null
   }
 
   openTypeChange = (key, value) => {
@@ -78,7 +80,7 @@
                   showSearch
                   filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   onChange={(value) => {this.openTypeChange(item.key, value)}}
-                  getPopupContainer={() => document.getElementById('form-box')}
+                  getPopupContainer={() => document.getElementById('commontable-search-form-box')}
                 >
                   {item.options.map(option =>
                     <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>
@@ -112,13 +114,7 @@
               <Col span={18} offset={6} key={'table' + index}>
                 <Form.Item className="text-area">
                   {getFieldDecorator('datasource', {
-                    initialValue: '',
-                    rules: [
-                      {
-                        required: true,
-                        message: this.props.dict['form.required.input'] + 'datasource !'
-                      }
-                    ]
+                    initialValue: ''
                   })(<TextArea rows={4} />)}
                 </Form.Item>
               </Col>
@@ -145,7 +141,10 @@
           }
           values.id = this.state.card.id
           values.uuid = this.state.card.uuid
-          resolve(values)
+          resolve({
+            type: 'search',
+            values
+          })
         } else {
           reject(err)
         }
@@ -153,8 +152,9 @@
     })
   }
 
-  UNSAFE_componentWillMount () {
-    let _item = this.props.formlist.filter(cell => cell.key === 'type')[0]
+  resetForm = (formlist) => {
+    if (!formlist) return
+    let _item = formlist.filter(cell => cell.key === 'type')[0]
     if (_item.initVal === 'select') {
       this.setState({
         inputType: 'select',
@@ -169,6 +169,10 @@
     }
   }
 
+  UNSAFE_componentWillMount () {
+    this.resetForm(this.props.formlist)
+  }
+
   render() {
     const formItemLayout = {
       labelCol: {
@@ -181,7 +185,7 @@
       }
     }
     return (
-      <Form {...formItemLayout} className="ant-advanced-search-form commontable-form" id="form-box">
+      <Form {...formItemLayout} className="ant-advanced-search-form commontable-search-form" id="commontable-search-form-box">
         <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )

--
Gitblit v1.8.0