From ef8acbf3859bd13e759fbb9b8ba726039c1fb2c5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 14 十一月 2023 15:51:59 +0800
Subject: [PATCH] 2023-11-14

---
 src/menu/components/form/formaction/formconfig.jsx        |   13 +---
 src/tabviews/zshare/mutilform/mkPopSelect/index.jsx       |    5 +
 src/tabviews/zshare/mutilform/index.jsx                   |   83 ++++++++++++++++++++++++---
 src/templates/zshare/modalform/index.jsx                  |    6 +
 src/tabviews/zshare/mutilform/mkSelect/index.jsx          |    5 +
 src/tabviews/zshare/mutilform/mkInput/index.jsx           |   18 -----
 src/tabviews/custom/components/form/simple-form/index.jsx |    6 +-
 src/tabviews/zshare/mutilform/mkVercode/index.jsx         |    4 
 src/tabviews/zshare/mutilform/mkNumberInput/index.jsx     |   11 ---
 src/menu/components/form/formaction/actionform/index.jsx  |   12 +++-
 src/tabviews/zshare/actionList/normalbutton/index.jsx     |    4 
 11 files changed, 107 insertions(+), 60 deletions(-)

diff --git a/src/menu/components/form/formaction/actionform/index.jsx b/src/menu/components/form/formaction/actionform/index.jsx
index a55b914..69ca082 100644
--- a/src/menu/components/form/formaction/actionform/index.jsx
+++ b/src/menu/components/form/formaction/actionform/index.jsx
@@ -57,10 +57,12 @@
     } else if (this.record.type === 'close' || this.record.type === 'reset') {
       shows = ['typeName', 'label']
     } else {
-      shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton', 'resetForm'] // 閫夐」鍒楄〃
-      
+      shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton'] // 閫夐」鍒楄〃
+
+      if (this.record.execSuccess === 'never') {
+        shows.push('resetForms')
+      }
       if (this.record.intertype === 'custom') {
-        shows.pop()
         shows.push('procMode', 'interface', 'callbackType', 'proInterface', 'method', 'cross', 'stringify', 'ContentType', 'outerBlacklist')
         if (this.record.procMode === 'system') {
           shows.push('sql', 'sqlType')
@@ -282,6 +284,7 @@
               })(
                 <Select
                   showSearch
+                  mode={item.mode || ''}
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                   onChange={(value) => {this.optionChange(item.key, value)}}
                   getPopupContainer={() => document.getElementById('winter')}
@@ -380,6 +383,9 @@
           if (values.outerBlacklist) {
             values.outerBlacklist = values.outerBlacklist.replace(/\s/ig, '')
           }
+          if (values.resetForms && values.resetForms.length === 0) {
+            values.resetForms = null
+          }
           resolve(values)
         } else {
           reject(err)
diff --git a/src/menu/components/form/formaction/formconfig.jsx b/src/menu/components/form/formaction/formconfig.jsx
index 75d27e3..f6800ae 100644
--- a/src/menu/components/form/formaction/formconfig.jsx
+++ b/src/menu/components/form/formaction/formconfig.jsx
@@ -125,18 +125,13 @@
 
   let resets = []
   fields.forEach(item => {
-    if (item.hidden === 'true') return
     if (item.type !== 'text' && item.type !== 'number') return
 
     resets.push({
-      value: item.uuid,
+      value: item.field,
       text: item.label
     })
   })
-
-  if (card.resetForm && resets.findIndex(item => item.value === card.resetForm) === -1) {
-    card.resetForm = ''
-  }
 
   return [
     {
@@ -492,12 +487,12 @@
     },
     {
       type: 'select',
-      key: 'resetForm',
+      key: 'resetForms',
       label: '閲嶇疆琛ㄥ崟',
       tooltip: '鎸夐挳鎵ц鎴愬姛鍚庨渶瑕侀噸缃殑琛ㄥ崟锛岃〃鍗曚細鎭㈠榛樿鍊煎苟鑱氱劍銆�',
-      initVal: card.resetForm || '',
+      initVal: card.resetForms || [],
       required: false,
-      allowClear: true,
+      mode: 'multiple',
       options: resets
     },
     {
diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx
index 9f8adb5..ebb2f97 100644
--- a/src/tabviews/custom/components/form/simple-form/index.jsx
+++ b/src/tabviews/custom/components/form/simple-form/index.jsx
@@ -383,12 +383,12 @@
     }
   }
 
-  mkFormSubmit = (btnId, callback) => {
+  mkFormSubmit = (btnId, callback, formId) => {
     const { group } = this.state
 
     if (group.uuid !== btnId) return
 
-    this.formRef.handleConfirm().then(res => {
+    this.formRef.handleConfirm(formId).then(res => {
       MKEmitter.emit('triggerFormSubmit', {menuId: btnId, form: res})
     }, () => {
       callback && callback()
@@ -432,7 +432,7 @@
           data={data}
           action={group}
           unload={config.setting.supModule && !BID}
-          inputSubmit={() => this.mkFormSubmit(group.uuid)}
+          inputSubmit={(id) => this.mkFormSubmit(group.uuid, null, id)}
           wrappedComponentRef={(inst) => this.formRef = inst}
         /> : null}
         {data ? <div className={'mk-form-action ' + (group.$button || '')}>
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index a274d27..d6c0450 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -2176,8 +2176,8 @@
     const { btn } = this.props
     const { autoMatic } = this.state
 
-    if (btn.resetForm) {
-      MKEmitter.emit('mkFC', 'reset', btn.resetForm)
+    if (btn.resetForms) {
+      MKEmitter.emit('resetForms', btn.uuid)
     }
 
     if (this.preCallback) {
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index d4b95fd..eff2368 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -46,10 +46,12 @@
     ID: '',
     send_type: '',
     timestamp: '',
-    n_id: ''
+    n_id: '',
+    focusId: ''
   }
 
   record = {}
+  submitId = ''
 
   componentDidMount () {
     const { action, unload } = this.props
@@ -268,7 +270,7 @@
       }
 
       if (item.type === 'number') {
-        if (isNaN(item.initval)) {
+        if (isNaN(item.initval) || item.initval === '') {
           item.initval = 0
         }
       } else if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') {
@@ -623,17 +625,19 @@
       }
 
       record[item.field] = item.initval
+      item.orgval = item.initval
 
       if (linkFields[item.field]) {
         item.linkFields = linkFields[item.field]
       }
       
       if (item.enter === 'tab' || item.enter === 'sub') {
-        if (fieldMap.has(item.tabField)) {
+        item.tabUuid = ''
+        if (item.tabField && fieldMap.has(item.tabField)) {
           item.tabUuid = fieldMap.get(item.tabField).uuid
         } else if (item.enter === 'tab') {
           item.enter = 'false'
-        } else if (item.enter === 'sub') {
+        } else if (item.enter === 'sub' && ['text', 'number'].includes(item.type)) {
           item.tabUuid = item.uuid
         }
       }
@@ -670,13 +674,16 @@
 
     this.record = record
     let ID = this.props.data ? this.props.data.$$uuid || '' : ''
+    let focusItem = null
 
-    this.setState({ formlist, ID }, () => {
+    if (action.setting.focus && fieldMap.has(action.setting.focus)) {
+      focusItem = fieldMap.get(action.setting.focus)
+    }
+
+    this.setState({ formlist, ID, focusId: focusItem ? focusItem.uuid : '' }, () => {
       if (unload) return
       
-      if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) {
-        let focusItem = fieldMap.get(action.setting.focus)
-
+      if (focusItem) {
         if (focusItem.type === 'text' || focusItem.type === 'number') {
           setTimeout(() => {
             MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
@@ -702,6 +709,62 @@
         }
       }
     })
+
+    if (action.subButton && action.subButton.resetForms) {
+      MKEmitter.addListener('resetForms', this.resetForms)
+    }
+  }
+
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('resetForms', this.resetForms)
+  }
+
+  resetForms = (id) => {
+    const { action } = this.props
+    const { focusId } = this.state
+
+    if (id !== action.uuid) return
+
+    let formlist = fromJS(this.state.formlist).toJS()
+    let resetForms = action.subButton.resetForms || []
+
+    formlist = formlist.map(item => {
+      if (item.type !== 'text' && item.type !== 'number') return item
+
+      if (resetForms.includes(item.field)) {
+        item.initval = item.orgval
+        this.record[item.field] = item.orgval
+      }
+
+      return item
+    })
+
+    let _list = fromJS(formlist).toJS().map(item => {
+      if (item.type !== 'text' && item.type !== 'number') return item
+
+      if (resetForms.includes(item.field) && !item.hidden) {
+        item.hidden = true
+      }
+
+      return item
+    })
+
+    this.setState({
+      formlist: _list
+    }, () => {
+      this.setState({
+        formlist
+      })
+    })
+
+    if (focusId || this.submitId) {
+      setTimeout(() => {
+        MKEmitter.emit('mkFC', 'focus', this.submitId || focusId)
+      }, 50)
+    }
   }
 
   getFormData = (deForms) => {
@@ -1218,7 +1281,7 @@
     return fields
   }
 
-  handleConfirm = () => {
+  handleConfirm = (formId) => {
     const { formlist, send_type, timestamp, n_id } = this.state
 
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
@@ -1316,6 +1379,8 @@
           forms.push(_item)
         })
 
+        this.submitId = formId || ''
+
         resolve(forms)
       })
     })
diff --git a/src/tabviews/zshare/mutilform/mkInput/index.jsx b/src/tabviews/zshare/mutilform/mkInput/index.jsx
index b85134d..cad739c 100644
--- a/src/tabviews/zshare/mutilform/mkInput/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkInput/index.jsx
@@ -78,22 +78,6 @@
       } else {
         this.props.onChange(_val, true)
       }
-    } else if (type === 'reset') {
-      let _val = this.props.config.initval
-
-      if (this.state.encryption === 'true' && _val) {
-        try {
-          _val = window.decodeURIComponent(window.atob(_val))
-        } catch (e) {
-          _val = this.props.config.initval
-        }
-      }
-
-      this.setState({value: _val}, () => {
-        this.inputRef.current.select()
-      })
-
-      this.props.onChange(this.props.config.initval)
     }
   }
 
@@ -139,7 +123,7 @@
       MKEmitter.emit('mkFC', 'focus', config.tabUuid)
     } else {
       MKEmitter.emit('mkFC', 'focus', config.tabUuid)
-      this.props.onSubmit()
+      this.props.onSubmit(config.tabUuid)
     }
   }
 
diff --git a/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx b/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx
index c517566..9e80af9 100644
--- a/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkNumberInput/index.jsx
@@ -44,15 +44,6 @@
     } else if (type === 'input') {
       this.setState({value})
       this.props.onChange(value, true)
-    } else if (type === 'reset') {
-      let _val = this.props.config.initval
-
-      this.setState({value: _val}, () => {
-        let node = document.getElementById(this.props.config.uuid)
-        node && node.select()
-      })
-
-      this.props.onChange(_val)
     }
   }
 
@@ -80,7 +71,7 @@
       MKEmitter.emit('mkFC', 'focus', config.tabUuid)
     } else {
       MKEmitter.emit('mkFC', 'focus', config.tabUuid)
-      this.props.onSubmit()
+      this.props.onSubmit(config.tabUuid)
     }
   }
 
diff --git a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx
index 320dceb..c9bc1d6 100644
--- a/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkPopSelect/index.jsx
@@ -265,12 +265,13 @@
       if (config.enter === 'tab') {
         MKEmitter.emit('mkFC', 'focus', config.tabUuid)
       } else if (config.enter === 'sub') {
+        config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid)
         if (config.subFields) {
           setTimeout(() => {
-            this.props.onSubmit()
+            this.props.onSubmit(config.tabUuid)
           }, 1000)
         } else {
-          this.props.onSubmit()
+          this.props.onSubmit(config.tabUuid)
         }
       }
     })
diff --git a/src/tabviews/zshare/mutilform/mkSelect/index.jsx b/src/tabviews/zshare/mutilform/mkSelect/index.jsx
index c8af8d3..6f94b5d 100644
--- a/src/tabviews/zshare/mutilform/mkSelect/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkSelect/index.jsx
@@ -149,12 +149,13 @@
       if (config.enter === 'tab') {
         MKEmitter.emit('mkFC', 'focus', config.tabUuid)
       } else if (config.enter === 'sub') {
+        config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid)
         if (config.linkFields || config.subFields || config.controlFields) {
           setTimeout(() => {
-            this.props.onSubmit()
+            this.props.onSubmit(config.tabUuid)
           }, 1000)
         } else {
-          this.props.onSubmit()
+          this.props.onSubmit(config.tabUuid)
         }
       }
     })
diff --git a/src/tabviews/zshare/mutilform/mkVercode/index.jsx b/src/tabviews/zshare/mutilform/mkVercode/index.jsx
index c0569d0..7f6eff9 100644
--- a/src/tabviews/zshare/mutilform/mkVercode/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkVercode/index.jsx
@@ -55,8 +55,8 @@
     if (config.enter === 'tab') {
       MKEmitter.emit('mkFC', 'focus', config.tabUuid)
     } else {
-      MKEmitter.emit('mkFC', 'focus', config.tabUuid)
-      this.props.onSubmit()
+      config.tabUuid && MKEmitter.emit('mkFC', 'focus', config.tabUuid)
+      this.props.onSubmit(config.tabUuid)
     }
   }
 
diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 7ae6d40..ffe236a 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -289,6 +289,10 @@
       if (this.record.interception === 'func') {
         shows.push('func')
       }
+    } else if (type === 'popSelect') {
+      if (this.record.enter === 'tab' || this.record.enter === 'sub') {
+        shows.push('tabField')
+      }
     }
 
     if (['multiselect', 'select', 'link', 'radio', 'checkbox', 'checkcard', 'cascader'].includes(type)) {
@@ -383,7 +387,7 @@
       if (value === 'text' || value === 'number') {
         this.record.enter = 'sub'
         _fieldval.enter = 'sub'
-      } else if (value === 'select' || value === 'link') {
+      } else if (['select', 'link', 'popSelect', 'vercode'].includes(value)) {
         _fieldval.enter = 'false'
       }
 

--
Gitblit v1.8.0