From a29d9d644a2a30e9ef4afcc6d728c20c218dc359 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 15 六月 2023 14:25:28 +0800
Subject: [PATCH] 2023-06-15

---
 src/templates/subtableconfig/index.jsx |  849 ++++++++++++++++++++++++-------------------------------
 1 files changed, 374 insertions(+), 475 deletions(-)

diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index 5a2cebe..19bfb12 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -1,17 +1,15 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { DndProvider } from 'react-dnd'
 import HTML5Backend from 'react-dnd-html5-backend'
-import { Button, Card, Modal, Collapse, notification, Spin, Icon, Switch, Tooltip, Col } from 'antd'
-import moment from 'moment'
+import { Button, Card, Modal, Collapse, notification, Spin, Switch, Tooltip, Col } from 'antd'
+import { QuestionCircleOutlined, RedoOutlined } from '@ant-design/icons'
+// import moment from 'moment'
 
 import Api from '@/api'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
 import Utils from '@/utils/utils.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateSubTable } from '@/utils/utils-update.js'
 
 import asyncComponent from '@/utils/asyncComponent'
 import SearchComponent from '@/templates/sharecomponent/searchcomponent'
@@ -19,7 +17,6 @@
 import ColumnComponent from '@/templates/sharecomponent/columncomponent'
 
 import MenuForm from './menuform'
-import EditComponent from '@/templates/zshare/editcomponent'
 import SourceElement from '@/templates/zshare/dragsource'
 import Source from './source'
 import './index.scss'
@@ -27,6 +24,9 @@
 const { Panel } = Collapse
 const { confirm } = Modal
 
+const Versions = asyncComponent(() => import('@/menu/versions'))
+// const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
+const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent'))
 const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcomponent'))
 const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
 const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
@@ -47,10 +47,8 @@
   }
 
   state = {
-    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,        // 瀛楀吀
     config: null,            // 椤甸潰閰嶇疆
     visible: false,          // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗
-    tableFields: [],         // 宸查�夎〃瀛楁闆�
     menuloading: false,      // 鑿滃崟淇濆瓨涓�
     menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨
     loading: false,          // 鍔犺浇涓紝椤甸潰spin
@@ -60,10 +58,9 @@
     delActions: [],          // 鍒犻櫎鎸夐挳鍒楄〃
     copyActions: [],         // 澶嶅埗鎸夐挳缁�
     tabviews: [],            // 鎵�鏈夋爣绛鹃〉
-    thawButtons: [],         // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳
     activeKey: '0',          // 榛樿灞曞紑鍩烘湰淇℃伅
     chartview: null,         // 褰撳墠瑙嗗浘
-    openEdition: ''          // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣�
+    openEdition: '',         // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣�
   }
 
   /**
@@ -90,6 +87,11 @@
     if (_config.type === 'user') {
       _config.action = _config.action.map(item => {
         let uuid = Utils.getuuid()
+
+        if (item.linkTab) {
+          item.linkTab = ''
+        }
+
         if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�
           _oriActions.push({
             prebtn: fromJS(item).toJS(),
@@ -106,11 +108,11 @@
     let _activeKey =  editSubTab ? editSubTab.activeKey : editTab.activeKey
 
     // 鐗堟湰鍏煎
-    _config = UtilsUpdate.updateSubTable(_config)
+    _config = updateSubTable(_config)
 
     this.setState({
       openEdition: editSubTab ? (editSubTab.open_edition || '') : (editTab.open_edition || ''),
-      chartview: _config.charts[0].uuid,
+      chartview: _config.charts ? _config.charts[0].uuid : '',
       originActions: _oriActions,
       config: _config,
       activeKey: _activeKey || '0',
@@ -125,6 +127,54 @@
    */
   componentDidMount () {
     this.reloadTab(false)
+    document.onkeydown = (event) => {
+      let e = event || window.event
+      let keyCode = e.keyCode || e.which || e.charCode
+      let preKey = ''
+
+      if (e.ctrlKey) {
+        preKey = 'ctrl'
+      }
+      if (e.shiftKey) {
+        preKey = 'shift'
+      } else if (e.altKey) {
+        preKey = 'alt'
+      }
+      
+      if (!preKey || !keyCode) return
+      
+      let _shortcut = `${preKey}+${keyCode}`
+
+      if (_shortcut === 'ctrl+83') {
+        let modals = document.querySelectorAll('.mk-pop-modal')
+        let msg = null
+        for (let i = 0; i < modals.length; i++) {
+          if (msg) {
+            break
+          }
+
+          let node = modals[i].querySelector('.mk-com-name')
+
+          if (node) {
+            msg = node.innerText
+          }
+        }
+        if (msg) {
+          notification.warning({
+            top: 92,
+            message: '璇蜂繚瀛�' + msg,
+            duration: 5
+          })
+          return false
+        }
+
+        let node = document.getElementById('save-config')
+        if (node && node.click) {
+          node.click()
+        }
+        return false
+      }
+    }
   }
 
   /**
@@ -184,6 +234,7 @@
     this.setState = () => {
       return
     }
+    document.onkeydown = () => {}
   }
 
   // 椤甸潰杩斿洖
@@ -195,7 +246,7 @@
     if (editSubTab) {
       _subconfig = tabConfig
       if (editTab.hasOwnProperty('OpenType')) {
-        _tabview = editTab.tabType
+        _tabview = editTab.tabType || 'SubTable'
       } else {
         _tabview = editTab.type
       }
@@ -232,7 +283,7 @@
    * @description 鏍囩椤典繚瀛�
    */
   submitConfig = () => {
-    const { delActions, thawButtons, openEdition } = this.state
+    const { delActions, openEdition } = this.state
     let _config = fromJS(this.state.config).toJS()
     let copyreg = /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}$/ig
 
@@ -240,7 +291,7 @@
     if (!_config.tabName || !_config.tabNo) {
       notification.warning({
         top: 92,
-        message: this.state.dict['model.menu.basemsg'],
+        message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒',
         duration: 5
       })
       this.setState({activeKey: '0'})
@@ -268,56 +319,16 @@
       }
     }
 
+    if (_config.setting.doubleClick && _config.action.findIndex((item) => item.uuid === _config.setting.doubleClick) === -1) {
+      _config.setting.doubleClick = ''
+    }
+
     // 鏈缃暟鎹簮鎴栦富閿椂锛屽惎鐢ㄧ姸鎬佷负false
     let result = this.verifyconfig(_config)
   
     if (result !== true) {
       _config.enabled = false
     }
-
-    // _config.funcs = []
-
-    // _config.funcs.push({
-    //   type: 'view',
-    //   subtype: 'view',
-    //   uuid: _config.uuid,
-    //   intertype: _config.setting.interType || 'system',
-    //   interface: _config.setting.interface || '',
-    //   tableName: _config.setting.tableName || '',
-    //   innerFunc: _config.setting.innerFunc || '',
-    //   outerFunc: _config.setting.outerFunc || ''
-    // })
-
-    // _config.action.forEach(item => {
-    //   let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '')
-
-    //   if (item.OpenType === 'excelOut' && item.intertype === 'system') {
-    //     tablename = _config.setting.tableName || ''
-    //   }
-
-    //   if (item.OpenType === 'popview') {
-    //     _config.funcs.push({
-    //       type: 'tab',
-    //       subtype: 'btn',
-    //       uuid: item.uuid,
-    //       label: item.label,
-    //       linkTab: item.linkTab
-    //     })
-    //   } else {
-    //     _config.funcs.push({
-    //       type: 'button',
-    //       subtype: 'btn',
-    //       uuid: item.uuid,
-    //       label: item.label,
-    //       tableName: tablename,
-    //       intertype: item.intertype,
-    //       interface: item.interface || '',
-    //       innerFunc: item.innerFunc || '',
-    //       outerFunc: item.outerFunc || '',
-    //       callbackFunc: item.callbackFunc || ''
-    //     })
-    //   }
-    // })
 
     if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬�
       this.setState({
@@ -329,297 +340,122 @@
       })
     }
 
-    new Promise(resolve => {
-      // let deffers = []
-      // _config.funcs.forEach(item => {
-      //   if (item.type === 'tab') {
-      //     let deffer = new Promise(resolve => {
-      //       Api.getSystemConfig({
-      //         func: 'sPC_Get_LongParam',
-      //         MenuID: item.linkTab
-      //       }).then(result => {
-      //         if (result.status && result.LongParam) {
-      //           let _LongParam = ''
-      
-      //           if (result.LongParam) {
-      //             try {
-      //               _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-      //             } catch (e) {
-      //               console.warn('Parse Failure')
-      //               _LongParam = ''
-      //             }
-      //           }
-    
-      //           if (_LongParam) {
-      //             item.menuNo = _LongParam.tabNo
-      //             item.subfuncs = _LongParam.funcs || []
-      //           }
-      //         }
-      //         resolve()
-      //       })
-      //     })
+    let _LongParam = ''
 
-      //     deffers.push(deffer)
-      //   }
-      // })
+    // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser
+    delete _config.type
+    delete _config.isAdd
 
-      // if (deffers.length === 0) {
-      //   resolve()
-      // } else {
-      //   Promise.all(deffers).then(() => {
-      //     resolve()
-      //   })
-      // }
-      resolve()
-    }).then(() => {
-      // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser
-      delete _config.type
-      delete _config.isAdd
-
-      let _LongParam = ''
-
-      try {
-        _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
-      } catch (e) {
-        notification.warning({
-          top: 92,
-          message: '缂栬瘧閿欒',
-          duration: 5
-        })
-
-        this.setState({
-          menucloseloading: false,
-          menuloading: false
-        })
-        return
-      }
-
-      let btnParam = {
-        func: 'sPC_Button_AddUpt',
-        Type: 40,
-        ParentID: _config.uuid,
-        MenuNo: _config.tabNo,
-        Template: 'SubTable',
-        PageParam: '',
-        LongParam: '',
-        LText: []
-      }
-
-      let btntabs = []
-
-      _config.action.forEach((item, index) => {
-        if (item.OpenType === 'popview') {
-          btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`)
-        }
-        btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`)
+    try {
+      _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
+    } catch (e) {
+      notification.warning({
+        top: 92,
+        message: '缂栬瘧閿欒',
+        duration: 5
       })
 
-      btnParam.LText = btnParam.LText.join(' union all ')
-      btnParam.LText = Utils.formatOptions(btnParam.LText)
-      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
+      this.setState({
+        menucloseloading: false,
+        menuloading: false
+      })
+      return
+    }
 
-      let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤�
-        func: 'sPC_sMenusTab_AddUpt',
-        MenuID: _config.uuid,
-        LText: btntabs.join(' union all ')
-      }
+    // let btnParam = {
+    //   func: 'sPC_Button_AddUpt',
+    //   Type: 40,
+    //   ParentID: _config.uuid,
+    //   MenuNo: _config.tabNo,
+    //   Template: 'SubTable',
+    //   PageParam: '',
+    //   LongParam: '',
+    //   LText: []
+    // }
 
-      tabParam.LText = Utils.formatOptions(tabParam.LText)
-      tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
+    // let btntabs = []
 
-      let param = {
-        func: 'sPC_Tab_AddUpt',
-        MenuID: _config.uuid,
-        MenuNo: _config.tabNo,
-        Template: 'SubTable',
-        MenuName: _config.tabName,
-        Remark: _config.Remark,
-        Sort: 0,
-        PageParam: JSON.stringify({Template: 'SubTable'}),
-        LongParam: _LongParam
-      }
+    // _config.action.forEach((item, index) => {
+    //   if (item.hidden === 'true') return
+    //   if (item.OpenType === 'popview') {
+    //     btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`)
+    //   }
+    //   btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`)
+    // })
 
-      if (openEdition) {
-        param.open_edition = openEdition
-      }
+    // btnParam.LText = btnParam.LText.join(' union all ')
+    // btnParam.LText = Utils.formatOptions(btnParam.LText)
+    // btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    // btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
 
-      // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣�
-      // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆
-      new Promise(resolve => {
-        if (delActions.length > 0) {
-          let deffers = delActions.map(item => {
-            let _param = {
-              func: 'sPC_MainMenu_Del',
-              MenuID: item.card.uuid
-            }
+    // let tabParam = { // 娣诲姞鏍囩鎸夐挳tab椤�
+    //   func: 'sPC_sMenusTab_AddUpt',
+    //   MenuID: _config.uuid,
+    //   LText: btntabs.join(' union all ')
+    // }
 
-            let _ParentParam = null
+    // tabParam.LText = Utils.formatOptions(tabParam.LText)
+    // tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    // tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
 
-            try {
-              _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
-            } catch (e) {
-              console.warn('Stringify Failure')
-              _ParentParam = null
-            }
+    let param = {
+      func: 'sPC_Tab_AddUpt',
+      MenuID: _config.uuid,
+      MenuNo: _config.tabNo,
+      Template: 'SubTable',
+      MenuName: _config.tabName,
+      Remark: _config.Remark,
+      Sort: 0,
+      PageParam: JSON.stringify({Template: 'SubTable'}),
+      LongParam: _LongParam
+    }
 
-            if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽�
-              _param.ParentParam = _ParentParam
-            }
+    if (openEdition) {
+      param.open_edition = openEdition
+    }
 
-            return new Promise(resolve => {
-              Api.getSystemConfig(_param).then(response => {
-                resolve(response)
-              })
-            })
-          })
-          Promise.all(deffers).then(result => {
-            let error = null
-            result.forEach(response => {
-              if (!response.status) {
-                error = response
-              }
-            })
-  
-            if (error) {
-              this.setState({
-                menuloading: false,
-                menucloseloading: false
-              })
-              notification.warning({
-                top: 92,
-                message: error.message,
-                duration: 5
-              })
-              resolve(false)
-            } else {
-              this.setState({
-                delActions: []
-              })
-              resolve(true)
-            }
-          })
-        } else if (delActions.length === 0) {
-          resolve(true)
-        }
-      }).then(resp => {
-        if (resp === false) return
-
-        if (thawButtons.length > 0) {
-          let defers = thawButtons.map(item => {
-            return new Promise((resolve) => {
-              Api.getSystemConfig({
-                func: 'sPC_MainMenu_ReDel',
-                MenuID: item
-              }).then(res => {
-                if (res.status) {
-                  resolve('')
-                } else {
-                  resolve(res.message)
-                }
-              })
-            })
-          })
-
-          return Promise.all(defers)
-        } else {
-          return true
-        }
-      }).then(res => {
-        if (res === true || res === false) return res
-
-        let msg = res.filter(Boolean)[0]
-        if (msg) {
-          notification.warning({
-            top: 92,
-            message: msg,
-            duration: 5
-          })
-          return false
-        } else {
-          this.setState({
-            thawButtons: []
-          })
-          return true
-        }
-      }).then(resp => {
-        if (resp === false) return
-
-        Api.getSystemConfig(param).then(response => {
-          if (response.status) {
-            this.setState({
-              openEdition: response.open_edition || '',
-              config: _config,
-              originConfig: fromJS(_config).toJS()
-            }, () => {
-              this.setState({
-                menuloading: false,
-                menucloseloading: false
-              })
-              this.submitAction(btnParam, tabParam)
-            })
-          } else {
-            this.setState({
-              menuloading: false,
-              menucloseloading: false
-            })
-            notification.warning({
-              top: 92,
-              message: response.message,
-              duration: 5
-            })
+    // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣�
+    // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆
+    new Promise(resolve => {
+      if (delActions.length > 0) {
+        let deffers = delActions.map(item => {
+          let _param = {
+            func: 'sPC_MainMenu_Del',
+            MenuID: item.card.uuid
           }
-        })
-      })
-    })
-    
-  }
 
-  /**
-   * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽�
-   */
-  submitAction = (btnParam, tabParam) => {
-    const { config } = this.state
+          let _ParentParam = null
 
-    new Promise(resolve => {
-      let deffers = []
+          try {
+            _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
+          } catch (e) {
+            console.warn('Stringify Failure')
+            _ParentParam = null
+          }
 
-      if (tabParam.LText) {
-        let defer = new Promise(resolve => {
-          Api.getSystemConfig(tabParam).then(result => {
-            resolve(result)
+          if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽�
+            _param.ParentParam = _ParentParam
+          }
+
+          return new Promise(resolve => {
+            Api.getSystemConfig(_param).then(response => {
+              resolve(response)
+            })
           })
         })
-        deffers.push(defer)
-      }
-
-      if (btnParam.LText) {
-        let defer = new Promise(resolve => {
-          Api.getSystemConfig(btnParam).then(result => {
-            if (result.status) {
-              this.setState({ // 淇濆瓨鎴愬姛鍚庢竻绌哄鍒跺垪琛�
-                copyActions: []
-              })
-            }
-            resolve(result)
-          })
-        })
-        deffers.push(defer)
-      }
-
-      if (deffers.length === 0) {
-        resolve(true)
-      } else {
         Promise.all(deffers).then(result => {
-          let error = false
-          result.forEach(res => {
-            if (!res.status) {
-              error = res
+          let error = null
+          result.forEach(response => {
+            if (!response.status) {
+              error = response
             }
           })
 
           if (error) {
+            this.setState({
+              menuloading: false,
+              menucloseloading: false
+            })
             notification.warning({
               top: 92,
               message: error.message,
@@ -627,82 +463,125 @@
             })
             resolve(false)
           } else {
+            this.setState({
+              delActions: []
+            })
             resolve(true)
           }
         })
+      } else if (delActions.length === 0) {
+        resolve(true)
       }
-    }).then(response => {
-      if (response === false) return response
+    }).then(resp => {
+      if (resp === false) return
 
-      let oriActions = []
-      this.state.originActions.forEach(item => {
-        let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦�
-        if (!curBtn) return
-        if (curBtn.OpenType !== item.prebtn.OpenType) return
+      return true
+    }).then(res => {
+      if (res === true || res === false) return res
 
-        oriActions.push({
-          prebtn: item.prebtn,
-          curBtn: curBtn
-        })
-      })
-
-      if (oriActions.length === 0) return 'true'
-
-      oriActions.forEach(action => {
-        Api.getSystemConfig({
-          func: 'sPC_Get_LongParam',
-          MenuID: action.prebtn ? action.prebtn.uuid : ''
-        }).then(result => {
-          if (result.status && result.LongParam) {
-            let _LongParam = ''
-  
-            if (result.LongParam) {
-              try {
-                _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-              } catch (e) {
-                console.warn('Parse Failure')
-                _LongParam = ''
-              }
-            }
-
-            if (_LongParam) {
-              let param = {
-                func: 'sPC_ButtonParam_AddUpt',
-                ParentID: config.uuid,
-                MenuID: action.curBtn.uuid,
-                MenuNo: config.tabNo,
-                Template: _LongParam.type,
-                MenuName: action.curBtn.label,
-                PageParam: JSON.stringify({Template: _LongParam.type}),
-                LongParam: result.LongParam
-              }
-              Api.getSystemConfig(param).then(() => {})
-            }
-          }
-        })
-      })
-      return 'true'
-    }).then(response => {
-      if (response === 'true') {
-        notification.success({
+      let msg = res.filter(Boolean)[0]
+      if (msg) {
+        notification.warning({
           top: 92,
-          message: '淇濆瓨鎴愬姛',
-          duration: 2
+          message: msg,
+          duration: 5
         })
-        if (this.state.closeVisible) {
-          this.handleViewBack()
+        return false
+      } else {
+        return true
+      }
+    }).then(resp => {
+      if (resp === false) return
+
+      Api.getSystemConfig(param).then(response => {
+        if (response.status) {
+          this.setState({
+            openEdition: response.open_edition || '',
+            config: _config,
+            originConfig: fromJS(_config).toJS()
+          }, () => {
+            this.setState({
+              menuloading: false,
+              menucloseloading: false
+            })
+            notification.success({
+              top: 92,
+              message: '淇濆瓨鎴愬姛',
+              duration: 2
+            })
+            if (this.state.closeVisible) {
+              this.handleViewBack()
+            }
+          })
+          this.submitAction()
         } else {
           this.setState({
             menuloading: false,
             menucloseloading: false
           })
+          notification.warning({
+            top: 92,
+            message: response.message,
+            duration: 5
+          })
         }
-      } else {
-        this.setState({
-          menuloading: false,
-          menucloseloading: false
-        })
-      }
+      })
+    })
+  }
+
+  /**
+   * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽�
+   */
+  submitAction = () => {
+    const { config } = this.state
+
+    let oriActions = []
+    this.state.originActions.forEach(item => {
+      let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦�
+      if (!curBtn) return
+      if (curBtn.OpenType !== item.prebtn.OpenType) return
+      if (curBtn.OpenType === 'funcbutton' && curBtn.execMode !== 'pop') return
+
+      oriActions.push({
+        prebtn: item.prebtn,
+        curBtn: curBtn
+      })
+    })
+
+    if (oriActions.length === 0) return
+
+    oriActions.forEach(action => {
+      Api.getSystemConfig({
+        func: 'sPC_Get_LongParam',
+        MenuID: action.prebtn ? action.prebtn.uuid : ''
+      }).then(result => {
+        if (result.status && result.LongParam) {
+          let _LongParam = ''
+
+          if (result.LongParam) {
+            try {
+              _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
+            } catch (e) {
+              console.warn('Parse Failure')
+              _LongParam = ''
+            }
+          }
+
+          if (_LongParam) {
+            let param = {
+              func: 'sPC_ButtonParam_AddUpt',
+              ParentID: config.uuid,
+              MenuID: action.curBtn.uuid,
+              MenuNo: config.tabNo,
+              Template: _LongParam.type,
+              MenuName: action.curBtn.label,
+              PageParam: JSON.stringify({Template: _LongParam.type}),
+              LongParam: result.LongParam
+            }
+            Api.getSystemConfig(param).then(() => {})
+          }
+        }
+      })
     })
   }
 
@@ -755,10 +634,10 @@
         let _view = ''
         let _subtab = editSubTab
 
-        if (btn.OpenType === 'pop') {
-          _view = 'Modal'             // 琛ㄥ崟椤甸潰
+        if (btn.OpenType === 'pop' || btn.execMode === 'pop') {
+          _view = 'Modal'      // 琛ㄥ崟椤甸潰
         } else if (btn.OpenType === 'popview') {
-          _view = btn.tabType        // 鏂板脊绐楁爣绛炬ā鏉�
+          _view = 'SubTable'   // 鏂板脊绐楁爣绛炬ā鏉� tabType 灞炴�у凡鍘婚櫎
           _subtab = btn
 
           if (editSubTab) {
@@ -905,8 +784,12 @@
       }
     })
 
-    if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) {
-      return '灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�'
+    if (config.setting.interType === 'system' && config.setting.default === 'false' && config.setting.scripts && config.setting.scripts.filter(item => item.status !== 'false').length === 0) {
+      return '鏁版嵁婧愪腑涓嶆墽琛岄粯璁ql锛屼笖鏈坊鍔犺嚜瀹氫箟鑴氭湰锛屼笉鍙惎鐢紒'
+    } else if (config.setting.interType === 'custom' && config.setting.procMode !== 'inner' && config.setting.preScripts && config.setting.preScripts.filter(item => item.status !== 'false').length === 0) {
+      return '鏁版嵁婧愭湭璁剧疆鍓嶇疆鑴氭湰锛屼笉鍙惎鐢紒'
+    } else if (config.setting.interType === 'custom' && config.setting.callbackType === 'script' && config.setting.cbScripts && config.setting.cbScripts.filter(item => item.status !== 'false').length === 0) {
+      return '鏁版嵁婧愭湭璁剧疆鍥炶皟鑴氭湰锛屼笉鍙惎鐢紒'
     } else if (!config.setting.primaryKey) {
       return '灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒'
     }  else if (config.columns.length === 0) {
@@ -921,27 +804,12 @@
   }
 
   /**
-   * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑
+   * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽瓑
    */
   updateConfig = (res) => {
-    if (res.type === 'thaw') {
-      this.setState({
-        thawButtons: res.thawButtons,
-        config: res.config
-      })
-    } else if (res.type === 'paste') {
-      let config = fromJS(this.state.config).toJS()
-      if (res.content.copyType === 'search') {
-        config.search.push(res.content)
-      } else if (res.content.copyType === 'action') {
-        config.action.push(res.content)
-      } else if (res.content.copyType === 'columns' && res.content.columns && res.content.columns.length > 0) {
-        config.columns = config.columns.filter(col => !col.origin)
-        config.columns = [...config.columns, ...res.content.columns]
-      }
-
-      this.setState({config})
-    }
+    this.setState({
+      config: res.config
+    })
   }
 
   /**
@@ -985,32 +853,68 @@
       chartview: _chartview
     })
   }
+
   
-  /**
-   * @description 鏇存柊甯哥敤琛ㄤ俊鎭紝蹇嵎娣诲姞鍚庢洿鏂伴厤缃俊鎭�
-   */
-  updatetable = (config, fields) => {
-    const { tableFields } = this.state
+  refreshConfig = () => {
+    const { config } = this.props
+    
+    let param = {
+      func: 'sPC_Get_LongParam',
+      MenuID: config.uuid
+    }
 
-    this.setState({
-      config: config,
-      tableFields: fields ? fields : tableFields
-    })
-  }
+    Api.getSystemConfig(param).then(res => {
+      if (res.status) {
+        let _config = ''
+        if (res.LongParam) {
+          try {
+            _config = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
+          } catch (e) {
+            console.warn('Parse Failure')
+            _config = ''
+          }
+        }
 
-  /**
-   * @description 鎵归噺娣诲姞锛屾洿鏂伴厤缃俊鎭�
-   */
-  updatefield = (config) => {
-    this.setState({
-      config: config
+        if (!_config) {
+          notification.warning({
+            top: 92,
+            message: '鏈幏鍙栧埌閰嶇疆淇℃伅锛�',
+            duration: 5
+          })
+          return
+        }
+
+        // 鐗堟湰鍏煎
+        _config = updateSubTable(_config)
+
+        this.setState({
+          config: null
+        }, () => {
+          this.setState({
+            chartview: _config.charts ? _config.charts[0].uuid : '',
+            config: _config,
+            openEdition: res.open_edition || '',
+            activeKey: '0',
+            originActions: [],
+            originConfig: fromJS(_config).toJS()
+          })
+        })
+      } else {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+      }
     })
   }
 
   render () {
-    const { activeKey, config, chartview } = this.state
+    const { activeKey, config, chartview, openEdition } = this.state
 
-    const confActions = config.action.filter(_action => !_action.origin && ['pop', 'popview', 'blank'].includes(_action.OpenType))
+    if (!config) return null
+
+    const confActions = config.action.filter(_action => !_action.origin && (['pop', 'popview'].includes(_action.OpenType) || (_action.OpenType === 'funcbutton' && _action.execMode === 'pop')))
 
     return (
       <div className="model-subtable-board">
@@ -1022,7 +926,6 @@
               <Panel forceRender={true} header={'鏍囩鍩烘湰淇℃伅'} key="0" id="subtable-basedata">
                 {/* 鑿滃崟淇℃伅 */}
                 <MenuForm
-                  dict={this.state.dict}
                   config={config}
                   updatemenu={this.updateconfig}
                 />
@@ -1030,25 +933,20 @@
                 <TableComponent
                   config={config}
                   containerId="subtable-basedata"
-                  updatetable={this.updatetable}
+                  updatetable={this.updateconfig}
                 />
               </Panel>
               {/* 鎼滅储鏉′欢娣诲姞 */}
-              <Panel header={this.state.dict['header.menu.search']} key="1">
+              <Panel header="鎼滅储" key="1">
                 <div className="search-element">
                   {Source.searchItems.map((item, index) => {
                     return (<SourceElement key={index} content={item}/>)
                   })}
                 </div>
-                <FieldsComponent
-                  config={config}
-                  type="search"
-                  tableFields={this.state.tableFields}
-                  updatefield={this.updatefield}
-                />
+                <FieldsComponent config={config} type="search" />
               </Panel>
               {/* 鎸夐挳娣诲姞 */}
-              <Panel header={this.state.dict['header.menu.action']} key="2">
+              <Panel header="鎸夐挳" key="2">
                 <div className="search-element">
                   {Source.actionItems.map((item, index) => {
                     return (<SourceElement key={index} content={item}/>)
@@ -1058,9 +956,9 @@
                   {confActions.length > 0 ?
                     <p className="config-btn-title">
                       <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��">
-                        <Icon type="question-circle" />
+                        <QuestionCircleOutlined className="mk-form-tip" />
                       </Tooltip>
-                      {this.state.dict['header.menu.action.configurable']}
+                      鎸夐挳閰嶇疆
                     </p> : null
                   }
                 </div>
@@ -1078,18 +976,13 @@
                 })}
               </Panel>
               {/* 娣诲姞鏄剧ず鍒� */}
-              <Panel header={this.state.dict['header.menu.column']} key="3">
+              <Panel header="鏄剧ず鍒�" key="3">
                 <div className="search-element">
                   {Source.columnItems.map((item, index) => {
                     return (<SourceElement key={index} content={item}/>)
                   })}
                 </div>
-                <FieldsComponent
-                  config={config}
-                  type="columns"
-                  tableFields={this.state.tableFields}
-                  updatefield={this.updatefield}
-                />
+                <FieldsComponent config={config} type="columns" />
               </Panel>
             </Collapse>
           </div>
@@ -1097,14 +990,16 @@
             <Card title={
               <div>
                 鏍囩锛堝瓙琛級椤甸潰閰嶇疆 
-                <Icon type="redo" style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} />
+                <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} />
               </div>
             } bordered={false} extra={
               <div>
-                <EditComponent dict={this.state.dict} type="subtable" config={this.state.config} thawButtons={this.state.thawButtons} refresh={this.updateConfig}/>
-                <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} />
-                <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button>
-                <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button>
+                <Versions MenuId={config.uuid} open_edition={openEdition} updateConfig={this.refreshConfig}/>
+                {/* <ReplaceField type="table" config={config} updateConfig={this.updateconfig}/> */}
+                <EditComponent type="table" options={['search', 'form', 'action', 'columns']} config={config} refresh={this.updateConfig}/>
+                <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} />
+                <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button>
+                <Button onClick={this.cancelConfig}>杩斿洖</Button>
               </div>
             } style={{ width: '100%' }}>
               <SettingComponent
@@ -1117,12 +1012,12 @@
                 config={config}
                 updatesearch={this.updatesearch}
               />
-              <div className="chart-view" style={{position: 'relative'}}>
-                {/* 瑙嗗浘缁� 鏉冮檺 浼氬憳绛夌骇20+ */}
-                {this.props.memberLevel >= 20 ? <ChartGroupComponent
+              {config.charts ? <div className="chart-view" style={{position: 'relative'}}>
+                {/* 瑙嗗浘缁� 宸插純鐢� */}
+                <ChartGroupComponent
                   config={config}
                   updatechartgroup={this.updatechartgroup}
-                /> : null}
+                />
                 {config.charts.map(item => {
                   if (!config.expand && chartview !== item.uuid) return ''
 
@@ -1167,7 +1062,21 @@
                     )
                   }
                 })}
-              </div>
+              </div> : <>
+                <ActionComponent
+                  type="subtable"
+                  menu={{MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo, fstMenuList: this.props.menu.fstMenuList}}
+                  config={config}
+                  tabs={this.state.tabviews}
+                  setSubConfig={this.setSubConfig}
+                  updateaction={this.updateaction}
+                />
+                <ColumnComponent
+                  config={config}
+                  menu={this.props.menu}
+                  updatecolumn={this.updateconfig}
+                />
+              </>}
             </Card>
           </div>
         </DndProvider>
@@ -1178,13 +1087,13 @@
           visible={this.state.closeVisible}
           onCancel={() => { this.setState({closeVisible: false}) }}
           footer={[
-            <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['model.save']}</Button>,
-            <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>{this.state.dict['model.notsave']}</Button>,
-            <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['model.cancel']}</Button>
+            <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>淇濆瓨</Button>,
+            <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>涓嶄繚瀛�</Button>,
+            <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>鍙栨秷</Button>
           ]}
           destroyOnClose
         >
-          {this.state.dict['header.menu.config.placeholder']}
+          閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛�
         </Modal>
         {this.state.loading && <Spin size="large" />}
       </div>
@@ -1192,14 +1101,4 @@
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    memberLevel: state.memberLevel
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(SubTableConfig)
+export default SubTableConfig

--
Gitblit v1.8.0