From 407c0f1765c7d085218a91ad8842784977383d05 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 23 十月 2020 00:18:13 +0800
Subject: [PATCH] 2020-10-23

---
 src/menu/actioncomponent/index.jsx |  731 +++++++++++--------------------------------------------
 1 files changed, 155 insertions(+), 576 deletions(-)

diff --git a/src/menu/actioncomponent/index.jsx b/src/menu/actioncomponent/index.jsx
index a1073ac..364806f 100644
--- a/src/menu/actioncomponent/index.jsx
+++ b/src/menu/actioncomponent/index.jsx
@@ -1,8 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { Modal, notification, Button } from 'antd'
-import moment from 'moment'
 
 import Api from '@/api'
 import options from '@/store/options.js'
@@ -12,6 +12,7 @@
 import enUS from '@/locales/en-US/model.js'
 import { getActionForm } from './formconfig'
 
+import MKEmitter from '@/utils/events.js'
 import ActionForm from './actionform'
 import VerifyCard from '@/templates/zshare/verifycard'
 import CreateFunc from '@/templates/zshare/createfunc'
@@ -26,9 +27,8 @@
 class ActionComponent extends Component {
   static propTpyes = {
     type: PropTypes.string,          // 鑿滃崟绫诲瀷锛屼富琛ㄦ垨瀛愯〃
-    menu: PropTypes.object,          // 鑿滃崟淇℃伅锛堣彍鍗昳d锛岃彍鍗曞弬鏁帮紝鑿滃崟鍚嶇О锛�
+    plus: PropTypes.any,             // 鏄惁瀛樺湪娣诲姞鎸夐挳锛屽�间负false鏃堕殣钘�
     config: PropTypes.object,        // 鑿滃崟閰嶇疆淇℃伅
-    tabs: PropTypes.array,           // 鎵�鏈夋爣绛�
     setSubConfig: PropTypes.func,    // 璁剧疆瀛愰厤缃俊鎭�
     updateaction: PropTypes.func     // 鑿滃崟閰嶇疆鏇存柊
   }
@@ -38,7 +38,6 @@
     card: null,          // 缂栬緫涓厓绱�
     formlist: null,      // 琛ㄥ崟淇℃伅
     actionlist: null,    // 鎸夐挳缁�
-    copying: false,      // 鎸夐挳澶嶅埗涓�
     visible: false,      // 妯℃�佹鎺у埗
     profVisible: false   // 楠岃瘉淇℃伅妯℃�佹
   }
@@ -52,6 +51,10 @@
     })
   }
 
+  componentDidMount () {
+    MKEmitter.addListener('addButton', this.addButton)
+  }
+
   /**
    * @description 鐩戝惉鍒版寜閽鍒舵椂锛岃Е鍙戞寜閽紪杈�
    */
@@ -61,6 +64,29 @@
     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()})
     }
+  }
+
+  shouldComponentUpdate (nextProps, nextState) {
+    return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState))
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('addButton', this.addButton)
+  }
+
+  addButton = (cardId, element) => {
+    if (cardId !== this.props.config.uuid) return
+
+    const { actionlist } = this.state
+
+    this.setState({actionlist: [...actionlist, element]})
+    this.handleAction(element)
   }
 
   /**
@@ -77,6 +103,57 @@
         this.props.updateaction({...config, action: list})
       })
     }
+  }
+
+  getModules = (components, selfId) => {
+    let modules = components.map(item => {
+      if (item.uuid === selfId) {
+        return {
+          children: null
+        }
+      } else if (item.format) {
+        return {
+          value: item.uuid,
+          label: item.name
+        }
+      } else if (item.type === 'tabs') {
+        let _item = {
+          value: item.uuid,
+          label: item.name,
+          children: item.subtabs.map(f_tab => {
+            let subItem = {
+              value: f_tab.uuid,
+              label: f_tab.label,
+              children: this.getModules(f_tab.components, selfId)
+            }
+
+            if (!subItem.children || subItem.children.length === 0) {
+              return {children: null}
+            }
+            return subItem
+          })
+        }
+
+        _item.children = _item.children.filter(t => t.children !== null)
+
+        if (_item.children.length === 0) {
+          return {children: null}
+        }
+
+        return _item
+      } else {
+        return {
+          children: null
+        }
+      }
+    })
+
+    modules = modules.filter(mod => mod.children !== null)
+
+    if (modules.length === 0) {
+      return null
+    }
+    return modules
   }
 
   /**
@@ -102,22 +179,7 @@
       })
     }
 
-    // let modules = []
-
-    // menu.components.forEach(item => {
-    //   if (item.uuid === config.uuid) return
-
-    //   modules.push({
-    //     value: item.uuid,
-    //     text: item.setting.name
-    //   })
-    // })
-
-    // if (supModule && supModule !== 'empty') {
-    //   if (modules.filter(item => item.value === supModule).length === 0) {
-    //     supModule = ''
-    //   }
-    // }
+    let modules = this.getModules(menu.components, config.uuid)
 
     if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) {
       let _param = {
@@ -166,14 +228,14 @@
         this.setState({
           visible: true,
           card: card,
-          formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist)
+          formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules)
         })
       })
     } else {
       this.setState({
         visible: true,
         card: card,
-        formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist)
+        formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules)
       })
     }
   }
@@ -203,15 +265,10 @@
   }
 
   /**
-   * @description 鎼滅储淇敼鍚庢彁浜や繚瀛�
-   * 1銆佸幓闄ょ郴缁熼粯璁ゆ悳绱㈡潯浠�
-   * 2銆佸瓧娈靛強鎻愮ず鏂囧瓧閲嶅鏍¢獙
-   * 3銆佹洿鏂颁笅鎷夎彍鍗曞彲閫夐泦鍚�
-   * 4銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉
+   * @description 鎸夐挳淇敼鍚庢彁浜や繚瀛�
    */
   handleSubmit = () => {
-    const { config, menu } = this.props
-    const { card } = this.state
+    const { config } = this.props
     let _actionlist = fromJS(this.state.actionlist).toJS()
 
     this.actionFormRef.handleConfirm().then(btn => {
@@ -240,370 +297,11 @@
       }
 
       this.setState({
-        copying: true
+        actionlist: _actionlist,
+        visible: false
+      }, () => {
+        this.props.updateaction({...config, action: _actionlist})
       })
-
-      let copyActionId = '' // 鎸夐挳涓哄鍒舵椂锛岃褰曞綋鍓嶆寜閽殑Id锛岃彍鍗曞彇娑堜繚瀛樻椂锛屽垹闄ゅ鍒舵寜閽厤缃俊鎭�
-
-      /**
-       * @description 鎸夐挳淇濆瓨鏍¢獙
-       * 1銆佹鏌ユ寜閽槸鍚︿负琛ㄥ崟鎴栬〃鍗曟爣绛鹃〉锛屽鍓嶅悗涓�鑷达紝鍒欏鍒跺叾鍐呭
-       * 2銆佹鏌ユ寜閽槸鍚︿负鏍囩椤碉紝濡傚墠鍚庝竴鑷达紝鍒欏鍒舵爣绛鹃〉
-       */
-      new Promise(resolve => {
-        if (
-          !card.originCard ||
-          (btn.OpenType === 'pop' && card.originCard.OpenType !== 'pop') ||
-          (['tab', 'blank'].includes(btn.OpenType) && !['tab', 'blank'].includes(card.originCard.OpenType)) ||
-          (btn.OpenType === 'popview' && (!btn.createTab || card.originCard.OpenType !== 'popview' || !card.originCard.linkTab))
-        ) { // 鎸夐挳涓嶆槸澶嶅埗锛屾垨鎸夐挳鍓嶅悗绫诲瀷涓嶄竴鑷存椂锛岀洿鎺ヤ繚瀛�
-          resolve('save')
-        } else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.OpenType === 'blank') {
-          resolve('subconf')
-        } else if (btn.OpenType === 'popview') {
-          resolve('subtab')
-        } else {
-          resolve('save')
-        }
-      }).then(result => { // 鏌ヨ鍘熸寜閽厤缃俊鎭�
-        if (result === 'save' || result === 'subtab') return result
-
-        return Api.getSystemConfig({
-          func: 'sPC_Get_LongParam',
-          MenuID: card.originCard.uuid
-        })
-      }).then(result => { // 澶嶅埗鎸夐挳閰嶇疆淇℃伅锛屼繚瀛樿嚦鏂版坊鍔犳寜閽�
-        if (result === 'save' || result === 'subtab') return result
-
-        if (result.status && result.LongParam) {
-          let _LongParam = ''
-
-          // 瑙f瀽閰嶇疆
-          if (result.LongParam) {
-            try {
-              _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-            } catch (e) {
-              console.warn('Parse Failure')
-              _LongParam = ''
-            }
-          }
-
-          let _temp = '' // 閰嶇疆淇℃伅绫诲瀷
-
-          // 淇敼妯℃�佹鏍囬鍚嶇О
-          if (btn.OpenType === 'pop' && _LongParam && _LongParam.type === 'Modal') {
-            try {
-              _LongParam.setting.title = btn.label
-              _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
-              _temp = 'Modal'
-            } catch {
-              console.warn('Stringify Failure')
-              _LongParam = ''
-              _temp = ''
-            }
-          } else if (['tab', 'blank'].includes(btn.OpenType) && _LongParam && _LongParam.type === 'FormTab') {
-            try {
-              _LongParam.action = _LongParam.action.map(_btn => {
-                _btn.uuid = Utils.getuuid()
-
-                return _btn
-              })
-              _LongParam.tabgroups.forEach(_groupId => {
-                _LongParam[_groupId] = _LongParam[_groupId].map(_tab => {
-                  _tab.uuid = Utils.getuuid()
-
-                  return _tab
-                })
-              })
-              _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
-              _temp = 'FormTab'
-            } catch {
-              console.warn('Stringify Failure')
-              _LongParam = ''
-              _temp = ''
-            }
-          }
-
-          if (!_temp) return 'save'
-
-          let param = {
-            func: 'sPC_ButtonParam_AddUpt',
-            ParentID: menu.MenuID,
-            MenuID: btn.uuid,
-            MenuNo: menu.MenuNo,
-            Template: _temp,
-            MenuName: btn.label,
-            PageParam: JSON.stringify({Template: _temp}),
-            LongParam: _LongParam
-          }
-
-          return Api.getSystemConfig(param)
-        } else {
-          if (!result.status) {
-            notification.warning({
-              top: 92,
-              message: result.message,
-              duration: 5
-            })
-          }
-          return 'save'
-        }
-      }).then(result => {
-        if (result === 'save' || result === 'subtab') return result
-
-        if (!result.status) {
-          notification.warning({
-            top: 92,
-            message: result.message,
-            duration: 5
-          })
-        } else {
-          copyActionId = btn.uuid
-        }
-
-        return 'save'
-      }).then(result => { // 鏌ヨ鍘熸寜閽叧鑱旀爣绛句俊鎭�
-        if (result === 'save') return result
-
-        return Api.getSystemConfig({
-          func: 'sPC_Get_LongParam',
-          MenuID: card.originCard.linkTab
-        })
-      }).then(result => { // 鏍囩澶嶅埗
-        if (result === 'save') return result
-
-        let _LongParam = '' // 鏍囩閰嶇疆淇℃伅
-
-        if (!result.status) {
-          notification.warning({
-            top: 92,
-            message: result.message,
-            duration: 5
-          })
-        } else if (result.LongParam) {
-          // 瑙f瀽鏍囩閰嶇疆
-          try {
-            _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-          } catch (e) {
-            console.warn('Parse Failure')
-            _LongParam = ''
-          }
-        }
-
-        if (!_LongParam) {
-          return 'save'
-        } else {
-          copyActionId = btn.linkTab
-
-          return new Promise(resolve => {
-            this.copytab(btn, _LongParam, resolve)
-          })
-        }
-      }).then(() => {
-        // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒�
-        let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
-        let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
-
-        if (_gridBtn) {
-          _gridBtn.display = _hasGridbtn
-        } else {
-          _gridBtn = {
-            display: _hasGridbtn,
-            Align: 'center',
-            IsSort: 'false',
-            uuid: Utils.getuuid(),
-            label: this.state.dict['model.form.column.action'],
-            type: 'action',
-            style: 'button',
-            show: 'horizontal',
-            Width: 120
-          }
-        }
-
-        this.setState({
-          actionlist: _actionlist,
-          copying: false,
-          visible: false
-        }, () => {
-          this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId)
-        })
-      })
-    })
-  }
-
-  /**
-   * @description 鏍囩澶嶅埗
-   * 1銆佷繚瀛樻寜閽叧鑱旂殑鏂版爣绛�
-   * 2銆佷繚瀛樻爣绛炬寜閽俊鎭�
-   * 3銆佷繚瀛樻柊鏍囩涓寜閽殑瀛愰厤缃俊鎭�
-   */
-  copytab = (btn, _tab, _resolve) => {
-    let _LongParam = ''
-
-    _tab.uuid = btn.linkTab
-    _tab.tabName = _tab.tabName + moment().format('YYYY-MM-DD HH:mm:ss')
-    _tab.tabNo = _tab.tabNo + moment().format('YYYY-MM-DD HH:mm:ss')
-
-    let param = {
-      func: 'sPC_Tab_AddUpt',
-      MenuID: _tab.uuid,
-      MenuNo: _tab.tabNo,
-      Template: _tab.Template,
-      MenuName: _tab.tabName,
-      Remark: _tab.Remark,
-      PageParam: JSON.stringify({Template: _tab.Template}),
-      Sort: 0
-    }
-
-    let _oriActions = []
-
-    let btnParam = {
-      func: 'sPC_Button_AddUpt',
-      Type: 40,
-      ParentID: _tab.uuid,
-      MenuNo: _tab.tabNo,
-      Template: _tab.Template,
-      PageParam: '',
-      LongParam: '',
-      LText: ''
-    }
-
-    try {
-      let _linkchange = {}
-      btnParam.LText = []
-
-      _tab.action = _tab.action.map((item, index) => {
-        let uuid = Utils.getuuid()
-
-        if (item.OpenType === 'pop') {
-          _oriActions.push({
-            prebtn: JSON.parse(JSON.stringify(item)),
-            curuuid: uuid,
-            Template: 'Modal'
-          })
-        } else if (item.OpenType === 'popview') {
-          _linkchange[item.linkTab] = Utils.getuuid()
-
-          item.linkTab = _linkchange[item.linkTab]
-        }
-
-        item.uuid = uuid
-
-        btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`)
-
-        return item
-      })
-
-      if (_tab.funcs && _tab.funcs.length > 0) {
-        _tab.funcs = _tab.funcs.map(item => {
-          if (item.type === 'tab') {
-            item.linkTab = _linkchange[item.linkTab]
-            item.menuNo = ''
-            item.subfuncs = []
-          }
-
-          return item
-        })
-      }
-
-      btnParam.LText = btnParam.LText.join(' union all ')
-      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      btnParam.LText = Utils.formatOptions(btnParam.LText)
-      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
-
-      _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab)))
-    } catch {
-      console.warn('Stringify Failure')
-      _LongParam = ''
-      _resolve('save')
-      return
-    }
-
-    param.LongParam = _LongParam
-
-    new Promise(resolve => {
-      Api.getSystemConfig(param).then(response => {
-        if (response.status) {
-          resolve(true)
-        } else {
-          notification.warning({
-            top: 92,
-            message: response.message,
-            duration: 5
-          })
-          resolve(false)
-        }
-      })
-    }).then(result => {
-      if (!result) return result
-      if (!btnParam.LText) return true
-
-      return Api.getSystemConfig(btnParam)
-    }).then(result => {
-      if (result === false || result === true) return result
-
-      if (result.status) {
-        return true
-      } else {
-        notification.warning({
-          top: 92,
-          message: result.message,
-          duration: 5
-        })
-        return false
-      }
-    }).then(result => {
-      if (!result) return result
-      if (_oriActions.length === 0) return true
-
-      let deffers = _oriActions.map(item => {
-        return new Promise(resolve => {
-          Api.getSystemConfig({
-            func: 'sPC_Get_LongParam',
-            MenuID: item.prebtn.uuid
-          }).then(response => {
-            if (!response.status || !response.LongParam) {
-              resolve(response)
-            } else {
-              let _param = {
-                func: 'sPC_ButtonParam_AddUpt',
-                ParentID: _tab.uuid,
-                MenuID: item.curuuid,
-                MenuNo: _tab.tabNo,
-                Template: item.Template,
-                MenuName: item.prebtn.label,
-                PageParam: JSON.stringify({Template: item.Template}),
-                LongParam: response.LongParam
-              }
-              Api.getSystemConfig(_param).then(resp => {
-                resolve(resp)
-              })
-            }
-          })
-        })
-      })
-
-      return Promise.all(deffers)
-    }).then(result => {
-      let error = ''
-
-      if (typeof(result) === 'object') {
-        result.forEach(resul => {
-          if (!resul.status && !error) {
-            error = resul
-          }
-        })
-      }
-      
-      if (error) {
-        notification.warning({
-          top: 92,
-          message: error.message,
-          duration: 5
-        })
-      }
-
-      _resolve('save')
     })
   }
 
@@ -622,34 +320,19 @@
 
         _actionlist = _actionlist.filter(item => item.uuid !== card.uuid)
 
-        let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
-        let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
-
-        if (_gridBtn) {
-          _gridBtn.display = _hasGridbtn
-        } else {
-          _gridBtn = {
-            display: _hasGridbtn,
-            Align: 'center',
-            IsSort: 'false',
-            uuid: Utils.getuuid(),
-            label: this.state.dict['model.form.column.action'],
-            type: 'action',
-            style: 'button',
-            show: 'horizontal',
-            Width: 120
-          }
+        let delButtons = sessionStorage.getItem('delButtons')
+        try {
+          delButtons = JSON.parse(delButtons)
+          delButtons.push(card.uuid)
+        } catch {
+          delButtons = [card.uuid]
         }
-
-        let delcard = {
-          type: 'action',
-          card: card
-        }
+        sessionStorage.setItem('delButtons', JSON.stringify(delButtons))
 
         _this.setState({
           actionlist: _actionlist
         }, () => {
-          _this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard)
+          _this.props.updateaction({...config, action: _actionlist})
         })
       },
       onCancel() {}
@@ -698,39 +381,13 @@
    * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼
    */
   creatFunc = () => {
-    const { config, menu } = this.props
+    const { menu } = this.props
     let _config = fromJS(this.props.config).toJS()
 
     this.actionFormRef.handleConfirm().then(res => {
       let btn = res         // 鎸夐挳淇℃伅
       let newLText = ''     // 鍒涘缓瀛樺偍杩囩▼sql
       let DelText = ''      // 鍒犻櫎瀛樺偍杩囩▼sql
-
-      let _actionlist = fromJS(this.state.actionlist).toJS()
-
-      _actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid)
-
-      let labelrepet = false
-      _actionlist = _actionlist.map(item => {
-        if (item.uuid !== btn.uuid && item.label === btn.label) {
-          labelrepet = true
-        }
-
-        if (item.uuid === btn.uuid) {
-          return btn
-        } else {
-          return item
-        }
-      })
-
-      if (labelrepet) {
-        notification.warning({
-          top: 92,
-          message: this.state.dict['model.name.exist'] + ' !',
-          duration: 5
-        })
-        return
-      }
 
       // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕
       if (btn.intertype !== 'inner') {
@@ -742,122 +399,50 @@
         return
       }
 
-      new Promise(resolve => {
-        // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€��
-        // 鑾峰彇淇℃伅鍚庣敓鎴愬垹闄ゅ拰鍒涘缓瀛樺偍杩囩▼鐨勮鍙�
-        if (btn.OpenType === 'pop') {
-          Api.getSystemConfig({
-            func: 'sPC_Get_LongParam',
-            MenuID: btn.uuid
-          }).then(res => {
-            let _LongParam = ''
-            if (res.status && res.LongParam) {
-              try {
-                _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
-              } catch (e) {
-                console.warn('Parse Failure')
-                _LongParam = ''
-              }
-            }
-
-            if (_LongParam) {
-              let fields = []
-              if (_LongParam.groups.length > 0) {
-                _LongParam.groups.forEach(group => {
-                  fields = [...fields, ...group.sublist]
-                })
-              } else {
-                fields = _LongParam.fields
-              }
-
-              let _param = {
-                funcName: btn.innerFunc,
-                name: _config.setting.tableName || '',
-                fields: fields,
-                menuNo: menu.MenuNo
-              }
-              newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
-              DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
-              resolve(true)
-            } else {
-              notification.warning({
-                top: 92,
-                message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒',
-                duration: 5
-              })
-              resolve(false)
-            }
+      if (btn.OpenType === 'pop') {
+        let fields = []
+        if (btn.groups.length > 0) {
+          btn.groups.forEach(group => {
+            fields = [...fields, ...group.sublist]
           })
-        } else if (btn.OpenType === 'excelIn') {
-          if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) {
-            let _param = {
-              funcName: btn.innerFunc,
-              menuNo: menu.MenuNo
-            }
-            newLText = Utils.formatOptions(DevUtils.getexcelInfunc(_param, btn, menu))
-            DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
-            resolve(true)
-          } else {
-            notification.warning({
-              top: 92,
-              message: '璇峰畬鍠勫鍏xcel楠岃瘉淇℃伅锛�',
-              duration: 5
-            })
-            resolve(false)
-          }
-        } else if (btn.OpenType === 'excelOut') {
-          let _param = {
-            innerFunc: btn.innerFunc
-          }
-
-          newLText = Utils.formatOptions(DevUtils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql
-          DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
-
-          resolve(true)
         } else {
-          let _param = {
-            funcName: btn.innerFunc,
-            name: _config.setting.tableName || '',
-            fields: '',
-            menuNo: menu.MenuNo
-          }
-          newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
-          DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
-          resolve(true)
+          fields = btn.fields
         }
-      }).then(res => {
-        if (!res) return
 
-        this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => {
-          if (result !== 'success') return
+        let _param = {
+          funcName: btn.innerFunc,
+          name: _config.setting.tableName || '',
+          fields: fields,
+          menuNo: menu.MenuNo
+        }
+        newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
+        DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
+      } else if (btn.OpenType === 'excelIn') {
+        let _param = {
+          funcName: btn.innerFunc,
+          menuNo: menu.MenuNo
+        }
+        newLText = Utils.formatOptions(DevUtils.getexcelInfunc(_param, btn, menu))
+        DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
+      } else if (btn.OpenType === 'excelOut') {
+        let _param = {
+          innerFunc: btn.innerFunc
+        }
 
-          // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒�
-          let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
-          let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
+        newLText = Utils.formatOptions(DevUtils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql
+        DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
+      } else {
+        let _param = {
+          funcName: btn.innerFunc,
+          name: _config.setting.tableName || '',
+          fields: '',
+          menuNo: menu.MenuNo
+        }
+        newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
+        DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
+      }
 
-          if (_gridBtn) {
-            _gridBtn.display = _hasGridbtn
-          } else {
-            _gridBtn = {
-              display: _hasGridbtn,
-              Align: 'center',
-              IsSort: 'false',
-              uuid: Utils.getuuid(),
-              label: this.state.dict['model.form.column.action'],
-              type: 'action',
-              style: 'button',
-              show: 'horizontal',
-              Width: 120
-            }
-          }
-
-          this.setState({
-            actionlist: _actionlist
-          }, () => {
-            this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn})
-          })
-        })
-      })
+      this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText)
     })
   }
 
@@ -865,7 +450,7 @@
    * @description 鎸夐挳鍙屽嚮瑙﹀彂瀛愰厤缃�
    */
   btnDoubleClick = (element) => {
-    if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank' || element.OpenType === 'tab')) {
+    if (element.OpenType === 'pop' || element.OpenType === 'popview') {
       this.props.setSubConfig(element)
     } else {
       notification.warning({
@@ -876,29 +461,15 @@
     }
   }
 
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
-  }
-
-  /**
-   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
-   */
-  componentWillUnmount () {
-    this.setState = () => {
-      return
-    }
-  }
-
   render() {
-    const { config, type } = this.props
-    const { actionlist, visible, card, dict, copying, profVisible } = this.state
+    const { config, plus } = this.props
+    const { actionlist, visible, card, dict, profVisible } = this.state
 
     return (
-      <div className="model-custom-chart-action-list">
+      <div className="model-menu-action-list">
         <DragElement
-          type={type}
+          plus={plus}
           list={actionlist}
-          setting={this.props.config.setting}
           handleList={this.handleList}
           handleMenu={this.handleAction}
           deleteMenu={this.deleteElement}
@@ -913,16 +484,15 @@
           maskClosable={false}
           onCancel={this.editModalCancel}
           footer={[
-            card && !card.copyType ? <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null,
+            <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/>,
             <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>,
-            <Button key="confirm" type="primary" loading={copying} onClick={this.handleSubmit}>{dict['model.confirm']}</Button>
+            <Button key="confirm" type="primary" onClick={this.handleSubmit}>{dict['model.confirm']}</Button>
           ]}
           destroyOnClose
         >
           <ActionForm
             dict={dict}
             card={card}
-            tabs={this.props.tabs}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
             setting={config.setting}
@@ -944,7 +514,6 @@
         >
           {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ?
             <VerifyCard
-              floor={this.props.type}
               card={card}
               dict={dict}
               config={config}
@@ -982,4 +551,14 @@
   }
 }
 
-export default ActionComponent
\ No newline at end of file
+const mapStateToProps = (state) => {
+  return {
+    menu: state.customMenu
+  }
+}
+
+const mapDispatchToProps = () => {
+  return {}
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(ActionComponent)
\ No newline at end of file

--
Gitblit v1.8.0