From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 九月 2021 10:31:45 +0800
Subject: [PATCH] 2021-09-01

---
 src/templates/formtabconfig/actionform/index.jsx |  183 ++++++++++++++++++---------------------------
 1 files changed, 74 insertions(+), 109 deletions(-)

diff --git a/src/templates/formtabconfig/actionform/index.jsx b/src/templates/formtabconfig/actionform/index.jsx
index a87c475..6fd1b18 100644
--- a/src/templates/formtabconfig/actionform/index.jsx
+++ b/src/templates/formtabconfig/actionform/index.jsx
@@ -9,10 +9,11 @@
 
 class MainSearch extends Component {
   static propTpyes = {
-    dict: PropTypes.object,  // 瀛楀吀椤�
-    formlist: PropTypes.any, // 琛ㄥ崟淇℃伅
-    card: PropTypes.any,     // 鎸夐挳淇℃伅
-    tabs: PropTypes.array    // 鎵�鏈夋爣绛鹃〉
+    dict: PropTypes.object,      // 瀛楀吀椤�
+    formlist: PropTypes.any,     // 琛ㄥ崟淇℃伅
+    card: PropTypes.any,         // 鎸夐挳淇℃伅
+    tabs: PropTypes.array,       // 鎵�鏈夋爣绛鹃〉
+    inputSubmit: PropTypes.any   // 鍥炶溅鎻愪氦浜嬩欢
   }
 
   state = {
@@ -21,23 +22,23 @@
     interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮�
     insertUpdateOptions: [{
       value: '',
-      text: this.props.dict['header.form.empty']
+      text: this.props.dict['model.empty']
     }, {
       value: 'insert',
       text: this.props.dict['header.form.action.insert']
     }, {
       value: 'update',
       text: this.props.dict['header.form.action.update']
+    }, {
+      value: 'insertOrUpdate',
+      text: this.props.dict['header.form.action.insertOrUpdate']
     }],
     returnoptions: [{ // 杩斿洖鍚�-涓嶅埛鏂般�佸埛鏂伴〉闈€�佸埛鏂拌〃鏍�
       value: 'never',
       text: this.props.dict['header.form.refresh.never']
     }, {
       value: 'grid',
-      text: this.props.dict['header.form.refresh.grid']
-    }, {
-      value: 'view',
-      text: this.props.dict['header.form.refresh.view']
+      text: this.props.dict['header.form.refresh']
     }],
     currentoptions: [{ // 涓嶈繑鍥炴椂-涓嶅埛鏂般�佸埛鏂�
       value: 'never',
@@ -52,35 +53,17 @@
   UNSAFE_componentWillMount () {
     const { card } = this.props
     let _intertype = ''
-    let _options = null
-    let _success = 'close'
-    let _error = 'notclose'
 
     this.props.formlist.forEach(form => {
       if (form.key === 'intertype') {
         _intertype = form.initVal
-      } else if (form.key === 'afterExecSuccess') {
-        _success = form.initVal
-      } else if (form.key === 'afterExecError') {
-        _error = form.initVal
+        if (card.btnType !== 'confirm') {
+          form.options = form.options.filter(op => op.value !== 'system')
+        }
       }
     })
 
-    if (card.btnType === 'cancel') {
-      _options = ['label', 'OpenType', 'icon', 'class', 'execSuccess']
-    } else if (card.btnType === 'confirm') {
-      if (_intertype === 'outer') {
-        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-      } else {
-        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError']
-      }
-    } else {
-      if (_intertype === 'outer') {
-        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-      } else {
-        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-      }
-    }
+    let _options = this.getOptions(card.btnType, _intertype)
 
     this.setState({
       formlist: this.props.formlist.map(item => {
@@ -88,16 +71,18 @@
           item.options = btnClasses
         } else if (item.key === 'icon') {
           item.options = btnIcons
+        } else if (item.key === 'resetPageIndex') {
+          item.tooltip = '椤甸潰鍏抽棴锛屼笖鎵ц鍒锋柊鏃剁敓鏁�'
         } else if (item.key === 'sqlType') {
           item.options = this.state.insertUpdateOptions
         } else if (item.key === 'OpenType') {
           item.options = [
             {
               value: 'prompt',
-              text: this.props.dict['header.form.prompt']
+              text: this.props.dict['model.form.prompt']
             }, {
               value: 'exec',
-              text: this.props.dict['header.form.exec']
+              text: this.props.dict['model.form.exec']
             }
           ]
           if (card.btnType === 'cancel') {
@@ -105,18 +90,9 @@
           }
         } else if (item.key === 'execSuccess' && card.btnType === 'cancel') {
           item.label = '鍏抽棴鍚�'
-        } else if (item.key === 'execSuccess' && card.btnType !== 'cancel') {
-          if (_success === 'close') {
-            item.options = this.state.returnoptions
-          } else {
-            item.options = this.state.currentoptions
-          }
-        } else if (item.key === 'execError') {
-          if (_error === 'close') {
-            item.options = this.state.returnoptions
-          } else {
-            item.options = this.state.currentoptions
-          }
+          item.options[1].text = '鍒锋柊'
+        } else if (item.key === 'execSuccess' || item.key === 'execError') {
+          item.options[1].text = '鍒锋柊'
         } else if (item.key === 'innerFunc' && card.btnType !== 'confirm' && _intertype === 'inner') {
           item.required = true
         }
@@ -134,48 +110,34 @@
       try {
         let _form = document.getElementById('label')
         _form.select()
-      } catch {
+      } catch (e) {
         console.warn('琛ㄥ崟focus澶辫触锛�')
       }
     }
   }
 
-  selectChange = (key, value) => {
-    if (key === 'afterExecSuccess') {
-      this.setState({
-        formlist: this.state.formlist.map(item => {
-          if (item.key === 'execSuccess') {
-            if (value === 'close') {
-              item.options = this.state.returnoptions
-            } else {
-              item.options = this.state.currentoptions
-            }
-          }
+  getOptions = (btnType, intertype) => {
+    let _options = []
 
-          return item
-        })
-      })
-      this.props.form.setFieldsValue({
-        execSuccess: 'never'
-      })
-    } else if (key === 'afterExecError') {
-      this.setState({
-        formlist: this.state.formlist.map(item => {
-          if (item.key === 'execError') {
-            if (value === 'close') {
-              item.options = this.state.returnoptions
-            } else {
-              item.options = this.state.currentoptions
-            }
-          }
-  
-          return item
-        })
-      })
-      this.props.form.setFieldsValue({
-        execError: 'never'
-      })
+    if (btnType === 'cancel') {
+      _options = ['label', 'OpenType', 'icon', 'class', 'execSuccess', 'resetPageIndex']
+    } else if (btnType === 'confirm') {
+      if (intertype === 'outer') {
+        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex']
+      } else if (intertype === 'system') {
+        _options = ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError', 'resetPageIndex']
+      } else {
+        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex']
+      }
+    } else {
+      if (intertype === 'outer') {
+        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex']
+      } else {
+        _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex']
+      }
     }
+
+    return _options
   }
 
   onChange = (e, key) => {
@@ -184,21 +146,7 @@
     let value = e.target.value
 
     if (key === 'intertype') {
-      let _options = null
-
-      if (card.btnType === 'confirm') {
-        if (value === 'outer') {
-          _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-        } else {
-          _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError']
-        }
-      } else {
-        if (value === 'outer') {
-          _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-        } else {
-          _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError']
-        }
-      }
+      let _options = this.getOptions(card.btnType, value)
 
       this.setState({
         interType: value,
@@ -209,9 +157,9 @@
             item.readonly = false
           } else if (item.key === 'sysInterface') {
             item.initVal = 'false'
-          } else if (item.key === 'innerFunc' && card.btnType !== 'confirm' && value === 'inner') {
+          } else if (item.key === 'innerFunc' && value === 'inner') {
             item.required = true
-          } else if (item.key === 'innerFunc' && card.btnType !== 'confirm' && value === 'outer') {
+          } else if (item.key === 'innerFunc' && value === 'outer') {
             item.required = false
           }
 
@@ -221,7 +169,7 @@
     } else if (key === 'sysInterface') {
       if (value === 'true') {
         this.props.form.setFieldsValue({
-          interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+          interface: window.GLOB.mainSystemApi || ''
         })
       }
       this.setState({
@@ -235,6 +183,14 @@
           return item
         })
       })
+    }
+  }
+
+  handleSubmit = (e) => {
+    e.preventDefault()
+
+    if (this.props.inputSubmit) {
+      this.props.inputSubmit()
     }
   }
 
@@ -288,7 +244,7 @@
                   },
                   ..._rules
                 ]
-              })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)}
+              })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)}
             </Form.Item>
           </Col>
         )
@@ -329,7 +285,6 @@
                   showSearch
                   filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   getPopupContainer={() => document.getElementById('winter')}
-                  onChange={(val) => this.selectChange(item.key, val)}
                   disabled={!!item.readonly}
                 >
                   {item.options.map((option, index) =>
@@ -345,7 +300,12 @@
       } else if (item.type === 'radio') {
         fields.push(
           <Col span={12} key={index}>
-            <Form.Item label={item.label}>
+            <Form.Item label={item.tooltip ?
+              <Tooltip placement="topLeft" title={item.tooltip}>
+                <Icon type="question-circle" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
               {getFieldDecorator(item.key, {
                 initialValue: item.initVal,
                 rules: [
@@ -373,8 +333,14 @@
           <Col span={24} key={index}>
             <Form.Item label={item.label} className="textarea">
               {getFieldDecorator(item.key, {
-                initialValue: item.initVal
-              })(<TextArea rows={4} />)}
+                initialValue: item.initVal,
+                rules: [
+                  {
+                    required: item.readonly ? false : !!item.required,
+                    message: this.props.dict['form.required.input'] + item.label + '!'
+                  }
+                ]
+              })(<TextArea rows={4} readOnly={item.readonly}/>)}
             </Form.Item>
           </Col>
         )
@@ -388,7 +354,6 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
-          values.id = this.props.card.id
           values.uuid = this.props.card.uuid
           values.verify = this.props.card.verify || null
           values.btnType = this.props.card.btnType || 'tabFormBtn'
@@ -397,14 +362,14 @@
           if (values.innerFunc === '' && values.sql === '') {
             notification.warning({
               top: 92,
-              message: this.props.dict['header.form.actionhelp.tablename'],
-              duration: 10
+              message: '浣跨敤绯荤粺鍑芥暟鏃讹紝璇峰~鍐欒〃鍚嶏紝浣跨敤鑷畾涔夊嚱鏁版椂锛屽彲蹇界暐銆�',
+              duration: 5
             })
           } else if (values.innerFunc === '' && values.sql !== '' && values.sqlType === '') {
             notification.warning({
               top: 92,
-              message: this.props.dict['header.form.actionhelp.sqlType'],
-              duration: 10
+              message: '浣跨敤绯荤粺鍑芥暟鏃讹紝璇烽�夋嫨鎿嶄綔绫诲瀷锛屼娇鐢ㄨ嚜瀹氫箟鍑芥暟鏃讹紝鍙拷鐣ャ��',
+              duration: 5
             })
           } else {
             resolve(values)
@@ -428,7 +393,7 @@
       }
     }
     return (
-      <Form {...formItemLayout} className="ant-advanced-search-form commontable-action-form" id="winter">
+      <Form {...formItemLayout} className="formtab-action-list-form" id="winter">
         <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )

--
Gitblit v1.8.0