king
2022-08-24 23c19efebd9f59fb6e78beff64782b39b3795a5d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
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 Api from '@/api'
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'))
const CalendarPageConfig = asyncLoadComponent(() => import('@/templates/calendarconfig'))
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 {
  state = {
    loading: false,         // 编辑菜单或使用已使用模板时,获取配置信息
    tabview: '',            // 选择模板窗口(template)、基础表格配置(CommonTable)、表单(Modal)、子表(SubTable)
    editMenu: null,         // 编辑菜单
    editAction: null,       // 编辑按钮
    editTab: null,          // 编辑标签
    tabConfig: null,        // 标签配置信息
    editSubTab: null,       // 编辑子标签(标签中的标签)
    subTabConfig: null,     // 子标签配置信息
    subConfig: null,        // 子配置信息
    btnTab: null,           // 打开新标签或当前页面刷新的按钮
    btnTabConfig: null,     // 打开新标签按钮配置
    handleMVisible: false,  // 添加或修改菜单模态框(角色权限分配等)
    sysMenu: null,          // 添加或编辑菜单(角色权限分配等)
    change: false
  }
 
  UNSAFE_componentWillMount() {
    try {
      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
 
      this.getMenuParam(param)
    } catch (e) {
      notification.warning({
        top: 92,
        message: '菜单信息解析错误!',
        duration: 5
      })
    }
  }
 
  getMenuParam = (editMenu) => {
    editMenu.fstMenuId = editMenu.FstId
    editMenu.supMenuList = []
    editMenu.fstMenuList = []
 
    let tree = sessionStorage.getItem('menuTree')
    if (tree) {
      tree = JSON.parse(tree)
      editMenu.fstMenuList = tree
 
      tree.forEach(item => {
        if (item.MenuID === editMenu.FstId) {
          editMenu.supMenuList = item.children
        }
      })
    }
 
    let param = {
      func: 'sPC_Get_LongParam',
      // MenuID: editMenu.MenuID
      MenuID: '1587005717541lov40vg61q7l1rbveon'
    }
 
    this.setState({
      loading: true
    })
 
    Api.getSystemConfig(param).then(res => {
      if (res.status) {
        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
        }
        
        this.setState({
          editMenu: editMenu,
          loading: false,
          tabview: editMenu.type
        })
      } else {
        this.setState({
          loading: false
        })
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
      }
    })
  }
 
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  handleView = (param) => {
    this.setState({
      tabview: ''
    }, () => {
      if (param) {
        this.setState(param)
      } else {
        window.close()
      }
    })
  }
 
  render () {
    const { loading } = 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>
      </div>
    )
  }
}
 
export default BaseDesign