From 5891206952e2ff63e87aed2f47df5324b019d32e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 25 十月 2022 00:39:38 +0800
Subject: [PATCH] 2022-10-25

---
 src/menu/components/share/actioncomponent/index.jsx |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx
index 0f29f3c..2bee4a7 100644
--- a/src/menu/components/share/actioncomponent/index.jsx
+++ b/src/menu/components/share/actioncomponent/index.jsx
@@ -60,17 +60,9 @@
   }
 
   componentDidMount () {
+    MKEmitter.addListener('revert', this.revert)
     MKEmitter.addListener('addButton', this.addButton)
-  }
-
-  /**
-   * @description 鐩戝惉鍒版寜閽鍒舵椂锛岃Е鍙戞寜閽紪杈�
-   */
-  UNSAFE_componentWillReceiveProps (nextProps) {
-    const { actionlist } = this.state
-    if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
-      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
-    }
+    MKEmitter.addListener('submitModal', this.handleSave)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -84,7 +76,41 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('revert', this.revert)
     MKEmitter.removeListener('addButton', this.addButton)
+    MKEmitter.removeListener('submitModal', this.handleSave)
+  }
+
+  revert = () => {
+    this.setState({
+      actionlist: fromJS(this.props.config.action).toJS()
+    })
+  }
+
+  handleSave = (componentId, btnId, modal) => {
+    const { config } = this.props
+
+    if (config.uuid !== componentId) return
+
+    const { actionlist } = this.state
+
+    let _index = actionlist.findIndex(cell => cell.uuid === btnId)
+
+    if (_index === -1) return
+
+    let _actionlist = actionlist.map(cell => {
+      if (cell.uuid === btnId) {
+        cell.modal = modal
+      }
+
+      return cell
+    })
+
+    this.setState({
+      actionlist: _actionlist
+    }, () => {
+      this.props.updateaction({...config, action: _actionlist})
+    })
   }
 
   getStyle = (style) => {
@@ -323,7 +349,6 @@
       profVisible: true,
       card: element
     })
-    MKEmitter.emit('modalStatus', '楠岃瘉淇℃伅')
   }
 
   /**
@@ -351,7 +376,6 @@
       }, () => {
         this.props.updateaction({...config, action: _actionlist})
       })
-      MKEmitter.emit('modalStatus', false)
     })
   }
 
@@ -555,11 +579,9 @@
             if (this.verifyRef.handleCancel) {
               this.verifyRef.handleCancel().then(() => {
                 this.setState({ profVisible: false })
-                MKEmitter.emit('modalStatus', false)
               })
             } else {
               this.setState({ profVisible: false })
-              MKEmitter.emit('modalStatus', false)
             }
           }}
           destroyOnClose

--
Gitblit v1.8.0