king
2025-02-20 1fb7e4f5569ac3da3b1b2319ce02f4f04b0865d3
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons'
 
import asyncComponent from '@/utils/asyncComponent'
import MKEmitter from '@/utils/events.js'
import './index.scss'
 
const TabTransfer = asyncComponent(() => import('@/tabviews/custom/components/share/tabtransfer'))
 
class NormalGroup extends Component {
  static propTpyes = {
    config: PropTypes.object
  }
 
  state = {
    visible: true,
    hidden: this.props.config.setting.bindPropId ? null : false,
    mergeAble: this.props.config.setting.mergeAble === 'true'
  }
 
  componentDidMount () {
    const { config } = this.props
 
    if (config.setting.bindPropId) {
      MKEmitter.addListener('resetSelectLine', this.resetStatus)
    }
  }
 
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('resetSelectLine', this.resetStatus)
  }
 
  resetStatus = (MenuID, _, data) => {
    const { config } = this.props
 
    if (config.setting.bindPropId !== MenuID) return
 
    if (!data || data.$$empty) {
      this.setState({hidden: true})
    } else {
      this.setState({hidden: false})
    }
  }
 
  render() {
    const { config, style } = this.props
    const { visible, mergeAble, hidden } = this.state
 
    if (config.components.length === 0) return (<div className={'ant-col ant-col-' + config.width} style={style}><div style={config.style}></div></div>)
 
    let _wrapStyle = style
    if (hidden) {
      _wrapStyle = {...style}
      _wrapStyle.display = 'none'
    }
 
    let title = config.setting && config.setting.title
 
    if (title && hidden === null) {
      title = ''
    }
    
    return (
      <div className={`ant-col ant-col-${config.width} ${mergeAble ? ' mk-merge-able mk-ctrl-' + (config.setting.ctrlNumber || 1) : ''} ${visible ? '' : ' close'}`} style={_wrapStyle}>
        <div className={'normal-group-wrap ' + (config.setting.layout || '')} id={'anchor' + config.uuid} style={config.style}>
          <div className="mk-control">
            <DoubleLeftOutlined onClick={() => this.setState({visible: false})}/>
            <DoubleRightOutlined onClick={() => this.setState({visible: true})}/>
          </div>
          {title ? <div className="group-header" style={config.headerStyle}>
            <span className="title">{title}</span>
          </div> : null}
          <TabTransfer config={config}/>
        </div>
      </div>
    )
  }
}
 
export default NormalGroup