king
2020-04-09 2ff464f30d94235b3ad04475593b75a74a354de9
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { DndProvider } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import { notification, Modal, Button, Spin, Icon, Col, Card, Tabs, Row, Input } from 'antd'
import moment from 'moment'
 
import Api from '@/api'
import { sysTemps } from '@/utils/option.js'
import zhCN from '@/locales/zh-CN/header.js'
import enUS from '@/locales/en-US/header.js'
import nortable from '@/assets/img/normaltable.jpg'
 
import Preview from './preview'
import MenuForm from './menuform'
import TransferForm from '@/components/transferform'
import Utils from '@/utils/utils.js'
import DragElement from '../menuelement'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import './index.scss'
 
const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig'))
const FormTabConfig = asyncLoadComponent(() => import('@/templates/formtabconfig'))
const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig'))
const SubTable = asyncLoadComponent(() => import('@/templates/subtableconfig'))
 
const { confirm } = Modal
const { TabPane } = Tabs
const { Search } = Input
 
const illust = { // 模板图片,用于已使用模板
  CommonTable: nortable
}
 
class EditMenu extends Component {
  static propTpyes = {
    reload: PropTypes.func,      // 菜单修改后刷新
    menulist: PropTypes.any,     // 三级菜单列表
    exitEdit: PropTypes.func,    // 退出编辑状态
    supMenu: PropTypes.object,   // 对应的上级菜单
    supMenuList: PropTypes.array // 上级菜单列表,用于三级菜单切换上级菜单
  }
 
  state = {
    dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS,
    thawmenulist: null,     // 已冻结的二级菜单
    type: '',               // 操作类型,新建或编辑菜单
    thawMvisible: false,    // 解除冻结模态框
    confirmLoading: false,  // 提交中。。。
    selectTemp: '',         // 选择模板
    usedTemplates: null,    // 已使用模板列表
    tempSearchKey: '',      // 菜单名称过滤值
    loading: false,         // 编辑菜单或使用已使用模板时,获取配置信息
    preview: null,          // 图片预览url
    pretemplate: null,      // 预览模板
    btnParam: null,         // 编辑按钮的配置信息
    menulist: null,         // 编辑中的菜单
    sysTemplates: sysTemps, // 系统模板
    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: false,         // 添加或编辑菜单(角色权限分配等)
    optionLibs: [],         // 自定义下拉选项库
    fstMenuId: null,        // 一级菜单Id
    fstMenuList: null       // 一级菜单列表
  }
 
  /**
   * @description 菜单顺序改变时,保存中间状态
   */
  handlePreviewList = (List) => {
    this.setState({
      menulist: List
    })
  }
 
  /**
   * @description 菜单编辑:修改、删除
   * 1、菜单修改或删除时,先查看菜单顺序是否改变
   * 2、菜单删除
   * 3、菜单编辑,查询菜单配置信息,信息正确,进入对应编辑页面
   */
  handleMenu = (menu) => {
    const _this = this
    if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
      notification.warning({
        top: 92,
        message: this.state.dict['header.menu.presave'],
        duration: 10
      })
    } else if (menu.type === 'close') {
      confirm({
        title: this.state.dict['header.menu.close'].replace('@M', menu.card.text),
        content: '',
        okText: this.state.dict['header.confirm'],
        cancelText: this.state.dict['header.cancel'],
        onOk() {
          let param = {
            func: 'sPC_MainMenu_Del',
            MenuID: menu.card.MenuID
          }
          return Api.getSystemConfig(param).then(res => {
            if (res.status) {
              _this.props.reload()
            } else {
              notification.warning({
                top: 92,
                message: res.message,
                duration: 10
              })
            }
          })
        },
        onCancel() {}
      })
    } else if (menu.type === 'edit') {
      let _menu = JSON.parse(JSON.stringify(menu.card))
 
      delete _menu.id
      delete _menu.src
      delete _menu.text
 
      if (_menu.PageParam && _menu.PageParam.Template === 'RolePermission') { // 单页面修改
        _menu.Template = _menu.PageParam.Template
 
        if (!this.state.fstMenuId) {
          notification.warning({
            top: 92,
            message: '菜单加载中,请稍后重试!',
            duration: 10
          })
          return
        }
 
        _menu.ParentID = this.props.supMenu.MenuID
        _menu.supMenuList = this.props.supMenuList
        _menu.fstMenuId = this.state.fstMenuId || ''
        _menu.fstMenuList = this.state.fstMenuList || []
  
        this.setState({
          handleMVisible: true,
          sysMenu: _menu
        })
 
        return
      }
 
 
      let param = {
        func: 'sPC_Get_LongParam',
        MenuID: _menu.MenuID
      }
 
      this.setState({
        loading: true
      })
 
      Api.getSystemConfig(param).then(res => {
        if (res.status) {
          let _LongParam = ''
          if (res.LongParam) {
            try {
              _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
            } catch (e) {
              console.warn('Parse Failure')
              _LongParam = ''
            }
          }
 
          _menu.LongParam = _LongParam
          _menu.ParentID = this.props.supMenu.MenuID
          _menu.supMenuList = this.props.supMenuList
          _menu.fstMenuId = this.state.fstMenuId || ''
          _menu.fstMenuList = this.state.fstMenuList || []
 
          // 检测模板是否存在
          let _Template = this.state.sysTemplates.filter(temp => temp.type === _menu.PageParam.Template)
 
          // 模板不存在时错误提示
          if (_Template.length === 0) {
            notification.warning({
              top: 92,
              message: this.state.dict['header.menu.template.empty'],
              duration: 10
            })
 
            this.setState({
              type: 'edit',
              editMenu: _menu,
              loading: false,
              tabview: 'template'
            }, () => {
              document.getElementById('root').style.overflowY = 'hidden'
            })
          } else if (_menu.fstMenuId) {
            this.setState({
              type: 'edit',
              editMenu: _menu,
              loading: false,
              optionLibs: new Map(), // 编辑时,初始化为空
              tabview: _menu.PageParam.Template
            }, () => {
              document.getElementById('root').style.overflowY = 'hidden'
            })
          } else {
            _menu.loadingFstMenuId = true
            this.setState({
              type: 'edit',
              editMenu: _menu,
              optionLibs: new Map()
            })
          }
        } else {
          this.setState({
            loading: false
          })
          notification.warning({
            top: 92,
            message: res.message,
            duration: 10
          })
        }
      })
    }
  }
 
  handleSubBtn = (type) => {
    // 操作按钮:添加、解除冻结、确认及关闭
    if (type === 'add') { // 点击添加时,展开模板
      if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
        notification.warning({
          top: 92,
          message: this.state.dict['header.menu.presave'],
          duration: 10
        })
        return
      }
 
      if (!this.state.fstMenuId) {
        notification.warning({
          top: 92,
          message: '菜单加载中,请稍后重试!',
          duration: 10
        })
        return
      }
 
      this.setState({
        tabview: 'template',
        editMenu: {
          MenuID: Utils.getuuid(),
          MenuName: '',
          MenuNo: '',
          type: '',
          PageParam: '',
          LongParam: '',
          isSubtable: '', // 是否为主子表
          ParentID: this.props.supMenu.MenuID,
          supMenuList: this.props.supMenuList,
          fstMenuId: this.state.fstMenuId,
          fstMenuList: this.state.fstMenuList,
          menuSort: (this.props.menulist.length + 1) * 10 // 新建菜单设置排序
        }
      }, () => {
        document.getElementById('root').style.overflowY = 'hidden'
      })
    } else if (type === 'thaw') {
      if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
        notification.warning({
          top: 92,
          message: this.state.dict['header.menu.presave'],
          duration: 10
        })
        return
      }
      this.setState({
        thawMvisible: true
      })
      Api.getSystemConfig({
        func: 'sPC_Get_FrozenMenu',
        ParentID: this.props.supMenu.MenuID,
        TYPE: 30
      }).then(res => {
        if (res.status) {
          this.setState({
            thawmenulist: res.data.map(menu => {
              return {
                key: menu.MenuID,
                title: menu.MenuName
              }
            })
          })
        } else {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 10
          })
        }
      })
    } else if (type === 'confirm') {
      if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) {
        let _this = this
        let param  = {
          func: 'sPC_Menu_SortUpt',
          LText: this.state.menulist.map((item, index) => {
            return 'select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort'
          })
        }
 
        param.LText = param.LText.join(' union ') // sql拼接
        param.LText = Utils.formatOptions(param.LText) // 关键字符替换,base64加密
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' // 时间戳
        param.secretkey = Utils.encrypt(param.LText, param.timestamp) // md5密钥
 
        confirm({
          title: this.state.dict['header.menu.resetorder'],
          content: '',
          okText: this.state.dict['header.confirm'],
          cancelText: this.state.dict['header.cancel'],
          onOk() {
            return Api.getSystemConfig(param).then(res => {
              if (res.status) {
                _this.props.reload()
              } else {
                notification.warning({
                  top: 92,
                  message: res.message,
                  duration: 10
                })
              }
            })
          },
          onCancel() {}
        })
      } else {
        this.props.exitEdit()
      }
    } else if (type === 'close') {
      this.props.exitEdit()
    }
  }
 
  thawMemuSubmit = () => {
    // 三级菜单解除冻结
    if (this.refs.trawmenu.state.targetKeys.length === 0) {
      notification.warning({
        top: 92,
        message: this.state.dict['header.menu.thawmenu.select'],
        duration: 10
      })
    } else {
      this.setState({
        confirmLoading: true
      })
      let defers = this.refs.trawmenu.state.targetKeys.map(item => {
        return new Promise((resolve) => {
          Api.getSystemConfig({
            func: 'sPC_MainMenu_ReDel',
            MenuID: item
          }).then(res => {
            if (res.status) {
              resolve('')
            } else {
              resolve(res.message)
            }
          })
        })
      })
      Promise.all(defers).then(res => {
        let msg = res.filter(Boolean)[0]
        if (msg) {
          notification.error({
            top: 92,
            message: msg,
            duration: 15
          })
        } else {
          this.setState({
            confirmLoading: false,
            thawMvisible: false,
            thawmenulist: null
          })
          this.props.reload()
        }
      })
    }
  }
 
  thawMemuCancel = () => {
    // 解除冻结-取消
    this.setState({
      thawMvisible: false,
      thawmenulist: null
    })
  }
 
  previewPicture = (template) => {
    // 图片预览
    this.setState({
      preview: template.url,
      pretemplate: template
    })
  }
 
  cancelPrePicture = () => {
    // 关闭图片预览
    this.setState({
      preview: null
    })
  }
 
  /**
   * @description 使用模板
   * 1、使用系统模板时,使用系统配置
   * 2、使用已有菜单模板时,获取菜单配置信息,标记为user(复制菜单按钮)
   */
  useTemplate = (template, useType) => {
    let editMenu = JSON.parse(JSON.stringify(this.state.editMenu))
 
    if (!this.state.fstMenuId) {
      notification.warning({
        top: 92,
        message: '菜单加载中,请稍后重试!',
        duration: 10
      })
      return
    }
 
    if (!editMenu.fstMenuId) {
      editMenu.fstMenuId = this.state.fstMenuId
      editMenu.fstMenuList = this.state.fstMenuList
    }
 
    if (useType === 'sys' && template.type === 'RolePermission') { // 独立页面
      let _menu = {
        ...editMenu,
        MenuID: Utils.getuuid(),
        MenuName: template.title,
        Template: template.type,
        ParentID: this.props.supMenu.MenuID,
      }
 
      this.setState({
        handleMVisible: true,
        sysMenu: _menu
      })
      return
    }
 
    new Promise(resolve => {
      if (useType === 'sys') {
        resolve(true)
      } else {
        let param = {
          func: 'sPC_Get_LongParam',
          MenuID: template.uuid
        }
        this.setState({
          loading: true
        })
 
        Api.getSystemConfig(param).then(result => {
          if (!result.status) {
            notification.warning({
              top: 92,
              message: result.message,
              duration: 10
            })
            resolve(false)
          } else {
            let _config = ''
            if (result.LongParam) {
              try {
                _config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
                _config.type = 'user'
              } catch (e) {
                console.warn('Parse Failure')
                _config = ''
              }
            }
 
            if (_config) {
              template.baseconfig = _config
              resolve(true)
            } else {
              notification.warning({
                top: 92,
                message: '模板信息获取失败!',
                duration: 10
              })
              resolve(false)
            }
          }
        })
      }
    }).then(res => {
      if (!res) { // 错误时,重置状态
        this.setState({
          loading: false
        })
        return
      }
 
      // 选择模板:添加菜单时(不存在menuId)
      let _PageParam = {
        OpenType: editMenu.PageParam ? editMenu.PageParam.OpenType : 'newtab',
        Template: template.type
      }
 
      this.setState({
        loading: false,
        tabview: template.type,
        optionLibs: new Map(), // 新建时,初始化下拉选项库
        editMenu: {
          ...editMenu,
          type: template.type,
          PageParam: _PageParam,
          LongParam: template.baseconfig,
          isSubtable: template.isSubtable
        }
      })
      document.getElementById('root').style.overflowY = 'hidden'
    })
  }
 
  getUsedTemplate = () => {
    let { sysTemplates } = this.state
 
    Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'menu'}).then(res => {
      let _templates = []
      let hasRolePermission = false
 
      res.UserTemp.forEach(temp => {
        if (temp.Template === 'RolePermission') {
          hasRolePermission = true
          return
        }
 
        _templates.push({
          uuid: temp.MenuID,
          title: temp.MenuName,
          type: temp.Template,
          url: illust[temp.Template]
        })
      })
 
      if (!hasRolePermission) {
        sysTemplates = sysTemplates.map(temp => {
          if (temp.type === 'RolePermission') {
            temp.hidden = false
          }
 
          return temp
        })
      }
 
      this.setState({
        usedTemplates: _templates,
        sysTemplates: sysTemplates
      })
    })
  }
 
  exittabview = () => {
    this.setState({tabview: ''})
    document.getElementById('root').style.overflowY = 'unset'
  }
 
  handleView = (param) => {
    this.setState({
      tabview: ''
    }, () => {
      if (param) {
        this.setState(param)
        document.getElementById('root').style.overflowY = 'hidden'
      } else {
        document.getElementById('root').style.overflowY = 'unset'
      }
    })
  }
 
  /**
   * @description 三级菜单添加或修改
   */
  memuSubmit = () => {
    const { sysMenu } = this.state
    let sysTemplates = JSON.parse(JSON.stringify(this.state.sysTemplates))
 
    if (sysMenu.isSystem) {
      sysTemplates = sysTemplates.map(temp => {
        if (temp.type === sysMenu.type) {
          temp.hidden = true
        }
 
        return temp
      })
    }
 
    this.menuFormRef.handleConfirm().then(res => {
 
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        FstID: res.fstMenuId,
        SndID: res.ParentID,
        ParentID: res.ParentID,
        MenuID: sysMenu.MenuID,
        MenuNo: res.MenuNo,
        Template: sysMenu.Template,
        MenuName: res.MenuName,
        PageParam: JSON.stringify({Template: sysMenu.Template, OpenType: 'newtab'}),
        LongParam: '',
        LText: '',
        LTexttb: ''
      }
 
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
 
      this.setState({
        confirmLoading: true
      })
 
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          this.setState({
            sysTemplates: sysTemplates,
            confirmLoading: false,
            handleMVisible: false,
            sysMenu: '',
            tabview: ''
          })
 
          this.props.reload()
        } else {
          this.setState({
            confirmLoading: false
          })
          notification.warning({
            top: 92,
            message: response.message,
            duration: 10
          })
        }
      })
    })
  }
 
 
  UNSAFE_componentWillMount () {
    this.getUsedTemplate()
 
    this.setState({
      menulist: this.props.menulist
    })
  }
 
  componentDidMount () {
    let _param = {
      func: 's_Get_FSMenusForOpen',
      SndMenuID: this.props.supMenu.MenuID,
      TYPE: 20,
      TypeCharOne: 'PC'
    }
    this.setState({
      loading: true
    })
 
    Api.getSystemConfig(_param).then(result => {
      if (result.status) {
        this.setState({
          loading: false,
          fstMenuId: result.FstIDSeleted,
          fstMenuList: result.data.map(smenu => {
            let _smenu = {
              MenuID: smenu.FstID,
              text: smenu.FstName,
              options: smenu.SndData.map(menu => {
                return {
                  MenuID: menu.SndID,
                  text: menu.SndName,
                }
              })
            }
 
            return _smenu
          })
        }, () => {
          let _menu = JSON.parse(JSON.stringify(this.state.editMenu))
  
          if (!_menu || !_menu.loadingFstMenuId) {
            return
          }
  
          delete _menu.loadingFstMenuId
          _menu.fstMenuId = this.state.fstMenuId
          _menu.fstMenuList = this.state.fstMenuList
  
          this.setState({
            type: 'edit',
            editMenu: _menu,
            loading: false,
            optionLibs: new Map(), // 编辑时,初始化为空
            tabview: _menu.PageParam.Template
          }, () => {
            document.getElementById('root').style.overflowY = 'hidden'
          })
        })
      } else {
        this.setState({
          loading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 10
        })
      }
    })
  }
 
  UNSAFE_componentWillReceiveProps (nextProps) {
    if (!is(fromJS(this.props.menulist), fromJS(nextProps.menulist))) {
      this.setState({
        menulist: nextProps.menulist
      })
    }
  }
 
  render () {
    return (
      <div className="third-edit-box">
        {!this.state.tabview ?
          <div className="mask">
            <div className="tipcard card1">
              拖动三级菜单可调整顺序,顺序调整后,请点击确定按钮保存。
            </div>
            <div className="tipcard card2">
              点击编辑图标会根据菜单模板,进入相应的模板编辑页面,点击删除图标可删除菜单。
            </div>
            <div className="tipcard card3">
              点击解除冻结按钮,可还原已删除的三级菜单。
            </div>
            <div className="tipcard card4">
              点击添加图标,会显示系统模板和已使用模板,选择已使用模板时,会复制已添加菜单的配置信息。
            </div>
            <div className="tipcard card5">
              <p>编辑状态中,菜单之外区域会锁定,查看系统数据请点击。</p>
              <div>
                <a target="blank" href="#/main" >新页面</a>
              </div>
            </div>
          </div> : null
        }
        <div className="cus-submenu-title">
          <Icon type={this.props.supMenu.PageParam.Icon} />
          <span>{this.props.supMenu.text}</span>
        </div>
        <DndProvider backend={HTML5Backend}>
          <DragElement
            list={this.state.menulist}
            handlePreviewList={this.handlePreviewList}
            handleMenu={this.handleMenu}
          />
        </DndProvider>
        <div className="menu-add" onClick={() => {this.handleSubBtn('add')}}>
          <Icon type="plus" />
        </div>
        <div className="menu-btn">
          <Button type="primary" onClick={() => {this.handleSubBtn('thaw')}}>{this.state.dict['header.thawmenu']}</Button>
          <Button type="primary" onClick={() => {this.handleSubBtn('confirm')}}>{this.state.dict['header.confirm']}</Button>
          <Button onClick={() => {this.handleSubBtn('close')}}>{this.state.dict['header.close']}</Button>
        </div>
        {this.state.tabview === 'template' ?
          <div className="editboard">
            <div className="workplace">
              <Button className="top-btn mk-yellow" onClick={this.exittabview}>{this.state.dict['header.cancel']}</Button>
              {this.state.tabview === 'template' && <Tabs defaultActiveKey="1">
                <TabPane tab="系统模板" key="1">
                  <Row>
                    {this.state.sysTemplates.map((template, index) => {
                      if (template.hidden) return ''
 
                      return (
                        <Col key={`${index}`} span={8}>
                          <Card
                            title={template.title}>
                            <img onClick={() => {this.previewPicture(template)}} src={template.url} alt=""/>
                            <div className="card-operation">
                              <Button type="primary" onClick={() => {this.useTemplate(template, 'sys')}}>使用模板</Button>
                            </div>
                          </Card>
                        </Col>
                      )
                    })}
                  </Row>
                </TabPane>
                <TabPane tab="已使用模板" key="2">
                  <Row>
                    <Col span={8}>
                      <Search placeholder="请输入菜单名称" defaultValue={this.state.tempSearchKey} onSearch={value => {this.setState({tempSearchKey: value})}} enterButton />
                    </Col>
                  </Row>
                  <Row>
                    {this.state.usedTemplates && this.state.usedTemplates.map((template, index) => {
                      if (template.title.toLowerCase().indexOf(this.state.tempSearchKey.toLowerCase()) >= 0) {
                        return (
                          <Col key={template.type + index} span={8}>
                            <Card
                              title={template.title}>
                              <img onClick={() => {this.previewPicture(template)}} src={template.url} alt=""/>
                              <div className="card-operation">
                                <Button type="primary" onClick={() => {this.useTemplate(template, 'user')}}>使用模板</Button>
                              </div>
                            </Card>
                          </Col>
                        )
                      } else {
                        return ''
                      }
                    })}
                  </Row>
                </TabPane>
              </Tabs>}
            </div>
          </div> : null
        }
        {this.state.tabview === 'CommonTable' ?
          <ComTableConfig
            menu={this.state.editMenu}
            optionLibs={this.state.optionLibs}
            reloadmenu={() => {this.props.reload()}}
            handleView={this.handleView}
          /> : null
        }
        {this.state.tabview === 'Modal' ?
          <ModalConfig
            menu={this.state.editMenu}
            optionLibs={this.state.optionLibs}
            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}
            optionLibs={this.state.optionLibs}
            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}
            optionLibs={this.state.optionLibs}
            btnTab={this.state.btnTab}
            config={this.state.subConfig}
            handleView={this.handleView}
          /> : null
        }
        {/* 图片预览 */}
        <Preview cancel={this.cancelPrePicture} preview={this.state.preview} template={this.state.pretemplate} confirm={this.useTemplate}/>
        {/* 解冻菜单模态框 */}
        <Modal
          title={this.state.dict['header.thawmenu']}
          okText={this.state.dict['header.confirm']}
          cancelText={this.state.dict['header.cancel']}
          visible={this.state.thawMvisible}
          onOk={this.thawMemuSubmit}
          confirmLoading={this.state.confirmLoading}
          onCancel={this.thawMemuCancel}
          destroyOnClose
        >
          {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
          {this.state.thawmenulist && <TransferForm ref="trawmenu" menulist={this.state.thawmenulist}/>}
        </Modal>
        {/* 添加系统菜单 */}
        <Modal
          title={this.state.sysMenu && this.state.sysMenu.isSystem ? this.state.dict['header.menu.tadd'] : this.state.dict['header.menu.tupdate']}
          okText={this.state.dict['header.confirm']}
          cancelText={this.state.dict['header.cancel']}
          visible={this.state.handleMVisible}
          onOk={this.memuSubmit}
          confirmLoading={this.state.confirmLoading}
          onCancel={() => {this.setState({handleMVisible: false})}}
          destroyOnClose
        >
          <MenuForm
            menu={this.state.sysMenu}
            dict={this.state.dict}
            wrappedComponentRef={(inst) => this.menuFormRef = inst}
          />
        </Modal>
        {this.state.loading && <Spin className="loading-thdmenu" size="large" />}
      </div>
    )
  }
}
 
export default EditMenu