From 4b6a4e2f04f492d770573cf48ca52d4e748a086a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 18 十月 2021 18:30:50 +0800
Subject: [PATCH] 2021-10-18

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |   56 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 0a9d684..5a6deb4 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -43,7 +43,8 @@
     loading: false,
     loadingNumber: '',
     disabled: false,
-    checkParam: null
+    checkParam: null,
+    autoMatic: false
   }
 
   moduleParams = null
@@ -68,13 +69,17 @@
   }
 
   componentDidMount () {
-    const { position } = this.props
+    const { position, btn } = this.props
 
     MKEmitter.addListener('triggerBtnId', this.actionTrigger)
     if (position === 'form') {
       MKEmitter.addListener('triggerFormSubmit', this.actionSubmit)
     }
     MKEmitter.addListener('returnModuleParam', this.resetModuleParam)
+
+    if (btn.autoMatic) {
+      MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
+    }
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
@@ -102,6 +107,15 @@
     MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
     MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit)
     MKEmitter.removeListener('returnModuleParam', this.resetModuleParam)
+    MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit)
+  }
+
+  triggerBtnPopSubmit = (id) => {
+    const { btn } = this.props
+
+    if (btn.uuid !== id) return
+
+    this.handleOk()
   }
 
   actionSubmit = (res) => {
@@ -154,6 +168,8 @@
         return
       }
     }
+
+    this.setState({autoMatic: type === 'autoMatic'})
 
     let _this = this
     let data = record || selectedData || []
@@ -1344,9 +1360,9 @@
    */
   execSuccess = (res) => {
     const { btn } = this.props
-    const { btnconfig } = this.state
+    const { btnconfig, autoMatic } = this.state
 
-    if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛
+    if ((res && res.ErrCode === 'S') || autoMatic) { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
         message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
@@ -1360,7 +1376,14 @@
 
     }
     
-    if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
+    if (autoMatic) {
+      this.setState({
+        loading: false,
+        visible: false
+      })
+      MKEmitter.emit('autoExecOver', btn.uuid, 'success')
+      return
+    } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') {
       this.setState({
         loading: false,
         visible: false
@@ -1526,13 +1549,13 @@
    */
   execError = (res) => {
     const { btn } = this.props
-    const { btnconfig } = this.state
+    const { btnconfig, autoMatic } = this.state
 
-    if (res.ErrCode === 'E') {
+    if (res.ErrCode === 'E' && !autoMatic) {
       Modal.error({
         title: res.message || res.ErrMesg,
       })
-    } else if (res.ErrCode === 'N') {
+    } else if (res.ErrCode === 'N' || autoMatic) {
       notification.error({
         top: 92,
         message: res.message || res.ErrMesg,
@@ -1547,6 +1570,16 @@
       })
     } else if (res.ErrCode === 'NM') {
       message.error(res.message || res.ErrMesg)
+    }
+
+    if (autoMatic) {
+      this.setState({
+        loading: false,
+        loadingNumber: '',
+        visible: false
+      })
+      MKEmitter.emit('autoExecOver', btn.uuid, 'error')
+      return
     }
     
     this.setState({
@@ -1644,10 +1677,10 @@
    */
   improveAction = () => {
     const { btn } = this.props
-    const { btnconfig } = this.state
+    const { btnconfig, autoMatic } = this.state
 
     if (btnconfig) {
-      if (btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+      if (!autoMatic && btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
         this.modelconfirm()
       } else {
         this.setState({
@@ -1691,7 +1724,7 @@
           this.setState({
             btnconfig: _LongParam
           }, () => {
-            if (_LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
+            if (!autoMatic && _LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず
               this.modelconfirm()
             } else {
               this.setState({
@@ -1708,6 +1741,7 @@
    * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁�
    */
   handleOk = () => {
+    if (!this.formRef) return
     this.formRef.handleConfirm().then(res => {
       this.setState({ confirmLoading: true })
 

--
Gitblit v1.8.0