king
2025-04-21 f3d4db769ba9b51b799d981511a710fd443d0e08
src/views/basedesign/index.jsx
@@ -1,24 +1,21 @@
import React, {Component} from 'react'
import { notification, Spin, ConfigProvider } from 'antd'
import enUS from 'antd/es/locale/en_US'
import zhCN from 'antd/es/locale/zh_CN'
import { notification, Spin } from 'antd'
import Api from '@/api'
import asyncComponent from '@/utils/asyncComponent'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import '@/assets/css/design.scss'
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'))
const CalendarPageConfig = asyncLoadComponent(() => import('@/templates/calendarconfig'))
const FormTabConfig = asyncLoadComponent(() => import('@/templates/formtabconfig'))
const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig'))
const SubTable = asyncLoadComponent(() => import('@/templates/subtableconfig'))
const UpdateFormTab = asyncLoadComponent(() => import('./updateFormTab'))
document.body.className = ''
sessionStorage.setItem('isEditState', 'true')
class BaseDesign extends Component {
  state = {
@@ -39,6 +36,20 @@
  }
  UNSAFE_componentWillMount() {
    if (sessionStorage.getItem('devError') === 'true') {
      sessionStorage.clear()
      window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
      window.location.reload()
      return
    }
    if (!sessionStorage.getItem('UserID')) {
      this.props.history.replace('/login')
      return
    }
    window.GLOB.developing = true
    try {
      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
@@ -78,7 +89,7 @@
      loading: true
    })
    Api.getSystemConfig(param).then(res => {
    Api.getCloudConfig(param).then(res => {
      if (res.status) {
        editMenu.open_edition = res.open_edition || ''
        editMenu.LongParam = ''
@@ -91,44 +102,29 @@
            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
              })
          if (_LongParam && (_LongParam.Template === 'BaseTable' || _LongParam.Template === 'CustomPage')) {
            let _param = {
              MenuId: editMenu.MenuID,
              MenuID: editMenu.MenuID,
              ParentId: _LongParam.ParentId,
              MenuName: _LongParam.MenuName,
              MenuNo: _LongParam.MenuNo
            }
          })
          return
            let url = ''
            if (_LongParam.Template === 'BaseTable') {
              url = window.location.href.split('#')[0] + `#/tabledesign/${window.btoa(window.encodeURIComponent(JSON.stringify(_param)))}`
            } else {
              _param.MenuType = 'custom'
              _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
              url = window.location.href.split('#')[0] + `#/menudesign/${_param}`
            }
            window.history.replaceState(null, null, url)
            window.location.reload()
            return
          }
          editMenu.LongParam = _LongParam
        }
        
        this.setState({
@@ -171,69 +167,60 @@
  }
  render () {
    const { loading } = this.state
    const { loading, editMenu, subConfig, btnTab } = this.state
    return (
      <div className="mk-base-design-wrap">
        <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>
        <Header/>
        {this.state.tabview === 'CommonTable' ?
          <ComTableConfig
            menu={editMenu}
            reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'SubTable' ?
          <SubTable
            menu={editMenu}
            editTab={this.state.editTab}
            editSubTab={this.state.editSubTab}
            tabConfig={this.state.tabConfig}
            btnTab={btnTab}
            btnTabConfig={this.state.btnTabConfig}
            config={subConfig}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'Modal' ?
          <ModalConfig
            menu={editMenu}
            editTab={this.state.editTab}
            tabConfig={this.state.tabConfig}
            editSubTab={this.state.editSubTab}
            subTabConfig={this.state.subTabConfig}
            btnTab={btnTab}
            btnTabConfig={this.state.btnTabConfig}
            editAction={this.state.editAction}
            subConfig={subConfig}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'TreePage' ?
          <TreePageConfig
            menu={editMenu}
            reloadmenu={() => {localStorage.setItem('menuUpdate', new Date().getTime())}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'FormTab' ?
          <UpdateFormTab
            menu={editMenu}
            btnTab={btnTab}
            config={subConfig}
            handleView={this.handleView}
          /> : null
        }
        {loading ? <Spin className="loading-view" size="large"/> : null}
      </div>
    )
  }