From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 十月 2021 23:17:08 +0800
Subject: [PATCH] 2021-10-21

---
 src/templates/sharecomponent/actioncomponent/index.jsx |   56 +++++++++++++++++++++++---------------------------------
 1 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx
index fba939a..3d27967 100644
--- a/src/templates/sharecomponent/actioncomponent/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/index.jsx
@@ -16,6 +16,7 @@
 import CreateInterface from '@/templates/zshare/createinterface'
 import { updateForm } from '@/utils/utils-update.js'
 import DragElement from './dragaction'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { confirm } = Modal
@@ -54,24 +55,22 @@
     })
   }
 
-  /**
-   * @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))) {
-      let len = nextProps.config.action.length
-      let item = nextProps.config.action[len - 1]
-      if (item && item.focus) {
-        this.handleAction(item)
-      }
-      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
-    }
-  }
-
   componentDidMount () {
     this.getBillPrintTemp()
+    MKEmitter.addListener('pasteButton', this.pasteButton)
+  }
+
+  pasteButton = (MenuId, btn) => {
+    const { config } = this.props
+    const { actionlist } = this.state
+
+    if (MenuId !== config.uuid) return
+
+    this.setState({
+      actionlist: [...actionlist, btn],
+    }, () => {
+      this.handleAction(btn)
+    })
   }
 
   getBillPrintTemp = () => {
@@ -144,23 +143,17 @@
     if (usefulFields) {
       try {
         usefulFields = JSON.parse(usefulFields)
-      } catch {
+      } catch (e) {
         usefulFields = []
       }
     } else {
       usefulFields = []
     }
 
-    let ableField = usefulFields.join(', ')
-    let functip = <div>
-      <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
-    </div>
-
     let menulist = []
 
     if (menu.fstMenuList) {
       let trees = fromJS(menu.fstMenuList).toJS()
-
       menulist = trees.map(fst => {
         fst.value = fst.MenuID
         fst.label = fst.MenuName
@@ -184,7 +177,7 @@
     this.setState({
       visible: true,
       card: card,
-      formlist: getActionForm(card, functip, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps)
+      formlist: getActionForm(card, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps)
     })
   }
 
@@ -308,7 +301,7 @@
               _LongParam.setting.title = btn.label
               _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
               _temp = 'Modal'
-            } catch {
+            } catch (e) {
               console.warn('Stringify Failure')
               _temp = ''
             }
@@ -328,7 +321,7 @@
               })
               _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
               _temp = 'FormTab'
-            } catch {
+            } catch (e) {
               console.warn('Stringify Failure')
               _temp = ''
             }
@@ -522,7 +515,7 @@
       btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
 
       _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab)))
-    } catch {
+    } catch (e) {
       console.warn('Stringify Failure')
       _LongParam = ''
       _resolve('save')
@@ -836,16 +829,12 @@
     if (!el.origin && (el.OpenType === 'pop' || el.execMode === 'pop' || el.OpenType === 'popview' || (el.OpenType === 'tab' && el.tabTemplate === 'FormTab'))) {
       this.props.setSubConfig(el)
     } else {
-      notification.warning({
-        top: 92,
-        message: '姝ゆ寜閽棤瀛愰厤缃」锛�',
-        duration: 5
-      })
+      this.handleAction(el)
     }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
+    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -855,6 +844,7 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('pasteButton', this.pasteButton)
   }
 
   render() {

--
Gitblit v1.8.0