From 977e6195d7d6a48769563cf90bfc307fb2ef6f2d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 14 十一月 2023 22:29:32 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/form/simple-form/index.jsx |   65 +++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx
index 3a87da3..ebb2f97 100644
--- a/src/tabviews/custom/components/form/simple-form/index.jsx
+++ b/src/tabviews/custom/components/form/simple-form/index.jsx
@@ -92,16 +92,14 @@
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
 
-    if (config.setting.useMSearch) {
-      MKEmitter.addListener('searchRefresh', this.searchRefresh)
-    }
-
     if (config.setting.sync === 'true') {
       MKEmitter.addListener('transferSyncData', this.transferSyncData)
     }
 
     if (config.wrap.datatype === 'public') {
       MKEmitter.addListener('mkPublicData', this.mkPublicData)
+    } else if (config.setting.useMSearch) {
+      MKEmitter.addListener('searchRefresh', this.searchRefresh)
     }
 
     this.initExec()
@@ -178,11 +176,39 @@
   }
 
   reloadData = (menuId, id) => {
-    const { config } = this.state
+    const { config, group } = this.state
 
     if (config.uuid !== menuId) return
 
-    this.loadData()
+    if (id === 'focus-refresh' && config.wrap.refocus) {
+      let _group = fromJS(group).toJS()
+      _group.setting.focus = config.wrap.refocus
+
+      if (config.wrap.datatype === 'static') {
+        this.setState({
+          data: null,
+          group: _group
+        }, () => {
+          this.setState({data: {$$empty: true}})
+        })
+      } else {
+        this.setState({
+          group: _group
+        }, () => {
+          this.loadData(true)
+        })
+      }
+    } else if (id === 'focus-nofresh' && config.wrap.refocus) {
+      let formId = ''
+      group.fields.forEach(item => {
+        if (item.field === config.wrap.refocus) {
+          formId = item.uuid
+        }
+      })
+      MKEmitter.emit('mkFC', 'focus', formId)
+    } else {
+      this.loadData()
+    }
   }
 
   /**
@@ -199,6 +225,14 @@
     if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) {
       MKEmitter.emit('reloadData', config.setting.supModule, BID)
     } else if (position === 'grid' && config.wrap.datatype === 'static') {
+      if (config.wrap.refocus && group.setting.focus === config.wrap.refocus) {
+        let _group = fromJS(group).toJS()
+        _group.setting.focus = config.wrap.focus
+  
+        this.setState({
+          group: _group
+        })
+      }
       this.setState({
         data: null
       }, () => {
@@ -255,8 +289,17 @@
     }
   }
 
-  async loadData () {
-    const { config, BID } = this.state
+  async loadData (refocus) {
+    const { config, BID, group } = this.state
+
+    if (config.wrap.refocus && !refocus && group.setting.focus === config.wrap.refocus) {
+      let _group = fromJS(group).toJS()
+      _group.setting.focus = config.wrap.focus
+
+      this.setState({
+        group: _group
+      })
+    }
 
     if (config.wrap.datatype === 'public') {
       MKEmitter.emit('reloadData', config.wrap.publicId)
@@ -340,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()
@@ -389,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 || '')}>

--
Gitblit v1.8.0