From 639fad34874ff57f1de713a44bf2e796ea35f734 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 28 七月 2022 14:41:58 +0800
Subject: [PATCH] 2022-07-28

---
 src/views/basedesign/index.jsx |  248 ++++++++++++++++++++++---------------------------
 1 files changed, 111 insertions(+), 137 deletions(-)

diff --git a/src/views/basedesign/index.jsx b/src/views/basedesign/index.jsx
index ddbea7f..b742a63 100644
--- a/src/views/basedesign/index.jsx
+++ b/src/views/basedesign/index.jsx
@@ -1,21 +1,15 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-// import { is, fromJS } from 'immutable'
-import { connect } from 'react-redux'
-import { withRouter } from 'react-router-dom'
-import { notification, Spin } from 'antd'
-// import moment from 'moment'
+import { notification, Spin, ConfigProvider } from 'antd'
+import enUS from 'antd/es/locale/en_US'
+import zhCN from 'antd/es/locale/zh_CN'
 
 import Api from '@/api'
-import MKEmitter from '@/utils/events.js'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
-// import Utils from '@/utils/utils.js'
-import MenuUtils from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncLoadComponent from '@/utils/asyncLoadComponent'
 import './index.scss'
 
+const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
 const Header = asyncComponent(() => import('@/menu/header'))
 const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig'))
 const TreePageConfig = asyncLoadComponent(() => import('@/templates/treepageconfig'))
@@ -23,6 +17,9 @@
 const FormTabConfig = asyncLoadComponent(() => import('@/templates/formtabconfig'))
 const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig'))
 const SubTable = asyncLoadComponent(() => import('@/templates/subtableconfig'))
+
+document.body.className = ''
+sessionStorage.setItem('isEditState', 'true')
 
 class BaseDesign extends Component {
   static propTpyes = {
@@ -33,7 +30,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     loading: false,         // 缂栬緫鑿滃崟鎴栦娇鐢ㄥ凡浣跨敤妯℃澘鏃讹紝鑾峰彇閰嶇疆淇℃伅
     btnParam: null,         // 缂栬緫鎸夐挳鐨勯厤缃俊鎭�
     menulist: null,         // 缂栬緫涓殑鑿滃崟
@@ -94,18 +90,56 @@
 
     Api.getSystemConfig(param).then(res => {
       if (res.status) {
-        let _LongParam = ''
+        editMenu.open_edition = res.open_edition || ''
+        editMenu.LongParam = ''
+
         if (res.LongParam) {
+          let _LongParam = ''
           try {
             _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
           } catch (e) {
             console.warn('Parse Failure')
             _LongParam = ''
           }
+          editMenu.LongParam = _LongParam
+        } else if (editMenu.PageParam.copyMenuId) {
+          let _param = {
+            func: 'sPC_Get_LongParam',
+            MenuID: editMenu.PageParam.copyMenuId
+          }
+      
+          Api.getSystemConfig(_param).then(res => {
+            if (res.status) {
+              if (res.LongParam) {
+                let _LongParam = ''
+                try {
+                  _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
+                  _LongParam.type = 'user'
+                } catch (e) {
+                  console.warn('Parse Failure')
+                  _LongParam = ''
+                }
+                editMenu.LongParam = _LongParam
+              }
+              
+              this.setState({
+                editMenu: editMenu,
+                loading: false,
+                tabview: editMenu.type
+              })
+            } else {
+              this.setState({
+                loading: false
+              })
+              notification.warning({
+                top: 92,
+                message: res.message,
+                duration: 5
+              })
+            }
+          })
+          return
         }
-
-        editMenu.LongParam = _LongParam
-        editMenu.open_edition = res.open_edition || ''
         
         this.setState({
           editMenu: editMenu,
@@ -140,60 +174,8 @@
     }, () => {
       if (param) {
         this.setState(param)
-      }
-    })
-  }
-
-  copyMenu = (param, MenuId) => {
-    Api.getSystemConfig({
-      func: 'sPC_Get_LongParam',
-      MenuID: MenuId
-    }).then(result => {
-      if (result.status) {
-        let config = null
-  
-        try {
-          config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null
-        } catch (e) {
-          console.warn('Parse Failure')
-          config = null
-        }
-  
-        if (config) {
-          config.uuid = param.MenuID
-          config.MenuID = param.MenuID
-          config.parentId = param.ParentID
-          config.MenuName = param.MenuName
-          config.MenuNo = param.MenuNo
-          config.easyCode = ''
-          config.components = MenuUtils.resetConfig(config.components)
-          config.enabled = false
-
-          param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(config)))
-        }
-
-        Api.getSystemConfig(param).then(response => {
-          if (response.status) {
-            this.setState({
-              handleMVisible: false,
-              sysMenu: null
-            })
-  
-            MKEmitter.emit('mkUpdateMenuList')
-          } else {
-            notification.warning({
-              top: 92,
-              message: response.message,
-              duration: 5
-            })
-          }
-        })
       } else {
-        notification.warning({
-          top: 92,
-          message: result.message,
-          duration: 5
-        })
+        window.close()
       }
     })
   }
@@ -203,77 +185,69 @@
 
     return (
       <div className="mk-base-design-wrap">
-        <Header/>
-        {this.state.tabview === 'TreePage' ?
-          <TreePageConfig
-            menu={this.state.editMenu}
-            reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
-            handleView={this.handleView}
-          /> : null
-        }
-        {this.state.tabview === 'CalendarPage' ?
-          <CalendarPageConfig
-            menu={this.state.editMenu}
-            reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
-            handleView={this.handleView}
-          /> : null
-        }
-        {this.state.tabview === 'CommonTable' ?
-          <ComTableConfig
-            menu={this.state.editMenu}
-            reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
-            handleView={this.handleView}
-          /> : null
-        }
-        {this.state.tabview === 'Modal' ?
-          <ModalConfig
-            menu={this.state.editMenu}
-            editTab={this.state.editTab}
-            tabConfig={this.state.tabConfig}
-            editSubTab={this.state.editSubTab}
-            subTabConfig={this.state.subTabConfig}
-            btnTab={this.state.btnTab}
-            btnTabConfig={this.state.btnTabConfig}
-            editAction={this.state.editAction}
-            subConfig={this.state.subConfig}
-            handleView={this.handleView}
-          /> : null
-        }
-        {this.state.tabview === 'SubTable' ?
-          <SubTable
-            menu={this.state.editMenu}
-            editTab={this.state.editTab}
-            editSubTab={this.state.editSubTab}
-            tabConfig={this.state.tabConfig}
-            btnTab={this.state.btnTab}
-            btnTabConfig={this.state.btnTabConfig}
-            config={this.state.subConfig}
-            handleView={this.handleView}
-          /> : null
-        }
-        {this.state.tabview === 'FormTab' ?
-          <FormTabConfig
-            menu={this.state.editMenu}
-            btnTab={this.state.btnTab}
-            config={this.state.subConfig}
-            handleView={this.handleView}
-          /> : null
-        }
-        {loading ? <Spin className="loading-view" /> : null}
+        <ConfigProvider locale={_locale}>
+          
+          <Header/>
+          {this.state.tabview === 'TreePage' ?
+            <TreePageConfig
+              menu={this.state.editMenu}
+              reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
+              handleView={this.handleView}
+            /> : null
+          }
+          {this.state.tabview === 'CalendarPage' ?
+            <CalendarPageConfig
+              menu={this.state.editMenu}
+              reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
+              handleView={this.handleView}
+            /> : null
+          }
+          {this.state.tabview === 'CommonTable' ?
+            <ComTableConfig
+              menu={this.state.editMenu}
+              reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
+              handleView={this.handleView}
+            /> : null
+          }
+          {this.state.tabview === 'Modal' ?
+            <ModalConfig
+              menu={this.state.editMenu}
+              editTab={this.state.editTab}
+              tabConfig={this.state.tabConfig}
+              editSubTab={this.state.editSubTab}
+              subTabConfig={this.state.subTabConfig}
+              btnTab={this.state.btnTab}
+              btnTabConfig={this.state.btnTabConfig}
+              editAction={this.state.editAction}
+              subConfig={this.state.subConfig}
+              handleView={this.handleView}
+            /> : null
+          }
+          {this.state.tabview === 'SubTable' ?
+            <SubTable
+              menu={this.state.editMenu}
+              editTab={this.state.editTab}
+              editSubTab={this.state.editSubTab}
+              tabConfig={this.state.tabConfig}
+              btnTab={this.state.btnTab}
+              btnTabConfig={this.state.btnTabConfig}
+              config={this.state.subConfig}
+              handleView={this.handleView}
+            /> : null
+          }
+          {this.state.tabview === 'FormTab' ?
+            <FormTabConfig
+              menu={this.state.editMenu}
+              btnTab={this.state.btnTab}
+              config={this.state.subConfig}
+              handleView={this.handleView}
+            /> : null
+          }
+          {loading ? <Spin className="loading-view" size="large"/> : null}
+        </ConfigProvider>
       </div>
     )
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    mainMenu: state.mainMenu,
-    menuTree: state.menuTree
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default withRouter(connect(mapStateToProps, mapDispatchToProps)(BaseDesign))
\ No newline at end of file
+export default BaseDesign
\ No newline at end of file

--
Gitblit v1.8.0