king
2021-10-18 ccbd330b46d2bddcf0228fd834bb82d482de3613
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
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Button } from 'antd'
 
// import MKEmitter from '@/utils/events.js'
import './index.scss'
 
class AutoMatic extends Component {
  static propTpyes = {
    autoMatic: PropTypes.object,
    config: PropTypes.object
  }
 
  state = {
    running: false,
    line: 0
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
 
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  trigger = () => {
    // const { config } = this.props
    let running = !this.state.running
 
    // MKEmitter.emit('autoQueryData', config.MenuID, 0)
 
    this.setState({running: running})
  }
 
  render() {
    const { running } = this.state
 
    return (
      <Button
        icon={running ? 'pause' : 'forward'}
        shape="circle"
        className={'auto-matic ' + (window.GLOB.systemType === 'production' ? 'low' : '')}
        onClick={this.trigger}
      />
    )
  }
}
 
export default AutoMatic