From 9d3c77a83bc4e7febbfb8fd05de2f90100c5af6c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 15 一月 2024 17:52:42 +0800
Subject: [PATCH] 2024-01-15

---
 src/menu/components/form/formaction/formconfig.jsx        |   15 +++++--
 src/tabviews/zshare/mutilform/index.jsx                   |   37 +++++++++++++-----
 src/tabviews/custom/components/form/simple-form/index.jsx |   24 ++++++++++--
 src/tabviews/zshare/actionList/normalbutton/index.jsx     |   14 ++++++
 4 files changed, 71 insertions(+), 19 deletions(-)

diff --git a/src/menu/components/form/formaction/formconfig.jsx b/src/menu/components/form/formaction/formconfig.jsx
index cb760da..27c9159 100644
--- a/src/menu/components/form/formaction/formconfig.jsx
+++ b/src/menu/components/form/formaction/formconfig.jsx
@@ -127,10 +127,17 @@
   fields.forEach(item => {
     if (item.type !== 'text' && item.type !== 'number') return
 
-    resets.push({
-      value: item.field,
-      text: item.label
-    })
+    if (item.label !== item.field) {
+      resets.push({
+        value: item.field,
+        text: item.label + ' (' + item.field + ')'
+      })
+    } else {
+      resets.push({
+        value: item.field,
+        text: item.label
+      })
+    }
   })
 
   return [
diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx
index 2968377..a844a2c 100644
--- a/src/tabviews/custom/components/form/simple-form/index.jsx
+++ b/src/tabviews/custom/components/form/simple-form/index.jsx
@@ -70,6 +70,10 @@
 
     let _group = _config.subcards[0]
 
+    if (_config.wrap.refocus) {
+      _group.setting.refocus = _config.wrap.refocus
+    }
+
     if (_group.subButton.enable === 'false' && (!_group.closeButton || _group.closeButton.enable !== 'true') && (!_group.resetButton || _group.resetButton.enable !== 'true')) {
       _group.subButton.style.display = 'none'
       _group.$button = 'no-button'
@@ -213,15 +217,27 @@
 
   /**
    * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂�
-   * @param {*} menuId     // 鑿滃崟Id
-   * @param {*} position   // 鍒锋柊浣嶇疆
-   * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
-  refreshByButtonResult = (menuId, position, btn, id) => {
+  refreshByButtonResult = (menuId, position, btn, id, lines, res) => {
     const { config, group, BID } = this.state
 
     if (config.uuid !== menuId) return
 
+    if (position === 'resetData') {
+      let _data = fromJS(this.state.data || {}).toJS()
+
+      Object.keys(_data).forEach(key => {
+        let _key = key.toLowerCase()
+        if (typeof(res[_key]) !== 'undefined') {
+          _data[key] = res[_key]
+        }
+      })
+
+      this.setState({
+        data: _data
+      })
+      return
+    }
     if (position === 'grid' && config.wrap.refocus) {
       let _group = fromJS(group).toJS()
       _group.setting.focus = config.wrap.refocus
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 46fe864..f7b4abe 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -2226,7 +2226,19 @@
     const { autoMatic } = this.state
 
     if (btn.resetForms) {
-      MKEmitter.emit('resetForms', btn.uuid)
+      let data = {}
+
+      Object.keys(res).forEach(key => {
+        data[key.toLowerCase()] = res[key]
+      })
+
+      delete data.errcode
+      delete data.errmesg
+      delete data.message
+      delete data.status
+
+      MKEmitter.emit('resetForms', btn.uuid, data)
+      MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'resetData', btn, null, null, data)
     }
 
     if (this.preCallback) {
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index 61dbda9..8a3b8e9 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -47,7 +47,8 @@
     send_type: '',
     timestamp: '',
     n_id: '',
-    focusId: ''
+    focusId: '',
+    reFocusId: ''
   }
 
   record = {}
@@ -680,14 +681,24 @@
       focusItem = fieldMap.get(action.setting.focus)
     }
 
-    this.setState({ formlist, ID, focusId: focusItem ? focusItem.uuid : '' }, () => {
+    let reFocusItem = null
+    if (action.setting.refocus && fieldMap.has(action.setting.refocus)) {
+      reFocusItem = fieldMap.get(action.setting.refocus)
+    }
+
+    this.setState({
+      formlist,
+      ID,
+      focusId: focusItem ? focusItem.uuid : '',
+      reFocusId: reFocusItem ? reFocusItem.uuid : ''
+    }, () => {
       if (unload) return
       
       if (focusItem) {
         if (focusItem.type === 'text' || focusItem.type === 'number') {
           setTimeout(() => {
             MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
-          }, 50)
+          }, 20)
         } else {
           setTimeout(() => {
             MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
@@ -722,9 +733,9 @@
     MKEmitter.removeListener('resetForms', this.resetForms)
   }
 
-  resetForms = (id) => {
+  resetForms = (id, data) => {
     const { action } = this.props
-    const { focusId } = this.state
+    const { focusId, reFocusId } = this.state
 
     if (id !== action.uuid) return
 
@@ -735,8 +746,14 @@
       if (item.type !== 'text' && item.type !== 'number') return item
 
       if (resetForms.includes(item.field)) {
-        item.initval = item.orgval
-        this.record[item.field] = item.orgval
+        let key = item.field.toLowerCase()
+        if (typeof(data[key]) !== 'undefined') {
+          item.initval = data[key]
+          this.record[item.field] = data[key]
+        } else {
+          item.initval = item.orgval
+          this.record[item.field] = item.orgval
+        }
       }
 
       return item
@@ -760,10 +777,10 @@
       })
     })
 
-    if (focusId || this.submitId) {
+    if (reFocusId || focusId || this.submitId) {
       setTimeout(() => {
-        MKEmitter.emit('mkFC', 'focus', this.submitId || focusId)
-      }, 50)
+        MKEmitter.emit('mkFC', 'focus', this.submitId || reFocusId || focusId)
+      }, 20)
     }
   }
 

--
Gitblit v1.8.0